Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from joblib import load | |
| import requests | |
| import os | |
| # Charger le modèle depuis Hugging Face | |
| MODEL_URL = "https://huggingface.co/MarouaneAyech/AppartmentPricePredictor/resolve/main/model.joblib" | |
| MODEL_PATH = "model.joblib" | |
| if not os.path.exists(MODEL_PATH): | |
| response = requests.get(MODEL_URL) | |
| with open(MODEL_PATH, "wb") as f: | |
| f.write(response.content) | |
| model = load(MODEL_PATH) | |
| # Fonction de prédiction | |
| def predict(features): | |
| features = [float(x) for x in features.split()] | |
| return model.predict([features])[0] | |
| # Interface utilisateur avec Gradio | |
| interface = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Textbox(label="Caractéristiques (séparées par des espaces)"), | |
| outputs=gr.Textbox(label="Prix prédit"), | |
| title="Prédicteur de prix d'appartement" | |
| ) | |
| if __name__ == "__main__": | |
| interface.launch() | |