import gradio as gr import joblib import pandas as pd model = joblib.load('esmat12/egyptian-real-estate-price-predictor') def predict_price(size_sqm, bedrooms, bathrooms, down_payment, location, payment_method): # بناء الـ DataFrame للمدخلات input_data = pd.DataFrame([{ 'size_sqm': size_sqm, 'bedrooms': bedrooms, 'bathrooms': bathrooms, 'down_payment': down_payment, 'location': location, 'payment_method': payment_method }]) # التنبؤ prediction = model.predict(input_data)[0] return f"{prediction:,.2f} EGP" # تصميم واجهة مستخدم Gradio interface = gr.Interface( fn=predict_price, inputs=[ gr.Number(label="Size (sqm)", value=120), gr.Slider(minimum=1, maximum=10, step=1, label="Bedrooms", value=3), gr.Slider(minimum=1, maximum=5, step=1, label="Bathrooms", value=2), gr.Number(label="Down Payment (EGP)", value=100000), gr.Dropdown(choices=["Cairo", "Giza", "New Cairo", "October"], label="Location"), gr.Dropdown(choices=["Cash", "Installments"], label="Payment Method") ], outputs=gr.Textbox(label="Predicted Property Price"), title="Egyptian Real Estate Price Predictor", description="Enter property details to estimate the price." ) if __name__ == "__main__": interface.launch()