File size: 4,589 Bytes
b904635
88104f4
b904635
d241830
7e03200
 
d241830
8cf364e
 
 
d79a11e
b904635
 
976b6b6
 
f21f318
654ba65
b904635
 
 
 
 
 
 
d79a11e
b904635
5fa173d
d79a11e
198aff7
 
b904635
d79a11e
 
 
 
 
b904635
d79a11e
b904635
 
 
 
 
 
 
d79a11e
88104f4
b904635
 
055cc07
d44b9d2
b904635
 
 
1730205
 
 
 
 
 
 
 
 
 
 
b904635
 
1730205
d79a11e
 
 
 
 
 
b904635
 
d79a11e
 
b904635
 
e0efb4c
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Use an official PyTorch image with CUDA support as the base image
FROM pytorch/pytorch:2.0.0-cuda11.7-cudnn8-devel

# Add NVIDIA CUDA GPG key
# Add NVIDIA CUDA GPG key using a different key server
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key A4B469963BF863CC

# Install Git and system libraries required for OpenGL without interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Install Git, OpenGL libraries, and libglib2.0
RUN apt-get update && apt-get install -y git libgl1-mesa-glx libglib2.0-0

RUN apt-get update && apt-get install -y ninja-build

# Install necessary dependencies, including CMake, a C++ compiler, and others
RUN apt-get update && apt-get install -y unzip ffmpeg cmake g++ build-essential aria2

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user

# Switch to the "user" user
USER user

# Set environment variables
ENV HOME=/home/user \
    CUDA_HOME=/usr/local/cuda \
    PATH=/home/user/.local/bin:$PATH \
    LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} \
    LIBRARY_PATH=${CUDA_HOME}/lib64/stubs:${LIBRARY_PATH} \
    PYTHONPATH=$HOME/app \
    PYTHONUNBUFFERED=1 \
    GRADIO_ALLOW_FLAGGING=never \
    GRADIO_NUM_PORTS=1 \
    GRADIO_SERVER_NAME=0.0.0.0 \
    GRADIO_THEME=huggingface \
    GRADIO_SHARE=False \
    SYSTEM=spaces

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Clone your repository or add your code to the container
RUN git clone -b main https://github.com/fffiloni/video-retalking $HOME/app

# Install specific versions of PyTorch and TorchVision
RUN pip install torch==2.0.0+cu117 torchvision==0.15.0+cu117 -f https://download.pytorch.org/whl/torch_stable.html

# Install dependencies
#COPY requirements.txt $HOME/app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt gradio==5.4.0 moviepy

# Download checkpoint files using aria2
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/30_net_gen.pth -d $HOME/app/checkpoints -o 30_net_gen.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/BFM.zip -d $HOME/app/checkpoints -o BFM.zip
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/DNet.pt -d $HOME/app/checkpoints -o DNet.pt
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/ENet.pth -d $HOME/app/checkpoints -o ENet.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/GFPGANv1.3.pth -d $HOME/app/checkpoints -o GFPGANv1.3.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/GPEN-BFR-512.pth -d $HOME/app/checkpoints -o GPEN-BFR-512.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/LNet.pth -d $HOME/app/checkpoints -o LNet.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/ParseNet-latest.pth -d $HOME/app/checkpoints -o ParseNet-latest.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/RetinaFace-R50.pth -d $HOME/app/checkpoints -o RetinaFace-R50.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/expression.mat -d $HOME/app/checkpoints -o expression.mat
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/face3d_pretrain_epoch_20.pth -d $HOME/app/checkpoints -o face3d_pretrain_epoch_20.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/video-retalking/resolve/main/shape_predictor_68_face_landmarks.dat -d $HOME/app/checkpoints -o shape_predictor_68_face_landmarks.dat
RUN unzip -d $HOME/app/checkpoints/BFM $HOME/app/checkpoints/BFM.zip


# Ensure the compiled CUDA code can be found
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}

# Update package lists and install other dependencies as needed
# Ensure that CUDA components are correctly installed and configured
# Install any other required packages

# Set the environment variable to specify the GPU device
ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
ENV CUDA_VISIBLE_DEVICES=0

# Run your app.py script
CMD ["python", "app.py"]