Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sizes of tensors must match except in dimension 2. Got 26 and 4 #147

Open
khany27 opened this issue Sep 8, 2020 · 2 comments
Open

Sizes of tensors must match except in dimension 2. Got 26 and 4 #147

khany27 opened this issue Sep 8, 2020 · 2 comments

Comments

@khany27
Copy link

khany27 commented Sep 8, 2020

Hello,

I am getting this error, when I run video_demo.py.

Loading network..... Network successfully loaded Traceback (most recent call last): File "video_demo.py", line 111, in <module> model(get_test_input(inp_dim, CUDA), CUDA) File "C:\Users\Salem\anaconda3\envs\yo1\lib\site-packages\torch\nn\modules\module.py", line 550, in __call__ result = self.forward(*input, **kwargs) File "C:\Users\Salem\yolov3\darknet.py", line 341, in forward x = torch.cat((map1, map2), 1) RuntimeError: Sizes of tensors must match except in dimension 2. Got 26 and 4

@rttariverdi67
Copy link

rttariverdi67 commented Nov 28, 2020

Dear khany27 ,
did you solve this error? I faced with same !
for me it was the input image, like "scream.jpg" gives error!
bests.

@Wenqing-Zheng
Copy link

Wenqing-Zheng commented Dec 3, 2020

I met semilar problem, I solved it.
Date: 2020.12.2
how to fix:
in detect.py around line 224,
change:
prediction[:,0] += i*batch_size
into:

    if len(prediction)!=0:
        prediction[:,0] += i*batch_size

AND:

in util.py, around line 121:
change:
output = prediction.new(1, prediction.size(2) + 1)
into:
output = torch.tensor([])

in total, change two places, solved it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants