Upload folder using huggingface_hub
Browse files- Dockerfile +17 -0
- __pycache__/app.cpython-313.pyc +0 -0
- app.py +67 -0
- requirements.txt +194 -0
- superkart_revenue_prediction_model_v1_0.joblib +3 -0
Dockerfile
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# FROM python:3.9-slim
|
2 |
+
FROM python:3.11-slim
|
3 |
+
|
4 |
+
# Set the working directory inside the container
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# Copy all files from the current directory to the container's working directory
|
8 |
+
COPY . .
|
9 |
+
|
10 |
+
# Install dependencies from the requirements file without using cache to reduce image size
|
11 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
12 |
+
|
13 |
+
# Define the command to start the application using Gunicorn with 4 worker processes
|
14 |
+
# - `-w 4`: Uses 4 worker processes for handling requests
|
15 |
+
# - `-b 0.0.0.0:7860`: Binds the server to port 7860 on all network interfaces
|
16 |
+
# - `app:app`: Runs the Flask app (assuming `app.py` contains the Flask instance named `app`)
|
17 |
+
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "app:app"]
|
__pycache__/app.cpython-313.pyc
ADDED
Binary file (2.5 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import joblib
|
2 |
+
import pandas as pd
|
3 |
+
from flask import Flask, request, jsonify
|
4 |
+
|
5 |
+
# Initialize Flask app with a name
|
6 |
+
app = Flask("SuperKart product sales revenue Prediction")
|
7 |
+
|
8 |
+
# Load the trained SuperKart sales revenue prediction model
|
9 |
+
model_superkart = joblib.load("superkart_revenue_prediction_model_v1_0.joblib")
|
10 |
+
|
11 |
+
# Define a route for the home page
|
12 |
+
@app.get('/')
|
13 |
+
def home():
|
14 |
+
return "Welcome to the SuperKart Revenue Prediction API, created by Vrundav Gamit"
|
15 |
+
|
16 |
+
# Define an endpoint to predict revenue for single data point
|
17 |
+
# POST endpoint
|
18 |
+
# v1 in the url is a industry practise for versioning of endpoint urls
|
19 |
+
# For example v1 urls can be used to testing, v2 urls can be used for validation testing
|
20 |
+
@app.post('/v1/predictrevenue')
|
21 |
+
# @app.route('/v1/predictrevenue', methods=['POST'])
|
22 |
+
def predict_revenue():
|
23 |
+
# Get JSON data from the request
|
24 |
+
sales_data = request.get_json()
|
25 |
+
|
26 |
+
# Extract relevant store and product features from the input data
|
27 |
+
payload = {
|
28 |
+
'Product_Weight': sales_data['Product_Weight'],
|
29 |
+
'Product_Allocated_Area': sales_data['Product_Allocated_Area'],
|
30 |
+
'Product_MRP': sales_data['Product_MRP'],
|
31 |
+
'Store_Size': sales_data['Store_Size'],
|
32 |
+
'Store_Location_City_Type': sales_data['Store_Location_City_Type'],
|
33 |
+
'Store_Type': sales_data['Store_Type'],
|
34 |
+
'Product_Sugar_Content': sales_data['Product_Sugar_Content'],
|
35 |
+
'Product_Type': sales_data['Product_Type']
|
36 |
+
}
|
37 |
+
|
38 |
+
# Convert the extracted data into a DataFrame
|
39 |
+
input_data = pd.DataFrame([payload])
|
40 |
+
|
41 |
+
# Make a sales revenue prediction using the trained model
|
42 |
+
prediction = model_superkart.predict(input_data).tolist()[0]
|
43 |
+
|
44 |
+
# Return the prediction as a JSON response
|
45 |
+
return jsonify({'Prediction': prediction})
|
46 |
+
|
47 |
+
# Define an endpoint to predict revenue for a batch of store and product data
|
48 |
+
@app.post('/v1/predictrevenuebatch')
|
49 |
+
def predict_revenue_batch():
|
50 |
+
# Get the uploaded CSV file from the request
|
51 |
+
file = request.files['file']
|
52 |
+
|
53 |
+
# Read the file into a DataFrame
|
54 |
+
input_data = pd.read_csv(file)
|
55 |
+
|
56 |
+
# Drop Product_Id from the input before performing a predict
|
57 |
+
# As Product_Id is not one of the input features of the model
|
58 |
+
predictions = model_superkart.predict(input_data.drop("Product_Id",axis=1)).tolist()
|
59 |
+
|
60 |
+
product_id_list = input_data.product_Id.values.tolist()
|
61 |
+
output_dict = dict(zip(product_id_list, predictions))
|
62 |
+
|
63 |
+
return output_dict
|
64 |
+
|
65 |
+
# Run the Flask app in debug mode
|
66 |
+
if __name__ == '__main__':
|
67 |
+
app.run(debug=True)
|
requirements.txt
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
absl-py==2.3.0
|
2 |
+
aiohappyeyeballs==2.6.1
|
3 |
+
aiohttp==3.12.0
|
4 |
+
aiosignal==1.3.2
|
5 |
+
altair==5.5.0
|
6 |
+
annotated-types==0.7.0
|
7 |
+
anyio==4.9.0
|
8 |
+
asgiref==3.8.1
|
9 |
+
asttokens==3.0.0
|
10 |
+
attrs==25.3.0
|
11 |
+
backoff==2.2.1
|
12 |
+
bcrypt==4.3.0
|
13 |
+
blinker==1.9.0
|
14 |
+
build==1.2.2.post1
|
15 |
+
cachetools==5.5.2
|
16 |
+
certifi==2025.4.26
|
17 |
+
charset-normalizer==3.4.2
|
18 |
+
chromadb==1.0.10
|
19 |
+
click==8.1.8
|
20 |
+
colorama==0.4.6
|
21 |
+
coloredlogs==15.0.1
|
22 |
+
comm==0.2.2
|
23 |
+
contourpy==1.3.2
|
24 |
+
cycler==0.12.1
|
25 |
+
dataclasses-json==0.6.7
|
26 |
+
debugpy==1.8.14
|
27 |
+
decorator==5.2.1
|
28 |
+
Deprecated==1.2.18
|
29 |
+
diskcache==5.6.3
|
30 |
+
distro==1.9.0
|
31 |
+
durationpy==0.10
|
32 |
+
executing==2.2.0
|
33 |
+
fastapi==0.115.9
|
34 |
+
filelock==3.18.0
|
35 |
+
Flask==3.1.1
|
36 |
+
flatbuffers==25.2.10
|
37 |
+
fonttools==4.58.2
|
38 |
+
frozenlist==1.6.0
|
39 |
+
fsspec==2025.5.1
|
40 |
+
gitdb==4.0.12
|
41 |
+
GitPython==3.1.44
|
42 |
+
google-auth==2.40.2
|
43 |
+
googleapis-common-protos==1.70.0
|
44 |
+
greenlet==3.2.2
|
45 |
+
grpcio==1.71.0
|
46 |
+
h11==0.16.0
|
47 |
+
h5py==3.14.0
|
48 |
+
httpcore==1.0.9
|
49 |
+
httptools==0.6.4
|
50 |
+
httpx==0.28.1
|
51 |
+
httpx-sse==0.4.0
|
52 |
+
huggingface-hub==0.32.0
|
53 |
+
humanfriendly==10.0
|
54 |
+
idna==3.10
|
55 |
+
importlib_metadata==8.6.1
|
56 |
+
importlib_resources==6.5.2
|
57 |
+
ipykernel==6.29.5
|
58 |
+
ipython==9.2.0
|
59 |
+
ipython_pygments_lexers==1.1.1
|
60 |
+
itsdangerous==2.2.0
|
61 |
+
jedi==0.19.2
|
62 |
+
Jinja2==3.1.6
|
63 |
+
joblib==1.5.1
|
64 |
+
jsonpatch==1.33
|
65 |
+
jsonpointer==3.0.0
|
66 |
+
jsonschema==4.23.0
|
67 |
+
jsonschema-specifications==2025.4.1
|
68 |
+
jupyter_client==8.6.3
|
69 |
+
jupyter_core==5.7.2
|
70 |
+
keras==3.10.0
|
71 |
+
kiwisolver==1.4.8
|
72 |
+
kubernetes==32.0.1
|
73 |
+
langchain==0.3.25
|
74 |
+
langchain-chroma==0.2.4
|
75 |
+
langchain-community==0.3.24
|
76 |
+
langchain-core==0.3.61
|
77 |
+
langchain-huggingface==0.2.0
|
78 |
+
langchain-text-splitters==0.3.8
|
79 |
+
langsmith==0.3.42
|
80 |
+
llama_cpp_python==0.1.85
|
81 |
+
markdown-it-py==3.0.0
|
82 |
+
MarkupSafe==3.0.2
|
83 |
+
marshmallow==3.26.1
|
84 |
+
matplotlib==3.10.3
|
85 |
+
matplotlib-inline==0.1.7
|
86 |
+
mdurl==0.1.2
|
87 |
+
ml_dtypes==0.5.1
|
88 |
+
mmh3==5.1.0
|
89 |
+
mpmath==1.3.0
|
90 |
+
multidict==6.4.4
|
91 |
+
mypy_extensions==1.1.0
|
92 |
+
namex==0.1.0
|
93 |
+
narwhals==1.46.0
|
94 |
+
nest-asyncio==1.6.0
|
95 |
+
networkx==3.4.2
|
96 |
+
numpy==2.3.0
|
97 |
+
oauthlib==3.2.2
|
98 |
+
onnxruntime==1.22.0
|
99 |
+
opencv-python==4.11.0.86
|
100 |
+
opentelemetry-api==1.33.1
|
101 |
+
opentelemetry-exporter-otlp-proto-common==1.33.1
|
102 |
+
opentelemetry-exporter-otlp-proto-grpc==1.33.1
|
103 |
+
opentelemetry-instrumentation==0.54b1
|
104 |
+
opentelemetry-instrumentation-asgi==0.54b1
|
105 |
+
opentelemetry-instrumentation-fastapi==0.54b1
|
106 |
+
opentelemetry-proto==1.33.1
|
107 |
+
opentelemetry-sdk==1.33.1
|
108 |
+
opentelemetry-semantic-conventions==0.54b1
|
109 |
+
opentelemetry-util-http==0.54b1
|
110 |
+
optree==0.16.0
|
111 |
+
orjson==3.10.18
|
112 |
+
overrides==7.7.0
|
113 |
+
packaging==24.2
|
114 |
+
pandas==2.2.3
|
115 |
+
parso==0.8.4
|
116 |
+
pillow==11.2.1
|
117 |
+
platformdirs==4.3.8
|
118 |
+
posthog==4.2.0
|
119 |
+
prompt_toolkit==3.0.51
|
120 |
+
propcache==0.3.1
|
121 |
+
protobuf==5.29.4
|
122 |
+
psutil==7.0.0
|
123 |
+
pure_eval==0.2.3
|
124 |
+
pyarrow==20.0.0
|
125 |
+
pyasn1==0.6.1
|
126 |
+
pyasn1_modules==0.4.2
|
127 |
+
pydantic==2.11.5
|
128 |
+
pydantic-settings==2.9.1
|
129 |
+
pydantic_core==2.33.2
|
130 |
+
pydeck==0.9.1
|
131 |
+
pyenv-win==3.1.1
|
132 |
+
Pygments==2.19.1
|
133 |
+
PyMuPDF==1.26.0
|
134 |
+
pyparsing==3.2.3
|
135 |
+
PyPika==0.48.9
|
136 |
+
pyproject_hooks==1.2.0
|
137 |
+
pyreadline3==3.5.4
|
138 |
+
python-dateutil==2.9.0.post0
|
139 |
+
python-dotenv==1.1.0
|
140 |
+
pytz==2025.2
|
141 |
+
pywin32==310
|
142 |
+
PyYAML==6.0.2
|
143 |
+
pyzmq==26.4.0
|
144 |
+
referencing==0.36.2
|
145 |
+
regex==2024.11.6
|
146 |
+
requests==2.32.3
|
147 |
+
requests-oauthlib==2.0.0
|
148 |
+
requests-toolbelt==1.0.0
|
149 |
+
rich==14.0.0
|
150 |
+
rpds-py==0.25.1
|
151 |
+
rsa==4.9.1
|
152 |
+
safetensors==0.5.3
|
153 |
+
scikit-learn==1.6.1
|
154 |
+
scipy==1.15.3
|
155 |
+
seaborn==0.13.2
|
156 |
+
sentence-transformers==4.1.0
|
157 |
+
setuptools==80.8.0
|
158 |
+
shellingham==1.5.4
|
159 |
+
six==1.17.0
|
160 |
+
smmap==5.0.2
|
161 |
+
sniffio==1.3.1
|
162 |
+
SQLAlchemy==2.0.41
|
163 |
+
stack-data==0.6.3
|
164 |
+
starlette==0.45.3
|
165 |
+
streamlit==1.46.1
|
166 |
+
sympy==1.14.0
|
167 |
+
tenacity==9.1.2
|
168 |
+
threadpoolctl==3.6.0
|
169 |
+
tiktoken==0.9.0
|
170 |
+
tokenizers==0.21.1
|
171 |
+
toml==0.10.2
|
172 |
+
torch==2.7.0
|
173 |
+
tornado==6.5.1
|
174 |
+
tqdm==4.67.1
|
175 |
+
traitlets==5.14.3
|
176 |
+
transformers==4.52.3
|
177 |
+
typer==0.15.4
|
178 |
+
typing-inspect==0.9.0
|
179 |
+
typing-inspection==0.4.1
|
180 |
+
typing_extensions==4.13.2
|
181 |
+
tzdata==2025.2
|
182 |
+
urllib3==2.4.0
|
183 |
+
uvicorn==0.34.2
|
184 |
+
watchdog==6.0.0
|
185 |
+
watchfiles==1.0.5
|
186 |
+
wcwidth==0.2.13
|
187 |
+
websocket-client==1.8.0
|
188 |
+
websockets==15.0.1
|
189 |
+
Werkzeug==3.1.3
|
190 |
+
wrapt==1.17.2
|
191 |
+
xgboost==3.0.2
|
192 |
+
yarl==1.20.0
|
193 |
+
zipp==3.21.0
|
194 |
+
zstandard==0.23.0
|
superkart_revenue_prediction_model_v1_0.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d15263fed5f116b2a3272497b48656c15c668caaef28a98839f9be4425a8a5ae
|
3 |
+
size 311137
|