Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- Dockerfile +9 -5
- app.py +44 -41
- requirements.txt +1 -9
Dockerfile
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
-
COPY . .
|
| 5 |
-
|
| 6 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
-
|
|
|
|
| 11 |
|
|
|
|
|
|
|
| 12 |
|
|
|
|
|
|
| 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
CHANGED
|
@@ -1,41 +1,44 @@
|
|
| 1 |
-
import
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
API_URL = "https://Hunagypsy-superkart-backend.hf.space/v1/predict"
|
| 5 |
+
|
| 6 |
+
st.title("Product Store Sales Prediction App")
|
| 7 |
+
|
| 8 |
+
# User Inputs
|
| 9 |
+
Product_Weight = st.number_input("Product Weight", min_value=0.0, value=12.66)
|
| 10 |
+
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
|
| 11 |
+
Product_Allocated_Area = st.selectbox("Product Allocated Area", ["Small", "Medium", "Large"])
|
| 12 |
+
Product_MRP = st.number_input("Product MRP", min_value=0.0, value=100.0)
|
| 13 |
+
Store_Size = st.selectbox("Store Size", ["Small", "Medium", "High"])
|
| 14 |
+
Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
|
| 15 |
+
Store_Type = st.selectbox("Store Type", ["Type 1", "Type 2", "Type 3", "Type 4"])
|
| 16 |
+
Product_Id_char = st.text_input("Product ID (char)", value="FDX")
|
| 17 |
+
Store_Age_Years = st.number_input("Store Age (Years)", min_value=0, value=5)
|
| 18 |
+
Product_Type_Category = st.selectbox("Product Type Category", ["Food", "Non-Food", "Drinks"])
|
| 19 |
+
|
| 20 |
+
# Package data
|
| 21 |
+
product_data = {
|
| 22 |
+
"Product_Weight": Product_Weight,
|
| 23 |
+
"Product_Sugar_Content": Product_Sugar_Content,
|
| 24 |
+
"Product_Allocated_Area": Product_Allocated_Area,
|
| 25 |
+
"Product_MRP": Product_MRP,
|
| 26 |
+
"Store_Size": Store_Size,
|
| 27 |
+
"Store_Location_City_Type": Store_Location_City_Type,
|
| 28 |
+
"Store_Type": Store_Type,
|
| 29 |
+
"Product_Id_char": Product_Id_char,
|
| 30 |
+
"Store_Age_Years": Store_Age_Years,
|
| 31 |
+
"Product_Type_Category": Product_Type_Category
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
if st.button("Predict", type='primary'):
|
| 35 |
+
try:
|
| 36 |
+
response = requests.post(API_URL, json=product_data)
|
| 37 |
+
if response.status_code == 200:
|
| 38 |
+
result = response.json()
|
| 39 |
+
predicted_sales = result["Sales"]
|
| 40 |
+
st.success(f"Predicted Product Store Sales Total: ₹{predicted_sales:.2f}")
|
| 41 |
+
else:
|
| 42 |
+
st.error(f"API request failed: {response.status_code}")
|
| 43 |
+
except Exception as e:
|
| 44 |
+
st.error(f"Error: {e}")
|
requirements.txt
CHANGED
|
@@ -1,10 +1,2 @@
|
|
| 1 |
-
|
| 2 |
-
numpy==2.0.2
|
| 3 |
-
scikit-learn==1.6.1
|
| 4 |
-
seaborn==0.13.2
|
| 5 |
-
joblib==1.4.2
|
| 6 |
-
xgboost==2.1.4
|
| 7 |
-
Werkzeug==2.2.2
|
| 8 |
-
flask==2.2.2
|
| 9 |
-
gunicorn==20.1.0
|
| 10 |
requests==2.32.3
|
|
|
|
| 1 |
+
streamlit==1.45.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
requests==2.32.3
|