首页 > 代码库 > KeyError: 'chair'
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 likeobjs = 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
KeyError: 'chair'