'RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton dimension 3
I ran detect.py in YOLOv5-5.0 and it shown me this. How can I fix it?
Here is the problem:
Traceback (most recent call last):
File "F:\python_yolov5\yolov5-5.0\detect.py", line 178, in <module>
detect()
File "F:\python_yolov5\yolov5-5.0\detect.py", line 61, in detect
model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run once
File "F:\anaconda\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "F:\python_yolov5\yolov5-5.0\models\yolo.py", line 123, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "F:\python_yolov5\yolov5-5.0\models\yolo.py", line 139, in forward_once
x = m(x) # run
File "F:\anaconda\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "F:\python_yolov5\yolov5-5.0\models\yolo.py", line 55, in forward
y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton dimension 3
Solution 1:[1]
Download the file at this link? https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt
replace default downloaded file(v6.1)---yolov5s.pt
then run detect.py. and it will be OK!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | agyness deyn |