Bobo-y / flexible-yolov5

More readable and flexible yolov5 with more backbone(gcn, resnet, shufflenet, moblienet, efficientnet, hrnet, swin-transformer, etc) and (cbam,dcn and so on), and tensorrt
GNU General Public License v3.0
665 stars 120 forks source link

swin_transformer: RuntimeError: Expected object of scalar type Float but got scalar type Half for argument #2 'mat2' in call to _th_bmm_out Images sizes do not match. This will causes images to be display incorrectly in the UI.` #62

Closed yssid closed 2 years ago

yssid commented 2 years ago

when training swin_transformer receiving Error: Here is the output: can you please explain what's the issue?.

`Epoch gpu_mem box obj cls total targets img_size 0/9 1.23G 0.08236 0.01982 0 0.1022 0 640: 100%|████████████████████████████████████████████████████| 1430/1430 [04:11<00:00, 5.68it/s] Class Images Targets P R mAP@.5 mAP@.5:.95: 0%| | 0/728 [00:00<?, ?it/s]

Traceback (most recent call last): File "scripts/train.py", line 527, in train(hyp, opt, device, tb_writer, wandb) File "scripts/train.py", line 354, in train compute_loss=compute_loss) File ".\scripts\eval.py", line 109, in test inf_out, train_out = model(img) # inference and training outputs

File "\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl result = self.forward(*input, **kwargs)

File ".\od\models\model.py", line 67, in forward out = self.backbone(x)

File "\site-packages\torch\nn\modules\module.py", line 727, in _call_impl result = self.forward(*input, **kwargs)

File ".\od\models\backbone\swin_transformer.py", line 598, in forward x_out, H, W, x, Wh, Ww = layer(x, Wh, Ww)

File "\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl result = self.forward(*input, **kwargs)

File ".\od\models\backbone\swin_transformer.py", line 382, in forward x = blk(x, attn_mask)

File "\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl result = self.forward(*input, **kwargs)

File ".\od\models\backbone\swin_transformer.py", line 224, in forward attn_windows = self.attn(x_windows, mask=attn_mask) # nWB, window_sizewindow_size, C

File "\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl result = self.forward(*input, **kwargs)

File ".\od\models\backbone\swintransformer.py", line 142, in forward x = (attn @ v).transpose(1, 2).reshape(B, N, C)

RuntimeError: Expected object of scalar type Float but got scalar type Half for argument #2 'mat2' in call to _th_bmm_out Images sizes do not match. This will causes images to be display incorrectly in the UI.`

Bobo-y commented 2 years ago

@yssid please see https://github.com/yl305237731/flexible-yolov5/issues/34