RPeltier commited on
Commit
52acefd
·
verified ·
1 Parent(s): 0cf4056

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +16 -0
  2. app.py +40 -0
  3. requirements.txt +2 -0
Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a minimal base image with Python 3.9 installed
2
+ FROM python:3.10.11-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 and make it accessible externally
14
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
15
+
16
+ # NOTE: Disable XSRF protection for easier external access in order to make batch predictions
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import requests
4
+
5
+ st.title("Super Kart Product Pricing Predictor")
6
+
7
+ # Input fields for product and store data
8
+ Product_Weight = st.number_input("Product Weight", min_value=0.0, value=10.00)
9
+ Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"], value="Low Sugar")
10
+ Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.0, value=100.00)
11
+ Product_MRP = st.number_input("Product MRP", min_value=0.0, value=100.00)
12
+ Product_Type = st.selectbox("Product Type", ["Baking Goods", "Breads", "Breakfest", "Canned", "Dairy", "Frozen Foods", "Fruits and Vegetables", "Hard Drinks", "Health and Hygiene", "Household", "Meat", "Others", "Seafood", "Snack Foods", "Soft Drinks", "Starchy Foods"], value="Baking Goods")
13
+ Store_Size = st.selectbox("Store Size", ["Small", "Medium", "Large"], value="Small")
14
+ Store_Location_City_Type = st.selectbox("Store Location City Type", ["Urban", "Suburban", "Rural"], value="Urban")
15
+ Store_Type = st.selectbox("Store Type", ["Grocery", "Supermarket", "Hypermarket"], value="Grocery")
16
+ Product_Id_char = st.text_input("Product Id", value="FD5075")
17
+ Store_Age_Years = st.selectbox("Store Opening Year", [1987, 1988, 1999, 2009], value=1987)
18
+ Product_Type_Category = st.selectbox("Product Type Category", ["Food", "Electronics", "Clothing"], value="Food")
19
+
20
+ product_data = {
21
+ "Product_Weight": Product_Weight,
22
+ "Product_Sugar_Content": Product_Sugar_Content,
23
+ "Product_Allocated_Area": Product_Allocated_Area,
24
+ "Product_MRP": Product_MRP,
25
+ "Store_Size": Store_Size,
26
+ "Store_Location_City_Type": Store_Location_City_Type,
27
+ "Store_Type": Store_Type,
28
+ "Product_Id_char": Product_Id_char,
29
+ "Store_Age_Years": Store_Age_Years,
30
+ "Product_Type_Category": Product_Type_Category
31
+ }
32
+
33
+ if st.button("Predict", type='primary'):
34
+ response = requests.post("https://rpeltier-SuperKartPredictorBackend.hf.space/v1/predict", json=product_data)
35
+ if response.status_code == 200:
36
+ result = response.json()
37
+ predicted_sales = result["Sales"]
38
+ st.write(f"Predicted Product Store Sales Total: ${predicted_sales :,.2f}")
39
+ else:
40
+ st.error("Error in API request")
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ requests==2.32.3
2
+ streamlit==1.45.0