R-CNN:训练和测试 Faster R-CNN 模型中遇到的问题

最近使用自己标注的数据集用 Faster R-CNN 训练了两个模型:VGG16 和 ResNet-50 ,在训练和测试的时候还是踩了很多坑,把遇到的问题及解决方法总结了一下,以供以后回顾。


一、训练

1. 错误:./tools/train_faster_rcnn_end2end.py is not found

执行文件的位置不正确,注意所有的命令最好都在 faster rcnn 的根目录中执行。

2. 错误:‘module’ object has no attribute ‘text_format’

./lib/fast_rcnn/train.py 文件里添加 import google.protobuf.text_format

3. 错误:TypeError: ‘numpy.float64’ object cannot be interpreted as an index

这个错误有人说可以降低 numpy 的版本来解决,本人试了,但还会报其他的错误,所以并不能算解决。

因为新版的 numpy 不能使用 float 类型来进行索引了,解决方法:转换类型

1./py-faster-rcnn/lib/roi_data_layer/minibatch.py

# 在第26行:
    fg_rois_per_image = np.round(cfg.TRAIN.FG_FRACTION * rois_per_image)
# 修改为:
    fg_rois_per_image = np.round(cfg.TRAIN.FG_FRACTION * rois_per_image).astype(np.int)

2./py-faster-rcnn/lib/datasets/ds_utils.py

# 在第12行:
    hashes = np.round(boxes * scale).dot(v)
# 修改为:
    hashes = np.round(boxes * scale).dot(v).astype(np.int)

3./py-faster-rcnn/lib/fast_rcnn/test.py

# 在129行:
        hashes = np.round(blobs['rois'] * cfg.DEDUP_BOXES).dot(v)
# 修改为:
        hashes = np.round(blobs['rois'] * cfg.DEDUP_BOXES).dot(v).astype(np.int)

4./py-faster-rcnn/lib/rpn/proposal_target_layer.py

# 在60行:
        fg_rois_per_image = np.round(cfg.TRAIN.FG_FRACTION * rois_per_image)
# 修改为:
        fg_rois_per_image = np.round(cfg.TRAIN.FG_FRACTION * rois_per_image).astype(np.int)
# 在123行起:
    for ind in inds:
        cls = clss[ind]
        start = 4 * cls
        end = start + 4
# 修改为:
    for ind in inds:
        ind = int(ind)
        cls = clss[ind]
        start = int(4 * cls)
        end = int(start + 4)
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值