HumanSignal / labelImg

LabelImg is now part of the Label Studio community. The popular image annotation tool created by Tzutalin is no longer actively being developed, but you can check out Label Studio, the open source data labeling tool for images, text, hypertext, audio, video and time-series data.
https://youtu.be/p0nR2YsCY_U
MIT License
22.15k stars 6.23k forks source link

BUG: GUI crashes for invalid label index #980

Open sohang3112 opened 1 year ago

sohang3112 commented 1 year ago

In classes.txt, if 2 items are present, but the label annotation text for an image has an invalid index (eg. 4), then the program crashes due to IndexError. Instead of crashing, this error should be caught and shown in error popup in the GUI.

1062)], None, None, False)]
Traceback (most recent call last):
  File "C:\Users\SohangChopra\AppData\Local\Programs\Python\Python311\Lib\site-packages\labelImg\labelImg.py", line 1348, in open_prev_image
    self.load_file(filename)
  File "C:\Users\SohangChopra\AppData\Local\Programs\Python\Python311\Lib\site-packages\labelImg\labelImg.py", line 1111, in load_file
    self.show_bounding_box_from_annotation_file(file_path)
  File "C:\Users\SohangChopra\AppData\Local\Programs\Python\Python311\Lib\site-packages\labelImg\labelImg.py", line 1154, in show_bounding_box_from_annotation_file
    self.load_yolo_txt_by_filename(txt_path)
  File "C:\Users\SohangChopra\AppData\Local\Programs\Python\Python311\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\SohangChopra\AppData\Local\Programs\Python\Python311\Lib\site-packages\libs\yolo_io.py", line 112, in __init__
    self.parse_yolo_format()
  File "C:\Users\SohangChopra\AppData\Local\Programs\Python\Python311\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\SohangChopra\AppData\Local\Programs\Python\Python311\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
gil938271 commented 1 year ago

isn't everything above 3.10 can not work because of the float to int bug?

gil938271 commented 1 year ago

from 3.10

sohang3112 commented 1 year ago

float to int bug

I don't know what you are referring to - can you please clarify?

gil938271 commented 1 year ago

https://github.com/heartexlabs/labelImg/issues/938

sohang3112 commented 1 year ago

So downgrading to version 1.8.1 should work on Windows, right?

gil938271 commented 1 year ago

not sure i downgrade my python as you can see in the link the real problem is with qt