ravikmrg6 commited on
Commit
d31c1d3
·
verified ·
1 Parent(s): dd70180

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +16 -0
  2. Superkart_model_v1.joblib +3 -0
  3. app.py +71 -0
  4. requirements.txt +4 -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
Superkart_model_v1.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bf225ec14e320dcfd1c67cd06d5482d3a3df311957bdb91935a5aa2b80d6caf0
3
+ size 222714
app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import requests
5
+
6
+
7
+ # Streamlit UI for Boston Housing Price Prediction
8
+ st.title("Super Kart sales revenue Predictor App")
9
+ st.write("This app predicts the Revenue of the superkart product .")
10
+
11
+ st.subheader("Enter the below listing details")
12
+
13
+ # Collect user input using sliders
14
+ PRODUCT_ID = st.text_input(" Enter product ID (PRODUCT ID)")
15
+ st.write(f"{PRODUCT_ID}")
16
+ PRODUCT_WGT = st.text_input(" Enter product Weight (PRODUCT WGT)")
17
+ st.write(f"{PRODUCT_WGT}")
18
+ PRODUCT_SGR_CNT = st.text_input(" Enter product Weight (PRODUCT SGR CNT)")
19
+ st.write(f"{PRODUCT_SGR_CNT}")
20
+ PRODUCT_ALOC_AREA = st.text_input(" Enter product Allocated Area (PRODUCT ALOC AREA)")
21
+ st.write(f"{PRODUCT_ALOC_AREA}")
22
+ PRODUCT_TYPE = st.text_input(" Enter product Type (PRODUCT TYPE)")
23
+ st.write(f"{PRODUCT_TYPE}")
24
+ PRODUCT_MRP = st.text_input(" Enter product MRP (PRODUCT MRP)")
25
+ st.write(f"{PRODUCT_MRP}")
26
+ STORE_EST_YEAR = st.text_input(" Enter Established Year (STORE EST YEAR)")
27
+ st.write(f"{STORE_EST_YEAR}")
28
+ STORE_SIZE = st.text_input(" Enter Store Size (STORE SIZE)")
29
+ st.write(f"{STORE_SIZE}")
30
+ STORE_LOC = st.text_input(" Enter Store Location (STORE LOC)")
31
+ st.write(f"{STORE_LOC}")
32
+ STORE_TYPE = st.text_input(" Enter Store type (STORE TYPE)")
33
+ st.write(f"{STORE_TYPE}")
34
+
35
+
36
+ # Create input DataFrame
37
+ input_data = pd.DataFrame([{
38
+ 'PRODUCT_ID': PRODUCT_ID,
39
+ 'PRODUCT_WGT': PRODUCT_WGT,
40
+ 'PRODUCT_SGR_CNT': PRODUCT_SGR_CNT,
41
+ 'PRODUCT_ALOC_AREA': PRODUCT_ALOC_AREA,
42
+ 'PRODUCT_TYPE': PRODUCT_TYPE,
43
+ 'PRODUCT_MRP': PRODUCT_MRP,
44
+ 'STORE_EST_YEAR': STORE_EST_YEAR,
45
+ 'STORE_SIZE': STORE_SIZE,
46
+ 'STORE_LOC': STORE_LOC,
47
+ 'STORE_TYPE': STORE_TYPE
48
+ }])
49
+
50
+ if st.button("Predict", type='primary'):
51
+ response = requests.post("https://ravikmrg6-SuperKartFrontEnd.hf.space/v1/house", json=input_data.to_dict(orient='records')[0]) # enter user name and space name before running the cell
52
+ if response.status_code == 200:
53
+ result = response.json()
54
+ predicted_price = result[""]
55
+ st.success(f"🏡 Predicted Product Revenu Value: **${predicted_price * 1000:.2f}**")
56
+ else:
57
+ st.error("Error in API request")
58
+
59
+ # Batch Prediction
60
+ st.subheader("Batch Prediction")
61
+
62
+ file = st.file_uploader("Upload CSV file", type=["csv"])
63
+ if file is not None:
64
+ if st.button("Predict for Batch", type='primary'):
65
+ response = requests.post("https://ravikmrg6-SuperKartFrontEnd.hf.space/v1/housebatch", files={"file": file}) # enter user name and space name before running the cell
66
+ if response.status_code == 200:
67
+ result = response.json()
68
+ st.header("Batch Prediction Results")
69
+ st.write(result)
70
+ else:
71
+ st.error("Error in API request")
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ pandas==2.2.2
2
+ requests==2.32.4
3
+ streamlit==1.43.2
4
+ huggingface_hub>=0.20.0