pytorch-yolo-v3 icon indicating copy to clipboard operation
pytorch-yolo-v3 copied to clipboard

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

Open khany27 opened this issue 5 years ago • 2 comments

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

khany27 avatar Sep 08 '20 13:09 khany27

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

rttariverdi67 avatar Nov 28 '20 12:11 rttariverdi67

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.

Wenqing-Zheng avatar Dec 03 '20 04:12 Wenqing-Zheng