ScottIzi commited on
Commit
36184e7
·
verified ·
1 Parent(s): 94e7105

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +16 -0
  2. app.py +82 -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.12-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,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import requests
4
+
5
+ st.title("SuperKart Sales Prediction App")
6
+
7
+ # Input fields for product and store data
8
+ Product_Weight = st.number_input("Product Weight", min_value=0.0, value=12.66)
9
+
10
+ Product_Sugar_Content = st.selectbox(
11
+ "Product Sugar Content",
12
+ ["Low Sugar", "Regular", "No Sugar"]
13
+ )
14
+
15
+ Product_Allocated_Area = st.number_input(
16
+ "Product Allocated Area",
17
+ min_value=0.0,
18
+ value=10.0
19
+ )
20
+
21
+ Product_MRP = st.number_input(
22
+ "Product MRP",
23
+ min_value=0.0,
24
+ value=100.0
25
+ )
26
+
27
+ Store_Size = st.selectbox(
28
+ "Store Size",
29
+ ["Small", "Medium", "High"]
30
+ )
31
+
32
+ Store_Location_City_Type = st.selectbox(
33
+ "Store Location City Type",
34
+ ["Tier 1", "Tier 2", "Tier 3"]
35
+ )
36
+
37
+ Store_Type = st.selectbox(
38
+ "Store Type",
39
+ ["Grocery Store", "Supermarket Type1", "Supermarket Type2", "Supermarket Type3"]
40
+ )
41
+
42
+ Product_Id_char = st.text_input(
43
+ "Product ID Character",
44
+ value="P001"
45
+ )
46
+
47
+ Store_Age_Years = st.number_input(
48
+ "Store Age (Years)",
49
+ min_value=0,
50
+ value=10
51
+ )
52
+
53
+ Product_Type_Category = st.selectbox(
54
+ "Product Type Category",
55
+ ["Food", "Drinks", "Household", "Health", "Other"]
56
+ )
57
+
58
+ product_data = {
59
+ "Product_Weight": Product_Weight,
60
+ "Product_Sugar_Content": Product_Sugar_Content,
61
+ "Product_Allocated_Area": Product_Allocated_Area,
62
+ "Product_MRP": Product_MRP,
63
+ "Store_Size": Store_Size,
64
+ "Store_Location_City_Type": Store_Location_City_Type,
65
+ "Store_Type": Store_Type,
66
+ "Product_Id_char": Product_Id_char,
67
+ "Store_Age_Years": Store_Age_Years,
68
+ "Product_Type_Category": Product_Type_Category
69
+ }
70
+
71
+ if st.button("Predict", type='primary'):
72
+ response = requests.post(
73
+ "https://scottizi-greatlearningdeploymentproject.hf.space/v1/predict",
74
+ json=product_data
75
+ )
76
+
77
+ if response.status_code == 200:
78
+ result = response.json()
79
+ predicted_sales = result["Sales"]
80
+ st.write(f"Predicted Product Store Sales Total: ₹{predicted_sales:.2f}")
81
+ else:
82
+ st.error("Error in API request")
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ requests==2.32.3
2
+ streamlit==1.45.0