mat1 dim 1 must match mat2 dim 0 #153

Open
opened 2021-11-17 11:57:13 +01:00 by f0restw0w · 2 comments
f0restw0w commented 2021-11-17 11:57:13 +01:00 (Migrated from github.com)

Traceback (most recent call last):
File "test_one_image.py", line 57, in
latend_id = model.netArc(img_id_downsample)
File "D:\Dev\Anaconda3\envs\simswap\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "E:\project\ai\SimSwap\models\models.py", line 145, in forward
x = self.fc(x)
File "D:\Dev\Anaconda3\envs\simswap\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Dev\Anaconda3\envs\simswap\lib\site-packages\torch\nn\modules\linear.py", line 94, in forward
return F.linear(input, self.weight, self.bias)
File "D:\Dev\Anaconda3\envs\simswap\lib\site-packages\torch\nn\functional.py", line 1753, in linear
return torch._C._nn.linear(input, weight, bias)
RuntimeError: mat1 dim 1 must match mat2 dim 0

Traceback (most recent call last): File "test_one_image.py", line 57, in <module> latend_id = model.netArc(img_id_downsample) File "D:\Dev\Anaconda3\envs\simswap\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "E:\project\ai\SimSwap\models\models.py", line 145, in forward x = self.fc(x) File "D:\Dev\Anaconda3\envs\simswap\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "D:\Dev\Anaconda3\envs\simswap\lib\site-packages\torch\nn\modules\linear.py", line 94, in forward return F.linear(input, self.weight, self.bias) File "D:\Dev\Anaconda3\envs\simswap\lib\site-packages\torch\nn\functional.py", line 1753, in linear return torch._C._nn.linear(input, weight, bias) RuntimeError: mat1 dim 1 must match mat2 dim 0
Bob-jpg commented 2021-11-18 07:11:27 +01:00 (Migrated from github.com)

you can use test_whole_swapimage.py

you can use test_whole_swapimage.py
jz-exwzd commented 2021-11-22 00:55:00 +01:00 (Migrated from github.com)

It can be due to an error in the input size on the upstream of the netArc model, causing the matrix dimension mat1 and mat2 to be mismatched on the shown linear layer.
In this case, it can be that your "img_id_downsample" is not of correct shape. Or the original img_a is of size which is not divisible by 2. I have tested with images of size 224 and 256, maybe you can try to play around with your input size.

It can be due to an error in the input size on the upstream of the netArc model, causing the matrix dimension mat1 and mat2 to be mismatched on the shown linear layer. In this case, it can be that your "img_id_downsample" is not of correct shape. Or the original img_a is of size which is not divisible by 2. I have tested with images of size 224 and 256, maybe you can try to play around with your input size.
Sign in to join this conversation.