Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import requests | |
| st.title("🛒 SuperKart Sales Predictor") | |
| # Input fields | |
| inputs = { | |
| 'Product_Weight': st.number_input("Weight (kg)", value=12.0), | |
| 'Product_Allocated_Area': st.number_input("Allocated Area", value=0.05), | |
| 'Product_MRP': st.number_input("MRP (₹)", value=150.0), | |
| 'Store_Age': st.number_input("Store Age", value=15), | |
| 'Product_Sugar_Content': st.selectbox("Sugar Content", ['Low', 'Regular', 'No Sugar']), | |
| 'Product_Type': st.selectbox("Product Type", ['Dairy', 'Meat', 'Snack Foods', 'Others']), | |
| 'Store_Size': st.selectbox("Store Size", ['Small', 'Medium', 'High']), | |
| 'Store_Location_City_Type': st.selectbox("City Tier", ['Tier 1', 'Tier 2', 'Tier 3']), | |
| 'Store_Type': st.selectbox("Store Type", ['Departmental Store', 'Supermarket Type1', 'Food Mart']) | |
| } | |
| # Prediction button | |
| if st.button("Predict Sales"): | |
| try: | |
| #response = requests.post("http://host.docker.internal:7860/predict", json=inputs) | |
| response = requests.post("https://labhara-superkart-backend.hf.space/predict", json=inputs) | |
| if response.ok: | |
| result = response.json()["predicted_sales"] | |
| st.success(f"💰 Predicted Sales: ₹{result}") | |
| else: | |
| st.error("Failed to get prediction.") | |
| except: | |
| st.error("Could not reach backend.") | |