diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bcfeef5b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,67 @@ +ARG CUDA_VERSION=11.1 + +# onnxruntime-gpu requires cudnn +ARG CUDNN_VER=8 + +# See possible types: https://hub.docker.com/r/nvidia/cuda/tags?page=1&ordering=last_updated +ARG IMAGE_TYPE=runtime + +FROM nvidia/cuda:${CUDA_VERSION}-cudnn${CUDNN_VER}-${IMAGE_TYPE}-ubuntu20.04 AS builder + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt update && \ + apt install -y software-properties-common && \ + # the latest version of Git + add-apt-repository ppa:git-core/ppa && \ + apt update && \ + apt install -y --no-install-recommends \ + git ca-certificates wget unzip libgl1-mesa-glx \ + && \ + apt autoremove -y && \ + apt clean -y + +# Install Miniconda See possible versions: https://repo.anaconda.com/miniconda/ +ARG CONDA_VERSION=3-py38_4.9.2 + +ARG CONDA_DIR=/opt/conda + +ENV PATH=$CONDA_DIR/bin:$PATH + +RUN wget -q -O ./miniconda.sh http://repo.continuum.io/miniconda/Miniconda${CONDA_VERSION}-Linux-x86_64.sh \ + && sh ./miniconda.sh -bfp $CONDA_DIR \ + && rm ./miniconda.sh + +WORKDIR /home + +COPY ./environment.yml ./environment.yml + +RUN conda env update -n base --prune --file ./environment.yml && \ + conda clean -ayf && rm ./environment.yml + +RUN git clone --single-branch https://github.com/neuralchen/SimSwap.git && \ + cd ./SimSwap && \ + rm -rf .git && \ + ./download-weights.sh && \ + wget -P ./parsing_model/checkpoint https://github.com/neuralchen/SimSwap/releases/download/1.0/79999_iter.pth + + +FROM nvidia/cuda:${CUDA_VERSION}-cudnn${CUDNN_VER}-${IMAGE_TYPE}-ubuntu20.04 + +ARG CONDA_DIR=/opt/conda + +# Copy conda installation +COPY --from=builder /opt/conda $CONDA_DIR + +ENV PATH=$CONDA_DIR/bin:$PATH + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt update && \ + apt install -y --no-install-recommends libgl1-mesa-glx && \ + apt autoremove -y && \ + apt clean -y + +COPY --from=builder /home/SimSwap /home/SimSwap + +WORKDIR /home/SimSwap diff --git a/download-weights.sh b/download-weights.sh index 54e6ea5c..9aba1396 100755 --- a/download-weights.sh +++ b/download-weights.sh @@ -7,3 +7,5 @@ wget --no-check-certificate "https://sh23tw.dm.files.1drv.com/y4mmGiIkNVigkSwOKD mkdir -p insightface_func/models unzip ./antelope.zip -d ./insightface_func/models/ rm antelope.zip +wget -P ./parsing_model/checkpoint https://github.com/neuralchen/SimSwap/releases/download/1.0/79999_iter.pth + diff --git a/environment.yml b/environment.yml new file mode 100644 index 00000000..f0a7f9fe --- /dev/null +++ b/environment.yml @@ -0,0 +1,16 @@ +channels: + - defaults + - conda-forge + - pytorch +dependencies: + - numpy=1.20.2 + - opencv=4.5.0 + - pillow=8.2.0 + - moviepy + - pip=21.2.2 + - pip: + - insightface==0.2.1 + - onnxruntime-gpu==1.8.1 + - -f https://download.pytorch.org/whl/torch_stable.html + - torch==1.9.0+cu111 + - torchvision==0.10.0+cu111