Closed buncybunny closed 2 years ago
The num_classes of the model must be equal to the num_classes of the dataset. You should reset the CLASSES of the datasets too. Here is the example: https://github.com/open-mmlab/mmdetection/blob/master/docs/tutorials/customize_dataset.md#1-modify-the-config-file-for-using-the-customized-dataset.
@AronLin Thanks for the reply but unfortunately this doesn't address the issue at all. If my num_classes of the model and the num_classes of the dataset was different as you said, it would output the assertion error like below.
The `num_classes` (80) in SCNetBBoxHead of MMDistributedDataParallel does not matches the length of `CLASSES` 60) in CocoDataset
There was no assertion errors like this since I've already set the num_classes of the model(in the config) and the dataset(mmdet/datasets/coco.py) equal. The model could be trained well for 1epoch and the error occurred while 'after_train_epoch'. I debugged the code and found out the model output was empty.
File "/home/pr04/tmp/tmp/mmdetection/mmdet/datasets/coco.py", line 266, in _segm2json data['category_id'] = self.cat_ids[label]
The predicted label may be out of range, you should check it first.
@AronLin I solved the problem by replacing the underbars in the class names to ' '. Thanks
Checklist
Describe the bug SCNet model output is empty when the num_classes is changed
Reproduction
Environment
python mmdet/utils/collect_env.py
to collect necessary environment information and paste it here.TorchVision: 0.9.1 OpenCV: 4.5.3 MMCV: 1.3.14 MMCV Compiler: GCC 7.3 MMCV CUDA Compiler: 10.1 MMDetection: 2.17.0+
I got into the _segm2json in coco.py and found out that the argument
results
(which is the output of the trained model) were empty tensors. I guess it has something to do with the num_classes since it worked properly when I set the num_classes to the default setting(even without the semantic head)What should I do if I want to change the num_classes of SCNet?
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!