Spaces:
Runtime error
Runtime error
carolanderson
commited on
Commit
•
0362c93
1
Parent(s):
f28a148
cache SentenceTransformer model and serve app with gunicorn
Browse files- Dockerfile +4 -1
- cache_model.py +11 -0
- requirements.txt +1 -0
- run_app.sh +1 -1
Dockerfile
CHANGED
@@ -34,9 +34,12 @@ USER user
|
|
34 |
ENV HOST=0.0.0.0
|
35 |
EXPOSE 5001
|
36 |
|
|
|
37 |
RUN gdown 1In9qAzV5t--rMmEH2R5miWpZ4IQStgFu \
|
38 |
&& unzip data.zip \
|
39 |
-
&& rm data.zip
|
|
|
|
|
40 |
|
41 |
ENTRYPOINT bash run_app.sh
|
42 |
|
|
|
34 |
ENV HOST=0.0.0.0
|
35 |
EXPOSE 5001
|
36 |
|
37 |
+
# Download data from Google Drive
|
38 |
RUN gdown 1In9qAzV5t--rMmEH2R5miWpZ4IQStgFu \
|
39 |
&& unzip data.zip \
|
40 |
+
&& rm data.zip \
|
41 |
+
# Download Sentence Transformers model
|
42 |
+
&& python3 cache_model.py
|
43 |
|
44 |
ENTRYPOINT bash run_app.sh
|
45 |
|
cache_model.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
""""
|
2 |
+
Intented for use by Dockerfile; downloads pytorch model and caches it
|
3 |
+
in the image, so the download doesn't have to run when app starts.
|
4 |
+
"""
|
5 |
+
|
6 |
+
from sentence_transformers import SentenceTransformer
|
7 |
+
|
8 |
+
model_name = "paraphrase-MiniLM-L6-v2"
|
9 |
+
model = SentenceTransformer(model_name)
|
10 |
+
|
11 |
+
|
requirements.txt
CHANGED
@@ -4,6 +4,7 @@ altair_transform==0.2.0
|
|
4 |
bertopic==0.11.0
|
5 |
Flask==2.2.2
|
6 |
gdown==4.7.1
|
|
|
7 |
matplotlib==3.5.3
|
8 |
mne==1.1.1
|
9 |
numpy==1.22.4
|
|
|
4 |
bertopic==0.11.0
|
5 |
Flask==2.2.2
|
6 |
gdown==4.7.1
|
7 |
+
gunicorn==21.2.0
|
8 |
matplotlib==3.5.3
|
9 |
mne==1.1.1
|
10 |
numpy==1.22.4
|
run_app.sh
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
cd indie_label_svelte
|
4 |
npm start &
|
5 |
cd ..
|
6 |
-
|
7 |
|
8 |
|
9 |
|
|
|
3 |
cd indie_label_svelte
|
4 |
npm start &
|
5 |
cd ..
|
6 |
+
gunicorn -b 0.0.0.0:5001 -w 4 --limit-request-line 0 server:app
|
7 |
|
8 |
|
9 |
|