From 9e4a4b711eb63597916eaf59cb7b95ac072b0164 Mon Sep 17 00:00:00 2001 From: PTA00 <59364024+PTA00@users.noreply.github.com> Date: Tue, 8 Mar 2022 14:56:10 +0800 Subject: [PATCH] Problems found while packaging as binaries.Has been tested. (#855) * Fix Error "IndexError: list index out of range" occurs when there is no "predefined_classes.txt". * Fix an error when default label is null. Error "IndexError: list index out of range" occurs when there is no "/data/predefined_classes.txt". * Update README.rst ADD: Package as a separate exe file method. --- README.rst | 9 +++++++++ labelImg.py | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 5c0c33d5..eadc49cf 100644 --- a/README.rst +++ b/README.rst @@ -119,6 +119,15 @@ Open cmd and go to the `labelImg <#labelimg>`__ directory python labelImg.py python labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE] +If you want to package it into a separate EXE file + +.. code:: shell + + Install pyinstaller and execute: + + pip install pyinstaller + pyinstaller --hidden-import=pyqt5 --hidden-import=lxml -F -n "labelImg" -c labelImg.py -p ./libs -p ./ + Windows + Anaconda ^^^^^^^^^^^^^^^^^^ diff --git a/labelImg.py b/labelImg.py index a19a11f7..053cde0c 100755 --- a/labelImg.py +++ b/labelImg.py @@ -109,7 +109,10 @@ class MainWindow(QMainWindow, WindowMixin): # Load predefined classes to the list self.load_predefined_classes(default_prefdef_class_file) - self.default_label = self.label_hist[0] + if self.label_hist: + self.default_label = self.label_hist[0] + else: + print("Not find:/data/predefined_classes.txt (optional)") # Main widgets and related state. self.label_dialog = LabelDialog(parent=self, list_item=self.label_hist)