hustvl/QueryInst

DynamicMaskHead of MMDistributedDataParallel does not matches the length of `CLASSES` in CocoDataset

Closed this issue · 5 comments

While training a custom dataset having 2 coco classes with the config configs/queryinst/queryinst_swin_large_patch4_window7_fpn_300_proposals_crop_mstrain_400-1200_50e_coco.py

the model shows an error like this -
Traceback (most recent call last): File "tools/train.py", line 188, in <module> main() File "tools/train.py", line 184, in main meta=meta) File "/content/QueryInst/mmdet/apis/train.py", line 193, in train_detector runner.run(data_loaders, cfg.workflow) File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/epoch_based_runner.py", line 127, in run epoch_runner(data_loaders[i], **kwargs) File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/epoch_based_runner.py", line 45, in train self.call_hook('before_train_epoch') File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/base_runner.py", line 307, in call_hook getattr(hook, fn_name)(self) File "/content/QueryInst/mmdet/datasets/utils.py", line 155, in before_train_epoch self._check_head(runner) File "/content/QueryInst/mmdet/datasets/utils.py", line 142, in _check_head (f'Thenum_classes({module.num_classes}) in ' AssertionError: Thenum_classes(80) in DynamicMaskHead of MMDistributedDataParallel does not matches the length ofCLASSES2) in CocoDataset

The environment is google colab with Tesla-K80 GPU enabled at GPU:0

I've updated the classes in /content/QueryInst/mmdet/datasets/coco.py , /content/QueryInst/mmdet/core/evaluation/class_names.py and also in the base files of the corresponding config file.
Please help !!

Hi, @sagnik1511! Thanks for your interest on our work.
Actually, the error logs already told us what's wrong and what to do. It seems that your custom dataset has 2 classes only, while the configuration you used still built a mask head with 80 classes. Please make sure the number of class in your model config is consistent with your custom dataset.

Thanks for replying. Actually, I've updated all the num_classes in the model configs but figured out that there was no specific variable associated with the DynamicMaskHead, so added the num_classes there and the program is running now.

It's glad to see you have solved this problem and as such I'm closing this issue. Let us know if you have any questions in the future!

qzsrh commented

Hi, @sagnik1511! Thanks for your interest on our work.
Actually, the error logs already told us what's wrong and what to do. It seems that your custom dataset has 2 classes only, while the configuration you used still built a mask head with 80 classes. Please make sure the number of class in your model config is consistent with your custom dataset.

Thanks for replying. Actually, I've updated all the num_classes in the model configs but figured out that there was no specific variable associated with the DynamicMaskHead, so added the num_classes there and the program is running now.

I also encountered this problem. I would like to ask you where you have modified and solved this problem. I look forward to your answer. Thank you!

Search for the variable DynamicMaskHead in the repo. Maybe you'll find it in the configs. Then below that config dict add a line num_classes={number of classes you want }, and it's done.