Skip to content

Commit

Permalink
Change fileState.txt file path format
Browse files Browse the repository at this point in the history
  • Loading branch information
aboutibm@163.com authored and aboutibm@163.com committed Sep 15, 2024
1 parent 9c69d7e commit a391828
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions PPOCRLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a391828

Please sign in to comment.