eriklindernoren / PyTorch-YOLOv3

Minimal PyTorch implementation of YOLOv3
GNU General Public License v3.0
7.3k stars 2.63k forks source link

error with own dataset #26

Closed lupotto closed 6 years ago

lupotto commented 6 years ago

Hello,

I found an error in the last commit:

Traceback (most recent call last): File "train.py", line 82, in loss = model(imgs, targets) File "/home/alupotto/anaconda3/envs/pt4_cu9_p35/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, kwargs) File "/home/alupotto/PycharmProjects/tracktorch/models.py", line 213, in forward x, losses = module[0](x, targets) File "/home/alupotto/anaconda3/envs/pt4_cu9_p35/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(input, kwargs) File "/home/alupotto/PycharmProjects/tracktorch/models.py", line 177, in forward return loss, loss_x.item(), loss_y.item(), loss_w.item(), loss_h.item(), loss_conf.item(), loss_cls.item(), float(nCorrect/nGT) ZeroDivisionError: division by zero

I am training with my own data/labels and I had some images that didn't have ground truth at all So the file .txt exists but inside is empty.

I just added a check control before return float(nCorrect/nGT) in models.py like this:

AP = float(nCorrect/nGT) if nGT is not 0 else 0 and then I return AP.

I mention it in case somebody has the same problem or for future updates.

lyzband commented 6 years ago

I have a same problem even after new commit(122c24b4aeb11ecba5f77c3bf5ef8f20f2167c77)

mshu1 commented 5 years ago

Hello, is this problem fixed? Thanks