From 2c2795d9bebcfc3c6644af803cf538ed56f27d5e Mon Sep 17 00:00:00 2001 From: deeppomf Date: Thu, 31 Oct 2019 17:22:10 -0400 Subject: [PATCH] Fix typo --- decensor.py | 10 +++++----- main.py | 4 ++-- progressWindow.py | 38 +++++++++++++++++++++++--------------- signals.py | 4 ++-- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/decensor.py b/decensor.py index c686a8f..bdc2a77 100755 --- a/decensor.py +++ b/decensor.py @@ -42,7 +42,7 @@ class Decensor(QtCore.QThread): self.decensor_input_original_path = args.decensor_input_original_path self.decensor_output_path = args.decensor_output_path - self.signals = None # Singals class will be given by progressWindow + self.signals = None # Signals class will be given by progressWindow if ui_mode is not None: self.ui_mode = ui_mode @@ -98,9 +98,9 @@ class Decensor(QtCore.QThread): #convert all images into np arrays and put them in a list for n, file_name in enumerate(file_names, start = 1): self.signals.total_ProgressBar_update_VALUE.emit("decensoring {} / {}".format(n, len(file_names)), n) - # singal progress bar value == masks decensored on image , + # signal progress bar value == masks decensored on image , # e.g) sample image : 17 - self.signals.singal_ProgressBar_update_VALUE.emit("reset value", 0) # set to 0 for every image at start + self.signals.signal_ProgressBar_update_VALUE.emit("reset value", 0) # set to 0 for every image at start self.signals.update_progress_LABEL.emit("for-loop, \"for file_name in file_names:\"","decensoring : "+str(file_name)) color_file_path = os.path.join(input_color_dir, file_name) @@ -203,7 +203,7 @@ class Decensor(QtCore.QThread): self.custom_print("No green regions detected! Make sure you're using exactly the right color.") return - self.signals.singal_ProgressBar_update_MAX_VALUE.emit("found {} masked regions".format(len(regions)), len(regions)) + self.signals.signal_ProgressBar_update_MAX_VALUE.emit("found {} masked regions".format(len(regions)), len(regions)) output_img_array = ori_array[0].copy() for region_counter, region in enumerate(regions, 1): @@ -287,7 +287,7 @@ class Decensor(QtCore.QThread): bounding_height_index = row + bounding_box[1] if (bounding_width_index, bounding_height_index) in region: output_img_array[bounding_height_index][bounding_width_index] = pred_img_array[i,:,:,:][row][col] - self.signals.singal_ProgressBar_update_VALUE.emit("{} out of {} regions decensored.".format(region_counter, len(regions)), region_counter) + self.signals.signal_ProgressBar_update_VALUE.emit("{} out of {} regions decensored.".format(region_counter, len(regions)), region_counter) self.custom_print("{region_counter} out of {region_count} regions decensored.".format(region_counter=region_counter, region_count=len(regions))) output_img_array = output_img_array * 255.0 diff --git a/main.py b/main.py index c7f75de..4bc6e7d 100644 --- a/main.py +++ b/main.py @@ -27,7 +27,7 @@ class MainWindow(QWidget): #Tutorial self.tutorialLabel = QLabel() - self.tutorialLabel.setText("Welcome to DeepCreamPy!\n\nIf you're new to DCP, please read the README.\nThis program does nothing without the proper setup of your images.\n\nSince this is an alpha release, expect issues like crashing or freezing.\nReport them to me on Github or Twitter @deeppomf.") + self.tutorialLabel.setText("Welcome to DeepCreamPy!\n\nIf you're new to DCP, please read the README.\nThis program does nothing without the proper setup of your images.\n\nReport them to me on Github or Twitter @deeppomf.") self.tutorialLabel.setAlignment(Qt.AlignCenter) self.tutorialLabel.setFont(QFont('Sans Serif', 13)) @@ -117,7 +117,7 @@ class MainWindow(QWidget): self.decensorButton.setEnabled(True) - self.hide() + # self.hide() self.progress = ProgressWindow(self, decensor = decensor) # decensor.decensor_all_images_in_folder() diff --git a/progressWindow.py b/progressWindow.py index 6df2a9d..304690e 100644 --- a/progressWindow.py +++ b/progressWindow.py @@ -4,7 +4,7 @@ import sys import PySide2 -from PySide2.QtWidgets import (QApplication, QMainWindow, QPushButton, +from PySide2.QtWidgets import (QApplication, QMainWindow, QDesktopWidget, QPushButton, QToolTip, QLabel, QProgressBar, QAction, qApp) # from PyQt5.QtCore import QThread from signals import Signals @@ -18,11 +18,13 @@ class ProgressWindow(QMainWindow): self.width = 700 self.height = 500 self.resize(self.width, self.height) - self.setWindowTitle("DeepCreamPy v2.2.0 Decensoring...") self.initUI() # signal class that could share update progress ui from decensor class (Decensor) self.setSignals() + + self.center() + self.setWindowTitle("DeepCreamPy v2.2.0 Decensoring...") self.show() if not debug: @@ -64,19 +66,19 @@ class ProgressWindow(QMainWindow): self.total_images_ProgressBar.setValue(0) # showing progress of decensored area - self.singal_image_decensor_ProgressBar = QProgressBar(self) - self.singal_image_decensor_ProgressBar.setGeometry(bar_X, bar_Y+80, bar_width,bar_height ) - self.singal_image_decensor_ProgressBar.setMaximum(100) - self.singal_image_decensor_ProgressBar.setValue(0) + self.signal_image_decensor_ProgressBar = QProgressBar(self) + self.signal_image_decensor_ProgressBar.setGeometry(bar_X, bar_Y+80, bar_width,bar_height ) + self.signal_image_decensor_ProgressBar.setMaximum(100) + self.signal_image_decensor_ProgressBar.setValue(0) progress_Label_1 = QLabel(self) progress_Label_1.move(50, 270) - progress_Label_1.setText("Number of your images") + progress_Label_1.setText("Decensor progress of all images") progress_Label_1.resize(progress_Label_1.sizeHint()) progress_Label_2 = QLabel(self) progress_Label_2.move(50, 300 + 50) - progress_Label_2.setText("Number of image censoring") + progress_Label_2.setText("Decensor progress of current image") progress_Label_2.resize(progress_Label_2.sizeHint()) self.progress_status_LABEL = QLabel(self) @@ -86,13 +88,19 @@ class ProgressWindow(QMainWindow): setProgressBar() + def center(self): + qr = self.frameGeometry() + cp = QDesktopWidget().availableGeometry().center() + qr.moveCenter(cp) + self.move(qr.topLeft()) + def setSignals(self): self.signals = Signals() # set signal variable name same as method name preventing confusion self.signals.total_ProgressBar_update_MAX_VALUE.connect(self.total_ProgressBar_update_MAX_VALUE) self.signals.total_ProgressBar_update_VALUE.connect(self.total_ProgressBar_update_VALUE) - self.signals.singal_ProgressBar_update_MAX_VALUE.connect(self.singal_ProgressBar_update_MAX_VALUE) - self.signals.singal_ProgressBar_update_VALUE.connect(self.singal_ProgressBar_update_VALUE) + self.signals.signal_ProgressBar_update_MAX_VALUE.connect(self.signal_ProgressBar_update_MAX_VALUE) + self.signals.signal_ProgressBar_update_VALUE.connect(self.signal_ProgressBar_update_VALUE) self.signals.update_progress_LABEL.connect(self.update_progress_LABEL) # total_images_to_decensor_ProgressBar @@ -106,15 +114,15 @@ class ProgressWindow(QMainWindow): print(msg) self.total_images_ProgressBar.setValue(val) - def singal_ProgressBar_update_MAX_VALUE(self, msg, max): + def signal_ProgressBar_update_MAX_VALUE(self, msg, max): # print msg for debugging print(msg) - self.singal_image_decensor_ProgressBar.setMaximum(max) + self.signal_image_decensor_ProgressBar.setMaximum(max) - def singal_ProgressBar_update_VALUE(self, msg, val): + def signal_ProgressBar_update_VALUE(self, msg, val): # print msg for debugging print(msg) - self.singal_image_decensor_ProgressBar.setValue(val) + self.signal_image_decensor_ProgressBar.setValue(val) def update_progress_LABEL(self, msg, status): print(msg) @@ -123,7 +131,7 @@ class ProgressWindow(QMainWindow): def runDecensor(self): # start decensor in other thread, preventing UI Freezing - print("start run") + # print("start run") self.decensor.start() if __name__ == "__main__": diff --git a/signals.py b/signals.py index 3af1965..74b3d8a 100644 --- a/signals.py +++ b/signals.py @@ -10,8 +10,8 @@ class Signals(QtCore.QObject): total_ProgressBar_update_MAX_VALUE = QtCore.Signal(str, int) total_ProgressBar_update_VALUE = QtCore.Signal(str, int) - singal_ProgressBar_update_MAX_VALUE = QtCore.Signal(str, int) - singal_ProgressBar_update_VALUE = QtCore.Signal(str, int) + signal_ProgressBar_update_MAX_VALUE = QtCore.Signal(str, int) + signal_ProgressBar_update_VALUE = QtCore.Signal(str, int) # str : tells status (print in cmd for debug) # str : String to update label