Taeyoung96 / Yolo-to-COCO-format-converter

Yolo to COCO annotation format converter
MIT License
280 stars 92 forks source link

IndexError: list index out of range #13

Closed thongvhoang closed 2 years ago

thongvhoang commented 2 years ago
Start!
Processing 0 ...Traceback (most recent call last):
  File "main.py", line 231, in <module>
    main(options)
  File "main.py", line 213, in main
    ) = get_images_info_and_annotations(opt)
  File "main.py", line 68, in get_images_info_and_annotations
    int(label_line.split()[0]) + 1
IndexError: list index out of range

I use this command but it's an error. How do fix this bug? Thank you. I attached my train.txt below. You can see. train.txt


!python main.py \
--path /content/drive/MyDrive/UIT/Four_Year/Term_2/DS505.M21/Dataset/detection_data/train.txt \
--output data/coco/annotation
Taeyoung96 commented 2 years ago

@thongvhoang
Hi, Did you check if the actual number of images matches the train.txt file?

The actual number of images must also be 5269 because the line in train.txt.
All images must also have a .txt file in the form of yolo label.

Therefore, In path /content/drive/MyDrive/UIT/Four_Year/Term_2/DS505.M21/Dataset/detection_data/train/ must have a total of 10538 items. (5269 images and 5269 txt files)

thongvhoang commented 2 years ago

I have solved this problem. Thank you very much. My txt file has '\n' at the end of the file, I removed the '\n' and space at the end of the file. So the problem is being solved.