Thanks for your error report and we appreciate it a lot.
Checklist
I have searched related issues but cannot get the expected help.
The bug has not been fixed in the latest version.
Describe the bug
Recently when I trained the model, I met with the error: label = self.cat2label[name] KeyError: 'grain', 'grain' is my class name. I followed the solution of https://github.com/open-mmlab/mmdetection/issues/283 to modify CLASSES = ('.....') to CLASSES = ('grain',) in voc.py, and it can train successfully, but when I use the command of 'python tools/test.py configs/pascal_voc/faster_rcnn_r50_fpn_1x_voc0712.py /home/drl/workspace/mmdetection-1.1.0-for-grain/output/latest.pth --eval mAP' to see the mAP value, I met the error: label = self.cat2label[name] KeyError: 'w', I don't know how to do, please help me.
You may add addition that may be helpful for locating the problem, such as
How you installed PyTorch [e.g., pip, conda, source]
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.) No
Error traceback
(mm) drl@drl-Precision:~/workspace/mmdetection-1.1.0-for-grain$ python tools/test.py configs/pascal_voc/faster_rcnn_r50_fpn_1x_voc0712.py /home/drl/workspace/mmdetection-1.1.0-for-grain/output/latest.pth --eval mAP
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 160/160, 21.3 task/s, elapsed: 8s, ETA: 0sTraceback (most recent call last):
File "tools/test.py", line 316, in <module>
main()
File "tools/test.py", line 312, in main
dataset.evaluate(outputs, args.eval, **kwargs)
File "/home/drl/workspace/mmdetection-1.1.0-for-grain/mmdet/datasets/voc.py", line 33, in evaluate
annotations = [self.get_ann_info(i) for i in range(len(self))]
File "/home/drl/workspace/mmdetection-1.1.0-for-grain/mmdet/datasets/voc.py", line 33, in <listcomp>
annotations = [self.get_ann_info(i) for i in range(len(self))]
File "/home/drl/workspace/mmdetection-1.1.0-for-grain/mmdet/datasets/xml_style.py", line 47, in get_ann_info
label = self.cat2label[name]
KeyError: 'w'
Bug fix
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!
Thanks for your error report and we appreciate it a lot.
Checklist
Describe the bug Recently when I trained the model, I met with the error: label = self.cat2label[name] KeyError: 'grain', 'grain' is my class name. I followed the solution of https://github.com/open-mmlab/mmdetection/issues/283 to modify CLASSES = ('.....') to CLASSES = ('grain',) in voc.py, and it can train successfully, but when I use the command of 'python tools/test.py configs/pascal_voc/faster_rcnn_r50_fpn_1x_voc0712.py /home/drl/workspace/mmdetection-1.1.0-for-grain/output/latest.pth --eval mAP' to see the mAP value, I met the error: label = self.cat2label[name] KeyError: 'w', I don't know how to do, please help me.
Reproduction
Environment
python mmdet/utils/collect_env.py
to collect necessary environment infomation and paste it here. sys.platform: linux Python: 3.6.10 |Anaconda, Inc.| (default, May 8 2020, 02:54:21) [GCC 7.3.0] CUDA available: True CUDA_HOME: /usr/local/cuda-9.0 NVCC: Cuda compilation tools, release 9.0, V9.0.176 GPU 0: GeForce GTX 1080 Ti GCC: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609 PyTorch: 1.1.0 PyTorch compiling details: PyTorch built with:TorchVision: 0.3.0 OpenCV: 4.2.0 MMCV: 0.5.9 MMDetection: 1.1.0+unknown MMDetection Compiler: GCC 5.4 MMDetection CUDA Compiler: 9.0
$PATH
,$LD_LIBRARY_PATH
,$PYTHONPATH
, etc.) NoError traceback
Bug fix If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!