Spaces:
Sleeping
Sleeping
grosse modif
Browse files353 unmodified lines354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420353 unmodified linesPrésence de GPS = + valeur ajoutée """)with tab3:st.header("🔮 Prédiction du prix de location via l’API")# URL de ton API Hugging FaceAPI_URL = "https://gdleds-api-get.hf.space/predict"# --- Formulaire ---with st.form("predict_form"):st.subheader("Remplissez les caractéristiques du véhicule")# Sélection de la marquemodel_key = st.selectbox("Marque",["Audi", "BMW", "Citroën", "Peugeot", "Renault", "Mercedes", "Volkswagen", "Ford", "Opel"])mileage = st.slider("Kilométrage", 0, 300000, 50000, step=5000)engine_power = st.slider("Puissance moteur (CV)", 50, 300, 110, step=5)fuel = st.selectbox("Carburant", ["diesel", "petrol", "hybrid_petrol", "electro"])paint_color = st.selectbox("Couleur", ["black", "grey", "white", "red", "silver", "blue", "orange", "beige", "brown", "green"])car_type = st.selectbox("Type de voiture", ["convertible", "coupe", "estate", "hatchback", "sedan", "subcompact", "suv", "van"])st.markdown("**Options (True = Oui, False = Non)**")private_parking_available = st.checkbox("Parking privé disponible")has_gps = st.checkbox("GPS")has_air_conditioning = st.checkbox("Climatisation")automatic_car = st.checkbox("Boîte automatique")has_getaround_connect = st.checkbox("Getaround Connect")has_speed_regulator = st.checkbox("Régulateur de vitesse")winter_tires = st.checkbox("Pneus hiver")submitted = st.form_submit_button("🚀 Prédire le prix")# --- Envoi à l’API ---if submitted:data = {"model_key": model_key,"mileage": mileage,"engine_power": engine_power,"fuel": fuel,"paint_color": paint_color,"car_type": car_type,"private_parking_available": private_parking_available,"has_gps": has_gps,"has_air_conditioning": has_air_conditioning,"automatic_car": automatic_car,"has_getaround_connect": has_getaround_connect,"has_speed_regulator": has_speed_regulator,"winter_tires": winter_tires}try:response = requests.post(API_URL, json=data)if response.status_code == 200:price = response.json()["rental_price"]st.success(f"💰 Prix prédit : **{price} $/jour**")else:st.error(f"Erreur API ({response.status_code}) : {response.text}")except Exception as e:st.error(f"❌ Impossible de joindre l’API : {e}")353 unmodified lines354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401353 unmodified linesPrésence de GPS = + valeur ajoutée """)with tab3:st.header("🔧 Prédiction API")# Sélection des valeursmodel_key = st.selectbox("Marque", ["Audi", "BMW", "Peugeot", "Renault", "Citroën"])mileage = st.number_input("Kilométrage", min_value=0, max_value=300000, value=50000, step=1000)engine_power = st.number_input("Puissance moteur (ch)", min_value=50, max_value=300, value=110)fuel = st.selectbox("Carburant", ["diesel", "petrol", "hybrid_petrol", "electro"])paint_color = st.selectbox("Couleur", ["black", "grey", "white", "red", "silver", "blue", "orange", "beige", "brown", "green"])car_type = st.selectbox("Type de voiture", ["estate", "hatchback", "sedan", "suv", "convertible", "coupe", "van"])private_parking_available = st.checkbox("Parking privé disponible")has_gps = st.checkbox("GPS")has_air_conditioning = st.checkbox("Climatisation")automatic_car = st.checkbox("Automatique")has_getaround_connect = st.checkbox("Getaround Connect")has_speed_regulator = st.checkbox("Régulateur de vitesse")winter_tires = st.checkbox("Pneus hiver")# Construire le JSON attendupayload = {"model_key": model_key,"mileage": mileage,"engine_power": engine_power,"fuel": fuel,"paint_color": paint_color,"car_type": car_type,"private_parking_available": private_parking_available,"has_gps": has_gps,"has_air_conditioning": has_air_conditioning,"automatic_car": automatic_car,"has_getaround_connect": has_getaround_connect,"has_speed_regulator": has_speed_regulator,"winter_tires": winter_tires}if st.button("🔮 Prédire le prix"):try:response = requests.post("https://gdleds-api-get.hf.space/predict", json=payload)if response.status_code == 200:result = response.json()st.success(f"💰 Prix estimé : {result['rental_price']} $/jour")else:st.error(f"Erreur API ({response.status_code}) : {response.text}")except Exception as e:st.error(f"⚠️ Impossible d'appeler l'API : {e}")
app.py+40-59