KeyError: 'chair'
Posted 塔上的樹
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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'的主要内容,如果未能解决你的问题,请参考以下文章
python3 日志检索异常抛出异常 raise KeyError(key),KeyError: 'formatters'
KeyError: 'SQLALCHEMY_TRACK_MODIFICATIONS' 报错
Flask報錯 KeyError 'SQLALCHEMY_TRACK_MODIFICATIONS'.md
KeyError: 'Spider not found: test'
R = [obj for obj in recs[imagename] if obj['name'] == classname] KeyError:'1'