Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +16 -0
- app.py +57 -0
- requirements.txt +3 -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
|
app.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
st.title("Super Kart Sales Prediction App")
|
5 |
+
st.write("This tool predicts sales forecast of a product based on its details. Enter the required information below.")
|
6 |
+
|
7 |
+
sugar_contents = ["Low Sugar", "No Sugar", "Regular"]
|
8 |
+
product_types = ['Baking Goods', 'Breads', 'Breakfast', 'Canned', 'Dairy', 'Frozen Foods', 'Fruits and Vegetables', 'Hard Drinks',
|
9 |
+
'Health and Hygiene', 'Household', 'Meat', 'Others', 'Seafood', 'Snack Foods', 'Soft Drinks', 'Starchy Foods']
|
10 |
+
establishment_years = [2004, 2009]
|
11 |
+
store_sizes = ['Small', 'Medium', 'High']
|
12 |
+
city_types = ['Tier 1', 'Tier 2', 'Tier 3']
|
13 |
+
store_types = ['Departmental Store','Food Mart','Supermarket Type1', 'Supermarket Type2']
|
14 |
+
|
15 |
+
# ProductId = st.text_input("Product Id")
|
16 |
+
# ProductWeight = st.number_input("Weight", min_value=0.0, value=50.0)
|
17 |
+
# ProductSugarContent = st.selectbox("Sugar Content?", sugar_contents)
|
18 |
+
# ProductAllocatedArea = st.number_input("Allocated Area, e.g 0.056 ", min_value=0.000, value=1.000)
|
19 |
+
# ProductType = st.selectbox("Type / Category", product_types)
|
20 |
+
# ProductMRP = st.number_input("MRP", min_value=0.0, value=500.0)
|
21 |
+
|
22 |
+
# StoreId = st.text_input("Store Id")
|
23 |
+
# StoreEstablishmentYear = st.selectbox("Year of Establishment", establishment_years)
|
24 |
+
# StoreSize = st.selectbox("Size", store_sizes)
|
25 |
+
# StoreLocationCityType = st.selectbox("Location", store_sizes)
|
26 |
+
# StoreType = st.selectbox("Store Type", store_types)
|
27 |
+
|
28 |
+
|
29 |
+
# input_data = {
|
30 |
+
# 'ProductId': ProductId,
|
31 |
+
# 'ProductWeight': ProductWeight,
|
32 |
+
# 'ProductSugarContent': ProductSugarContent,
|
33 |
+
# 'ProductAllocatedArea': ProductAllocatedArea,
|
34 |
+
# 'ProductType': ProductType,
|
35 |
+
# 'ProductMRP': ProductMRP,
|
36 |
+
|
37 |
+
# 'StoreId': StoreId,
|
38 |
+
# 'StoreEstablishmentYear': StoreEstablishmentYear,
|
39 |
+
# 'StoreSize': StoreSize,
|
40 |
+
# 'StoreLocationCityType': StoreLocationCityType,
|
41 |
+
# 'StoreType': StoreType
|
42 |
+
# }
|
43 |
+
|
44 |
+
# base_url = os.getenv("API_BASE")
|
45 |
+
# api_key = os.getenv("API_KEY")
|
46 |
+
|
47 |
+
# # base_url = 'https://balakishan77-skart.hf.space'
|
48 |
+
# forecast_url = base_url + '/forecast'
|
49 |
+
|
50 |
+
# if st.button("Predict", type='primary'):
|
51 |
+
# response = requests.post(forecast_url, json=input_data)
|
52 |
+
# if response.status_code == 200:
|
53 |
+
# result = response.json()
|
54 |
+
# sales_forecast_prediction = result["Prediction"]
|
55 |
+
# st.write(f"Based on the information provided, the sales forecast for product having ID {ProductId} is likely to {sales_forecast_prediction}.")
|
56 |
+
# else:
|
57 |
+
# st.error("Error in API request")
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
pandas==2.2.2
|
2 |
+
requests==2.28.1
|
3 |
+
streamlit==1.43.2
|