pavanipriyanka commited on
Commit
397bba4
·
verified ·
1 Parent(s): 44a4fc2

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +9 -13
  2. SuperKart_Model_V1_0.joblib +3 -0
  3. app.py +53 -0
  4. requirements.txt +3 -3
Dockerfile CHANGED
@@ -1,20 +1,16 @@
1
- FROM python:3.13.5-slim
 
2
 
 
3
  WORKDIR /app
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
- curl \
8
- git \
9
- && rm -rf /var/lib/apt/lists/*
10
-
11
- COPY requirements.txt ./
12
- COPY src/ ./src/
13
 
 
14
  RUN pip3 install -r requirements.txt
15
 
16
- EXPOSE 8501
17
-
18
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
19
 
20
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
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
SuperKart_Model_V1_0.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06234b86b6bdeea8fa7023e0d50f4e8e378d395609985f79b17a456f7311bc27
3
+ size 211281
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import joblib
5
+ import numpy as np
6
+
7
+ # Load the trained model
8
+ @st.cache_resource
9
+ def load_model():
10
+ return joblib.load("deployment_files/SuperKart_Model_V1_0.joblib")
11
+
12
+ model = load_model()
13
+
14
+ # Streamlit UI for Price Prediction
15
+ st.title("SuperKart Revenue Prediction App")
16
+ st.write("This tool predicts the sales revenue listing based on the given details.")
17
+
18
+ st.subheader("Enter the listing details:")
19
+
20
+ # Collect user input
21
+ Product_Type = st.selectbox("Product_Type", ["Fruits and Vegetables ", "Snack Foods", "Frozen Foods","Dairy","Household","Baking Goods","Canned","Health and Hygiene","Meat","Soft Drinks","Breads","Hard Drinks","Others","Starchy Foods ","Breakfast","Seafood"])
22
+ Product_Weight = st.number_input("Product_Weight", min_value=0.0, max_value=1000.0, step=0.1, value=5.0)
23
+ Product_MRP = st.number_input("Product_MRP", min_value=0.0, max_value=1000.0, step=0.1, value=5.0)
24
+ Product_Allocated_Area = st.number_input("Product_Allocated_Area", min_value=0.0, max_value=1000.0, step=0.1, value=5.0)
25
+ Product_Sugar_Content = st.selectbox("Sugar_Type", ["Low Sugar", "No Sugar", "Regular", "reg"])
26
+ Store_Type = st.selectbox("Store_Type", ["Supermarket Type2 ", "Supermarket Type1","Departmental Store","Food Mart"])
27
+ Store_Location_City_Type = st.selectbox("Store_Location_City_Type", ["Tier 2", "Tier 1","Tier 3"])
28
+ Store_Id = st.selectbox("Store_Id",["OUT004","OUT003","OUT002","OUT001"]
29
+
30
+ # Convert user input into a DataFrame
31
+ input_data = pd.DataFrame([{
32
+ 'Product_Type': Product_Type,
33
+ 'Product_Weight': Product_Weight,
34
+ 'Product_MRP': Product_MRP,
35
+ 'Product_Allocated_Area': Product_Allocated_Area,
36
+ 'Product_Sugar_Content': Sugar_Type,
37
+ 'Store_Type': Store_Type,
38
+ 'Store_Location_City_Type': Store_Location_City_Type,
39
+ 'Store_Id': Store_Id
40
+ }])
41
+
42
+ # Predict button
43
+ 'Product_Type': Product_Type,
44
+ 'Product_MRP': Product_MRP,
45
+ 'Product_Weight': Product_Weight,
46
+ 'Store_Location_City_Type': Store_Location_City_Type,
47
+
48
+ }])
49
+
50
+ # Predict button
51
+ if st.button("Predict"):
52
+ prediction = model.predict(input_data)
53
+ st.write(f"The predicted revnue is ${np.exp(prediction)[0]:.2f}.")
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- altair
2
- pandas
3
- streamlit
 
1
+ pandas==2.2.2
2
+ requests==2.28.1
3
+ streamlit==1.43.2