Pytorch-yolov3: Problem in train.py

Created on 16 May 2019  ยท  9Comments  ยท  Source: eriklindernoren/PyTorch-YOLOv3

Computing AP:   4%|โ–ˆโ–ˆโ–‰                                                                  | 1/24 [00:00<00:03,  6.08it/Computing AP:  12%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‹                                                            | 3/24 [00:00<00:03,  6Computing AP:  25%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Ž                                                   | 6/24 [00:00<Computing AP:  46%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–                                    |Computing AP:  58%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‹                     Computing AP:  96%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ Computing AP: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 24/24 [00:00<00:00, 25.96it/s]
Traceback (most recent call last):
  File "train.py", line 173, in <module>
    ap_table += [[c, class_names[c], "%.5f" % AP[i]]]
IndexError: list index out of range

Print class APs and mAP

ap_table = [["Index", "Class name", "AP"]]
for i, c in enumerate(ap_class):
ap_table += [[c, class_names[c], "%.5f" % AP[i]]]
print(AsciiTable(ap_table).table)
print(f"---- mAP {AP.mean()}")

This module might have some problems in my custom training, do you know what happened?

Most helpful comment

I found the solution! In your custom class name file (/data/custom/classes.names), you need to leave an empty line at the end.

Because in utils/utils.py, the function "load_classes" parses the name file like this: [:-1], which ends up only selecting the first n-1 names in the file if u don't leave an empty line at the end.

If you look at the coco dataset name file, you'll find that empty line in the end as well. (data/coco.names)

I tried removing the empty line and change the [:-1] to [:], but somehow the evaluation gets stuck and not working. It's really weird. But anyways, it should be working with this fix.

All 9 comments

I have the same problem!

I found the solution! In your custom class name file (/data/custom/classes.names), you need to leave an empty line at the end.

Because in utils/utils.py, the function "load_classes" parses the name file like this: [:-1], which ends up only selecting the first n-1 names in the file if u don't leave an empty line at the end.

If you look at the coco dataset name file, you'll find that empty line in the end as well. (data/coco.names)

I tried removing the empty line and change the [:-1] to [:], but somehow the evaluation gets stuck and not working. It's really weird. But anyways, it should be working with this fix.

I found the solution! In your custom class name file (/data/custom/classes.names), you need to leave an empty line at the end.

Because in utils/utils.py, the function "load_classes" parses the name file like this: [:-1], which ends up only selecting the first n-1 names in the file if u don't leave an empty line at the end.

If you look at the coco dataset name file, you'll find that empty line in the end as well. (data/coco.names)

I tried removing the empty line and change the [:-1] to [:], but somehow the evaluation gets stuck and not working. It's really weird. But anyways, it should be working with this fix.

I followed your guide and succeeded. Thank you so much.

@SirongHuang Awesome. Thanks .:)

SirongHuang
Awesome. Thanks

SirongHuang
Awesome. Thanks

SirongHuang
Awesome.Thanks

Awsome, Thanks

Is this issue still relevant/occurring?

I closed this issue due to inactivity. Feel free to reopen for further discussion.

Was this page helpful?
0 / 5 - 0 ratings