[labelImg] IndexError: list index out of range

박휘버그·2024년 1월 31일
0
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39-32\lib\site-packages\labelImg\labelImg.py", line 1376, in open_next_image
    self.load_file(filename)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39-32\lib\site-packages\labelImg\labelImg.py", line 1111, in load_file
    self.show_bounding_box_from_annotation_file(file_path)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39-32\lib\site-packages\labelImg\labelImg.py", line 1144, in show_bounding_box_from_annotation_file
    self.load_yolo_txt_by_filename(txt_path)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39-32\lib\site-packages\labelImg\labelImg.py", line 1557, in load_yolo_txt_by_filename
    t_yolo_parse_reader = YoloReader(txt_path, self.image)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39-32\lib\site-packages\libs\yolo_io.py", line 112, in __init__
    self.parse_yolo_format()
  File "C:\Users\user\AppData\Local\Programs\Python\Python39-32\lib\site-packages\libs\yolo_io.py", line 143, in parse_yolo_format
    label, x_min, y_min, x_max, y_max = self.yolo_line_to_shape(class_index, x_center, y_center, w, h)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39-32\lib\site-packages\libs\yolo_io.py", line 125, in yolo_line_to_shape
    label = self.classes[int(class_index)]
IndexError: list index out of range

🍀오류 현상

labelImg로 라벨링 작업 중 프롬포트에 이런 오류가 나오면서 자꾸 labelImg가 꺼지는 현상이 발생했다.

🍀원인

나 같은 경우에 기존 작업할 때 라벨을 cow, tail 이 2가지로 설정해놓았었는데, labelImg에서 Open Dir을 할 때마다 classes.txt가 새로 생성 됐던 것.
따라서 2가지 라벨 중 하나가 없어져서 자꾸 오류가 났었던 것!

🍀해결방법

  1. Open Dir을 한다

  2. label 저장소에 있는 classes.txt 파일을 연다

  3. 기존 label들을 다시 적는다.
    (필자같은 경우, cow와 tail을 적는다.)

  4. ctrl+S

🍀해결 끝 !!

profile
I'm coding bakhwee bug🪳

0개의 댓글