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.56k stars 6.27k forks source link

Few problems #946

Open SperenzaNarra opened 2 years ago

SperenzaNarra commented 2 years ago

THIS PROGRAM HAVE TO RUN WITH Python3.8 instead of 3.10, if unable to solve the problem, please make a detection of python version

You should notice people they can build default labels before opening files I edit the function in the labelImg.py

    def load_predefined_classes(self, predef_classes_file):
        if os.path.exists(predef_classes_file) is True:
            with codecs.open(predef_classes_file, 'r', 'utf8') as f:
                for line in f:
                    line = line.strip()
                    if self.label_hist is None:
                        self.label_hist = [line]
                    else:
                        self.label_hist.append(line)
                print(f"INFO: {predef_classes_file} is loaded")
        if self.label_hist is None:
            print(f"INFO: Empty or {predef_classes_file} not found, you can edit for building default labels")

Also, this app crashed because I don't have enough lines in the labels/classes.txt file, you should notice people to solve the problem. yolo_io.py

class YoloReader:

    def __init__(self, file_path, image, class_list_path=None):
        # shapes type:
        # [label, [(x1,y1), (x2,y2), (x3,y3), (x4,y4)], color, color, difficult]
        self.shapes = []
        self.file_path = file_path
        ...

    def yolo_line_to_shape(self, class_index, x_center, y_center, w, h):
        try:
            label = self.classes[int(class_index)]
        except IndexError as e:
            class_path = os.path.join(os.path.dirname(os.path.abspath(self.file_path)), "classes.txt")
            raise type(e)(f"{e}, failed to reach classes[{class_index}], please try to update {class_path}")