使用coco資料集,faster rcnn類方法訓練出錯解決
阿新 • • 發佈:2018-12-30
問題:
在caffe框架下,使用coco資料集進行faster rcnn類方法訓練,得到如下錯誤:
File "/data/zn/light_head_rcnn/script/py-RFCN-priv/tools/../lib/rpn/anchor_target_layer.py", line 146, in forward
argmax_overlaps = overlaps.argmax(axis=1)
ValueError: attempt to get argmax of an empty sequence
原因:
由於gt_boxes為空而引起的overlaps==[].
解決辦法:
將資料集裡boxes為空的影象刪除。
更改./lib/datasets/coco.py檔案,
將
self._image_index = self._load_image_set_index()
更改為
#rm bad img res_img_index = [] temp_img_indexs = self._load_image_set_index() print 'zn=========Original img num:', len(temp_img_indexs) for temp_img_index in temp_img_indexs: temp_dict = self._load_coco_annotation(temp_img_index) #print 'zn=======temp_dict:',temp_dict temp_boxes = temp_dict['boxes'] if len(temp_boxes) == 0: print 'zn=======temp_boxes:',temp_boxes continue else: res_img_index.append(temp_img_index) print 'zn=========Real img num:', len(res_img_index) self._image_index = res_img_index