nimerml commited on
Commit
3806410
·
verified ·
1 Parent(s): 39e7045

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +8 -14
  2. app.py +45 -0
  3. requirements.txt +2 -3
Dockerfile CHANGED
@@ -1,20 +1,14 @@
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=7860", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
 
 
 
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import requests
4
+
5
+ st.title("SuperKart Sales Forecasting 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
+
11
+ Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.0, value=16.0)
12
+ Product_MRP = st.number_input("Product MRP", min_value=0.0, value=250.0)
13
+
14
+ Store_Size = st.selectbox("Store Size", ["Small", "Medium", "High"])
15
+ Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
16
+ Store_Type = st.selectbox("Store Type", ["Departmental Store", "Food Mart","Supermarket Type1"," Supermarket Type2"])
17
+
18
+ Product_Id_char = st.selectbox("Product Id Char", ["FD", "DR", "NC"])
19
+ Store_Age_Years = st.number_input("Store Age (Years)", min_value=0, value=14, step=1)
20
+ Product_Type_Category = st.selectbox("Product Type Category", ["Perishable", "Non Perishable"])
21
+
22
+ product_data = {
23
+ "Product_Weight": Product_Weight,
24
+ "Product_Sugar_Content": Product_Sugar_Content,
25
+ "Product_Allocated_Area": Product_Allocated_Area,
26
+ "Product_MRP": Product_MRP,
27
+ "Store_Size": Store_Size,
28
+ "Store_Location_City_Type": Store_Location_City_Type,
29
+ "Store_Type": Store_Type,
30
+ "Product_Id_char": Product_Id_char,
31
+ "Store_Age_Years": Store_Age_Years,
32
+ "Product_Type_Category": Product_Type_Category
33
+ }
34
+
35
+ if st.button("Predict", type="primary"):
36
+ response = requests.post(
37
+ "https://nimerml-backend.hf.space/v1/predict",
38
+ json=product_data
39
+ )
40
+ if response.status_code == 200:
41
+ result = response.json()
42
+ predicted_sales = result["Sales"]
43
+ st.write(f"Predicted Product Store Sales Total: ${predicted_sales:.2f}")
44
+ else:
45
+ st.error("Error in API request")
requirements.txt CHANGED
@@ -1,3 +1,2 @@
1
- altair
2
- pandas
3
- streamlit
 
1
+ requests==2.32.3
2
+ streamlit==1.45.0