mmdetection: AssertionError: The `num_classes` (3) in Shared2FCBBoxHead of MMDataParallel does not matches the length of `CLASSES` 80) in CocoDataset
loading annotations into memory…
Done (t=0.00s)
creating index…
index created!
2021-03-24 16:40:44,706 - mmdet - INFO - Start running, host: jingduo@jingduo-laptop, work_dir: /media/jingduo/8aeddfe4-d52c-4516-85ec-aa500a9390d1/jingduo/mmdetection/work_dirs/cascade_rcnn_x101_32x4d_fpn_1x_coco
2021-03-24 16:40:44,707 - mmdet - INFO - workflow: [(‘train’, 1)], max: 12 epochs
Traceback (most recent call last):
File “./tools/train.py”, line 190, in <module>
main()
File “./tools/train.py”, line 186, in main
meta=meta)
File “/home/jingduo/anaconda3/envs/mmdet/lib/python3.7/site-packages/mmdet/apis/train.py”, line 170, in train_detector
runner.run(data_loaders, cfg.workflow)
File “/home/jingduo/mmcv/mmcv/runner/epoch_based_runner.py”, line 125, in run
epoch_runner(data_loaders[i], **kwargs)
File “/home/jingduo/mmcv/mmcv/runner/epoch_based_runner.py”, line 45, in train
self.call_hook(‘before_train_epoch’)
File “/home/jingduo/mmcv/mmcv/runner/base_runner.py”, line 307, in call_hook
getattr(hook, fn_name)(self)
File “/home/jingduo/anaconda3/envs/mmdet/lib/python3.7/site-packages/mmdet/datasets/utils.py”, line 150, in before_train_epoch
self._check_head(runner)
File “/home/jingduo/anaconda3/envs/mmdet/lib/python3.7/site-packages/mmdet/datasets/utils.py”, line 137, in _check_head
(f’The num_classes ({module.num_classes}) in ’
AssertionError: The num_classes (3) in Shared2FCBBoxHead of MMDataParallel does not matches the length of CLASSES 80) in CocoDataset
Can you help answer the question ? thanks
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15
Don’t write like that; (‘person’ )
You must class name like that; (‘person’, )
If you have one class; you should use a comma after the class name.
Please check your dataset number or classes names in “mmdet/datasets/coco.py” and “mmdet/core/evaluation/class_names.py” . You must change with your class name in these codes.
Hi i solve with before you build datasets, you must run this:
import mmdetmmdet.datasets.coco.CocoDataset.CLASSES=('class_1','class2')you can adjust it with the dataset you have 😃It seems that only num_classes is modified but the class names are not modified in dataset. The config should specify classes in dataset.