a-ragab-h-m commited on
Commit
6eed7cc
·
verified ·
1 Parent(s): 0b32cc2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
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()