MainiSandeep1987 commited on
Commit
3d3ebe5
·
verified ·
1 Parent(s): 86aa619

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +6 -0
  2. app.py +64 -0
  3. requirements.txt +3 -0
Dockerfile ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ FROM python:3.9-slim
2
+ WORKDIR /app
3
+ COPY requirements.txt .
4
+ RUN pip install --no-cache-dir -r requirements.txt
5
+ COPY app.py .
6
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
app.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import requests
4
+
5
+
6
+ # Set the title of the Streamlit app
7
+ st.title("Product Store Sales Revenue Predictor")
8
+
9
+ # Section for online prediction
10
+ st.subheader("Online Prediction")
11
+
12
+
13
+ # Collect user input for property features
14
+ ProductWeight = st.number_input("Product_Weight", min_value=1.00, value=1.00)
15
+ ProductAllocatedArea = st.number_input("Product_Allocated_Area", min_value=0.0001, value=0.0001)
16
+ ProductMRP = st.number_input("Product_MRP", min_value=1.00,value=1.00)
17
+ StoreEstablishmentYear = st.number_input("Store_Establishment_Year", min_value=1980,value=1990)
18
+ ProductSugarContent = st.selectbox("Product_Sugar_Content", ["Low Sugar", "Regular", "No Sugar"])
19
+ ProductType = 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",
20
+ "Seafood"])
21
+ StoreId = st.selectbox("Store_Id", ["OUT001", "OUT002", "OUT003","OUT004"])
22
+ StoreSize = st.selectbox("Store_Size", ["Small", "Medium", "High"])
23
+ StoreLocationCityType = st.selectbox("Store_Location_City_Type", ["Tier 1", "Tier 2", "Tier 3"])
24
+ StoreType = st.selectbox("Store_Type", ["Departmental Store", "Food Mart", "Supermarket Type1","Supermarket Type2"])
25
+
26
+ # Convert user input into a DataFrame
27
+ input_data = pd.DataFrame([{
28
+ 'Product_Weight': ProductWeight,
29
+ 'Product_Allocated_Area': ProductAllocatedArea,
30
+ 'Product_MRP': ProductMRP,
31
+ 'Store_Establishment_Year': StoreEstablishmentYear,
32
+ 'Product_Sugar_Content': ProductSugarContent,
33
+ ##'instant_bookable': 'f' if instant_bookable=="False" else "t", # Convert to 't' or 'f'
34
+ 'Product_Type': ProductType,
35
+ 'Store_Id': StoreId,
36
+ 'Store_Size': StoreSize,
37
+ 'Store_Location_City_Type': StoreLocationCityType,
38
+ 'Store_Type': StoreType
39
+ }])
40
+
41
+ # Make prediction when the "Predict" button is clicked
42
+ # if st.button("Predict"):
43
+ # response = requests.post("https://MainiSandeep1987-SuperKartBackEnd.hf.space/v1/salesTotal", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API
44
+ # if response.status_code == 200:
45
+ # prediction = response.json()['Predicted Sales Revenue Price']
46
+ # st.success(f"Predicted Sales Revenue : {prediction}")
47
+ # else:
48
+ # st.error("Error making prediction.")
49
+
50
+ if st.button("Predict"):
51
+ try:
52
+ response = requests.post(
53
+ "https://MainiSandeep1987-SuperKartBackEnd.hf.space/v1/salesTotal",
54
+ json=input_data.to_dict(orient='records')[0]
55
+ ) # Send data to Flask API
56
+
57
+ if response.status_code == 200:
58
+ prediction = response.json().get('Predicted Sales Revenue Price', "Prediction not found")
59
+ st.success(f"Predicted Sales Revenue : {prediction}")
60
+ else:
61
+ st.error(f"Error {response.status_code}: {response.text}")
62
+
63
+ except requests.exceptions.RequestException as e:
64
+ st.error(f"Request failed: {str(e)}")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ pandas==2.2.2
2
+ requests==2.28.1
3
+ streamlit==1.43.2