From a391828a7a040b3e90a175b9109f572b7481cc70 Mon Sep 17 00:00:00 2001 From: "aboutibm@163.com" <7p=e763wN3A6k+[C> Date: Sun, 15 Sep 2024 15:09:09 +0800 Subject: [PATCH] Change fileState.txt file path format --- PPOCRLabel.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/PPOCRLabel.py b/PPOCRLabel.py index c4e4724..3d87fa9 100644 --- a/PPOCRLabel.py +++ b/PPOCRLabel.py @@ -2148,9 +2148,12 @@ def showBoundingBoxFromPPlabel(self, filePath): self.canvas.verified = False def validFilestate(self, filePath): - if filePath not in self.fileStatedict.keys(): - return None - elif self.fileStatedict[filePath] == 1: + if filePath in self.fileStatedict.keys() and self.fileStatedict[filePath] == 1: + return True + elif ( + self.getImglabelidx(filePath) in self.fileStatedict.keys() + and self.fileStatedict[self.getImglabelidx(filePath)] == 1 + ): return True else: return False @@ -2284,7 +2287,9 @@ def openDatasetDirDialog(self): else: if self.lang == "ch": - self.msgBox.warning(self, "提示", "\n 原文件夹已不存在,请从新选择数据集路径!") + self.msgBox.warning( + self, "提示", "\n 原文件夹已不存在,请从新选择数据集路径!" + ) else: self.msgBox.warning( self, @@ -2473,7 +2478,7 @@ def _saveFile(self, annotationFilePath, mode="Manual"): item = self.fileListWidget.item(currIndex) item.setIcon(newIcon("done")) - self.fileStatedict[self.filePath] = 1 + self.fileStatedict[self.getImglabelidx(self.filePath)] = 1 if len(self.fileStatedict) % self.autoSaveNum == 0: self.saveFilestate() self.savePPlabel(mode="Auto") @@ -2753,6 +2758,8 @@ def getImglabelidx(self, filePath): else: spliter = "/" filepathsplit = filePath.split(spliter)[-2:] + if len(filepathsplit) == 1: + return filePath return filepathsplit[0] + "/" + filepathsplit[1] def autoRecognition(self): @@ -3241,7 +3248,7 @@ def loadFilestate(self, saveDir): states = f.readlines() for each in states: file, state = each.split("\t") - self.fileStatedict[file] = 1 + self.fileStatedict[self.getImglabelidx(file)] = 1 self.actions.saveLabel.setEnabled(True) self.actions.saveRec.setEnabled(True) self.actions.exportJSON.setEnabled(True)