commit 8eb71d55049eddcf79b890506e1332f00edc956f Author: henryruhs Date: Sun Sep 10 20:48:16 2023 +0200 Initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b88a39d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +indent_size = 4 +indent_style = tab +trim_trailing_whitespace = true diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..718d8a6 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: henryruhs +custom: https://paypal.me/henryruhs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..830f12d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: ci + +on: [ push, pull_request ] + +jobs: + test: + name: ${{ matrix.config.image-name }} + runs-on: ubuntu-latest + strategy: + matrix: + config: + - { docker-file: 'Dockerfile.cpu', image-name: 'facefusion-cpu' } + steps: + - name: Checkout + uses: actions/checkout@v2 + - run: docker build -f ${{ matrix.config.docker-file }} -t ${{ matrix.config.image-name }} . + - run: docker run -d ${{ matrix.config.image-name }} + - run: docker ps | grep -q ${{ matrix.config.image-name }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66381e3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.assets +.idea +.vscode diff --git a/Dockerfile.cpu b/Dockerfile.cpu new file mode 100644 index 0000000..be3bd31 --- /dev/null +++ b/Dockerfile.cpu @@ -0,0 +1,12 @@ +FROM python:3.10 + +ARG FACEFUSION_VERSION=1.1.0 + +ENV GRADIO_SERVER_NAME=0.0.0.0 +WORKDIR /facefusion + +RUN apt-get update +RUN apt-get install ffmpeg -y + +RUN git clone https://github.com/facefusion/facefusion.git --branch $FACEFUSION_VERSION --single-branch . +RUN pip install -r requirements.txt diff --git a/Dockerfile.cuda b/Dockerfile.cuda new file mode 100644 index 0000000..05c32a0 --- /dev/null +++ b/Dockerfile.cuda @@ -0,0 +1,18 @@ +FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 + +ARG FACEFUSION_VERSION=1.1.0 + +ENV GRADIO_SERVER_NAME=0.0.0.0 +WORKDIR /facefusion + +RUN apt-get update +RUN apt-get install python3.10 -y +RUN apt-get install python-is-python3 -y +RUN apt-get install pip -y +RUN apt-get install git -y +RUN apt-get install ffmpeg -y + +RUN git clone https://github.com/facefusion/facefusion.git --branch $FACEFUSION_VERSION --single-branch . +RUN pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu118 +RUN pip uninstall onnxruntime -y +RUN pip install onnxruntime-gpu==1.15.1 diff --git a/Dockerfile.rocm b/Dockerfile.rocm new file mode 100644 index 0000000..bdbda5b --- /dev/null +++ b/Dockerfile.rocm @@ -0,0 +1,33 @@ +FROM rocm/dev-ubuntu-22.04:5.4.2-complete + +ARG FACEFUSION_VERSION=1.1.0 +ARG ONNXRUNTIME_VERSION=1.15.0 + +ENV GRADIO_SERVER_NAME=0.0.0.0 + +RUN apt-get update +RUN apt-get install python3-dev -y +RUN apt-get install git -y +RUN apt-get install ffmpeg -y + +RUN pip install numpy +RUN pip install flake8 +RUN pip install packaging +RUN pip install wheel + +RUN curl -L https://github.com/Kitware/CMake/releases/download/v3.27.4/cmake-3.27.4-linux-x86_64.tar.gz | tar xz -C /opt +RUN sudo ln -sf /opt/cmake-3.27.4-linux-x86_64/bin/cmake /usr/bin/cmake +RUN sudo ln -sf /opt/cmake-3.27.4-linux-x86_64/bin/ctest /usr/bin/ctest + +WORKDIR /onnxruntime + +RUN git clone https://github.com/Microsoft/onnxruntime --branch v$ONNXRUNTIME_VERSION --single-branch . +RUN chmod +x /onnxruntime/tools/ci_build/build.py +RUN /onnxruntime/tools/ci_build/build.py --allow_running_as_root --build_dir build --config Release --build_wheel --update --build --parallel --skip_tests --cmake_extra_defines ONNXRUNTIME_VERSION=$ONNXRUNTIME_VERSION --use_rocm --rocm_home /opt/rocm + +WORKDIR /facefusion + +RUN git clone https://github.com/facefusion/facefusion.git --branch $FACEFUSION_VERSION --single-branch . +RUN pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/rocm5.4.2 +RUN pip uninstall onnxruntime -y +RUN pip install /onnxruntime/build/Release/dist/*.whl diff --git a/README.md b/README.md new file mode 100644 index 0000000..e9c6421 --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +FaceFusion Docker +================= + +> Next generation face swapper and enhancer. + +[![Build Status](https://img.shields.io/github/actions/workflow/status/facefusion/facefusion-docker/ci.yml.svg?branch=master)](https://github.com/facefusion/facefusion-docker/actions?query=workflow:ci) +![License](https://img.shields.io/badge/license-MIT-green) + + +Installation +------------ + +Clone the repository: + +``` +git clone https://github.com/facefusion/facefusion-docker.git +``` + +Run the `CPU` container: + +``` +docker-compose -f docker-compose.cpu.yml up +``` + +Run the `CUDA` container: + +``` +docker-compose -f docker-compose.cuda.yml up +``` + +Run the `ROCM` container: + +``` +docker-compose -f docker-compose.rocm.yml up +``` + + +Usage +----- + +Browse the `CPU` container: + +``` +http://localhost:7870 +``` + +Browse the `CUDA` container: + +``` +http://localhost:7880 +``` + +Browse the `ROCM` container: + +``` +http://localhost:7890 +``` + + +Documentation +------------- + +Read the [documentation](https://docs.facefusion.io) for a deep dive. diff --git a/docker-compose.cpu.yml b/docker-compose.cpu.yml new file mode 100644 index 0000000..d8c166b --- /dev/null +++ b/docker-compose.cpu.yml @@ -0,0 +1,10 @@ +services: + facefusion-cpu: + build: + context: . + dockerfile: Dockerfile.cpu + command: [ 'python', 'run.py' ] + volumes: + - .assets:/facefusion/.assets + ports: + - 7870:7860 diff --git a/docker-compose.cuda.yml b/docker-compose.cuda.yml new file mode 100644 index 0000000..d429325 --- /dev/null +++ b/docker-compose.cuda.yml @@ -0,0 +1,16 @@ +services: + facefusion-cuda: + build: + context: . + dockerfile: Dockerfile.cuda + command: [ 'python', 'run.py', '--execution-providers', 'cuda' ] + volumes: + - .assets:/facefusion/.assets + ports: + - 7880:7860 + deploy: + resources: + reservations: + devices: + - driver: nvidia + capabilities: [ gpu, video ] diff --git a/docker-compose.rocm.yml b/docker-compose.rocm.yml new file mode 100644 index 0000000..49b6223 --- /dev/null +++ b/docker-compose.rocm.yml @@ -0,0 +1,16 @@ +services: + facefusion-rocm: + build: + context: . + dockerfile: Dockerfile.rocm + command: [ 'python', 'run.py', '--execution-providers', 'rocm' ] + volumes: + - .assets:/facefusion/.assets + ports: + - 7890:7860 + deploy: + resources: + reservations: + devices: + - driver: rocm + capabilities: [ gpu, video ]