用自定义数据训练FasterRCNN报错image invalid, skipping

Traceback (most recent call last):

File “C:\Users\think\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\script_ops.py”, line 157, in call
ret = func(*args)

File “D:\Faster-RCNN-TensorFlow-Python3.5-master\lib\layer_utils\proposal_target_layer.py”, line 47, in proposal_target_layer
rois_per_image, _num_classes)

File “D:\Faster-RCNN-TensorFlow-Python3.5-master\lib\layer_utils\proposal_target_layer.py”, line 135, in _sample_rois
raise Exception()

Exception
image invalid, skipping

研究一下报错信息是proposal_target_layer.py里的_sample_rois函数,因为

 if fg_inds.size > 0 and bg_inds.size > 0:
        fg_rois_per_image = min(fg_rois_per_image, fg_inds.size)
        fg_inds = npr.choice(fg_inds, size=int(fg_rois_per_image), replace=False)
        bg_rois_per_image = rois_per_image - fg_rois_per_image
        to_replace = bg_inds.size < bg_rois_per_image
        bg_inds = npr.choice(bg_inds, size=int(bg_rois_per_image), replace=to_replace)
    elif fg_inds.size > 0:
        to_replace = fg_inds.size < rois_per_image
        fg_inds = npr.choice(fg_inds, size=int(rois_per_image), replace=to_replace)
        fg_rois_per_image = rois_per_image
    elif bg_inds.size > 0:
        to_replace = bg_inds.size < rois_per_image
        bg_inds = npr.choice(bg_inds, size=int(rois_per_image), replace=to_replace)
        fg_rois_per_image = 0
    else:
        raise Exception()

报错原因是fg_inds和bg_inds的数量都小于0,这张图片没办法训练了,所以直接跳过这张图。办法是调整config.py里的

roi_bg_threshold_high和roi_bg_threshold_low,一般把roi_bg_threshold_low改成0.0就不会出现这个问题。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员阿明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值