Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- Dockerfile +11 -15
- app.py +23 -0
- requirements.txt +10 -3
- superkart_sales_prediction_model_v1_0.joblib +3 -0
Dockerfile
CHANGED
|
@@ -1,20 +1,16 @@
|
|
| 1 |
-
FROM python:3.
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
curl \
|
| 8 |
-
git \
|
| 9 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
| 1 |
+
FROM python:3.9-slim
|
| 2 |
|
| 3 |
+
# Set the working directory inside the container
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
+
# Copy all files from the current directory to the container's working directory
|
| 7 |
+
COPY . .
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
# Install dependencies from the requirements file without using cache to reduce image size
|
| 10 |
+
RUN pip install --upgrade -r requirements.txt
|
| 11 |
|
| 12 |
+
# Define the command to start the application using Gunicorn with 4 worker processes
|
| 13 |
+
# - `-w 4`: Uses 4 worker processes for handling requests
|
| 14 |
+
# - `-b 0.0.0.0:7860`: Binds the server to port 7860 on all network interfaces
|
| 15 |
+
# - `app:app`: Runs the Flask app (assuming `app.py` contains the Flask instance named `app`)
|
| 16 |
+
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:8080", "app:app"]
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import joblib
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from flask import Flask, request, jsonify
|
| 4 |
+
|
| 5 |
+
import time
|
| 6 |
+
start = time.time()
|
| 7 |
+
|
| 8 |
+
# Initialize Flask app with a name
|
| 9 |
+
app = Flask("Superkart Sales Predictor")
|
| 10 |
+
|
| 11 |
+
# Load the trained churn prediction model
|
| 12 |
+
#model = joblib.load("superkart_sales_prediction_model_v1_0.joblib")
|
| 13 |
+
|
| 14 |
+
print(f"Model loaded in {time.time() - start:.2f} seconds")
|
| 15 |
+
|
| 16 |
+
# Define a route for the home page
|
| 17 |
+
@app.get('/')
|
| 18 |
+
def home():
|
| 19 |
+
return "Welcome to the Superkart Sales Prediction API"
|
| 20 |
+
|
| 21 |
+
# Run the Flask app in debug mode
|
| 22 |
+
if __name__ == '__main__':
|
| 23 |
+
app.run(debug=True)
|
requirements.txt
CHANGED
|
@@ -1,3 +1,10 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas==2.2.2
|
| 2 |
+
numpy==2.0.2
|
| 3 |
+
scikit-learn==1.6.1
|
| 4 |
+
joblib==1.4.2
|
| 5 |
+
Werkzeug==2.2.2
|
| 6 |
+
flask==2.2.2
|
| 7 |
+
gunicorn==20.1.0
|
| 8 |
+
requests==2.28.1
|
| 9 |
+
uvicorn[standard]
|
| 10 |
+
streamlit==1.43.2
|
superkart_sales_prediction_model_v1_0.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:724ef8d892ab1475996176a84c27e4592751d547524d66212d6de005c89f889b
|
| 3 |
+
size 53187
|