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 (28) must match the size of tensor b (76) at non-singleton dimension 3 when Image size is changed from 608 to 224 #523

Open imihassan opened 2 years ago

imihassan commented 2 years ago

Hi, I changed the image size in Cfg file to

Cfg.width = 224
Cfg.height = 224

I got the below error. I am not able to resolve it. Can you help me to find out the problem.

Epoch 1/3:   0%|           | 0/2 [00:03<?, ?img/s]
Traceback (most recent call last):
  File "train.py", line 634, in <module>
    train(model=model,
  File "train.py", line 383, in train
    loss, loss_xy, loss_wh, loss_obj, loss_cls, loss_l2 = criterion(bboxes_pred, bboxes)
  File "C:\ProgramData\Anaconda3\envs\yolov4t\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "train.py", line 249, in forward
    pred[..., 0] += self.grid_x[output_id]
RuntimeError: The size of tensor a (28) must match the size of tensor b (76) at non-singleton dimension 3
imihassan commented 2 years ago

any suggestions?

imihassan commented 2 years ago

I am still not able to solve this problem. Any one know this?

pavlik-tikhomirov commented 1 year ago

try change strides in train.py (from [8, 16, 32] to [32, 16, 8]

I am still not able to solve this problem. Any one know this?

imihassan commented 1 year ago

try change strides in train.py (from [8, 16, 32] to [32, 16, 8]

I am still not able to solve this problem. Any one know this?

I changed but still no success.