ying09 / TextFuseNet

A PyTorch implementation of "TextFuseNet: Scene Text Detection with Richer Fused Features".
MIT License
474 stars 121 forks source link

IndexError: The shape of the mask [114] at index 0 does not match the shape of the indexed tensor [149, 256, 14, 14] at index 0 #60

Open Dengligedeng opened 3 years ago

Dengligedeng commented 3 years ago

Hi, my training procedure failed and the log is as below:

Traceback (most recent call last): File "D:\nlp_projects\git_code\TextFuseNet\detectron2\engine\train_loop.py", line 132, in train self.run_step() File "D:\nlp_projects\git_code\TextFuseNet\detectron2\engine\train_loop.py", line 212, in run_step loss_dict = self.model(data) File "D:\anaconda\envs\pujinyi\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, kwargs) File "D:\nlp_projects\git_code\TextFuseNet\detectron2\modeling\metaarch\rcnn.py", line 88, in forward , detector_losses = self.roi_heads(images, features, proposals, gt_instances) File "D:\anaconda\envs\pujinyi\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, *kwargs) File "D:\nlp_projects\git_code\TextFuseNet\detectron2\modeling\roi_heads\roi_heads.py", line 584, in forward losses.update(self._forward_mask(features_list, proposals, targets)) File "D:\nlp_projects\git_code\TextFuseNet\detectron2\modeling\roi_heads\roi_heads.py", line 684, in _forward_mask mask_features = self.mutil_path_fuse_module(mask_features, global_context, proposals) File "D:\anaconda\envs\pujinyi\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(input, kwargs) File "D:\nlp_projects\git_code\TextFuseNet\detectron2\modeling\roi_heads\mutil_path_fuse_module.py", line 94, in forward text = x[char_pos[i]] IndexError: The shape of the mask [114] at index 0 does not match the shape of the indexed tensor [149, 256, 14, 14] at index 0

I check the code and find in detectron2/modeling/roi_heads/multi_path_fuse_module.py, there is code to only take the proposals of the first image in the batch:

image

However, the first dim size of input x(shown in the upper image) is the total num of proposals in this batch, then we will meet with this dose-not-match problem. If I change the batch size in the config file as 1, this problem don't exists anymore because the total num of proposals is just the number of 1st image's proposal.

I wonder did I make any mistake in understanding this code and would you pls tell me why only the first image's proposal is used here?

Mehedi-Hasan-NSL commented 2 years ago

If i change the batch size or input size i get these type of error Didn't they handle it dynamically on their implementation on detectrin2 ?

satheeshkatipomu commented 2 years ago

@Dengligedeng Hi,

I am also facing the same issue. Are you able to solve this issue?

LIYHUI commented 2 years ago

@satheeshkatipomu Hi,

I am also facing the same issue. Have you solved it?