import gradio as gr import pandas as pd from huggingface_hub import hf_hub_download import joblib # Load the model repo_id = "rmaitest/mlmodel2" model_file = "house_price_model.pkl" # Adjust as necessary # Download and load the model model_path = hf_hub_download(repo_id, model_file) model = joblib.load(model_path) def predict_price(size, bedrooms, age): # Create a DataFrame from the input input_data = pd.DataFrame({ 'Size (sq ft)': [size], 'Number of Bedrooms': [bedrooms], 'Age of House (years)': [age] }) # Make prediction prediction = model.predict(input_data) return prediction[0] # Define the Gradio interface iface = gr.Interface( fn=predict_price, inputs=[ gr.Number(label="Size (sq ft)"), gr.Number(label="Number of Bedrooms"), gr.Number(label="Age of House (years)") ], outputs=gr.Number(label="Predicted Price ($)"), title="House Price Prediction", description="Enter the size, number of bedrooms, and age of the house to get the predicted price." ) # Launch the interface with a public URL iface.launch(share=True)