JulianPhillips commited on
Commit
1827bea
·
verified ·
1 Parent(s): 1cae688

Update Dockerfile

Browse files
Files changed (1) hide show
  1. 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 Flask
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/sapiens_pose /models/motionbert
25
-
26
- # Python script to download models
27
- RUN echo "import requests\n\
28
- url = 'https://huggingface.co/facebook/sapiens-pose-1b-torchscript/resolve/main/model.pt'\n\
29
- response = requests.get(url)\n\
30
- if response.status_code == 200:\n\
31
- with open('/models/sapiens_pose/model.pt', 'wb') as f:\n\
32
- f.write(response.content)\n\
33
- else:\n\
34
- raise Exception(f'Failed to download model: {response.status_code}')\n\
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
+