Yolact运行内存报错

current_masks = masks[mask, :, :].copy() numpy.core._exceptions.MemoryError: Unable to allocate 5.31 GiB for an array with shape (340, 4729, 3547) and data type uint8

本来以为是模型参数设置不合理,导致运行内存爆炸,但在设置num_works = 0 batchsize=1的条件后问题依然存在。

然后发现报错的数组大小不合理,远大于我的图片大小,debug找原因,发现340是我的单张图片的目标数,没办法就这么多,图像尺寸却比我的图片大好2 3倍,这就是导致内存爆炸的原因。

解决办法:找到expand类,其是用来扩展图片大小的,修改参数ratio为1到1.5

class Expand(object):
    def __init__(self, mean):
        self.mean = mean

    def __call__(self, image, masks, boxes, labels):
        if random.randint(2):
            return image, masks, boxes, labels

        height, width, depth = image.shape
        ratio = random.uniform(1, 1.5)#(1,4)
        left = random.uniform(0, width*ratio - width)
        top = random.uniform(0, height*ratio - height)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值