-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.py
More file actions
144 lines (121 loc) * 4.87 KB
/
gui.py
File metadata and controls
144 lines (121 loc) * 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import tkinter as tk
from tkinter import scrolledtext, messagebox, filedialog
import subprocess
import threading
import os
# Global variables
MODEL_PATH = "./original_model"
DATASET_PATH = "./underwater_data"
FINE_TUNED_PATH = "./fine_tuned_model"
# Function to download the model
def download_model():
def run_download():
output_text.insert(tk.END, "Downloading model...\n")
try:
result = subprocess.run(
["python", "download_model.py"],
capture_output=True,
text=True
)
output_text.insert(tk.END, result.stdout)
output_text.insert(tk.END, result.stderr)
output_text.insert(tk.END, "Model downloaded successfully!\n")
except Exception as e:
output_text.insert(tk.END, f"Error: {e}\n")
threading.Thread(target=run_download).start()
# Function to prepare the dataset
def prepare_dataset():
def run_prepare():
output_text.insert(tk.END, "Preparing dataset...\n")
try:
result = subprocess.run(
["python", "prepare_dataset.py"],
capture_output=True,
text=True
)
output_text.insert(tk.END, result.stdout)
output_text.insert(tk.END, result.stderr)
output_text.insert(tk.END, "Dataset prepared successfully!\n")
except Exception as e:
output_text.insert(tk.END, f"Error: {e}\n")
threading.Thread(target=run_prepare).start()
# Function to fine-tune the model
def fine_tune_model():
def run_fine_tune():
output_text.insert(tk.END, "Fine-tuning model...\n")
try:
result = subprocess.run(
["python", "finetune_model.py"],
capture_output=True,
text=True
)
output_text.insert(tk.END, result.stdout)
output_text.insert(tk.END, result.stderr)
output_text.insert(tk.END, "Model fine-tuned successfully!\n")
except Exception as e:
output_text.insert(tk.END, f"Error: {e}\n")
threading.Thread(target=run_fine_tune).start()
# Function to verify the model
def verify_model():
def run_verify():
output_text.insert(tk.END, "Verifying model...\n")
try:
result = subprocess.run(
["python", "verify_model.py"],
capture_output=True,
text=True
)
output_text.insert(tk.END, result.stdout)
output_text.insert(tk.END, result.stderr)
output_text.insert(tk.END, "Model verification complete!\n")
except Exception as e:
output_text.insert(tk.END, f"Error: {e}\n")
threading.Thread(target=run_verify).start()
# Function to classify using the fine-tuned model
def classify_object():
description = classification_input.get("1.0", tk.END).strip()
if not description:
messagebox.showwarning("Input Error", "Please enter a description.")
return
def run_classify():
output_text.insert(tk.END, f"Classifying: {description}\n")
try:
result = subprocess.run(
["python", "auv_object_classifier.py"],
input=description,
capture_output=True,
text=True
)
output_text.insert(tk.END, result.stdout)
output_text.insert(tk.END, result.stderr)
except Exception as e:
output_text.insert(tk.END, f"Error: {e}\n")
threading.Thread(target=run_classify).start()
# Create the Tkinter GUI
root = tk.Tk()
root.title("Underwater Object Classification Pipeline")
root.geometry("800x600")
# Output console
output_text = scrolledtext.ScrolledText(root, wrap=tk.WORD, width=90, height=20)
output_text.pack(pady=10)
# Buttons for each step
button_frame = tk.Frame(root)
button_frame.pack(pady=10)
download_button = tk.Button(button_frame, text="1. Download Model", command=download_model)
download_button.grid(row=0, column=0, padx=5)
prepare_button = tk.Button(button_frame, text="2. Prepare Dataset", command=prepare_dataset)
prepare_button.grid(row=0, column=1, padx=5)
fine_tune_button = tk.Button(button_frame, text="3. Fine-Tune Model", command=fine_tune_model)
fine_tune_button.grid(row=0, column=2, padx=5)
verify_button = tk.Button(button_frame, text="4. Verify Model", command=verify_model)
verify_button.grid(row=0, column=3, padx=5)
# Classification input
classification_frame = tk.Frame(root)
classification_frame.pack(pady=10)
tk.Label(classification_frame, text="Enter object description:").grid(row=0, column=0, padx=5)
classification_input = tk.Text(classification_frame, width=50, height=3)
classification_input.grid(row=0, column=1, padx=5)
classify_button = tk.Button(classification_frame, text="Classify", command=classify_object)
classify_button.grid(row=0, column=2, padx=5)
# Run the Tkinter event loop
root.mainloop()