KeyError: 'chair'

使用py-faster-rcnn训练VOC2007数据集时遇到如下问题:

File "/home/sai/py-faster-rcnn/tools/../lib/datasets/pascal_voc.py", line 217, in _load_pascal_annotation
cls = self._class_to_ind[obj.find(‘name‘).text.lower().strip()]
KeyError: ‘chair‘

解决:

You probably need to write some line of codes to ignore any objects with classes except the classes you are looking for when you are loading the annotation _load_pascal_annotation.
Something like
cls_objs = [
obj for obj, clas in objs, self._classes if obj.find(‘name‘).text== clas]

when you are loading the annotation in _load_pascal_annotation method, look for something like
objs = diff_objs (or non_diff_objs)
After that line insert something similar to below code

cls_objs = [obj for obj in objs if obj.find(‘name‘).text in self._classes]
objs = cls_objs


https://github.com/rbgirshick/py-faster-rcnn/issues/316
文章来自:http://www.cnblogs.com/JZ-Ser/p/6924156.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3