#5103·detectron2

AssertionError: A prediction has class=10, but the dataset only has 10 classes and predicted class id should be in [0, 9].

Author: mahilaMoghadamiCreated Oct 4, 2023Updated Jan 3, 2026
Labelsdocumentation

File "train_fcos.py", line 89, in launch( File "/home/mahilamoghadami.mut/miniconda3/envs/CZDET/lib/python3.8/site-packages/detectron2/engine/launch.py", line 82, in launch main_func(*args) File "train_fcos.py", line 80, in main return trainer.train() File "/home/mahilamoghadami.mut/miniconda3/envs/CZDET/lib/python3.8/site-packages/detectron2/engine/defaults.py", line 484, in train super().train(self.start_iter, self.max_iter) File "/home/mahilamoghadami.mut/miniconda3/envs/CZDET/lib/python3.8/site-packages/detectron2/engine/train_loop.py", line 150, in train self.after_step() File "/home/mahilamoghadami.mut/miniconda3/envs/CZDET/lib/python3.8/site-packages/detectron2/engine/train_loop.py", line 180, in after_step h.after_step() File "/home/mahilamoghadami.mut/miniconda3/envs/CZDET/lib/python3.8/site-packages/detectron2/engine/hooks.py", line 552, in after_step self._do_eval() File "/home/mahilamoghadami.mut/miniconda3/envs/CZDET/lib/python3.8/site-packages/detectron2/engine/hooks.py", line 525, in _do_eval results = self._func() File "/home/mahilamoghadami.mut/CZDet/DroneDetectron2/croptrain/engine/trainer_fcos.py", line 234, in test_and_save_results self._last_eval_results = self.test_crop(self.cfg, self.model, self.iter) File "/home/mahilamoghadami.mut/CZDet/DroneDetectron2/croptrain/engine/trainer_fcos.py", line 278, in test_crop results_i = inference_fcos.inference_with_crops(model, data_loader, evaluator, cfg, iter) File "/home/mahilamoghadami.mut/CZDet/DroneDetectron2/croptrain/engine/inference_fcos.py", line 124, in inference_with_crops results = evaluator.evaluate() File "/home/mahilamoghadami.mut/miniconda3/envs/CZDET/lib/python3.8/site-packages/detectron2/evaluation/coco_evaluation.py", line 194, in evaluate self._eval_predictions(predictions, img_ids=img_ids) File "/home/mahilamoghadami.mut/miniconda3/envs/CZDET/lib/python3.8/site-packages/detectron2/evaluation/coco_evaluation.py", line 228, in _eval_predictions assert category_id < num_classes, ( **AssertionError: A prediction has class=10, but the dataset only has 10 classes and predicted class id should be in [0, 9].

AssertionError: A prediction has class=10, but the dataset only has 10 classes and predicted class id should be in [0, 9].**

Source: facebookresearch/detectron2