Tianxiaomo / pytorch-YOLOv4

PyTorch ,ONNX and TensorRT implementation of YOLOv4
Apache License 2.0
4.46k stars 1.49k forks source link

RuntimeError: The size of tensor a (52) must match the size of tensor b (19) at non-singleton dimension 3 #559

Open imihassan opened 1 year ago

imihassan commented 1 year ago

I have same problem I faced few months ago but I am not able to solve. Is this implementation is not compatible with changing input image size.

In configuration file I changed image size form 608 to 416 as shown below

Cfg.width = 416 Cfg.height = 416

I got the following error.

Traceback (most recent call last): File "./pytorch-YOLOv4/train.py", line 445, in train(model=model, File "./pytorch-YOLOv4/train.py", line 321, in train loss, loss_xy, loss_wh, loss_obj, loss_cls, loss_l2 = criterion(bboxes_pred, bboxes) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, **kwargs) File "./pytorch-YOLOv4/train.py", line 205, in forward pred[..., 0] += self.grid_x[output_id] RuntimeError: The size of tensor a (52) must match the size of tensor b (19) at non-singleton dimension 3

Any help is appreciated.

MKmilky commented 11 months ago

code train.py also need to be editted in line 135 image_size=608 ,you need to change it to your size as cfg.py