Upload folder using huggingface_hub
Browse files- Dockerfile +15 -0
- app.py +51 -0
- requirements.txt +3 -0
Dockerfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a minimal base image with Python 3.9 installed
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
+
|
| 4 |
+
# Set the working directory inside the container to /app
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy all files from the current directory on the host to the container's /app directory
|
| 8 |
+
COPY . .
|
| 9 |
+
|
| 10 |
+
# Install Python dependencies listed in requirements.txt
|
| 11 |
+
RUN pip3 install -r requirements.txt
|
| 12 |
+
|
| 13 |
+
# Define the command to run the Streamlit app on port 8501
|
| 14 |
+
# We set server.address to 0.0.0.0 to make it accessible externally
|
| 15 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
app.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import requests
|
| 4 |
+
|
| 5 |
+
# Set the title of the Streamlit app
|
| 6 |
+
st.title("Store Product Sales Prediction")
|
| 7 |
+
|
| 8 |
+
# Section for online prediction
|
| 9 |
+
st.subheader("Online Prediction")
|
| 10 |
+
|
| 11 |
+
# Collect user input for property features
|
| 12 |
+
# Using selectbox for categorical features to match model expectations
|
| 13 |
+
Product_Sugar_Content = st.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
|
| 14 |
+
Product_Type = st.selectbox("Product Type", ["Meat", "Snack Foods", "Hard Drinks", "Dairy", "Canned", "Soft Drinks", "Health and Hygiene", "Baking Goods", "Bread", "Breakfast", "Frozen Foods", "Fruits and Vegetables", "Household", "Seafood", "Starchy Foods", "Others"])
|
| 15 |
+
Store_Size = st.selectbox("Store Size", ["High", "Medium", "Small"])
|
| 16 |
+
Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
|
| 17 |
+
Store_Type = st.selectbox("Store Type", ["Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"])
|
| 18 |
+
|
| 19 |
+
# Numerical inputs
|
| 20 |
+
Product_Weight = st.number_input("Product Weight", min_value=0.0, value=10.0)
|
| 21 |
+
Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.0, value=0.05)
|
| 22 |
+
Product_MRP = st.number_input("Product MRP", min_value=0.0, value=100.0)
|
| 23 |
+
Store_Age = st.number_input("Store Age", min_value=0, value=10)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# Convert user input into a DataFrame
|
| 27 |
+
input_data = pd.DataFrame([{
|
| 28 |
+
'Product_Sugar_Content': Product_Sugar_Content,
|
| 29 |
+
'Product_Type': Product_Type,
|
| 30 |
+
'Store_Size': Store_Size,
|
| 31 |
+
'Store_Location_City_Type': Store_Location_City_Type,
|
| 32 |
+
'Store_Type': Store_Type,
|
| 33 |
+
'Product_Weight': Product_Weight,
|
| 34 |
+
'Product_Allocated_Area': Product_Allocated_Area,
|
| 35 |
+
'Product_MRP': Product_MRP,
|
| 36 |
+
'Store_Age': Store_Age
|
| 37 |
+
}])
|
| 38 |
+
|
| 39 |
+
# Make prediction when the "Predict" button is clicked
|
| 40 |
+
if st.button("Predict"):
|
| 41 |
+
# Replace with your actual Backend URL if different
|
| 42 |
+
backend_url = "https://debasishdas1985-StoreSalesPredictionBackend.hf.space/v1/predict"
|
| 43 |
+
try:
|
| 44 |
+
response = requests.post(backend_url, json=input_data.to_dict(orient='records')[0])
|
| 45 |
+
if response.status_code == 200:
|
| 46 |
+
prediction = response.json().get('Predicted Sales (in dollars)')
|
| 47 |
+
st.success(f"Predicted Store Sales (in dollars): {prediction}")
|
| 48 |
+
else:
|
| 49 |
+
st.error(f"Error: {response.status_code} - {response.text}")
|
| 50 |
+
except Exception as e:
|
| 51 |
+
st.error(f"Connection Error: {e}")
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit==1.43.2
|
| 2 |
+
pandas==2.2.2
|
| 3 |
+
requests==2.32.3
|