WongKinYiu / yolor

implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks (https://arxiv.org/abs/2105.04206)
GNU General Public License v3.0
1.99k stars 521 forks source link

Training on custom dataset and labels #45

Closed devloper13 closed 3 years ago

devloper13 commented 3 years ago

I have a dataset of my own which has 8 labels, completely different from the coco labels. I changed the data/coco.names and data/coco.yaml accordingly. But I get an index error:

Traceback (most recent call last):
  File "train.py", line 537, in <module>
    train(hyp, opt, device, tb_writer, wandb)
  File "train.py", line 344, in train
    log_imgs=opt.log_imgs if wandb else 0)
  File "/home/ubuntu/yolor/test.py", line 226, in test
    plot_images(img, output_to_target(output, width, height), paths, f, names)  # predictions
  File "/home/ubuntu/yolor/utils/plots.py", line 164, in plot_images
    cls = names[cls] if names else cls
IndexError: list index out of range

I tried printing the detection classes and its in the range 0-79 i.e coco labels. But why is this happening when I completely changed the labels?

Training command: python train.py --batch-size 1 --img 1280 1280 --data coco.yaml --cfg cfg/yolor_p6.cfg --weights yolor_p6.pt --device 0 --name yolor_p6_digit --hyp hyp.scratch.1280.yaml --epochs 5

LaoGanGit commented 3 years ago

你好,我也遇到这个问题,请问您找到解决方法了吗

neel04 commented 2 years ago

Hey, how did you solve this?

dripdropdr commented 2 years ago

How did you solve this? I have the same problem, too.

LoveDH commented 2 years ago

In coco.names, there is an empty line at the last. Screenshot from 2022-03-17 10-31-42 maybe you didn't create the last empty line. It worked for me after added this line.