adel67460 commited on
Commit
d583187
·
verified ·
1 Parent(s): 8c9a91c

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +73 -0
app.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from train_interface import start_training
3
+ import os
4
+ from huggingface_hub import login
5
+ import json
6
+ from connect_huggingface import setup_huggingface
7
+ import sys
8
+
9
+ print("=== Démarrage de l'application ===")
10
+ print(f"Python version: {sys.version}")
11
+ print(f"Working directory: {os.getcwd()}")
12
+
13
+ # Charger la configuration
14
+ print("\nChargement de la configuration...")
15
+ with open('config.json', 'r') as f:
16
+ config = json.load(f)
17
+
18
+ def create_interface():
19
+ # Configurer Hugging Face
20
+ print("\nConfiguration de Hugging Face...")
21
+ if not setup_huggingface():
22
+ print("Erreur : Impossible de configurer Hugging Face")
23
+
24
+ # Interface Gradio
25
+ demo = gr.Interface(
26
+ fn=start_training,
27
+ inputs=[],
28
+ outputs=[
29
+ gr.Textbox(
30
+ label="Statut de l'entraînement",
31
+ lines=10,
32
+ interactive=False
33
+ ),
34
+ gr.Markdown(
35
+ """
36
+ ### Logs d'entraînement
37
+ Les logs seront affichés ici pendant l'entraînement.
38
+ """
39
+ )
40
+ ],
41
+ title="AUTO Training Space",
42
+ description=f"""
43
+ ### Configuration actuelle
44
+ - **Modèle** : {config['model']['name']}
45
+ - **Dataset** : {config['dataset']['name']}
46
+ - **Nombre d'époques** : {config['training']['epochs']}
47
+
48
+ ### Format du dataset
49
+ Le dataset contient des exemples structurés avec :
50
+ - Une instruction (question utilisateur)
51
+ - Une entrée (contexte optionnel)
52
+ - Une sortie (réponse avec recommandations)
53
+
54
+ ### Optimisations
55
+ - Utilisation de BF16 pour une meilleure performance
56
+ - Gestion optimisée des données avec pandas
57
+ """,
58
+ theme="huggingface",
59
+ allow_flagging="never"
60
+ )
61
+
62
+ return demo
63
+
64
+ if __name__ == "__main__":
65
+ print("\nCréation de l'interface...")
66
+ demo = create_interface()
67
+
68
+ print("\nLancement de l'application...")
69
+ demo.launch(
70
+ server_name="0.0.0.0",
71
+ server_port=7860,
72
+ show_api=False
73
+ )