Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,36 +1,38 @@
|
|
| 1 |
-
import
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
"
|
| 20 |
-
"
|
| 21 |
-
"
|
| 22 |
-
"
|
| 23 |
-
"
|
| 24 |
-
"
|
| 25 |
-
"
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
st.title("🛒 SuperKart Sales Predictor")
|
| 5 |
+
|
| 6 |
+
# Sidebar inputs
|
| 7 |
+
Product_Weight = st.sidebar.number_input("Product Weight", min_value=0.0, max_value=100.0, value=10.0)
|
| 8 |
+
Product_Sugar_Content = st.sidebar.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
|
| 9 |
+
Product_Allocated_Area = st.sidebar.number_input("Allocated Area", min_value=0.0, max_value=10.0, value=0.5)
|
| 10 |
+
Product_Type = st.sidebar.text_input("Product Type", "Snack foods")
|
| 11 |
+
Product_MRP = st.sidebar.number_input("MRP", min_value=0.0, max_value=1000.0, value=100.0)
|
| 12 |
+
Store_Size = st.sidebar.selectbox("Store Size", ["Small", "Medium", "High"])
|
| 13 |
+
Store_Location_City_Type = st.sidebar.selectbox("City Type", ["Tier 1", "Tier 2", "Tier 3"])
|
| 14 |
+
Store_Type = st.sidebar.text_input("Store Type", "Supermarket Type1")
|
| 15 |
+
|
| 16 |
+
if st.button("Predict Sales"):
|
| 17 |
+
sample = [{
|
| 18 |
+
"Product_Weight": Product_Weight,
|
| 19 |
+
"Product_Sugar_Content": Product_Sugar_Content,
|
| 20 |
+
"Product_Allocated_Area": Product_Allocated_Area,
|
| 21 |
+
"Product_Type": Product_Type,
|
| 22 |
+
"Product_MRP": Product_MRP,
|
| 23 |
+
"Store_Size": Store_Size,
|
| 24 |
+
"Store_Location_City_Type": Store_Location_City_Type,
|
| 25 |
+
"Store_Type": Store_Type
|
| 26 |
+
}]
|
| 27 |
+
|
| 28 |
+
url = "https://akhilraja-superkart-flask-api.hf.space/predict"
|
| 29 |
+
try:
|
| 30 |
+
response = requests.post(url, json=sample)
|
| 31 |
+
response.raise_for_status()
|
| 32 |
+
prediction = response.json().get("predictions", [None])[0]
|
| 33 |
+
if prediction is not None:
|
| 34 |
+
st.success(f"Predicted Sales: {prediction:.2f}")
|
| 35 |
+
else:
|
| 36 |
+
st.error("No prediction returned.")
|
| 37 |
+
except Exception as e:
|
| 38 |
+
st.error(f"Error: {e}")
|