我按照https://github.com/deboc/py-faster-rcnn/blob/master/help/Readme.md的指示训练py-faster-rcnn 在自定义数据集上。
但是,我收到以下错误:
Preparing training data...
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "./train_faster_rcnn_alt_opt.py", line 122, in train_rpn
roidb, imdb = get_roidb(imdb_name)
File "./train_faster_rcnn_alt_opt.py", line 67, in get_roidb
roidb = get_training_roidb(imdb)
File "/home/Work/code/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 122, in get_training_roidb
rdl_roidb.prepare_roidb(imdb)
File "/home/Work/code/py-faster-rcnn/tools/../lib/roi_data_layer/roidb.py", line 31, in prepare_roidb
gt_overlaps = roidb[i]['gt_overlaps'].toarray()
AttributeError: 'numpy.ndarray' object has no attribute 'toarray'
这是roidb.py的代码片段(第31行):
for i in xrange(len(imdb.image_index)):
roidb[i]['image'] = imdb.image_path_at(i)
roidb[i]['width'] = sizes[i][0]
roidb[i]['height'] = sizes[i][1]
# need gt_overlaps as a dense array for argmax
gt_overlaps = roidb[i]['gt_overlaps'].toarray()
我无法找到解决方法。
答案 0 :(得分:0)
在标准实现中,发布行上的roidb[i]['gt_overlaps']
应该是稀疏矩阵。您可能在定义自己的数据集地面实况读取器时忘记了这一点,因为它最初是一个numpy.ndarray,后来被转换。其他解决方法是可能的(并且可能更好,具体取决于应用程序)但如果您希望保持尽可能接近py-faster-rcnn,只需将每个基础事实的gt_overlaps
键包裹起来,如overlaps = scipy.sparse.csr_matrix(overlaps)
,引用可以在原始数据集文件中找到(即lib/datasets/pascal_voc.py
)。