VeerendraManikonda commited on
Commit
fcb1069
·
verified ·
1 Parent(s): d5d9097

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +16 -0
  2. app.py +75 -0
  3. requirements.txt +3 -0
Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 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,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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("SuperKart Revenue Prediction")
7
+
8
+ # Section for online prediction
9
+ st.subheader("Online Prediction")
10
+
11
+ # Input fields for product and store data
12
+ Product_Weight = st.number_input("Product Weight", min_value=0.0, value=12.66)
13
+
14
+ Product_Sugar_Content = st.selectbox(
15
+ "Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"]
16
+ )
17
+
18
+ Product_Allocated_Area = st.number_input(
19
+ "Product Allocated Area", min_value=0.00, max_value=0.30, value=0.15, step=0.05
20
+ )
21
+
22
+ Product_MRP = st.slider(
23
+ "Product MRP", min_value=0, max_value=250, value=100, step=50
24
+ )
25
+
26
+ Store_Size = st.selectbox(
27
+ "Store Size", ["High", "Medium", "Small"]
28
+ )
29
+
30
+ Store_Location_City_Type = st.selectbox(
31
+ "Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"]
32
+ )
33
+
34
+ Store_Type = st.selectbox(
35
+ "Store Type", ["Departmental Store", "Food Mart", "Supermarket Type1", "Supermarket Type2"]
36
+ )
37
+
38
+ Product_Id_char = st.text_input(
39
+ "Product ID", value="FD306"
40
+ )
41
+
42
+ Store_Age_Years = st.slider(
43
+ "Store Age (in years)", min_value=0, max_value=30, value=10, step=1
44
+ )
45
+
46
+ Product_Type_Category = st.selectbox(
47
+ "Product Type Category",
48
+ [
49
+ "Baking Goods", "Breads", "Breakfast", "Canned", "Dairy", "Frozen Foods",
50
+ "Fruits and Vegetables", "Hard Drinks", "Health and Hygiene", "Household",
51
+ "Meat", "Others", "Seafood", "Snack Foods", "Soft Drinks", "Starchy Foods"
52
+ ]
53
+ )
54
+
55
+ product_data = {
56
+ "Product_Weight": Product_Weight,
57
+ "Product_Sugar_Content": Product_Sugar_Content,
58
+ "Product_Allocated_Area": Product_Allocated_Area,
59
+ "Product_MRP": Product_MRP,
60
+ "Store_Size": Store_Size,
61
+ "Store_Location_City_Type": Store_Location_City_Type,
62
+ "Store_Type": Store_Type,
63
+ "Product_Id_char": Product_Id_char,
64
+ "Store_Age_Years": Store_Age_Years,
65
+ "Product_Type_Category": Product_Type_Category
66
+ }
67
+
68
+ if st.button("Predict", type='primary'):
69
+ response = requests.post("https://randhigoswami-my-work-space.hf.space/v1/predict", json=product_data)
70
+ if response.status_code == 200:
71
+ result = response.json()
72
+ predicted_sales = result["Sales"]
73
+ st.write(f"Predicted Product Store Sales Total: ₹{predicted_sales:.2f}")
74
+ else:
75
+ st.error("Error in API request")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ pandas==2.2.2
2
+ requests==2.28.1
3
+ streamlit==1.43.2