Upload 9 files
Browse files- STATUS.md +14 -2
- app.py +6 -0
- bayesian_network_interface.py +39 -15
STATUS.md
CHANGED
|
@@ -86,8 +86,20 @@ HF/ (104KB total)
|
|
| 86 |
- Local bayesian_network_interface.py: 33.2 kB (avec debugging)
|
| 87 |
- HF repo bayesian_network_interface.py: 32.3 kB (version ancienne)
|
| 88 |
|
| 89 |
-
**Solution**: Re-upload des fichiers mis à jour avec debugging vers HuggingFace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
---
|
| 92 |
|
| 93 |
-
**✅ Package HuggingFace Spaces -
|
|
|
|
|
|
|
|
|
| 86 |
- Local bayesian_network_interface.py: 33.2 kB (avec debugging)
|
| 87 |
- HF repo bayesian_network_interface.py: 32.3 kB (version ancienne)
|
| 88 |
|
| 89 |
+
**Solution**: Re-upload des fichiers mis à jour avec debugging complet vers HuggingFace
|
| 90 |
+
|
| 91 |
+
**Debugging Amélioré Ajouté**:
|
| 92 |
+
- ✅ Capture des messages de chargement détaillés
|
| 93 |
+
- ✅ Affichage dans interface Streamlit des erreurs précises
|
| 94 |
+
- ✅ Vérification fichier BIF, libraries, répertoire de travail
|
| 95 |
+
- ✅ Test local réussi avec debugging complet
|
| 96 |
+
|
| 97 |
+
**Nouvelles tailles fichiers avec debugging**:
|
| 98 |
+
- app.py: 25.3 kB (vs 23.4 kB sur HF)
|
| 99 |
+
- bayesian_network_interface.py: 34.2 kB (vs 32.3 kB sur HF)
|
| 100 |
|
| 101 |
---
|
| 102 |
|
| 103 |
+
**✅ Package HuggingFace Spaces - Debugging Complet Intégré**
|
| 104 |
+
|
| 105 |
+
Une fois re-uploadé, la page "Structure du Réseau" révélera exactement pourquoi le chargement échoue sur HuggingFace.
|
app.py
CHANGED
|
@@ -173,6 +173,12 @@ def show_structure_page(network):
|
|
| 173 |
st.error("❌ Réseau non initialisé!")
|
| 174 |
return
|
| 175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
st.write(f"- pgmpy_model exists: {network.pgmpy_model is not None}")
|
| 177 |
if network.pgmpy_model:
|
| 178 |
st.write(f"- pgmpy nodes: {len(list(network.pgmpy_model.nodes()))}")
|
|
|
|
| 173 |
st.error("❌ Réseau non initialisé!")
|
| 174 |
return
|
| 175 |
|
| 176 |
+
# Afficher les messages de debug détaillés du chargement
|
| 177 |
+
if hasattr(network, 'debug_messages'):
|
| 178 |
+
st.write("**Messages de chargement détaillés:**")
|
| 179 |
+
for msg in network.debug_messages:
|
| 180 |
+
st.code(msg)
|
| 181 |
+
|
| 182 |
st.write(f"- pgmpy_model exists: {network.pgmpy_model is not None}")
|
| 183 |
if network.pgmpy_model:
|
| 184 |
st.write(f"- pgmpy nodes: {len(list(network.pgmpy_model.nodes()))}")
|
bayesian_network_interface.py
CHANGED
|
@@ -56,38 +56,62 @@ class AutonomyBayesianNetwork:
|
|
| 56 |
def load_network(self):
|
| 57 |
"""Charge le réseau depuis le fichier BIF"""
|
| 58 |
# Debug: Vérifier l'environnement
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
| 65 |
|
| 66 |
if os.path.exists(self.bif_file):
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
if PGMPY_AVAILABLE and os.path.exists(self.bif_file):
|
| 72 |
try:
|
| 73 |
reader = BIFReader(self.bif_file)
|
| 74 |
self.pgmpy_model = reader.get_model()
|
| 75 |
self.inference_engine = VariableElimination(self.pgmpy_model)
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
| 78 |
except Exception as e:
|
| 79 |
-
|
|
|
|
|
|
|
| 80 |
|
| 81 |
if PYAGRUM_AVAILABLE and os.path.exists(self.bif_file):
|
| 82 |
try:
|
| 83 |
self.pyagrum_model = gum.loadBN(self.bif_file)
|
| 84 |
-
|
|
|
|
|
|
|
| 85 |
except Exception as e:
|
| 86 |
-
|
|
|
|
|
|
|
| 87 |
|
| 88 |
# Vérification finale
|
| 89 |
if self.pgmpy_model is None and self.pyagrum_model is None:
|
| 90 |
-
|
|
|
|
|
|
|
| 91 |
|
| 92 |
def get_network_structure(self) -> Dict:
|
| 93 |
"""Retourne la structure du réseau"""
|
|
|
|
| 56 |
def load_network(self):
|
| 57 |
"""Charge le réseau depuis le fichier BIF"""
|
| 58 |
# Debug: Vérifier l'environnement
|
| 59 |
+
debug_messages = []
|
| 60 |
+
debug_messages.append(f"🔍 Debug - Chargement réseau:")
|
| 61 |
+
debug_messages.append(f" - Fichier BIF: {self.bif_file}")
|
| 62 |
+
debug_messages.append(f" - Répertoire courant: {os.getcwd()}")
|
| 63 |
+
debug_messages.append(f" - Fichier existe: {os.path.exists(self.bif_file)}")
|
| 64 |
+
debug_messages.append(f" - pgmpy disponible: {PGMPY_AVAILABLE}")
|
| 65 |
+
debug_messages.append(f" - pyagrum disponible: {PYAGRUM_AVAILABLE}")
|
| 66 |
|
| 67 |
if os.path.exists(self.bif_file):
|
| 68 |
+
try:
|
| 69 |
+
with open(self.bif_file, 'r') as f:
|
| 70 |
+
content_preview = f.read(200)
|
| 71 |
+
debug_messages.append(f" - Aperçu fichier: {content_preview[:100]}...")
|
| 72 |
+
except Exception as e:
|
| 73 |
+
debug_messages.append(f" - Erreur lecture fichier: {e}")
|
| 74 |
+
else:
|
| 75 |
+
debug_messages.append(f" - ❌ Fichier {self.bif_file} non trouvé!")
|
| 76 |
+
|
| 77 |
+
# Sauvegarder les messages de debug pour Streamlit
|
| 78 |
+
self.debug_messages = debug_messages
|
| 79 |
+
|
| 80 |
+
# Aussi les imprimer
|
| 81 |
+
for msg in debug_messages:
|
| 82 |
+
print(msg)
|
| 83 |
|
| 84 |
if PGMPY_AVAILABLE and os.path.exists(self.bif_file):
|
| 85 |
try:
|
| 86 |
reader = BIFReader(self.bif_file)
|
| 87 |
self.pgmpy_model = reader.get_model()
|
| 88 |
self.inference_engine = VariableElimination(self.pgmpy_model)
|
| 89 |
+
success_msg = f"✓ Réseau chargé avec pgmpy depuis {self.bif_file}"
|
| 90 |
+
nodes_msg = f" - {len(list(self.pgmpy_model.nodes()))} nœuds, {len(list(self.pgmpy_model.edges()))} arcs"
|
| 91 |
+
print(success_msg)
|
| 92 |
+
print(nodes_msg)
|
| 93 |
+
self.debug_messages.extend([success_msg, nodes_msg])
|
| 94 |
except Exception as e:
|
| 95 |
+
error_msg = f"❌ Erreur pgmpy: {e}"
|
| 96 |
+
print(error_msg)
|
| 97 |
+
self.debug_messages.append(error_msg)
|
| 98 |
|
| 99 |
if PYAGRUM_AVAILABLE and os.path.exists(self.bif_file):
|
| 100 |
try:
|
| 101 |
self.pyagrum_model = gum.loadBN(self.bif_file)
|
| 102 |
+
success_msg = f"✓ Réseau chargé avec pyAgrum depuis {self.bif_file}"
|
| 103 |
+
print(success_msg)
|
| 104 |
+
self.debug_messages.append(success_msg)
|
| 105 |
except Exception as e:
|
| 106 |
+
error_msg = f"❌ Erreur pyAgrum: {e}"
|
| 107 |
+
print(error_msg)
|
| 108 |
+
self.debug_messages.append(error_msg)
|
| 109 |
|
| 110 |
# Vérification finale
|
| 111 |
if self.pgmpy_model is None and self.pyagrum_model is None:
|
| 112 |
+
final_msg = "❌ Aucun modèle chargé!"
|
| 113 |
+
print(final_msg)
|
| 114 |
+
self.debug_messages.append(final_msg)
|
| 115 |
|
| 116 |
def get_network_structure(self) -> Dict:
|
| 117 |
"""Retourne la structure du réseau"""
|