sbstagiare commited on
Commit
8172992
·
verified ·
1 Parent(s): e7189df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -1,12 +1,30 @@
 
1
  import subprocess
2
  import threading
 
3
 
4
  # Fonction pour lancer train.py en arrière-plan
5
  def train_model():
6
  process = subprocess.Popen(["python", "trainer.py"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
7
  stdout, stderr = process.communicate()
8
- print(stdout.decode()) # Afficher les logs d'entraînement
9
- print(stderr.decode()) # Afficher les erreurs s'il y en a
10
 
11
- # Lancer l'entraînement dans un thread séparé
12
  threading.Thread(target=train_model, daemon=True).start()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
  import subprocess
3
  import threading
4
+ import time
5
 
6
  # Fonction pour lancer train.py en arrière-plan
7
  def train_model():
8
  process = subprocess.Popen(["python", "trainer.py"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
9
  stdout, stderr = process.communicate()
10
+ return stdout.decode() + "\n" + stderr.decode() # Retourne les logs
 
11
 
12
+ # Démarrer l'entraînement en arrière-plan
13
  threading.Thread(target=train_model, daemon=True).start()
14
+
15
+ # ✅ Assurer que Gradio démarre bien après un court délai
16
+ time.sleep(3)
17
+
18
+ # Interface Gradio
19
+ demo = gr.ChatInterface(
20
+ respond,
21
+ additional_inputs=[
22
+ gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
23
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
24
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
25
+ gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
26
+ ],
27
+ )
28
+
29
+ if __name__ == "__main__":
30
+ demo.launch()