Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,28 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import subprocess
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
#
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import subprocess
|
3 |
+
import os
|
4 |
+
|
5 |
+
def run_training():
|
6 |
+
# Run train.py and capture logs
|
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 |
+
result_msg = "\n✅ Model was successfully zipped to model.zip.\n"
|
13 |
+
result_msg += "📥 You can download it from the Files tab or this URL:\n"
|
14 |
+
result_msg += "https://huggingface.co/spaces/darrenphodgson76/SmolLM2-1.7B-Instruct-Bussiness-Analysis/+/blob/main/model.zip\n"
|
15 |
+
else:
|
16 |
+
result_msg = "\n❌ model.zip not found. Check logs below for issues.\n"
|
17 |
+
|
18 |
+
return result.stdout + "\n" + result.stderr + result_msg
|
19 |
+
|
20 |
+
iface = gr.Interface(
|
21 |
+
fn=run_training,
|
22 |
+
inputs=[],
|
23 |
+
outputs="text",
|
24 |
+
title="LLaMA LoRA Fine-Tuning",
|
25 |
+
description="Click the button below to start fine-tuning the model using PEFT/LoRA. The fine-tuned model will be saved as a ZIP for download."
|
26 |
+
)
|
27 |
+
|
28 |
+
iface.launch()
|