faster-rcnn训练自己的数据集遇到的问题

我汇总了一些网上很难找到答案的错误,(可能只有我自己觉得很难)
当之前运行出错,然后修改完再运行是一定要删除data/cache文件和py-faster-rcnn中所有的.pyc文件
错误1:

F0525 16:55:08.301654 12360 io.cpp:54] Check failed: fd != -1 (-1 vs. -1) File not found: data/imagenet_models/ZF.v2.caffemodel
*** Check failure stack trace: ***

下载ZF.caffemodel文件:

错误2:

pb2.text_format.Merge(f.read(), self.solver_param)
AttributeError: 'module' object has no attribute 'text_format'
解决办法:

解决办法:
办法一:在文件./lib/fast_rcnn/train.py增加一行import google.protobuf.text_format
办法二:sudo pip install protobuf==2.5.0


File "mtrand.pyx", line 1192, in mtrand.RandomState.choice
TypeError: 'numpy.float64' object cannot be interpreted as an index

网上很多解决办法是这样的

调整numpy版本
ubuntu@ubuntu-System-Product-Name:~/py-faster-rcnn$ python
>>> import numpy
>>> print numpy.version.version
1.14.3
>>> quit()
ubuntu@ubuntu-System-Product-Name:~/py-faster-rcnn$ pip install -U numpy==1.11.0  

但是之后会遇到如下问题:

安装之后遇到问题:
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: numpy.core.multiarray failed to import

解决办法

1) /home/xxx/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) /home/xxx/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) /home/xxx/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) /home/xxx/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)

但是呢,还没有完,你还会遇到提示你TypeError: slice indices must be integers or None or have an __index__ method的问题
!1)修改/home/ubuntu/py-faster-rcnn/lib/roi_data_layer/minibatch.py从第172行 开始的一个for语句:

 for ind in inds:
    ind = int(ind)
        cls = clss[ind]
        start = int(4 * cls)
        end = int(start + 4)
        bbox_targets[ind, start:end] = bbox_target_data[ind, 1:]
        bbox_inside_weights[ind, start:end] = cfg.TRAIN.BBOX_INSIDE_WEIGHTS
    return bbox_targets, bbox_inside_weights

2)修改/home/ubuntu/py-faster-rcnn/lib/rpn/proposal_target_layer.py 从124行开始的for语句,与之前的文件中的语句相同,都是将其改为:

 for ind in inds:
    ind = int(ind)
        cls = clss[ind]
        start = int(4 * cls)
        end = int(start + 4)
        bbox_targets[ind, start:end] = bbox_target_data[ind, 1:]
        bbox_inside_weights[ind, start:end] = cfg.TRAIN.BBOX_INSIDE_WEIGHTS
    return bbox_targets, bbox_inside_weights

因为原先的for语句中的ind,start,end都是 numpy.int 类型,这种类型的数据不能作为索引,所以必须对其进行强制类型转换。

参考文献:
https://www.cnblogs.com/han1ning1/p/7858357.html

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值