Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
import threading
|
| 4 |
+
|
| 5 |
+
logs = [] # لتجميع اللوجات
|
| 6 |
+
|
| 7 |
+
def run_training():
|
| 8 |
+
global logs
|
| 9 |
+
logs = []
|
| 10 |
+
process = subprocess.Popen(
|
| 11 |
+
["python", "run.py"],
|
| 12 |
+
stdout=subprocess.PIPE,
|
| 13 |
+
stderr=subprocess.STDOUT,
|
| 14 |
+
text=True,
|
| 15 |
+
bufsize=1
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
for line in process.stdout:
|
| 19 |
+
logs.append(line)
|
| 20 |
+
yield "\n".join(logs[-50:]) # عرض آخر 50 سطر فقط
|
| 21 |
+
|
| 22 |
+
with gr.Blocks() as demo:
|
| 23 |
+
with gr.Row():
|
| 24 |
+
btn = gr.Button("🚀 Start Training")
|
| 25 |
+
output = gr.Textbox(label="Logs", lines=25)
|
| 26 |
+
|
| 27 |
+
btn.click(fn=run_training, outputs=output)
|
| 28 |
+
|
| 29 |
+
demo.launch()
|