joe-siyuan-qiao / DetectoRS

DetectoRS: Detecting Objects with Recursive Feature Pyramid and Switchable Atrous Convolution
Apache License 2.0
1.13k stars 178 forks source link

how to train DetectoRS with the COCO2017 datasets #20

Open wuqingshan2010 opened 4 years ago

wuqingshan2010 commented 4 years ago

when i train DetectoRS with the config DetectoRS_mstrain_400_1200_r50_40e.py, i get an error: RuntimeError: 1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size: : [1, 148, 152, 3]. the error is in "loss_semantic_seg = self.criterion(mask_pred, labels)" i have found the mask_pred size is [1, 163, 148, 152], but the label is [1, 148, 152, 3]. how to solve it?

i modified the config files: data = dict( imgs_per_gpu=1, workers_per_gpu=1, train=dict( type=dataset_type, ann_file=data_root + 'annotations/stuff_train2017.json', img_prefix=data_root + 'train2017/', seg_prefix=data_root + 'annotations/stuff_train2017_pixelmaps/', pipeline=train_pipeline), val=dict( type=dataset_type, ann_file=data_root + 'annotations/stuff_val2017.json', img_prefix=data_root + 'val2017/', pipeline=test_pipeline), test=dict( type=dataset_type, ann_file=data_root + 'annotations/stuff_val2017.json', img_prefix=data_root + 'val2017/', pipeline=test_pipeline))

i do not know how you get the instances_train2017.json.

joe-siyuan-qiao commented 4 years ago

It will be included in http://images.cocodataset.org/annotations/annotations_trainval2017.zip from http://cocodataset.org/#download. Please also take a look at https://github.com/joe-siyuan-qiao/DetectoRS/tree/master/configs/htc to prepare the dataset.

EnternalTwinkle commented 4 years ago

hey man, have you solved the above problem? I also encountered a similar problem. So I want to ask you how to prepare seg_prefix=data_root + 'annotations/stuff_train2017_pixelmaps/'. Although I have referred https://github.com/joe-siyuan-qiao/DetectoRS/tree/master/configs/htc. I still cant figure it out.

rose-jinyang commented 4 years ago

Hi I met the same issue.

Traceback (most recent call last): File "tools/train.py", line 142, in main() File "tools/train.py", line 138, in main meta=meta) File "/mnt/Jin/DetectoRS/mmdet/apis/train.py", line 102, in train_detector meta=meta) File "/mnt/Jin/DetectoRS/mmdet/apis/train.py", line 181, in _dist_train runner.run(data_loaders, cfg.workflow, cfg.total_epochs) File "/home/vishwam/anaconda3/envs/py37/lib/python3.7/site-packages/mmcv/runner/runner.py", line 359, in run epoch_runner(data_loaders[i], kwargs) File "/home/vishwam/anaconda3/envs/py37/lib/python3.7/site-packages/mmcv/runner/runner.py", line 263, in train self.model, data_batch, train_mode=True, kwargs) File "/mnt/Jin/DetectoRS/mmdet/apis/train.py", line 75, in batch_processor losses = model(data) File "/home/vishwam/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, *kwargs) File "/home/vishwam/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/parallel/distributed.py", line 447, in forward output = self.module(inputs[0], kwargs[0]) File "/home/vishwam/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, kwargs) File "/mnt/Jin/DetectoRS/mmdet/core/fp16/decorators.py", line 49, in new_func return old_func(args, kwargs) File "/mnt/Jin/DetectoRS/mmdet/models/detectors/base.py", line 147, in forward return self.forward_train(img, img_metas, kwargs) File "/mnt/Jin/DetectoRS/mmdet/models/detectors/htc.py", line 230, in forward_train loss_seg = self.semantic_head.loss(semantic_pred, gt_semantic_seg) File "/mnt/Jin/DetectoRS/mmdet/core/fp16/decorators.py", line 127, in new_func return old_func(args, kwargs) File "/mnt/Jin/DetectoRS/mmdet/models/mask_heads/fused_semantic_head.py", line 104, in loss loss_semantic_seg = self.criterion(mask_pred, labels) File "/home/vishwam/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, **kwargs) File "/home/vishwam/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/loss.py", line 916, in forward ignore_index=self.ignore_index, reduction=self.reduction) File "/home/vishwam/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/functional.py", line 2021, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction) File "/home/vishwam/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/functional.py", line 1840, in nll_loss ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index) RuntimeError: 1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size: : [1, 84, 124, 3]

I used default config file "DetectoRS_mstrain_400_1200_x101_32x4d_40e.py" and COCO 2017 dataset. I tried to Please let me know the reason asap. Thanks

dsnqr commented 3 years ago

I alse used default config file ‘’DetectoRS_mstrain_400_1200_r50_40e.py and COCO 2017 dataset,encountered the same problem as you.Has the problem been solved later? Can you let me know?

Traceback (most recent call last): File "tools/train.py", line 143, in main() File "tools/train.py", line 139, in main meta=meta) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/mmdet-1.1.0+612916b-py3.7-linux-x86_64.egg/mmdet/apis/train.py", line 111, in train_detector meta=meta) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/mmdet-1.1.0+612916b-py3.7-linux-x86_64.egg/mmdet/apis/train.py", line 242, in _non_dist_train runner.run(data_loaders, cfg.workflow, cfg.total_epochs) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/mmcv/runner/runner.py", line 384, in run epoch_runner(data_loaders[i], kwargs) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/mmcv/runner/runner.py", line 283, in train self.model, data_batch, train_mode=True, kwargs) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/mmdet-1.1.0+612916b-py3.7-linux-x86_64.egg/mmdet/apis/train.py", line 75, in batch_processor losses = model(data) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, *kwargs) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 150, in forward return self.module(inputs[0], kwargs[0]) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, kwargs) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/mmdet-1.1.0+612916b-py3.7-linux-x86_64.egg/mmdet/core/fp16/decorators.py", line 49, in new_func return old_func(args, kwargs) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/mmdet-1.1.0+612916b-py3.7-linux-x86_64.egg/mmdet/models/detectors/base.py", line 147, in forward return self.forward_train(img, img_metas, kwargs) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/mmdet-1.1.0+612916b-py3.7-linux-x86_64.egg/mmdet/models/detectors/htc.py", line 230, in forward_train loss_seg = self.semantic_head.loss(semantic_pred, gt_semantic_seg) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/mmdet-1.1.0+612916b-py3.7-linux-x86_64.egg/mmdet/core/fp16/decorators.py", line 127, in new_func return old_func(args, kwargs) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/mmdet-1.1.0+612916b-py3.7-linux-x86_64.egg/mmdet/models/mask_heads/fused_semantic_head.py", line 104, in loss loss_semantic_seg = self.criterion(mask_pred, labels) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, **kwargs) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/torch/nn/modules/loss.py", line 916, in forward ignore_index=self.ignore_index, reduction=self.reduction) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/torch/nn/functional.py", line 2021, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction) File "/home/qh/.conda/envs/mm1/lib/python3.7/site-packages/torch/nn/functional.py", line 1840, in nll_loss ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index) RuntimeError: 1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size: : [1, 52, 64, 3]

Thank you very much.

dsnqr commented 3 years ago

hey man, have you solved the above problem? I also encountered a similar problem. So I want to ask you how to prepare seg_prefix=data_root + 'annotations/stuff_train2017_pixelmaps/'. Although I have referred https://github.com/joe-siyuan-qiao/DetectoRS/tree/master/configs/htc. I still cant figure it out.

How did you solve this problem later? Looking forward to your reply! @EnternalTwinkle