Update app.py
Browse files
app.py
CHANGED
@@ -2,27 +2,22 @@ import gradio as gr
|
|
2 |
import subprocess
|
3 |
import os
|
4 |
|
5 |
-
def
|
6 |
-
# Run
|
7 |
result = subprocess.run(["python", "train.py"], capture_output=True, text=True)
|
8 |
-
|
9 |
-
# Check for zipped model
|
10 |
zip_path = "/home/user/app/model.zip"
|
11 |
if os.path.exists(zip_path):
|
12 |
-
|
13 |
-
|
14 |
-
result_msg += "https://huggingface.co/spaces/darrenphodgson76/SmolLM2-1.7B-Instruct-Bussiness-Analysis/+/blob/main/model.zip\n"
|
15 |
else:
|
16 |
-
|
17 |
-
|
18 |
-
return result.stdout + "\n" + result.stderr + result_msg
|
19 |
|
20 |
-
|
21 |
-
fn=
|
22 |
inputs=[],
|
23 |
-
outputs="text",
|
24 |
title="LLaMA LoRA Fine-Tuning",
|
25 |
-
description="Click the button
|
26 |
-
)
|
27 |
-
|
28 |
-
iface.launch()
|
|
|
2 |
import subprocess
|
3 |
import os
|
4 |
|
5 |
+
def run_training_and_return_zip():
|
6 |
+
# Run training and capture logs
|
7 |
result = subprocess.run(["python", "train.py"], capture_output=True, text=True)
|
8 |
+
|
|
|
9 |
zip_path = "/home/user/app/model.zip"
|
10 |
if os.path.exists(zip_path):
|
11 |
+
logs = result.stdout + "\n" + result.stderr + "\n✅ Training complete. Download your model below."
|
12 |
+
return logs, zip_path
|
|
|
13 |
else:
|
14 |
+
logs = result.stdout + "\n" + result.stderr + "\n❌ model.zip not found. Check logs for issues."
|
15 |
+
return logs, None
|
|
|
16 |
|
17 |
+
gr.Interface(
|
18 |
+
fn=run_training_and_return_zip,
|
19 |
inputs=[],
|
20 |
+
outputs=["text", "file"],
|
21 |
title="LLaMA LoRA Fine-Tuning",
|
22 |
+
description="Click the button to fine-tune. After training, download the zipped model directly."
|
23 |
+
).launch()
|
|
|
|