diff --git a/.github/workflows/docker-publish-sadtalker.yml b/.github/workflows/docker-publish-sadtalker.yml new file mode 100644 index 0000000..97d4fca --- /dev/null +++ b/.github/workflows/docker-publish-sadtalker.yml @@ -0,0 +1,65 @@ +# Adapted from +# https://github.com/actions/starter-workflows/ci/docker-publish.yml +# If using base images, don't forget to add READ access, eg. from a package settings page like: +# https://github.com/orgs/storytold/packages/container/docker-base-images-rust-ssl/settings/actions_access +name: Build SadTalker Docker Image +on: + push: + branches: + # NB: Default-branch doesn't work, despite Github's documentation. + #- $default-branch + - master +env: + IMAGE_NAME: sadtalker + +jobs: + # Push image to GitHub Packages. + # See also https://docs.docker.com/docker-hub/builds/ + push: + runs-on: ubuntu-latest + if: github.event_name == 'push' + permissions: + packages: write + contents: read + + steps: + - uses: actions/checkout@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + #username: ${{ github.repository_owner }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build image + run: cd animation/SadTalker/ && docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" + + - name: Push image to GitHub Container Registry + run: | + IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME + + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + + # Use Docker `latest` tag convention + [ "$VERSION" == "$default-branch" ] && VERSION=latest + + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + + docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION + + SHORT_SHA=$(echo ${GITHUB_SHA} | cut -c1-12) + + docker tag $IMAGE_NAME $IMAGE_ID:$SHORT_SHA + docker push $IMAGE_ID:$SHORT_SHA + diff --git a/animation/SadTalker/.dockerignore b/animation/SadTalker/.dockerignore new file mode 100644 index 0000000..7615ad3 --- /dev/null +++ b/animation/SadTalker/.dockerignore @@ -0,0 +1,12 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# NB(bt): Local testing +python/ +inputs/ +outputs/ + +# Garbage +*~ \ No newline at end of file diff --git a/animation/SadTalker/Dockerfile b/animation/SadTalker/Dockerfile new file mode 100644 index 0000000..504eaf6 --- /dev/null +++ b/animation/SadTalker/Dockerfile @@ -0,0 +1,47 @@ +# syntax=docker/dockerfile:1 + +#FROM nvidia/cuda:12.0.1-runtime-ubuntu22.04 # NB: Does this not work??? +FROM nvidia/cuda:11.8.0-runtime-ubuntu22.04 + +ENV DEBIAN_FRONTEND=noninteractive + +# NB: SadTalker obviously requires ffmpeg +# NB: rsync to monitor time it takes for files to sync in k8s initContainer. +# NB(bt,2023-05-04): Installing lsof, htop, ripgrep, and other debugging tools +# NB: I had to remove `nvidia-driver-515` because it broke CUDA / nvidia-smi +RUN apt-get update && apt-get install -y \ + build-essential \ + curl \ + ffmpeg \ + htop \ + libsndfile1 \ + lsof \ + python3-pip \ + python3.10 \ + python3.10-dev \ + python3.10-venv \ + ripgrep \ + rsync \ + vim \ + wget \ + --no-install-recommends \ + && apt-get clean autoclean && apt-get autoremove -y && rm -rf /var/lib/{apt,dpkg,cache,log}/ + +RUN mkdir /python_install + +WORKDIR /python_install + +COPY requirements.txt . + +# NB: Kubernetes will copy over the venv we create here. +RUN python3 -m venv python \ + && . python/bin/activate \ + && pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113 \ + && pip install -r requirements.txt + +# Model code is kept separate from the venv +RUN mkdir /model_code + +WORKDIR /model_code + +COPY . . diff --git a/animation/SadTalker/elonmusk.jpg b/animation/SadTalker/elonmusk.jpg new file mode 100644 index 0000000..ba19d62 Binary files /dev/null and b/animation/SadTalker/elonmusk.jpg differ diff --git a/animation/SadTalker/link.jpg b/animation/SadTalker/link.jpg new file mode 100644 index 0000000..318338b Binary files /dev/null and b/animation/SadTalker/link.jpg differ diff --git a/animation/SadTalker/link2.jpg b/animation/SadTalker/link2.jpg new file mode 100644 index 0000000..eeb18cb Binary files /dev/null and b/animation/SadTalker/link2.jpg differ diff --git a/animation/SadTalker/paul.wav b/animation/SadTalker/paul.wav new file mode 100644 index 0000000..89d2a09 Binary files /dev/null and b/animation/SadTalker/paul.wav differ diff --git a/animation/SadTalker/scripts/download_models.sh b/animation/SadTalker/scripts/download_models.sh old mode 100644 new mode 100755