AttributeError: 'COCOEvaluator' object has no attribute '_novel_classes'
Hi guys
I am using the tag v0.4 and I just retrained the base model on COCO using python -m tools.train_net --num-gpus 3 --config-file configs/COCO-detection/faster_rcnn_R_101_FPN_base.yaml everything went smoothly but upon evaluation I run into the error
Traceback (most recent call last):
File "/scratch_net/clariden/chmayer/conda_envs/simpledet/lib/python3.6/site-packages/torch/multiprocessing/spawn.py", line 19, in _wrap
fn(i, *args)
File "/scratch_net/clariden/chmayer/conda_envs/simpledet/lib/python3.6/site-packages/detectron2/engine/launch.py", line 94, in _distributed_worker
main_func(*args)
File "/home/chmayer/github/few-shot-object-detection/tools/train_net.py", line 107, in main
return trainer.train()
File "/home/chmayer/github/few-shot-object-detection/fsdet/engine/defaults.py", line 444, in train
super().train(self.start_iter, self.max_iter)
File "/scratch_net/clariden/chmayer/conda_envs/simpledet/lib/python3.6/site-packages/detectron2/engine/train_loop.py", line 148, in train
self.after_train()
File "/scratch_net/clariden/chmayer/conda_envs/simpledet/lib/python3.6/site-packages/detectron2/engine/train_loop.py", line 157, in after_train
h.after_train()
File "/home/chmayer/github/few-shot-object-detection/fsdet/engine/hooks.py", line 87, in after_train
self._do_eval()
File "/home/chmayer/github/few-shot-object-detection/fsdet/engine/hooks.py", line 36, in _do_eval
results = self._func()
File "/home/chmayer/github/few-shot-object-detection/fsdet/engine/defaults.py", line 391, in test_and_save_results
self._last_eval_results = self.test(self.cfg, self.model)
File "/home/chmayer/github/few-shot-object-detection/fsdet/engine/defaults.py", line 556, in test
results_i = inference_on_dataset(model, data_loader, evaluator)
File "/home/chmayer/github/few-shot-object-detection/fsdet/evaluation/evaluator.py", line 162, in inference_on_dataset
results = evaluator.evaluate()
File "/home/chmayer/github/few-shot-object-detection/fsdet/evaluation/coco_evaluation.py", line 129, in evaluate
self._eval_predictions()
File "/home/chmayer/github/few-shot-object-detection/fsdet/evaluation/coco_evaluation.py", line 179, in _eval_predictions
self._novel_classes,
AttributeError: 'COCOEvaluator' object has no attribute '_novel_classes'
It seems that indeed self._novel_classes is not defined anymore but used in line 179 in coco_evaluation.py. For coco only the base classes are defined.
Seems that the problem stems from this pull request at least self._novel_classes was still there in the version just before the PR merge. @Anthuang could you maybe have a look and fix this since you were doing the merge?
Thanks a lot and best Christoph
I also encountered this problem during the validation period
I also have the same question. Did you solve it ?
I also have the same question. Did you solve it ?
I have solved this problem.Open the coco_evaluation.py ,about line170,
add
self._novel_classes = [ novel_classes_id ]
after the self._base_classes = [ 8, 10, 11, 13, 14, 15, 22, 23, 24, 25, 27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 65, 70, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, ]
I also have the same question. Did you solve it ?
I have solved this problem.Open the coco_evaluation.py ,about line170, add
self._novel_classes = [ novel_classes_id ]after theself._base_classes = [ 8, 10, 11, 13, 14, 15, 22, 23, 24, 25, 27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 65, 70, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, ]
Do you mean line 70?I have the error: name 'novel_classes_id' is not defined. Cloud you sent me your coco_evaluation.py to me? [email protected]
I also have the same question. Did you solve it ?
I have solved this problem.Open the coco_evaluation.py ,about line170, add
self._novel_classes = [ novel_classes_id ]after theself._base_classes = [ 8, 10, 11, 13, 14, 15, 22, 23, 24, 25, 27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 65, 70, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, ]Do you mean line 70?I have the error: name 'novel_classes_id' is not defined. Cloud you sent me your coco_evaluation.py to me? [email protected]
novel_ classes_ id means that there are 80 classes in the coco dataset.There are 60 classes in the previous self._ base_classes. You need to fill in the ids of the remaining 20 classes into self._novel_classses array
Hey guys.
Sorry for not posting the solution earlier I just thought that the maintainers would fix the faulty merge right away. The issue was just meant to inform them such that they can check if other things went wrong too.
All you need to do is adding self._novel_classes = [1, 2, 3, 4, 5, 6, 7, 9, 16, 17, 18, 19, 20, 21, 44, 62, 63, 64, 67, 72] to this line. You should then have both the self._novel_classes and self._base_classes and the error should go away.