Sraja0310 commited on
Commit
cf700f2
·
verified ·
1 Parent(s): 0f105ce

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +5 -12
  2. app.py +40 -0
  3. requirements.txt +3 -3
Dockerfile CHANGED
@@ -1,20 +1,13 @@
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
+ FROM python:3.9-slim
2
 
3
  WORKDIR /app
4
 
5
+ COPY requirements.txt requirements.txt
6
+ RUN pip install -r requirements.txt
 
 
 
7
 
8
+ COPY . .
 
 
 
9
 
10
  EXPOSE 8501
11
 
12
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
13
 
 
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+
4
+ # Backend API URL (replace with your HF backend space URL when deployed)
5
+ BACKEND_URL = "http://127.0.0.1:7860/predict"
6
+
7
+ st.title("🛒 SuperKart Sales Forecast")
8
+ st.write("Enter product & store details to predict sales revenue.")
9
+
10
+ # Inputs (simplified — you can add all features as per dataset)
11
+ Product_Weight = st.number_input("Product Weight", min_value=0.1, max_value=100.0, step=0.1)
12
+ Product_Sugar_Content = st.selectbox("Product Sugar Content", ["low sugar", "regular", "no sugar"])
13
+ Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.0, max_value=1.0, step=0.01)
14
+ Product_Type = st.selectbox("Product Type", ["snack foods", "meat", "dairy", "soft drinks", "others"])
15
+ Product_MRP = st.number_input("Product MRP", min_value=1.0, max_value=1000.0, step=1.0)
16
+ Store_Size = st.selectbox("Store Size", ["High", "Medium", "Low"])
17
+ Store_Location_City_Type = st.selectbox("Store City Type", ["Tier 1", "Tier 2", "Tier 3"])
18
+ Store_Type = st.selectbox("Store Type", ["Departmental Store", "Supermarket Type 1", "Supermarket Type 2", "Food Mart"])
19
+
20
+ if st.button("Predict Sales"):
21
+ input_data = {
22
+ "Product_Weight": Product_Weight,
23
+ "Product_Sugar_Content": Product_Sugar_Content,
24
+ "Product_Allocated_Area": Product_Allocated_Area,
25
+ "Product_Type": Product_Type,
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
+ }
31
+
32
+ try:
33
+ response = requests.post(BACKEND_URL, json=input_data)
34
+ if response.status_code == 200:
35
+ result = response.json()
36
+ st.success(f"✅ Predicted Sales: {result['prediction']:.2f}")
37
+ else:
38
+ st.error(f"Error: {response.text}")
39
+ except Exception as e:
40
+ st.error(f"Connection Error: {e}")
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