Spaces:
Sleeping
Sleeping
import gradio as gr | |
import pandas as pd | |
import joblib | |
from huggingface_hub import hf_hub_download | |
# Download model and feature names from Hugging Face | |
model_path = hf_hub_download(repo_id="alperugurcan/mercedes", filename="mercedes_model.joblib") | |
feature_names_path = hf_hub_download(repo_id="alperugurcan/mercedes", filename="feature_names.joblib") | |
# Load the saved model and feature names | |
model = joblib.load(model_path) | |
feature_names = joblib.load(feature_names_path) | |
def predict(*features): | |
# Create a DataFrame with the input features | |
df = pd.DataFrame([features], columns=feature_names) | |
# Make prediction | |
prediction = model.predict(df)[0] | |
return f"Predicted time: {prediction:.2f}" | |
# Create the interface | |
inputs = [gr.Number(label=f"Feature {i+1}") for i in range(len(feature_names))] | |
output = gr.Textbox(label="Prediction") | |
interface = gr.Interface( | |
fn=predict, | |
inputs=inputs, | |
outputs=output, | |
title="Mercedes-Benz Manufacturing Time Prediction", | |
description="Enter feature values to predict manufacturing time" | |
) | |
interface.launch() |