created app.py
Browse files
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()
|