From 1e6af3bb886107639de901c1cecd7061f18480a8 Mon Sep 17 00:00:00 2001 From: Leif <4603009@qq.com> Date: Thu, 5 May 2022 22:36:59 +0800 Subject: [PATCH] merge from new merge from new --- PPOCRLabel/PPOCRLabel.py | 21 +++++++++---------- PPOCRLabel/libs/dataPartitionDialog.py | 28 ++++++++++++++++++-------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 6729c574..534e0cd8 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -2285,13 +2285,15 @@ class MainWindow(QMainWindow): import pandas as pd from libs.dataPartitionDialog import DataPartitionDialog - if self.lang == 'ch': - QMessageBox.information(self, "Information", "导出JSON前请保存所有图像的标注且关闭EXCEL!!!!!!!!!!!!") - else: - QMessageBox.information(self, "Information", "Please save all the annotations and close the EXCEL before exporting JSON!!!!!!!!!!!!") + # data partition user input + partitionDialog = DataPartitionDialog(parent=self) + partitionDialog.exec() + if partitionDialog.getStatus() == False: + return # automatically save annotations - self.saveLabelFile() + self.saveFilestate() + self.savePPlabel(mode='auto') # load box annotations labeldict = {} @@ -2318,12 +2320,7 @@ class MainWindow(QMainWindow): # 'Please check the label.txt and tableRec_excel_output\n' # QMessageBox.information(self, "Information", msg) # return - - # data partition user input - partitionDialog = DataPartitionDialog() - partitionDialog.exec() - if partitionDialog.getStatus() == False: - return + train_split, val_split, test_split = partitionDialog.getDataPartition() # check validate @@ -2379,7 +2376,7 @@ class MainWindow(QMainWindow): # save json with open("{}/annotation.json".format(self.lastOpenDir), "w", encoding='utf-8') as fid: - fid.write(json.dumps(json_results)) + fid.write(json.dumps(json_results, ensure_ascii=False)) msg = 'JSON sucessfully saved in {}/annotation.json'.format(self.lastOpenDir) QMessageBox.information(self, "Information", msg) diff --git a/PPOCRLabel/libs/dataPartitionDialog.py b/PPOCRLabel/libs/dataPartitionDialog.py index 051b9722..33bd4915 100644 --- a/PPOCRLabel/libs/dataPartitionDialog.py +++ b/PPOCRLabel/libs/dataPartitionDialog.py @@ -18,8 +18,9 @@ import numpy as np BB = QDialogButtonBox class DataPartitionDialog(QDialog): - def __init__(self): + def __init__(self, parent=None): super().__init__() + self.parnet = parent self.title = 'DATA PARTITION' self.train_ratio = 70 @@ -34,6 +35,16 @@ class DataPartitionDialog(QDialog): self.flag_accept = True + if self.parnet.lang == 'ch': + msg = "导出JSON前请保存所有图像的标注且关闭EXCEL!" + else: + msg = "Please save all the annotations and close the EXCEL before exporting JSON!" + + info_msg = QLabel(msg, self) + info_msg.setWordWrap(True) + info_msg.setStyleSheet("color: red") + info_msg.setFont(QFont('Arial', 12)) + train_lbl = QLabel('Train split: ', self) train_lbl.setFont(QFont('Arial', 15)) val_lbl = QLabel('Valid split: ', self) @@ -58,19 +69,20 @@ class DataPartitionDialog(QDialog): self.test_input.setValidator(validator) gridlayout = QGridLayout() - gridlayout.addWidget(train_lbl, 0, 0) - gridlayout.addWidget(val_lbl, 1, 0) - gridlayout.addWidget(test_lbl, 2, 0) - gridlayout.addWidget(self.train_input, 0, 1) - gridlayout.addWidget(self.val_input, 1, 1) - gridlayout.addWidget(self.test_input, 2, 1) + gridlayout.addWidget(info_msg, 0, 0, 1, 2) + gridlayout.addWidget(train_lbl, 1, 0) + gridlayout.addWidget(val_lbl, 2, 0) + gridlayout.addWidget(test_lbl, 3, 0) + gridlayout.addWidget(self.train_input, 1, 1) + gridlayout.addWidget(self.val_input, 2, 1) + gridlayout.addWidget(self.test_input, 3, 1) bb = BB(BB.Ok | BB.Cancel, Qt.Horizontal, self) bb.button(BB.Ok).setIcon(newIcon('done')) bb.button(BB.Cancel).setIcon(newIcon('undo')) bb.accepted.connect(self.validate) bb.rejected.connect(self.cancel) - gridlayout.addWidget(bb, 3, 0, 1, 2) + gridlayout.addWidget(bb, 4, 0, 1, 2) self.setLayout(gridlayout) -- GitLab