import requests import streamlit as st import pandas as pd st.title("Product Store Sales Total") st.subheader("Online Prediction") # Input fields for customer data Product_Id = st.text_input("Product ID") Product_Weight = st.number_input("Product Weight (e.g., 12.5)", min_value=0.0, value=100.0) Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"]) Product_Allocated_Area = st.number_input("Product Allocated Area (e.g., 0.05)", min_value=0.0, value=0.5) Product_Type = st.selectbox("Product Type", ['Soft Drinks', 'Dairy', 'Snack Foods', 'Household', 'Baking Goods', 'Others', 'Health and Hygiene', 'Meat', 'Fruits and Vegetables', 'Breads', 'Frozen Foods', 'Canned', 'Hard Drinks', 'Seafood', 'Starchy Foods', 'Breakfast']) Product_MRP = st.number_input("Product MRP (e.g., 145.0)", min_value=0.0, value=145.0) Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1980, max_value=2025, value=2009) Store_Size = st.selectbox("Store Size", ["High", "Medium", "Small"]) Store_Location_City_Type = st.selectbox("City Type", ["Tier 1", "Tier 2", "Tier 3"]) Store_Type = st.selectbox("Store Type", ["Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"]) # Prepare the JSON payload product_data = { "Product_Id": Product_Id, "Product_Weight": Product_Weight, "Product_Sugar_Content": Product_Sugar_Content, "Product_Allocated_Area": Product_Allocated_Area, "Product_Type": Product_Type, "Product_MRP": Product_MRP, "Store_Establishment_Year": Store_Establishment_Year, "Store_Size": Store_Size, "Store_Location_City_Type": Store_Location_City_Type, "Store_Type": Store_Type } if st.button("Predict", type='primary'): response = requests.post("https://hsaluja431-Backend.hf.space/v1/product", json=product_data) # enter user name and space name before running the cell if response.status_code == 200: result = response.json() product_store_total_sales = result["Product Store Sales Total"] # Extract only the value st.write(f"Based on the information provided, the product with ID {Product_Id} is having sales total as {product_store_total_sales}.") else: st.error("Error in API request")