After auto labeling, add None to key list at the same time
@@ -1565,24 +1565,11 @@ class MainWindow(QMainWindow):
self.actions.open_dataset_dir.setEnabled(False)
defaultOpenDirPath = os.path.dirname(self.filePath) if self.filePath else '.'
- def importDirImages(self, dirpath, isDelete=False):
- if not self.mayContinue() or not dirpath:
+ def init_key_list(self, label_dict):
+ if not self.kie_mode:
return
- if self.defaultSaveDir and self.defaultSaveDir != dirpath:
- self.saveLabelFile()
-
- if not isDelete:
- self.loadFilestate(dirpath)
- self.PPlabelpath = dirpath + '/Label.txt'
- self.PPlabel = self.loadLabelFile(self.PPlabelpath)
- self.Cachelabelpath = dirpath + '/Cache.cach'
- self.Cachelabel = self.loadLabelFile(self.Cachelabelpath)
- if self.Cachelabel:
- self.PPlabel = dict(self.Cachelabel, **self.PPlabel)
-
- if self.kie_mode:
# load key_cls
- for image, info in self.PPlabel.items():
+ for image, info in label_dict.items():
for box in info:
if "key_cls" not in box:
continue
@@ -1595,6 +1582,7 @@ class MainWindow(QMainWindow):
rgb = self._get_rgb_by_label(key_text, self.kie_mode)
self.keyList.setItemLabel(item, key_text, rgb)
+ if self.keyDialog is None:
# key list dialog
self.keyDialog = KeyDialog(
text=self.key_dialog_tip,
@@ -1606,6 +1594,26 @@ class MainWindow(QMainWindow):
fit_to_content={'column': True, 'row': False},
flags=None
)
+ else:
+ self.keyDialog.labelList.addItems(self.existed_key_cls_set)
+
+
+ def importDirImages(self, dirpath, isDelete=False):
+ if not self.mayContinue() or not dirpath:
+ return
+ if self.defaultSaveDir and self.defaultSaveDir != dirpath:
+ self.saveLabelFile()
+
+ if not isDelete:
+ self.loadFilestate(dirpath)
+ self.PPlabelpath = dirpath + '/Label.txt'
+ self.PPlabel = self.loadLabelFile(self.PPlabelpath)
+ self.Cachelabelpath = dirpath + '/Cache.cach'
+ self.Cachelabel = self.loadLabelFile(self.Cachelabelpath)
+ if self.Cachelabel:
+ self.PPlabel = dict(self.Cachelabel, **self.PPlabel)
+
+ self.init_key_list(self.PPlabel)
self.lastOpenDir = dirpath
self.dirname = dirpath
@@ -1943,6 +1951,8 @@ class MainWindow(QMainWindow):
self.setDirty()
self.saveCacheLabel()
+ self.init_key_list(self.Cachelabel)
+
def reRecognition(self):
img = cv2.imread(self.filePath)
# org_box = [dic['points'] for dic in self.PPlabel[self.getImglabelidx(self.filePath)]]
