File size: 716 Bytes
840e37c
 
 
 
 
d04cf51
 
 
 
 
 
840e37c
d04cf51
 
 
 
a9706bf
d04cf51
 
a3bf050
840e37c
 
 
d04cf51
840e37c
d04cf51
840e37c
 
 
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
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()