Upload folder using huggingface_hub
Browse files- Dockerfile +9 -13
- app.py +38 -0
- requirements.txt +3 -3
Dockerfile
CHANGED
|
@@ -1,20 +1,16 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 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 |
-
|
| 17 |
-
|
| 18 |
-
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 19 |
|
| 20 |
-
|
|
|
|
| 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,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import requests
|
| 4 |
+
|
| 5 |
+
# Set the title of the Streamlit app
|
| 6 |
+
st.title("SuperKart Retail Store Sales Predictor App")
|
| 7 |
+
|
| 8 |
+
# Section for online prediction
|
| 9 |
+
st.subheader("This tool predicts SuperKart Retail Store Sales based on the product and store details. Enter the required information below.")
|
| 10 |
+
|
| 11 |
+
st.subheader("Enter the Product and Store details:")
|
| 12 |
+
|
| 13 |
+
# Collect user input
|
| 14 |
+
Product_Type = 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","Seafood"])
|
| 15 |
+
Product_Sugar_Content = st.selectbox("Product Sugar Content",["Low Sugar","Regular","No Sugar"])
|
| 16 |
+
Store_Type = st.selectbox("Store Type",["Supermarket Type2","Supermarket Type1","Departmental Store","Food Mart"])
|
| 17 |
+
Product_Weight = st.number_input("Product Weight (Lbs):",min_value = 5.00, step = 0.01, value = 25.00)
|
| 18 |
+
Product_MRP = st.number_input("Product MRP ($):",min_value = 40.00, step = 0.02, value = 240.00)
|
| 19 |
+
Product_Allocated_Area = st.number_input("Product Allocated Area (%):",min_value = 0.001, step = 0.001, value = 0.3000)
|
| 20 |
+
|
| 21 |
+
# Convert user input into a DataFrame
|
| 22 |
+
input_data = pd.DataFrame([{
|
| 23 |
+
"Product_Weight" : Product_Weight,
|
| 24 |
+
"Product_Allocated_Area" : Product_Allocated_Area,
|
| 25 |
+
"Product_MRP" : Product_MRP,
|
| 26 |
+
"Product_Sugar_Content" : Product_Sugar_Content,
|
| 27 |
+
"Product_Type" : Product_Type,
|
| 28 |
+
"Store_Type" : Store_Type
|
| 29 |
+
}])
|
| 30 |
+
|
| 31 |
+
# Make prediction when the "Predict" button is clicked
|
| 32 |
+
if st.button("Predict"):
|
| 33 |
+
response = requests.post("https://<username>-<repo_id>.hf.space/v1/superkart", json=input_data) # Send data to Flask API
|
| 34 |
+
if response.status_code == 200:
|
| 35 |
+
prediction = response.json()['Predicted Store Sales (in dollars)']
|
| 36 |
+
st.success(f"Predicted Store Sales (in dollars): {prediction}")
|
| 37 |
+
else:
|
| 38 |
+
st.error("Error making prediction.")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
streamlit
|
|
|
|
| 1 |
+
pandas==2.2.2
|
| 2 |
+
requests==2.32.4
|
| 3 |
+
streamlit==1.43.2
|