darrenphodgson76 commited on
Commit
f47057d
·
verified ·
1 Parent(s): 0c0545f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -18
app.py CHANGED
@@ -1,18 +1,28 @@
1
- import gradio as gr
2
- import subprocess
3
-
4
- def run_training():
5
- # Execute train.py and capture its output
6
- result = subprocess.run(["python", "train.py"], capture_output=True, text=True)
7
- return result.stdout + "\n" + result.stderr
8
-
9
- # Create a Gradio interface with no inputs and a text output for logs
10
- iface = gr.Interface(
11
- fn=run_training,
12
- inputs=[],
13
- outputs="text",
14
- title="LLaMA LoRA Fine-Tuning",
15
- description="Click the button below to start fine-tuning the LLaMA 3.2 3B Instruct model using PEFT/LoRA."
16
- )
17
-
18
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
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()