| | import gradio as gr |
| | from train_interface import start_training |
| | import os |
| | from huggingface_hub import login |
| | import json |
| | from connect_huggingface import setup_huggingface |
| | import sys |
| |
|
| | print("=== Démarrage de l'application ===") |
| | print(f"Python version: {sys.version}") |
| | print(f"Working directory: {os.getcwd()}") |
| |
|
| | |
| | print("\nChargement de la configuration...") |
| | with open('config.json', 'r') as f: |
| | config = json.load(f) |
| |
|
| | def create_interface(): |
| | |
| | print("\nConfiguration de Hugging Face...") |
| | if not setup_huggingface(): |
| | print("Erreur : Impossible de configurer Hugging Face") |
| | |
| | |
| | demo = gr.Interface( |
| | fn=start_training, |
| | inputs=[], |
| | outputs=[ |
| | gr.Textbox( |
| | label="Statut de l'entraînement", |
| | lines=10, |
| | interactive=False |
| | ), |
| | gr.Markdown( |
| | """ |
| | ### Logs d'entraînement |
| | Les logs seront affichés ici pendant l'entraînement. |
| | """ |
| | ) |
| | ], |
| | title="AUTO Training Space", |
| | description=f""" |
| | ### Configuration actuelle |
| | - **Modèle** : {config['model']['name']} |
| | - **Dataset** : {config['dataset']['name']} |
| | - **Nombre d'époques** : {config['training']['epochs']} |
| | |
| | ### Format du dataset |
| | Le dataset contient des exemples structurés avec : |
| | - Une instruction (question utilisateur) |
| | - Une entrée (contexte optionnel) |
| | - Une sortie (réponse avec recommandations) |
| | |
| | ### Optimisations |
| | - Utilisation de BF16 pour une meilleure performance |
| | - Gestion optimisée des données avec pandas |
| | """, |
| | theme="huggingface", |
| | allow_flagging="never" |
| | ) |
| |
|
| | return demo |
| |
|
| | if __name__ == "__main__": |
| | print("\nCréation de l'interface...") |
| | demo = create_interface() |
| |
|
| | print("\nLancement de l'application...") |
| | demo.launch( |
| | server_name="0.0.0.0", |
| | server_port=7860, |
| | show_api=False |
| | ) |
| |
|