diff --git a/scripts/GUI_debug.py b/scripts/GUI_debug.py new file mode 100644 index 0000000000000000000000000000000000000000..d698c105c8e4ffa3c5dd95516f5b4b0f3c3e00ad --- /dev/null +++ b/scripts/GUI_debug.py @@ -0,0 +1,193 @@ +import tkinter as tk +from tkinter import ttk, messagebox +import tkinter.filedialog +import os +import configparser + +class ModuleDebugGUI: + def __init__(self): + self.window = tk.Tk() + self.window.title("Pipeline Debug Tool - Config & Paths") + + # Initialize paths + self.SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) + self.ROOT_DIR = os.path.dirname(self.SCRIPT_DIR) + + # Initialize directories and file paths + self.setup_directories() + + # Read config + self.config = {} + self.read_config() + + self.setup_ui() + + def setup_directories(self): + self.directories = { + 'scriptDir': self.SCRIPT_DIR, + 'rootDir': self.ROOT_DIR, + 'monoDepthDir': os.path.join(self.ROOT_DIR, "scripts", "360monodepthexecution"), + 'outputDir': os.path.join(self.ROOT_DIR, "edgenet-360", "Output"), + 'materialRecogDir': os.path.join(self.ROOT_DIR, "Dynamic-Backward-Attention-Transformer"), + 'edgeNetDir': os.path.join(self.ROOT_DIR, "edgenet-360") + } + + self.file_paths = { + 'checkpointFile': os.path.join( + self.directories['materialRecogDir'], + "checkpoints/dpglt_mode95/accuracy/epoch=126-valid_acc_epoch=0.87.ckpt" + ), + 'shiftedImage': os.path.join(self.SCRIPT_DIR, "shifted_t.png"), + 'monoDepthImage': os.path.join( + self.directories['monoDepthDir'], + "rgb.jpg" + ) + } + + def read_config(self): + config_path = os.path.join(self.SCRIPT_DIR, "config.ini") + try: + with open(config_path, 'r') as f: + for line in f: + if '=' in line: + key, value = line.strip().split('=', 1) + self.config[key.strip()] = value.strip() + except FileNotFoundError: + messagebox.showerror("Error", "config.ini not found!") + return False + return True + + def setup_ui(self): + # Main container + main_frame = ttk.Frame(self.window, padding="10") + main_frame.pack(fill=tk.BOTH, expand=True) + + # Config section + config_frame = ttk.LabelFrame(main_frame, text="Config Values", padding="5") + config_frame.pack(fill=tk.X, pady=5) + + self.config_text = tk.Text(config_frame, height=6, wrap=tk.WORD) + self.config_text.pack(fill=tk.X) + + # Directory paths section + dir_frame = ttk.LabelFrame(main_frame, text="Directory Paths", padding="5") + dir_frame.pack(fill=tk.X, pady=5) + + self.dir_text = tk.Text(dir_frame, height=8, wrap=tk.WORD) + self.dir_text.pack(fill=tk.X) + + # File paths section + file_frame = ttk.LabelFrame(main_frame, text="File Paths", padding="5") + file_frame.pack(fill=tk.X, pady=5) + + self.file_text = tk.Text(file_frame, height=5, wrap=tk.WORD) + self.file_text.pack(fill=tk.X) + + # Path verification section + verify_frame = ttk.LabelFrame(main_frame, text="Path Verification", padding="5") + verify_frame.pack(fill=tk.X, pady=5) + + self.verify_text = tk.Text(verify_frame, height=8, wrap=tk.WORD) + self.verify_text.pack(fill=tk.X) + + # Buttons + button_frame = ttk.Frame(main_frame) + button_frame.pack(fill=tk.X, pady=5) + + ttk.Button( + button_frame, + text="Refresh Config", + command=self.refresh_all + ).pack(side=tk.LEFT, padx=5) + + ttk.Button( + button_frame, + text="Verify Paths", + command=self.verify_paths + ).pack(side=tk.LEFT, padx=5) + + ttk.Button( + button_frame, + text="Save Debug Info", + command=self.save_debug_info + ).pack(side=tk.RIGHT, padx=5) + + # Initial display + self.refresh_all() + + def refresh_all(self): + self.refresh_config_display() + self.refresh_directory_display() + self.refresh_file_display() + self.verify_paths() + + def refresh_config_display(self): + self.config_text.delete(1.0, tk.END) + for key, value in self.config.items(): + self.config_text.insert(tk.END, f"{key} = {value}\n") + + def refresh_directory_display(self): + self.dir_text.delete(1.0, tk.END) + for key, path in self.directories.items(): + self.dir_text.insert(tk.END, f"{key}: {path}\n") + + def refresh_file_display(self): + self.file_text.delete(1.0, tk.END) + for key, path in self.file_paths.items(): + self.file_text.insert(tk.END, f"{key}: {path}\n") + + def verify_paths(self): + self.verify_text.delete(1.0, tk.END) + + # Verify directories + self.verify_text.insert(tk.END, "Directory Verification:\n") + for key, path in self.directories.items(): + exists = os.path.exists(path) + status = "✓ exists" if exists else "✗ missing" + color = "green" if exists else "red" + self.verify_text.insert(tk.END, f"{key}: {status}\n", color) + + self.verify_text.insert(tk.END, "\nFile Verification:\n") + for key, path in self.file_paths.items(): + exists = os.path.exists(path) + status = "✓ exists" if exists else "✗ missing" + color = "green" if exists else "red" + self.verify_text.insert(tk.END, f"{key}: {status}\n", color) + + # Add tags for colors + self.verify_text.tag_config("green", foreground="green") + self.verify_text.tag_config("red", foreground="red") + + def save_debug_info(self): + debug_info = "=== Pipeline Debug Information ===\n\n" + + debug_info += "=== Config Values ===\n" + for key, value in self.config.items(): + debug_info += f"{key} = {value}\n" + + debug_info += "\n=== Directory Paths ===\n" + for key, path in self.directories.items(): + exists = os.path.exists(path) + status = "exists" if exists else "missing" + debug_info += f"{key}: {path} ({status})\n" + + debug_info += "\n=== File Paths ===\n" + for key, path in self.file_paths.items(): + exists = os.path.exists(path) + status = "exists" if exists else "missing" + debug_info += f"{key}: {path} ({status})\n" + + # Save to file + try: + with open("pipeline_debug_info.txt", "w") as f: + f.write(debug_info) + messagebox.showinfo("Success", "Debug information saved to pipeline_debug_info.txt") + except Exception as e: + messagebox.showerror("Error", f"Failed to save debug info: {str(e)}") + + def run(self): + self.window.mainloop() + +if __name__ == "__main__": + app = ModuleDebugGUI() + app.run() \ No newline at end of file