Spaces:
Sleeping
Sleeping
grosse modif
Browse files
app.py
CHANGED
|
@@ -354,67 +354,48 @@ with tab2:
|
|
| 354 |
Présence de GPS = + valeur ajoutée """)
|
| 355 |
|
| 356 |
with tab3:
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
if
|
| 393 |
-
data = {
|
| 394 |
-
"model_key": model_key,
|
| 395 |
-
"mileage": mileage,
|
| 396 |
-
"engine_power": engine_power,
|
| 397 |
-
"fuel": fuel,
|
| 398 |
-
"paint_color": paint_color,
|
| 399 |
-
"car_type": car_type,
|
| 400 |
-
"private_parking_available": private_parking_available,
|
| 401 |
-
"has_gps": has_gps,
|
| 402 |
-
"has_air_conditioning": has_air_conditioning,
|
| 403 |
-
"automatic_car": automatic_car,
|
| 404 |
-
"has_getaround_connect": has_getaround_connect,
|
| 405 |
-
"has_speed_regulator": has_speed_regulator,
|
| 406 |
-
"winter_tires": winter_tires
|
| 407 |
-
}
|
| 408 |
-
|
| 409 |
try:
|
| 410 |
-
response = requests.post(
|
| 411 |
-
|
| 412 |
if response.status_code == 200:
|
| 413 |
-
|
| 414 |
-
st.success(f"💰 Prix
|
| 415 |
else:
|
| 416 |
st.error(f"Erreur API ({response.status_code}) : {response.text}")
|
| 417 |
-
|
| 418 |
except Exception as e:
|
| 419 |
-
st.error(f"
|
| 420 |
-
|
|
|
|
| 354 |
Présence de GPS = + valeur ajoutée """)
|
| 355 |
|
| 356 |
with tab3:
|
| 357 |
+
st.header("🔧 Prédiction API")
|
| 358 |
+
|
| 359 |
+
# Sélection des valeurs
|
| 360 |
+
model_key = st.selectbox("Marque", ["Audi", "BMW", "Peugeot", "Renault", "Citroën"])
|
| 361 |
+
mileage = st.number_input("Kilométrage", min_value=0, max_value=300000, value=50000, step=1000)
|
| 362 |
+
engine_power = st.number_input("Puissance moteur (ch)", min_value=50, max_value=300, value=110)
|
| 363 |
+
fuel = st.selectbox("Carburant", ["diesel", "petrol", "hybrid_petrol", "electro"])
|
| 364 |
+
paint_color = st.selectbox("Couleur", ["black", "grey", "white", "red", "silver", "blue", "orange", "beige", "brown", "green"])
|
| 365 |
+
car_type = st.selectbox("Type de voiture", ["estate", "hatchback", "sedan", "suv", "convertible", "coupe", "van"])
|
| 366 |
+
|
| 367 |
+
private_parking_available = st.checkbox("Parking privé disponible")
|
| 368 |
+
has_gps = st.checkbox("GPS")
|
| 369 |
+
has_air_conditioning = st.checkbox("Climatisation")
|
| 370 |
+
automatic_car = st.checkbox("Automatique")
|
| 371 |
+
has_getaround_connect = st.checkbox("Getaround Connect")
|
| 372 |
+
has_speed_regulator = st.checkbox("Régulateur de vitesse")
|
| 373 |
+
winter_tires = st.checkbox("Pneus hiver")
|
| 374 |
+
|
| 375 |
+
# Construire le JSON attendu
|
| 376 |
+
payload = {
|
| 377 |
+
"model_key": model_key,
|
| 378 |
+
"mileage": mileage,
|
| 379 |
+
"engine_power": engine_power,
|
| 380 |
+
"fuel": fuel,
|
| 381 |
+
"paint_color": paint_color,
|
| 382 |
+
"car_type": car_type,
|
| 383 |
+
"private_parking_available": private_parking_available,
|
| 384 |
+
"has_gps": has_gps,
|
| 385 |
+
"has_air_conditioning": has_air_conditioning,
|
| 386 |
+
"automatic_car": automatic_car,
|
| 387 |
+
"has_getaround_connect": has_getaround_connect,
|
| 388 |
+
"has_speed_regulator": has_speed_regulator,
|
| 389 |
+
"winter_tires": winter_tires
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
if st.button("🔮 Prédire le prix"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
try:
|
| 394 |
+
response = requests.post("https://gdleds-api-get.hf.space/predict", json=payload)
|
|
|
|
| 395 |
if response.status_code == 200:
|
| 396 |
+
result = response.json()
|
| 397 |
+
st.success(f"💰 Prix estimé : {result['rental_price']} $/jour")
|
| 398 |
else:
|
| 399 |
st.error(f"Erreur API ({response.status_code}) : {response.text}")
|
|
|
|
| 400 |
except Exception as e:
|
| 401 |
+
st.error(f"⚠️ Impossible d'appeler l'API : {e}")
|
|
|