|
import gradio as gr |
|
import subprocess |
|
|
|
logs = [] |
|
|
|
def run_training(): |
|
global logs |
|
logs = [] |
|
process = subprocess.Popen( |
|
["python", "run.py"], |
|
stdout=subprocess.PIPE, |
|
stderr=subprocess.STDOUT, |
|
text=True, |
|
bufsize=1 |
|
) |
|
|
|
for line in process.stdout: |
|
logs.append(line) |
|
yield "\n".join(logs[:]) |
|
|
|
with gr.Blocks() as demo: |
|
with gr.Row(): |
|
btn = gr.Button("๐ Start Training") |
|
output = gr.Textbox(label="Logs", lines=25, interactive=False) |
|
|
|
btn.click(fn=run_training, outputs=output) |
|
|
|
demo.launch(server_name="0.0.0.0", server_port=7860) |
|
|