Upload folder using huggingface_hub
Browse files- Dockerfile +15 -0
- app.py +96 -0
- requirements.txt +5 -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 --no-cache -r requirements.txt
|
| 12 |
+
|
| 13 |
+
# Define the command to run the Streamlit app on port 8502 and make it accessible externally
|
| 14 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
|
| 15 |
+
|
app.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import requests
|
| 4 |
+
|
| 5 |
+
API_ENDPOINT="https://TokenTutor-SuperKartSalesPrectionBackend.hf.space/v1/forecast"
|
| 6 |
+
|
| 7 |
+
#product type
|
| 8 |
+
product_types = [
|
| 9 |
+
"Fruits and Vegetables",
|
| 10 |
+
"Snack Foods",
|
| 11 |
+
"Frozen Foods",
|
| 12 |
+
"Dairy",
|
| 13 |
+
"Household",
|
| 14 |
+
"Baking Goods",
|
| 15 |
+
"Canned",
|
| 16 |
+
"Health and Hygiene",
|
| 17 |
+
"Meat",
|
| 18 |
+
"Soft Drinks",
|
| 19 |
+
"Breads",
|
| 20 |
+
"Hard Drinks",
|
| 21 |
+
"Others",
|
| 22 |
+
"Starchy Foods",
|
| 23 |
+
"Breakfast",
|
| 24 |
+
"Seafood"
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
#store types
|
| 28 |
+
store_types = [
|
| 29 |
+
"Food Mart",
|
| 30 |
+
"Supermarket Type1",
|
| 31 |
+
"Supermarket Type2",
|
| 32 |
+
"Departmental Store"
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
#Store Id
|
| 36 |
+
store_ids = [
|
| 37 |
+
"OUT001",
|
| 38 |
+
"OUT002",
|
| 39 |
+
"OUT003",
|
| 40 |
+
"OUT004"
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
store_Location_City_Types=[
|
| 44 |
+
"Tier 1",
|
| 45 |
+
"Tier 2",
|
| 46 |
+
"Tier 3"
|
| 47 |
+
]
|
| 48 |
+
|
| 49 |
+
store_sizes=[
|
| 50 |
+
"Small",
|
| 51 |
+
"Medium",
|
| 52 |
+
"Large"
|
| 53 |
+
]
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
#Set title of the Streamlit app
|
| 57 |
+
st.title("Product Revenue prediction")
|
| 58 |
+
|
| 59 |
+
#Section for online prediction
|
| 60 |
+
st.subheader("Online Prediction")
|
| 61 |
+
|
| 62 |
+
#Collect user input for features
|
| 63 |
+
Product_Weight = st.number_input("Product Weight", min_value=4.0, max_value=25.0, step=0.5)
|
| 64 |
+
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["No Sugar", "Low Sugar", "Regular"])
|
| 65 |
+
Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.001, max_value=0.3)
|
| 66 |
+
Product_Type = st.selectbox("Product Type", product_types)
|
| 67 |
+
Product_MRP = st.number_input("Product MRP", min_value=30.0, max_value=300.0)
|
| 68 |
+
Store_Id = st.selectbox("Store Id", store_ids)
|
| 69 |
+
Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1988, max_value=2010, step=1)
|
| 70 |
+
Store_Size = st.selectbox("Store Size", store_sizes)
|
| 71 |
+
Store_Location_City_Type = st.selectbox("Store Location City Type", store_Location_City_Types)
|
| 72 |
+
Store_Type = st.selectbox("Store Type", store_types)
|
| 73 |
+
|
| 74 |
+
payload = {
|
| 75 |
+
'Product_Weight': Product_Weight,
|
| 76 |
+
'Product_Sugar_Content': Product_Sugar_Content,
|
| 77 |
+
'Product_Allocated_Area': Product_Allocated_Area,
|
| 78 |
+
'Product_Type': Product_Type ,
|
| 79 |
+
'Product_MRP': Product_MRP,
|
| 80 |
+
'Store_Id': Store_Id,
|
| 81 |
+
'Store_Establishment_Year': Store_Establishment_Year,
|
| 82 |
+
'Store_Size': Store_Size,
|
| 83 |
+
'Store_Location_City_Type': Store_Location_City_Type,
|
| 84 |
+
'Store_Type': Store_Type
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
if st.button("Predict"):
|
| 89 |
+
response = requests.post(API_ENDPOINT, json=payload)
|
| 90 |
+
if response.status_code == 200:
|
| 91 |
+
json_data= response.json()
|
| 92 |
+
st.write('Predicted Sales revenue ', json_data.get('Prediction'))
|
| 93 |
+
else:
|
| 94 |
+
st.write(f"Error making prediction: {response.status_code}")
|
| 95 |
+
|
| 96 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas==2.2.2
|
| 2 |
+
numpy==2.0.2
|
| 3 |
+
scikit-learn==1.6.1
|
| 4 |
+
requests==2.28.1
|
| 5 |
+
streamlit==1.43.2
|