visram commited on
Commit
0de7a7b
·
verified ·
1 Parent(s): 084e985

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +32 -0
  2. app.py +38 -0
  3. requirements.txt +3 -0
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Use a minimal base image with Python 3.9 installed
3
+
4
+ FROM python:3.9-slim
5
+
6
+
7
+
8
+ # Set the working directory inside the container to /app
9
+
10
+ WORKDIR /app
11
+
12
+
13
+
14
+ # Copy all files from the current directory on the host to the container's /app directory
15
+
16
+ COPY . .
17
+
18
+
19
+
20
+ # Install Python dependencies listed in requirements.txt
21
+
22
+ RUN pip3 install -r requirements.txt
23
+
24
+
25
+
26
+ # Define the command to run the Streamlit app on port 8501 and make it accessible externally
27
+
28
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
29
+
30
+
31
+
32
+ # NOTE: Disable XSRF protection for easier external access in order to make batch predictions
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import requests
4
+
5
+ st.title("SuperKartForntend") #Complete the code to define the title of the 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
+ Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
10
+ Product_Allocated_Area = st.number_input("Area", min_value=0.004, max_value=0.298) #Complete the code to define the UI element for Product_Allocated_Area
11
+ Product_MRP = st.number_input("MRP", min_value=30, max_value=266) #Complete the code to define the UI element for Product_MRP
12
+ Store_Size =st.selectbox("size", ["small", "Medium", "high"]) #Complete the code to define the UI element for Store_Size
13
+ Store_Location_City_Type =st.selectbox("citytype", ["Tire1", "Tire2", "Tire3"]) #Complete the code to define the UI element for Store_Location_City_Type
14
+ Store_Type =st.selectbox("citytype",["Departmental Store", "Supermarket Type1", "Supermarket Type2","Food Mart"]) #Complete the code to define the UI element for Store_Type
15
+ Product_Id_char = st.selectbox("ProductId",["FD6114","FD7839","FD5075","FD8233","NC1180"]) #Complete the code to define the UI element for Product_Id_char
16
+ Store_Age_Years = st.number_input("StoreAge", min_value=1987, max_value=2009) #Complete the code to define the UI element for Store_Age_Years
17
+ Product_Type_Category = st.selectbox("ProductType",["Frozen Foods","Dairy","Canned","Baking Goods","Health and Hygiene"])
18
+ product_data = {
19
+ "Product_Weight": Product_Weight,
20
+ "Product_Sugar_Content": Product_Sugar_Content,
21
+ "Product_Allocated_Area": Product_Allocated_Area,
22
+ "Product_MRP": Product_MRP,
23
+ "Store_Size": Store_Size,
24
+ "Store_Location_City_Type": Store_Location_City_Type,
25
+ "Store_Type": Store_Type,
26
+ "Product_Id_char": Product_Id_char,
27
+ "Store_Age_Years": Store_Age_Years,
28
+ "Product_Type_Category": Product_Type_Category
29
+ }
30
+
31
+ if st.button("Predict", type='primary'):
32
+ response = requests.post("https://visram-SuperkartBackendAPI.hf.space/v1/predict", json=product_data) # Complete the code to enter user name and space name to correctly define the endpoint
33
+ if response.status_code == 200:
34
+ result = response.json()
35
+ predicted_sales = result["Sales"]
36
+ st.write(f"Predicted Product Store Sales Total: ₹{predicted_sales:.2f}")
37
+ else:
38
+ st.error("Error in API request")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+
2
+ requests==2.32.3
3
+ streamlit==1.45.0