open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
28.52k stars 9.29k forks source link

KeyError: 'gt_instances' of eval_metric.py #11696

Open HaMeow-lst1 opened 1 month ago

HaMeow-lst1 commented 1 month ago

I use MMDtection 3.x. The dataset is voc-format. I have trained a model and get detection_results.pkl

However, I run

python tools/analysis_tools/eval_metric.py configs/saga/cascade-rcnn_flir.py ./detection_results.pkl

and get errors

  File "/home/lisongtao/mm3+conda/saga_test/mmdet/evaluation/metrics/voc_metric.py", line 89, in process
    gt_instances = gt['gt_instances']
KeyError: 'gt_instances'

Could you please tell me how to solve this problem?

Besides, I want to open source the code for evaluation. You can also tell me how to calculate the map according to a .pkl file and config. Thanks a lot!

HaMeow-lst1 commented 1 month ago

Besides, if convenient, could I only use annotations for the test dataset without images and training data? I want to others can get mAP conveniently without downloading too much. Thanks a lot!

sofiapfund commented 1 month ago

I ran into the same issue and solved as described below :)

The detection_results.pkl file does not, by default, store any information regarding the ground truth instances. To incorporate the ground truth data for offline evaluation of the detections, one needs to comment out line 32 within the DumpDetResults class.

File location: mmdetection/tree/main/mmdet/evaluation/metrics/dump_det_results.py

Modify: line 32 # data_sample.pop('gt_instances', None)