Skip to content
Snippets Groups Projects
Commit 32d5ac74 authored by mhby1g21's avatar mhby1g21
Browse files

added progress bar, removed auto generate tickbox, reimplemented pipeline worker and steps

parent 136a2efc
No related branches found
No related tags found
1 merge request!74.3.1 - Redesign GUI and remove .bat dependencies and GDP 4.3.3 - Delete Temporary Files On Main Pipeline Run on new GUI.py
from PyQt6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, from PyQt6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout,
QGroupBox, QCheckBox, QMessageBox, QPushButton) QGroupBox, QCheckBox, QMessageBox, QPushButton,
QProgressBar)
from PyQt6.QtCore import Qt, QThread, pyqtSignal from PyQt6.QtCore import Qt, QThread, pyqtSignal
import os import os
import sys import sys
...@@ -31,19 +32,35 @@ class PipelineWorker(QThread): ...@@ -31,19 +32,35 @@ class PipelineWorker(QThread):
except Exception as e: except Exception as e:
self.finished.emit(False, f"Pipeline failed: {str(e)}") self.finished.emit(False, f"Pipeline failed: {str(e)}")
def run_pipeline(self): def shift_image(self):
steps = [ if not self.tab.shift_image_check.isChecked():
(self.tab.shift_image, "Shifting input image..."), self.progress.emit("Skipping image shift...")
(self.tab.run_depth_estimation, "Running depth estimation..."), return
(self.tab.run_material_recognition, "Running material recognition..."), self.progress.emit("Shifting input image...")
(self.tab.run_edge_net, "Running EdgeNet..."), self.tab.shifter.run_shifter()
(self.tab.run_mesh_splitting, "Running mesh splitting..."),
(self.tab.run_blender_flip, "Running Blender flip...")
]
for step_func, message in steps: def run_depth_estimation(self):
self.progress.emit(message) self.progress.emit("Running depth estimation...")
step_func() self.tab.depth.clean_input_dir()
self.tab.depth.remove_rgb()
self.tab.depth.copy_file()
self.tab.depth.run_depth_estimation()
def run_material_recognition(self):
self.progress.emit("Running material recognition...")
self.tab.material.run_all_steps()
def run_edge_net(self):
self.progress.emit("Running EdgeNet...")
self.tab.edge_net.include_top = self.tab.include_top_check.isChecked()
self.tab.edge_net.clean_output_directory()
self.tab.edge_net.run_all_steps()
def run_pipeline(self):
self.shift_image()
self.run_depth_estimation()
self.run_material_recognition()
self.run_edge_net()
class SimpleTab(QWidget): class SimpleTab(QWidget):
def __init__(self, config_reader): def __init__(self, config_reader):
...@@ -84,10 +101,6 @@ class SimpleTab(QWidget): ...@@ -84,10 +101,6 @@ class SimpleTab(QWidget):
# Options # Options
options_layout = QHBoxLayout() options_layout = QHBoxLayout()
self.auto_depth_check = QCheckBox("Auto Generate Depth Map")
self.auto_depth_check.setChecked(True)
options_layout.addWidget(self.auto_depth_check)
self.include_top_check = QCheckBox("Include Top in Mesh") self.include_top_check = QCheckBox("Include Top in Mesh")
options_layout.addWidget(self.include_top_check) options_layout.addWidget(self.include_top_check)
...@@ -96,12 +109,25 @@ class SimpleTab(QWidget): ...@@ -96,12 +109,25 @@ class SimpleTab(QWidget):
controls_layout.addLayout(options_layout) controls_layout.addLayout(options_layout)
# Progress Bar
self.progress_bar = QProgressBar()
self.progress_bar.setMinimum(0)
self.progress_bar.setMaximum(0) # Makes it an indefinite progress bar
self.progress_bar.hide() # Hidden by default
controls_layout.addWidget(self.progress_bar)
# Buttons # Buttons
buttons = [ self.run_pipeline_btn = QPushButton("Run Pipeline")
("Select Input Image", self.handle_file_select, 'left'), self.run_pipeline_btn.clicked.connect(self.run_full_pipeline)
("Run Pipeline", self.run_full_pipeline, 'right') self.run_pipeline_btn.setEnabled(False) # Disabled by default
]
controls_layout.addLayout(create_button_layout(*buttons)) buttons_layout = QHBoxLayout()
select_btn = QPushButton("Select Input Image")
select_btn.clicked.connect(self.handle_file_select)
buttons_layout.addWidget(select_btn)
buttons_layout.addWidget(self.run_pipeline_btn)
controls_layout.addLayout(buttons_layout)
layout.addWidget(controls_group) layout.addWidget(controls_group)
...@@ -134,6 +160,9 @@ class SimpleTab(QWidget): ...@@ -134,6 +160,9 @@ class SimpleTab(QWidget):
update_preview(self.input_preview, file_path, update_preview(self.input_preview, file_path,
error_callback=self.update_status) error_callback=self.update_status)
# Enable the run pipeline button
self.run_pipeline_btn.setEnabled(True)
# Provide input path to all modules # Provide input path to all modules
self.shifter.depth_input_path = file_path self.shifter.depth_input_path = file_path
self.depth.depth_input_path = file_path self.depth.depth_input_path = file_path
...@@ -149,16 +178,27 @@ class SimpleTab(QWidget): ...@@ -149,16 +178,27 @@ class SimpleTab(QWidget):
QMessageBox.warning(self, "Warning", "Pipeline is already running") QMessageBox.warning(self, "Warning", "Pipeline is already running")
return return
# Show progress bar and update status
self.progress_bar.show()
self.run_pipeline_btn.setEnabled(False)
self.pipeline_thread = PipelineWorker(self) self.pipeline_thread = PipelineWorker(self)
# Connect signals
self.pipeline_thread.progress.connect(self.update_status) self.pipeline_thread.progress.connect(self.update_status)
self.pipeline_thread.finished.connect(self.pipeline_completed) self.pipeline_thread.finished.connect(self.pipeline_completed)
self.pipeline_thread.start()
# Disable controls while running # Disable controls while running
self.setEnabled(False) self.setEnabled(False)
self.progress_bar.setEnabled(True) # Keep progress bar enabled
# Start the pipeline
self.pipeline_thread.start()
def pipeline_completed(self, success, message): def pipeline_completed(self, success, message):
self.setEnabled(True) self.setEnabled(True)
self.progress_bar.hide()
self.run_pipeline_btn.setEnabled(True)
self.update_status(message) self.update_status(message)
if success: if success:
...@@ -172,29 +212,3 @@ class SimpleTab(QWidget): ...@@ -172,29 +212,3 @@ class SimpleTab(QWidget):
# Scroll to bottom # Scroll to bottom
scrollbar = self.status_text.verticalScrollBar() scrollbar = self.status_text.verticalScrollBar()
scrollbar.setValue(scrollbar.maximum()) scrollbar.setValue(scrollbar.maximum())
\ No newline at end of file
# Pipeline steps using existing module implementations
def shift_image(self):
if not self.shift_image_check.isChecked():
self.update_status("Skipping image shift...")
return
self.shifter.run_shifter()
def run_depth_estimation(self):
if not self.auto_depth_check.isChecked():
self.update_status("Skipping depth estimation - manual depth selected")
return
self.depth.run_depth_estimation()
def run_material_recognition(self):
self.material.run_material_recognition()
def run_edge_net(self):
self.edge_net.include_top = self.include_top_check.isChecked()
self.edge_net.run_edge_net()
def run_mesh_splitting(self):
self.edge_net.run_mesh_splitting()
def run_blender_flip(self):
self.edge_net.run_blender_flip()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment