faster rcnn报错:TypeError: slice indices must be integers or None or have an __index__ method

https://blog.csdn.net/qq_27637315/article/details/78849756

faster rcnn报错:TypeError: slice indices must be integers or None or have an __index__ method

博主之前在跑faster rcnn训练的时候别的问题都能按照网上教程解决唯独这个问题一直不行,去网上搜说是numpy有问题,我安装过conda所以我有两个numpy一个是pip安装的还有一个是conda安装的,我的python2.7使用的是conda环境下的,这个numpy坑确实不小,我对numpy一通乱改把conda装的降到了1.11.3,将pip安装的升到了1.13.3但还是不行,于是我就开始看代码改错了,我主要改的是/home/xiaohua/py-faster-rcnn/lib/roi_data_layer下的minibatch.py文件转到172行,将
for ind in inds:
cls = clss[ind]
start = 4 * cls
end = 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 in inds:
ind = int(ind)
cls = clss[ind]
start = int(4 * cos)
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
即可,自己注意python语法格式哦。

猜你喜欢

转载自www.cnblogs.com/shuimuqingyang/p/10152809.html