rshakked commited on
Commit
840e37c
·
1 Parent(s): cf896a1

created app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+
4
+ def run_training():
5
+ try:
6
+ # Run train.py using subprocess and capture output
7
+ result = subprocess.run(["python", "train.py"], capture_output=True, text=True)
8
+ # Return stdout if success, otherwise stderr
9
+ return result.stdout if result.returncode == 0 else f"Error:\n{result.stderr}"
10
+ except Exception as e:
11
+ return f"Exception occurred:\n{str(e)}"
12
+
13
+ # Define a simple Gradio interface with one button
14
+ demo = gr.Interface(
15
+ fn=run_training,
16
+ inputs=[],
17
+ outputs="text",
18
+ title="Run Model Training",
19
+ description="Click the button to execute train.py. This will use GPU if available."
20
+ )
21
+
22
+ demo.launch()