Upload Streamlit app and model
Browse files- Dockerfile +7 -14
- SuperKart_Mode_v2_0.joblib +3 -0
- streamlit_app.py +32 -40
Dockerfile
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
curl \
|
| 8 |
-
software-properties-common \
|
| 9 |
-
git \
|
| 10 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
-
|
| 12 |
-
COPY requirements.txt ./
|
| 13 |
-
COPY src/ ./src/
|
| 14 |
|
|
|
|
| 15 |
RUN pip3 install -r requirements.txt
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 20 |
-
|
| 21 |
-
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
| 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"]
|
|
|
|
|
|
|
|
|
SuperKart_Mode_v2_0.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:76964249af602d97766de8e0ae7aa9464ff20afeeb16ca2e4f3ff363288740c3
|
| 3 |
+
size 405737
|
streamlit_app.py
CHANGED
|
@@ -1,52 +1,44 @@
|
|
| 1 |
-
|
| 2 |
import streamlit as st
|
| 3 |
import pandas as pd
|
| 4 |
import joblib
|
| 5 |
|
| 6 |
# Load trained model pipeline
|
| 7 |
-
model = joblib.load('
|
| 8 |
-
|
| 9 |
-
#
|
| 10 |
-
st.title("
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
if submit:
|
| 34 |
-
input_dict = {
|
| 35 |
"Product_Weight": [product_weight],
|
| 36 |
-
"Product_Allocated_Area": [
|
| 37 |
"Product_MRP": [product_mrp],
|
| 38 |
"Store_Age": [store_age],
|
| 39 |
-
"Product_Sugar_Content": [
|
| 40 |
"Product_Type": [product_type],
|
| 41 |
"Store_Size": [store_size],
|
| 42 |
-
"Store_Location_City_Type": [
|
| 43 |
"Store_Type": [store_type]
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
input_df = pd.DataFrame(input_dict)
|
| 47 |
-
|
| 48 |
-
# Predict using loaded model
|
| 49 |
-
prediction = model.predict(input_df)[0]
|
| 50 |
|
| 51 |
-
|
| 52 |
-
st.success(f"
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import joblib
|
| 4 |
|
| 5 |
# Load trained model pipeline
|
| 6 |
+
model = joblib.load('SuperKart_Mode_v2_0.joblib') # Update the path if needed
|
| 7 |
+
|
| 8 |
+
# App title
|
| 9 |
+
st.title("Sales Predictor")
|
| 10 |
+
|
| 11 |
+
# Sidebar inputs
|
| 12 |
+
st.sidebar.header("Input Product & Store Details")
|
| 13 |
+
|
| 14 |
+
product_weight = st.sidebar.slider("Product Weight (kg)", 1.0, 50.0, 13.5)
|
| 15 |
+
allocated_area = st.sidebar.slider("Allocated Area (0 to 1)", 0.001, 1.0, 0.08)
|
| 16 |
+
product_mrp = st.sidebar.slider("Product MRP (₹)", 1.0, 1000.0, 250.75)
|
| 17 |
+
store_age = st.sidebar.slider("Store Age (years)", 1, 100, 20)
|
| 18 |
+
|
| 19 |
+
sugar_content = st.sidebar.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar", "High Sugar"])
|
| 20 |
+
product_type = st.sidebar.selectbox("Product Type", [
|
| 21 |
+
"Meat", "Snack Foods", "Hard Drinks", "Dairy", "Canned", "Soft Drinks",
|
| 22 |
+
"Health and Hygiene", "Baking Goods", "Bread", "Breakfast", "Frozen Foods",
|
| 23 |
+
"Fruits and Vegetables", "Household", "Seafood", "Starchy Foods", "Others"
|
| 24 |
+
])
|
| 25 |
+
store_size = st.sidebar.selectbox("Store Size", ["Small", "Medium", "High"])
|
| 26 |
+
city_tier = st.sidebar.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"])
|
| 27 |
+
store_type = st.sidebar.selectbox("Store Type", ["Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"])
|
| 28 |
+
|
| 29 |
+
# Predict button
|
| 30 |
+
if st.sidebar.button("Predict Sales"):
|
| 31 |
+
input_data = pd.DataFrame({
|
|
|
|
|
|
|
| 32 |
"Product_Weight": [product_weight],
|
| 33 |
+
"Product_Allocated_Area": [allocated_area],
|
| 34 |
"Product_MRP": [product_mrp],
|
| 35 |
"Store_Age": [store_age],
|
| 36 |
+
"Product_Sugar_Content": [sugar_content],
|
| 37 |
"Product_Type": [product_type],
|
| 38 |
"Store_Size": [store_size],
|
| 39 |
+
"Store_Location_City_Type": [city_tier],
|
| 40 |
"Store_Type": [store_type]
|
| 41 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
prediction = model.predict(input_data)[0]
|
| 44 |
+
st.success(f"Predicted Sales: Rs{prediction:,.2f}")
|