motokimura / PyTorch_Gaussian_YOLOv3

PyTorch implementation of Gaussian YOLOv3 (including training code for COCO dataset)
Other
156 stars 44 forks source link

IndexError: index 19 is out of bounds for dimension 3 with size 19 Line 196 yolo_layer #49

Open Akola-Mbey-Denis opened 2 years ago

Akola-Mbey-Denis commented 2 years ago

Please any idea on how to fix this issue Traceback (most recent call last): File "train.py", line 238, in main() File "train.py", line 186, in main loss = model(imgs, targets) File "/home/agnan/workspace_denis/PyTorch_Gaussian_YOLOv3/YOLO/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, kwargs) File "/home/agnan/workspace_denis/PyTorch_Gaussian_YOLOv3/models/yolov3.py", line 154, in forward x, loss_dict = module(x, targets) File "/home/agnan/workspace_denis/PyTorch_Gaussian_YOLOv3/YOLO/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, kwargs) File "/home/agnan/workspace_denis/PyTorch_Gaussian_YOLOv3/models/yolo_layer.py", line 196, in forward obj_mask[b, a, j, i] = 1 IndexError: index 19 is out of bounds for dimension 3 with size 19

Akola-Mbey-Denis commented 2 years ago

This fixed my error: truth_i_all[truth_i_all < 0] = 0 truth_j_all[truth_j_all < 0] = 0 truth_w_all[truth_w_all < 0] = 0 truth_h_all[truth_h_all < 0] = 0

    truth_i_all[truth_i_all > fsize- 1] = fsize - 1
    truth_j_all[truth_j_all > fsize- 1] = fsize - 1
    truth_w_all[truth_w_all > fsize -1] = fsize - 1
    truth_h_all[truth_h_all > fsize - 1] = fsize - 1