Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
import streamlit as st
|
| 3 |
+
import pandas as pd
|
| 4 |
+
|
| 5 |
+
st.title("Product Store Sales Total")
|
| 6 |
+
|
| 7 |
+
st.subheader("Online Prediction")
|
| 8 |
+
|
| 9 |
+
# Input fields for customer data
|
| 10 |
+
ProductID = st.text_input("Product ID")
|
| 11 |
+
Product_Weight = st.number_input("Product Weight (e.g., 12.5)", min_value=0.0, value=100.0)
|
| 12 |
+
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
|
| 13 |
+
Product_Allocated_Area = st.number_input("Product Allocated Area (e.g., 0.05)", min_value=0.0, value=0.5)
|
| 14 |
+
Product_Type = st.selectbox("Product Type", ['Soft Drinks', 'Dairy', 'Snack Foods', 'Household', 'Baking Goods',
|
| 15 |
+
'Others', 'Health and Hygiene', 'Meat', 'Fruits and Vegetables',
|
| 16 |
+
'Breads', 'Frozen Foods', 'Canned', 'Hard Drinks', 'Seafood',
|
| 17 |
+
'Starchy Foods', 'Breakfast'])
|
| 18 |
+
Product_MRP = st.number_input("Product MRP (e.g., 145.0)", min_value=0.0, value=14500.0)
|
| 19 |
+
Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1980, max_value=2025, value=2009)
|
| 20 |
+
Store_Size = st.selectbox("Store Size", ["High", "Medium", "Small"])
|
| 21 |
+
Store_Location_City_Type = st.selectbox("City Type", ["Tier 1", "Tier 2", "Tier 3"])
|
| 22 |
+
Store_Type = st.selectbox("Store Type", ["Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"])
|
| 23 |
+
|
| 24 |
+
# Prepare the JSON payload
|
| 25 |
+
product_data = {
|
| 26 |
+
"Product_Weight": Product_Weight,
|
| 27 |
+
"Product_Sugar_Content": Product_Sugar_Content,
|
| 28 |
+
"Product_Allocated_Area": Product_Allocated_Area,
|
| 29 |
+
"Product_Type": Product_Type,
|
| 30 |
+
"Product_MRP": Product_MRP,
|
| 31 |
+
"Store_Establishment_Year": Store_Establishment_Year,
|
| 32 |
+
"Store_Size": Store_Size,
|
| 33 |
+
"Store_Location_City_Type": Store_Location_City_Type,
|
| 34 |
+
"Store_Type": Store_Type
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
if st.button("Predict", type='primary'):
|
| 38 |
+
response = requests.post("https://hsaluja431-Backend.hf.space/v1/product", json=product_data) # enter user name and space name before running the cell
|
| 39 |
+
if response.status_code == 200:
|
| 40 |
+
result = response.json()
|
| 41 |
+
product_store_total_sales = result["Product Store Sales Total"] # Extract only the value
|
| 42 |
+
st.write(f"Based on the information provided, the product with ID {ProductID} is having sales total as {product_store_total_sales}.")
|
| 43 |
+
else:
|
| 44 |
+
st.error("Error in API request")
|