Spaces:
Sleeping
Sleeping
File size: 1,073 Bytes
eb72ddf 0c8455f eb72ddf 0c8455f 5970c5c eb72ddf 0c8455f eb72ddf 0c8455f eb72ddf 0c8455f eb72ddf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import gradio as gr
import subprocess
def train_model():
# Run the training script
process = subprocess.Popen(
["python", "train_model.py"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
bufsize=1
)
logs = ""
for line in process.stdout:
logs += line
yield logs
# Return final download link
logs += "\n✅ Training complete! Download your model below."
yield logs
with gr.Blocks() as demo:
gr.Markdown("🧠 *Quiz Model Trainer*\nClick start to train and download your model.")
train_button = gr.Button("🚀 Start Training")
output = gr.Textbox(label="Training Log", lines=20)
file_output = gr.File(label="Download Trained Model")
def start_training():
logs = ""
for log in train_model():
logs = log
yield logs, None
# Attach zip file after training
yield logs, "trained_model.zip"
train_button.click(start_training, outputs=[output, file_output])
demo.launch() |