qitianwu/SGFormer

RuntimeError: shape '[10, 18, 7, 18, 7, 32]' is invalid for input of size 5242880

Closed this issue · 1 comments

Thank you for your contribution to science, I am having the following problem reproducing your code
Traceback (most recent call last):
File "/tmp/pycharm_project_772/tools/train.py", line 195, in
main()
File "/tmp/pycharm_project_772/tools/train.py", line 184, in main
train_detector(
File "/tmp/pycharm_project_772/mmdet/apis/train.py", line 186, in train_detector
runner.run(data_loaders, cfg.workflow)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 136, in run
epoch_runner(data_loaders[i], **kwargs)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 53, in train
self.run_iter(data_batch, train_mode=True, **kwargs)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 31, in run_iter
outputs = self.model.train_step(data_batch, self.optimizer,
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/mmcv/parallel/data_parallel.py", line 77, in train_step
return self.module.train_step(*inputs[0], **kwargs[0])
File "/tmp/pycharm_project_772/mmdet/models/detectors/base.py", line 247, in train_step
losses = self(**data)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/mmcv/runner/fp16_utils.py", line 146, in new_func
output = old_func(*new_args, **new_kwargs)
File "/tmp/pycharm_project_772/mmdet/models/detectors/base.py", line 181, in forward
return self.forward_train(img, img_metas, **kwargs)
File "/tmp/pycharm_project_772/mmdet/models/detectors/two_stage.py", line 142, in forward_train
x = self.extract_feat(img)
File "/tmp/pycharm_project_772/mmdet/models/detectors/two_stage.py", line 82, in extract_feat
x = self.backbone(img)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/tmp/pycharm_project_772/mmdet/models/backbones/sgformer.py", line 484, in forward
x, mask = blk(x, H, W, mask)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in call_impl
return forward_call(*args, **kwargs)
File "/tmp/pycharm_project_772/mmdet/models/backbones/sgformer.py", line 263, in forward
x
, mask = self.attn(self.norm1(x), H, W, mask)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/tmp/pycharm_project_772/mmdet/models/backbones/sgformer.py", line 150, in forward
q2, k2, v2 = window_partition(q2, q_window, H, W), window_partition(k2, window_size, H, W),
File "/tmp/pycharm_project_772/mmdet/models/backbones/sgformer.py", line 24, in window_partition
x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)
RuntimeError: shape '[10, 18, 7, 18, 7, 32]' is invalid for input of size 5242880, I entered an image size of 512x512

Hi, can you provide more details on this issue? What dataset and script did you use?