Spaces:
Sleeping
Sleeping
Tracy André
commited on
Commit
·
70f01b9
1
Parent(s):
1bed691
updated
Browse files
app.py
CHANGED
|
@@ -38,39 +38,12 @@ class AgricultureAnalyzer:
|
|
| 38 |
dataset = load_dataset(dataset_id, token=hf_token)
|
| 39 |
print(f"🔑 Authentification avec token réussie")
|
| 40 |
else:
|
| 41 |
-
print(f"⚠️ Aucun token HF_TOKEN trouvé, tentative sans authentification")
|
| 42 |
-
dataset = load_dataset(dataset_id)
|
| 43 |
-
|
| 44 |
print(f"📊 Splits disponibles: {list(dataset.keys())}")
|
| 45 |
except Exception as e:
|
| 46 |
print(f"⚠️ Erreur lors du chargement depuis Hugging Face: {e}")
|
| 47 |
-
print("🔄 Basculement vers les fichiers locaux...")
|
| 48 |
-
|
| 49 |
return self.analyze_data()
|
| 50 |
-
|
| 51 |
-
def create_sample_data(self):
|
| 52 |
-
"""Crée des données d'exemple pour la démo"""
|
| 53 |
-
np.random.seed(42)
|
| 54 |
-
n_parcels = 45
|
| 55 |
-
n_interventions = 653
|
| 56 |
-
|
| 57 |
-
parcels = {
|
| 58 |
-
'numparcell': np.random.randint(1, n_parcels+1, n_interventions),
|
| 59 |
-
'nomparc': [f"Parcelle_{i}" for i in np.random.randint(1, n_parcels+1, n_interventions)],
|
| 60 |
-
'surfparc': np.random.uniform(0.1, 7.0, n_interventions),
|
| 61 |
-
'libelleusag': np.random.choice(['blé tendre hiver', 'maïs grain', 'colza hiver', 'haricot vert industrie',
|
| 62 |
-
'CIPAN autre', 'orge hiver', 'soja', 'avoine printemps'], n_interventions),
|
| 63 |
-
'familleprod': np.random.choice(['Herbicides', 'Fongicides', 'Insecticides', 'Fertilisants'],
|
| 64 |
-
n_interventions, p=[0.16, 0.25, 0.15, 0.44]),
|
| 65 |
-
'produit': [f"Produit_{i}" for i in np.random.randint(1, 50, n_interventions)],
|
| 66 |
-
'quantitetot': np.random.uniform(0.1, 25.0, n_interventions),
|
| 67 |
-
'libevenem': ['Traitement et protection des cultures'] * n_interventions,
|
| 68 |
-
'millesime': [2025] * n_interventions,
|
| 69 |
-
'raisonsoci': ['Station Expérimentale de Kerguéhennec'] * n_interventions
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
return pd.DataFrame(parcels)
|
| 73 |
-
|
| 74 |
def analyze_data(self):
|
| 75 |
"""Analyse des données et calcul des risques"""
|
| 76 |
if self.df is None:
|
|
|
|
| 38 |
dataset = load_dataset(dataset_id, token=hf_token)
|
| 39 |
print(f"🔑 Authentification avec token réussie")
|
| 40 |
else:
|
| 41 |
+
print(f"⚠️ Aucun token HF_TOKEN trouvé, tentative sans authentification")
|
|
|
|
|
|
|
| 42 |
print(f"📊 Splits disponibles: {list(dataset.keys())}")
|
| 43 |
except Exception as e:
|
| 44 |
print(f"⚠️ Erreur lors du chargement depuis Hugging Face: {e}")
|
|
|
|
|
|
|
| 45 |
return self.analyze_data()
|
| 46 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
def analyze_data(self):
|
| 48 |
"""Analyse des données et calcul des risques"""
|
| 49 |
if self.df is None:
|