Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
import os
|
3 |
import json
|
4 |
import torch
|
|
|
5 |
from dotenv import load_dotenv
|
6 |
import logging
|
7 |
|
@@ -38,6 +39,23 @@ MODEL_NAME = model_config.get("model_name_or_path", "unsloth/DeepSeek-R1-Distill
|
|
38 |
SPACE_NAME = os.getenv("HF_SPACE_NAME", "phi4training")
|
39 |
TRAINING_ACTIVE = os.path.exists("TRAINING_ACTIVE")
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
# Create Gradio interface - training status only, no model outputs
|
42 |
with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
43 |
gr.Markdown(f"# {SPACE_NAME}: Training Status Dashboard")
|
@@ -67,8 +85,13 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
|
67 |
"""
|
68 |
)
|
69 |
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
def refresh_status():
|
74 |
# Re-check if training is active
|
@@ -94,22 +117,23 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
|
94 |
⚠️ **NOTE**: This space does not provide model outputs during the research training phase.
|
95 |
"""
|
96 |
|
|
|
|
|
97 |
refresh_btn.click(refresh_status, outputs=status)
|
98 |
|
99 |
gr.Markdown("""
|
100 |
### Research Training Information
|
101 |
This model is being fine-tuned on research-focused datasets and is not available for interactive querying.
|
102 |
Training logs are available to authorized researchers only.
|
|
|
|
|
|
|
|
|
|
|
103 |
""")
|
104 |
|
105 |
# Launch the interface
|
106 |
if __name__ == "__main__":
|
107 |
-
# Create an empty TRAINING_ACTIVE file to indicate training is in progress
|
108 |
-
# This would be managed by the actual training script
|
109 |
-
if not os.path.exists("TRAINING_ACTIVE"):
|
110 |
-
with open("TRAINING_ACTIVE", "w") as f:
|
111 |
-
f.write("Training in progress")
|
112 |
-
|
113 |
# Start Gradio with minimal features
|
114 |
logger.info("Starting training status dashboard")
|
115 |
-
demo.launch(share=False)
|
|
|
2 |
import os
|
3 |
import json
|
4 |
import torch
|
5 |
+
import subprocess
|
6 |
from dotenv import load_dotenv
|
7 |
import logging
|
8 |
|
|
|
39 |
SPACE_NAME = os.getenv("HF_SPACE_NAME", "phi4training")
|
40 |
TRAINING_ACTIVE = os.path.exists("TRAINING_ACTIVE")
|
41 |
|
42 |
+
# Function to start the training process
|
43 |
+
def start_training():
|
44 |
+
try:
|
45 |
+
# Create TRAINING_ACTIVE file
|
46 |
+
with open("TRAINING_ACTIVE", "w") as f:
|
47 |
+
f.write("Training in progress")
|
48 |
+
|
49 |
+
# Run the training script in the background
|
50 |
+
subprocess.Popen(["python", "run_cloud_training.py"],
|
51 |
+
stdout=subprocess.PIPE,
|
52 |
+
stderr=subprocess.PIPE)
|
53 |
+
|
54 |
+
return "✅ Training started! Check status below for updates."
|
55 |
+
except Exception as e:
|
56 |
+
logger.error(f"Error starting training: {str(e)}")
|
57 |
+
return f"❌ Error starting training: {str(e)}"
|
58 |
+
|
59 |
# Create Gradio interface - training status only, no model outputs
|
60 |
with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
61 |
gr.Markdown(f"# {SPACE_NAME}: Training Status Dashboard")
|
|
|
85 |
"""
|
86 |
)
|
87 |
|
88 |
+
with gr.Row():
|
89 |
+
# Add buttons for starting training and refreshing status
|
90 |
+
start_btn = gr.Button("Start Training", variant="primary")
|
91 |
+
refresh_btn = gr.Button("Refresh Status")
|
92 |
+
|
93 |
+
# Output area for training start messages
|
94 |
+
training_output = gr.Markdown("")
|
95 |
|
96 |
def refresh_status():
|
97 |
# Re-check if training is active
|
|
|
117 |
⚠️ **NOTE**: This space does not provide model outputs during the research training phase.
|
118 |
"""
|
119 |
|
120 |
+
# Connect button clicks to functions
|
121 |
+
start_btn.click(start_training, outputs=training_output)
|
122 |
refresh_btn.click(refresh_status, outputs=status)
|
123 |
|
124 |
gr.Markdown("""
|
125 |
### Research Training Information
|
126 |
This model is being fine-tuned on research-focused datasets and is not available for interactive querying.
|
127 |
Training logs are available to authorized researchers only.
|
128 |
+
|
129 |
+
### Instructions
|
130 |
+
1. Click "Start Training" to begin the fine-tuning process
|
131 |
+
2. Use "Refresh Status" to check training progress
|
132 |
+
3. Training logs are saved to the output directory
|
133 |
""")
|
134 |
|
135 |
# Launch the interface
|
136 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
# Start Gradio with minimal features
|
138 |
logger.info("Starting training status dashboard")
|
139 |
+
demo.launch(share=False) # Removed enable_queue parameter which is no longer supported in Gradio 5.x
|