Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
import os
|
| 3 |
import subprocess
|
| 4 |
import sys
|
|
@@ -703,4 +703,133 @@ def create_interface():
|
|
| 703 |
|
| 704 |
with gr.Column():
|
| 705 |
training_status = gr.Textbox(
|
| 706 |
-
label="Status
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
imp ort gradio as gr
|
| 2 |
import os
|
| 3 |
import subprocess
|
| 4 |
import sys
|
|
|
|
| 703 |
|
| 704 |
with gr.Column():
|
| 705 |
training_status = gr.Textbox(
|
| 706 |
+
label="Status d'entraînement",
|
| 707 |
+
interactive=False,
|
| 708 |
+
lines=15
|
| 709 |
+
)
|
| 710 |
+
|
| 711 |
+
train_btn.click(
|
| 712 |
+
trainer.simulate_training,
|
| 713 |
+
inputs=[output_dir, num_epochs, learning_rate, batch_size],
|
| 714 |
+
outputs=training_status
|
| 715 |
+
)
|
| 716 |
+
|
| 717 |
+
with gr.Tab("📈 Monitoring"):
|
| 718 |
+
gr.Markdown("### 📊 Suivi de l'entraînement")
|
| 719 |
+
|
| 720 |
+
with gr.Row():
|
| 721 |
+
with gr.Column():
|
| 722 |
+
gr.Markdown("#### 🎯 Métriques")
|
| 723 |
+
metrics_display = gr.Textbox(
|
| 724 |
+
label="Métriques actuelles",
|
| 725 |
+
value="📊 Aucun entraînement en cours",
|
| 726 |
+
interactive=False,
|
| 727 |
+
lines=8
|
| 728 |
+
)
|
| 729 |
+
|
| 730 |
+
refresh_metrics_btn = gr.Button("🔄 Actualiser métriques")
|
| 731 |
+
|
| 732 |
+
with gr.Column():
|
| 733 |
+
gr.Markdown("#### 📝 Logs")
|
| 734 |
+
logs_display = gr.Textbox(
|
| 735 |
+
label="Logs d'entraînement",
|
| 736 |
+
value="📋 Aucun log disponible",
|
| 737 |
+
interactive=False,
|
| 738 |
+
lines=8
|
| 739 |
+
)
|
| 740 |
+
|
| 741 |
+
clear_logs_btn = gr.Button("🧹 Nettoyer logs")
|
| 742 |
+
|
| 743 |
+
def get_dummy_metrics():
|
| 744 |
+
return "📊 MÉTRIQUES (SIMULATION):\n\n🔥 Loss: 2.34\n📈 Accuracy: 0.78\n⚡ Speed: 1.2 steps/sec\n💾 Memory: 4.2GB"
|
| 745 |
+
|
| 746 |
+
def clear_logs():
|
| 747 |
+
return "📋 Logs nettoyés"
|
| 748 |
+
|
| 749 |
+
refresh_metrics_btn.click(get_dummy_metrics, outputs=metrics_display)
|
| 750 |
+
clear_logs_btn.click(clear_logs, outputs=logs_display)
|
| 751 |
+
|
| 752 |
+
with gr.Tab("🛠️ Outils"):
|
| 753 |
+
gr.Markdown("### 🔧 Utilitaires et outils avancés")
|
| 754 |
+
|
| 755 |
+
with gr.Row():
|
| 756 |
+
with gr.Column():
|
| 757 |
+
gr.Markdown("#### 💾 Gestion des modèles")
|
| 758 |
+
|
| 759 |
+
model_path = gr.Textbox(
|
| 760 |
+
label="Chemin du modèle local",
|
| 761 |
+
placeholder="/path/to/model"
|
| 762 |
+
)
|
| 763 |
+
|
| 764 |
+
with gr.Row():
|
| 765 |
+
save_model_btn = gr.Button("💾 Sauvegarder modèle")
|
| 766 |
+
load_local_btn = gr.Button("📂 Charger local")
|
| 767 |
+
|
| 768 |
+
gr.Markdown("#### 🧹 Nettoyage")
|
| 769 |
+
with gr.Row():
|
| 770 |
+
clear_cache_btn = gr.Button("🗑️ Vider cache")
|
| 771 |
+
reset_all_btn = gr.Button("🔄 Reset complet", variant="stop")
|
| 772 |
+
|
| 773 |
+
with gr.Column():
|
| 774 |
+
tools_status = gr.Textbox(
|
| 775 |
+
label="Status des outils",
|
| 776 |
+
interactive=False,
|
| 777 |
+
lines=12
|
| 778 |
+
)
|
| 779 |
+
|
| 780 |
+
def save_model_placeholder():
|
| 781 |
+
return "💾 Fonction de sauvegarde (implémentation requise)"
|
| 782 |
+
|
| 783 |
+
def load_local_placeholder():
|
| 784 |
+
return "📂 Fonction de chargement local (implémentation requise)"
|
| 785 |
+
|
| 786 |
+
def clear_cache():
|
| 787 |
+
return "🗑️ Cache vidé (simulation)"
|
| 788 |
+
|
| 789 |
+
def reset_all():
|
| 790 |
+
return "🔄 Système réinitialisé (simulation)"
|
| 791 |
+
|
| 792 |
+
save_model_btn.click(save_model_placeholder, outputs=tools_status)
|
| 793 |
+
load_local_btn.click(load_local_placeholder, outputs=tools_status)
|
| 794 |
+
clear_cache_btn.click(clear_cache, outputs=tools_status)
|
| 795 |
+
reset_all_btn.click(reset_all, outputs=tools_status)
|
| 796 |
+
|
| 797 |
+
# Footer
|
| 798 |
+
gr.Markdown("""
|
| 799 |
+
---
|
| 800 |
+
🔥 **Multimodal Training Hub** | Optimisé pour Qwen2.5-Omni et modèles multimodaux
|
| 801 |
+
|
| 802 |
+
💡 **Conseils:**
|
| 803 |
+
- Vérifiez les dépendances avant de commencer
|
| 804 |
+
- Utilisez le diagnostic pour analyser les modèles
|
| 805 |
+
- Les entraînements sont simulés sans GPU adapté
|
| 806 |
+
""")
|
| 807 |
+
|
| 808 |
+
return app
|
| 809 |
+
|
| 810 |
+
# Lancement de l'application
|
| 811 |
+
if __name__ == "__main__":
|
| 812 |
+
app = create_interface()
|
| 813 |
+
|
| 814 |
+
# Configuration du lancement
|
| 815 |
+
launch_kwargs = {
|
| 816 |
+
"share": False, # Changez à True pour un lien public
|
| 817 |
+
"server_name": "0.0.0.0",
|
| 818 |
+
"server_port": 7860,
|
| 819 |
+
"show_error": True,
|
| 820 |
+
"quiet": False
|
| 821 |
+
}
|
| 822 |
+
|
| 823 |
+
# Affichage des informations système au lancement
|
| 824 |
+
print("\n" + "="*60)
|
| 825 |
+
print("��� MULTIMODAL TRAINING HUB")
|
| 826 |
+
print("="*60)
|
| 827 |
+
print(trainer.check_dependencies())
|
| 828 |
+
print("="*60)
|
| 829 |
+
print("🚀 Lancement de l'interface...")
|
| 830 |
+
|
| 831 |
+
try:
|
| 832 |
+
app.launch(**launch_kwargs)
|
| 833 |
+
except Exception as e:
|
| 834 |
+
print(f"❌ Erreur de lancement: {e}")
|
| 835 |
+
print("💡 Essayez de changer le port ou les paramètres réseau")
|