import gradio as gr | |
import subprocess | |
def run_training(): | |
try: | |
process = subprocess.Popen( | |
["python", "train_abuse_model.py"], | |
stdout=subprocess.PIPE, | |
stderr=subprocess.STDOUT, | |
text=True | |
) | |
output_lines = [] | |
for line in process.stdout: | |
output_lines.append(line) | |
yield "".join(output_lines) | |
except Exception as e: | |
yield f"Exception occurred:\n{str(e)}" | |
demo = gr.Interface( | |
fn=run_training, | |
inputs=[], | |
outputs=gr.Textbox(lines=25, label="Training Logs"), | |
title="Run Model Training", | |
description="Click the button to start training and see live logs below." | |
) | |
demo.launch() | |