yjh0410 / PyTorch_YOLO-Family

Apache License 2.0
158 stars 47 forks source link

RuntimeError: The size of tensor a (45) must match the size of tensor b (46) at non-singleton dimension 2 #14

Closed kulkarnikeerti closed 1 year ago

kulkarnikeerti commented 2 years ago

I get this error when RuntimeError: The size of tensor a (45) must match the size of tensor b (46) at non-singleton dimension 2I use (720,1440) as an input image size. But the same model works without any issues when I use (960,1920)as image size. How does this image sizes differs? Both of them are rectangle.

https://github.com/yjh0410/PyTorch_YOLO-Family/blob/a26e9ddd3c2263d6384bee0b0f9ef353775fb281/models/yolo/yolo_nano.py#L204

Can you please tell me where its going wrong. It would be great if you can guide me here. Thanks

yjh0410 commented 1 year ago

@kulkarnikeerti You need to make sure that the sizes (width and height) of the input images are all multiples of 32 (such as 640x480), otherwise you will encounter the error you show, since the maximum output stride of the network is 32.