andy-yun / pytorch-0.4-yolov3

Yet Another Implimentation of Pytroch 0.4.1 and YoloV3 on python3
MIT License
278 stars 72 forks source link

problem with train.py in python3, IndexError: index 2 is out of bounds for dimension 0 with size 1 #57

Closed vishnu41 closed 5 years ago

vishnu41 commented 5 years ago

I'm getting this error only while using python3 Screenshot (32)

find attached cfg file yolo-voc.txt

andy-yun commented 5 years ago

Attached file is used at yolov2. But your error is occurred while yolov3 is running. Would you check the command or cfg once more?

vishnu41 commented 5 years ago

Got it. The problem was with the data. Anyway thanks for the code man

On Thu, Mar 21, 2019 at 12:01 PM Young-Sun (Andy) Yun < notifications@github.com> wrote:

Attached file is used at yolov2. But your error is occurred while yolov3 is running. Would you check the command or cfg once more?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/andy-yun/pytorch-0.4-yolov3/issues/57#issuecomment-475124960, or mute the thread https://github.com/notifications/unsubscribe-auth/AmTI8NIduOdAzf5w1RMhKf2iEcnClpduks5vYyc9gaJpZM4b-6k5 .

mrkieumy commented 5 years ago

Hi @andy-yun , I meet the same this error in test function. Training is normal, no error. But: Because I want to see the test loss, so I copy 3 lines in train function to test function: test_loss = 0.0 for i, l in enumerate(loss_layers): ol = l(output[i]['x'], target) test_loss += ol.item() And when run to this line in test function ( ol = l(output[i]['x'], target) ) , the error is: ......... File "/home/kieumy/YOLO/pytorch/yolo_layer.py", line 152, in forward self.build_targets(pred_boxes, target.detach(), anchors.detach(), nA, nH, nW) File "/home/kieumy/YOLO/pytorch_conditioning/yolo_layer.py", line 102, in build_targets tcls[b][best_n][gj][gi][int(tbox[t][0])] = 1 IndexError: index 1 is out of bounds for dimension 0 with size 1

I saw on the code of build_targets that the index best_n is a torch tensor (0), so I tried best_n = int(best_n.item()). But the error's still there. I don't understand because, during training, it runs normally, but when I call test function, this error occurs. Does anyone know the reason why? Thanks.

vishnu41 commented 5 years ago

@mrkieumy there's problem with the one of the .txt file in test data set. One or more images in test data set is wrongly annotated. I got the error because there are more than given number of classes in one of the .txt file

mrkieumy commented 5 years ago

Thank you very much @vishnu41 . You save my life :)