Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +18 -13
Dockerfile
CHANGED
@@ -7,32 +7,36 @@ RUN apt-get update && apt-get install -y \
|
|
7 |
wget \
|
8 |
&& rm -rf /var/lib/apt/lists/*
|
9 |
|
10 |
-
# Install Python packages including Hugging Face Transformers, TorchScript, and
|
11 |
RUN pip install --no-cache-dir \
|
12 |
torch \
|
13 |
torchvision \
|
14 |
transformers \
|
15 |
requests \
|
16 |
Flask \
|
17 |
-
Pillow
|
|
|
|
|
18 |
|
19 |
# Set Hugging Face cache to a guaranteed writable directory
|
20 |
ENV TRANSFORMERS_CACHE=/tmp/cache
|
21 |
RUN mkdir -p /tmp/cache
|
22 |
|
23 |
# Create directories for the models
|
24 |
-
RUN mkdir -p /models/
|
25 |
-
|
26 |
-
# Python script to download models
|
27 |
-
RUN echo "import
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
\n\
|
|
|
|
|
36 |
from transformers import AutoModel, AutoTokenizer\n\
|
37 |
AutoModel.from_pretrained('walterzhu/MotionBERT').save_pretrained('/models/motionbert')\n\
|
38 |
AutoTokenizer.from_pretrained('walterzhu/MotionBERT').save_pretrained('/models/motionbert')" > download_models.py
|
@@ -48,3 +52,4 @@ EXPOSE 7860
|
|
48 |
|
49 |
# Run the Flask app
|
50 |
CMD ["python", "/app/app.py"]
|
|
|
|
7 |
wget \
|
8 |
&& rm -rf /var/lib/apt/lists/*
|
9 |
|
10 |
+
# Install Python packages including Hugging Face Transformers, TorchScript, Flask, and TensorFlow
|
11 |
RUN pip install --no-cache-dir \
|
12 |
torch \
|
13 |
torchvision \
|
14 |
transformers \
|
15 |
requests \
|
16 |
Flask \
|
17 |
+
Pillow \
|
18 |
+
huggingface_hub \
|
19 |
+
tensorflow
|
20 |
|
21 |
# Set Hugging Face cache to a guaranteed writable directory
|
22 |
ENV TRANSFORMERS_CACHE=/tmp/cache
|
23 |
RUN mkdir -p /tmp/cache
|
24 |
|
25 |
# Create directories for the models
|
26 |
+
RUN mkdir -p /models/movenet /models/motionbert
|
27 |
+
|
28 |
+
# Python script to download models using tensorflow_hub and huggingface_hub
|
29 |
+
RUN echo "import os\n\
|
30 |
+
import tensorflow_hub as hub\n\
|
31 |
+
\n\
|
32 |
+
# Download MoveNet model from TensorFlow Hub\n\
|
33 |
+
movenet_model = hub.load('https://tfhub.dev/google/movenet/singlepose/lightning/4')\n\
|
34 |
+
movenet_model_path = '/models/movenet/movenet_lightning'\n\
|
35 |
+
os.makedirs(movenet_model_path, exist_ok=True)\n\
|
36 |
+
movenet_model.save(movenet_model_path)\n\
|
37 |
\n\
|
38 |
+
# Download MotionBERT model and tokenizer using huggingface_hub\n\
|
39 |
+
from huggingface_hub import hf_hub_download\n\
|
40 |
from transformers import AutoModel, AutoTokenizer\n\
|
41 |
AutoModel.from_pretrained('walterzhu/MotionBERT').save_pretrained('/models/motionbert')\n\
|
42 |
AutoTokenizer.from_pretrained('walterzhu/MotionBERT').save_pretrained('/models/motionbert')" > download_models.py
|
|
|
52 |
|
53 |
# Run the Flask app
|
54 |
CMD ["python", "/app/app.py"]
|
55 |
+
|