File size: 1,743 Bytes
77902b8
65c9437
 
1cae688
65c9437
 
 
 
 
1827bea
77902b8
 
 
6a6e71d
77902b8
69a4674
1827bea
 
 
7686cad
71ba2e2
 
 
65c9437
6a6e71d
1827bea
 
 
 
 
 
 
 
 
 
 
1cae688
1827bea
 
1cae688
6a6e71d
 
65c9437
6a6e71d
 
65c9437
77902b8
65c9437
 
77902b8
65c9437
 
77902b8
65c9437
1827bea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Base image with PyTorch and CUDA for GPU support
FROM pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    wget \
    && rm -rf /var/lib/apt/lists/*

# Install Python packages including Hugging Face Transformers, TorchScript, Flask, and TensorFlow
RUN pip install --no-cache-dir \
    torch \
    torchvision \
    transformers \
    requests \
    Flask \
    Pillow \
    huggingface_hub \
    tensorflow

# Set Hugging Face cache to a guaranteed writable directory
ENV TRANSFORMERS_CACHE=/tmp/cache
RUN mkdir -p /tmp/cache

# Create directories for the models
RUN mkdir -p /models/movenet /models/motionbert

# Python script to download models using tensorflow_hub and huggingface_hub
RUN echo "import os\n\
import tensorflow_hub as hub\n\
\n\
# Download MoveNet model from TensorFlow Hub\n\
movenet_model = hub.load('https://tfhub.dev/google/movenet/singlepose/lightning/4')\n\
movenet_model_path = '/models/movenet/movenet_lightning'\n\
os.makedirs(movenet_model_path, exist_ok=True)\n\
movenet_model.save(movenet_model_path)\n\
\n\
# Download MotionBERT model and tokenizer using huggingface_hub\n\
from huggingface_hub import hf_hub_download\n\
from transformers import AutoModel, AutoTokenizer\n\
AutoModel.from_pretrained('walterzhu/MotionBERT').save_pretrained('/models/motionbert')\n\
AutoTokenizer.from_pretrained('walterzhu/MotionBERT').save_pretrained('/models/motionbert')" > download_models.py

# Run the script to download models
RUN python download_models.py

# Copy the inference script (app.py) into the container
COPY app.py /app/app.py

# Expose the default port for Flask
EXPOSE 7860

# Run the Flask app
CMD ["python", "/app/app.py"]