kritish205's picture
Upload folder using huggingface_hub
ae6a97f verified
import streamlit as st
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download
import os
# 1. Load the model from Hugging Face Hub
# Ensure you use your actual username and repo name
REPO_ID = "your_username/superkart-sales-predictor"
model_path = hf_hub_download(repo_id=REPO_ID, filename="model.joblib")
model = joblib.load(model_path)
st.title("SuperKart Sales Forecast Dashboard")
st.write("This MLOps pipeline predicts total revenue based on product and store attributes.")
# 2. Get inputs through Streamlit sidebar or main page
st.header("Input Product & Store Details")
col1, col2 = st.columns(2)
with col1:
prod_weight = st.number_input("Product Weight", value=12.0)
sugar_content = st.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
area_ratio = st.slider("Allocated Area Ratio", 0.0, 1.0, 0.05)
prod_type = st.selectbox("Product Type", ['Frozen Foods', 'Dairy', 'Canned', 'Baking Goods', 'Health and Hygiene', 'Others'])
with col2:
mrp = st.number_input("Product MRP", value=150.0)
est_year = st.number_input("Store Establishment Year", value=2000)
store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
city_type = st.selectbox("City Type", ["Tier 1", "Tier 2", "Tier 3"])
store_type = st.selectbox("Store Type", ["Supermarket Type1", "Supermarket Type2", "Departmental Store", "Food Mart"])
# 3. Predict Button
if st.button("Generate Sales Forecast"):
input_df = pd.DataFrame([{
'Product_Weight': prod_weight,
'Product_Sugar_Content': sugar_content,
'Product_Allocated_Area': area_ratio,
'Product_Type': prod_type,
'Product_MRP': mrp,
'Store_Establishment_Year': est_year,
'Store_Size': store_size,
'Store_Location_City_Type': city_type,
'Store_Type': store_type
}])
prediction = model.predict(input_df)[0]
st.success(f"### Predicted Total Sales: ${prediction:,.2f}")