From be70ea702ad22ebda383ad6813ee606f424499f5 Mon Sep 17 00:00:00 2001 From: Oleksandr Chychkan Date: Thu, 11 Nov 2021 13:48:49 -0800 Subject: [PATCH 1/8] Create stale-issues.yml --- .github/workflows/stale-issues.yml | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/stale-issues.yml diff --git a/.github/workflows/stale-issues.yml b/.github/workflows/stale-issues.yml new file mode 100644 index 0000000..b3d84fd --- /dev/null +++ b/.github/workflows/stale-issues.yml @@ -0,0 +1,31 @@ +# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. +# +# You can adjust the behavior by modifying this file. +# For more information, see: +# https://github.com/actions/stale +name: Mark stale issues and pull requests + +on: + schedule: + - cron: '45 14 * * *' + +jobs: + stale: + + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + + steps: + - uses: actions/stale@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + days-before-stale: -1 + days-before-issue-stale: 30 + days-before-close: -1 + days-before-issue-close: 45 + stale-issue-message: 'The issue is tagged as "stale issue" due to no activity in 30 days. If there is no activity for 15 more days, the issue will be closed.' + stale-issue-label: 'stale issue' + close-issue-message: 'Closing this issue due to no activity in last 45 days' + From 889af19a8dcedee7b926121542fc11368f9aa8b8 Mon Sep 17 00:00:00 2001 From: Oleksandr Chychkan Date: Thu, 11 Nov 2021 14:49:13 -0800 Subject: [PATCH 2/8] Add numexpr dependency (#54) --- requirements.txt | 1 + requirements_3.6.txt | 1 + requirements_3.9.txt | 1 + 3 files changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 1b6c48a..379bd21 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,3 +9,4 @@ Pillow==8.4.0 scikit-image==0.18.3 h5py==3.1.0 PyQt5==5.15.4 +numexpr==2.7.3 diff --git a/requirements_3.6.txt b/requirements_3.6.txt index d4a7650..f1c7201 100644 --- a/requirements_3.6.txt +++ b/requirements_3.6.txt @@ -9,3 +9,4 @@ Pillow==8.4.0 scikit-image==0.17.2 h5py==3.1.0 PyQt5==5.15.4 +numexpr==2.7.3 diff --git a/requirements_3.9.txt b/requirements_3.9.txt index 0e5beb3..b356b27 100644 --- a/requirements_3.9.txt +++ b/requirements_3.9.txt @@ -9,3 +9,4 @@ Pillow==8.4.0 scikit-image==0.18.3 h5py==3.1.0 PyQt5==5.15.4 +numexpr==2.7.3 From 9bd56f367635a48cca43266a2cb11bf39fbaddc6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Nov 2021 15:17:33 -0800 Subject: [PATCH 3/8] Bump tensorflow from 2.6.0 to 2.7.0 (#53) Bumps [tensorflow](https://github.com/tensorflow/tensorflow) from 2.6.0 to 2.7.0. - [Release notes](https://github.com/tensorflow/tensorflow/releases) - [Changelog](https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md) - [Commits](https://github.com/tensorflow/tensorflow/compare/v2.6.0...v2.7.0) --- updated-dependencies: - dependency-name: tensorflow dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- requirements_3.6.txt | 2 +- requirements_3.9.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 379bd21..8538b90 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ numpy==1.19.5 opencv-contrib-python-headless==4.1.2.30 scipy==1.7.1 -tensorflow==2.6.0 +tensorflow==2.6.1 colorama==0.4.4 tqdm==4.62.3 ffmpeg-python==0.2.0 diff --git a/requirements_3.6.txt b/requirements_3.6.txt index f1c7201..b911a9b 100644 --- a/requirements_3.6.txt +++ b/requirements_3.6.txt @@ -1,7 +1,7 @@ numpy==1.19.2 opencv-contrib-python-headless==4.1.2.30 scipy==1.5.4 -tensorflow==2.6.0 +tensorflow==2.6.1 colorama==0.4.4 tqdm==4.62.3 ffmpeg-python==0.2.0 diff --git a/requirements_3.9.txt b/requirements_3.9.txt index b356b27..9e88bfb 100644 --- a/requirements_3.9.txt +++ b/requirements_3.9.txt @@ -1,7 +1,7 @@ numpy==1.19.5 opencv-contrib-python-headless==4.5.1.48 scipy==1.7.1 -tensorflow==2.6.0 +tensorflow==2.6.1 colorama==0.4.4 tqdm==4.62.3 ffmpeg-python==0.2.0 From 00c38c0bbc6b38dd505ed735f2574460b5861f82 Mon Sep 17 00:00:00 2001 From: Oleksandr Chychkan Date: Thu, 11 Nov 2021 15:49:31 -0800 Subject: [PATCH 4/8] Bump scipy to 1.7.2 for Python 3.7+ (#55) --- requirements.txt | 2 +- requirements_3.9.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8538b90..fbe1bc2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ numpy==1.19.5 opencv-contrib-python-headless==4.1.2.30 -scipy==1.7.1 +scipy==1.7.2 tensorflow==2.6.1 colorama==0.4.4 tqdm==4.62.3 diff --git a/requirements_3.9.txt b/requirements_3.9.txt index 9e88bfb..a6a68f7 100644 --- a/requirements_3.9.txt +++ b/requirements_3.9.txt @@ -1,6 +1,6 @@ numpy==1.19.5 opencv-contrib-python-headless==4.5.1.48 -scipy==1.7.1 +scipy==1.7.2 tensorflow==2.6.1 colorama==0.4.4 tqdm==4.62.3 From cb5dbb53ecfab4a278db3efdbb0610fa92aea1ac Mon Sep 17 00:00:00 2001 From: Oleksandr Chychkan Date: Fri, 12 Nov 2021 14:18:19 -0800 Subject: [PATCH 5/8] Bump tensorflow to 2.7.0 for Python 3.7+ (#58) --- requirements.txt | 2 +- requirements_3.9.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index fbe1bc2..65e8c6f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ numpy==1.19.5 opencv-contrib-python-headless==4.1.2.30 scipy==1.7.2 -tensorflow==2.6.1 +tensorflow==2.7.0 colorama==0.4.4 tqdm==4.62.3 ffmpeg-python==0.2.0 diff --git a/requirements_3.9.txt b/requirements_3.9.txt index a6a68f7..98136a3 100644 --- a/requirements_3.9.txt +++ b/requirements_3.9.txt @@ -1,7 +1,7 @@ numpy==1.19.5 opencv-contrib-python-headless==4.5.1.48 scipy==1.7.2 -tensorflow==2.6.1 +tensorflow==2.7.0 colorama==0.4.4 tqdm==4.62.3 ffmpeg-python==0.2.0 From cff388ea89e99137496d27e1d489aafee6e2562f Mon Sep 17 00:00:00 2001 From: Oleksandr Chychkan Date: Fri, 12 Nov 2021 14:43:34 -0800 Subject: [PATCH 6/8] Bump numpy to 1.21.4 for Python 3.7+ (#59) --- requirements.txt | 2 +- requirements_3.9.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 65e8c6f..a06a1e0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy==1.19.5 +numpy==1.21.4 opencv-contrib-python-headless==4.1.2.30 scipy==1.7.2 tensorflow==2.7.0 diff --git a/requirements_3.9.txt b/requirements_3.9.txt index 98136a3..e10d38f 100644 --- a/requirements_3.9.txt +++ b/requirements_3.9.txt @@ -1,4 +1,4 @@ -numpy==1.19.5 +numpy==1.21.4 opencv-contrib-python-headless==4.5.1.48 scipy==1.7.2 tensorflow==2.7.0 From a3ab8d8b632a9cf0ffa28a593c0a6e45c76e90ce Mon Sep 17 00:00:00 2001 From: Alexander Canton <1@alexcanton.com> Date: Wed, 23 Feb 2022 13:41:21 +1000 Subject: [PATCH 7/8] Add support for Apple M1 laptops (#71) * Add support for Apple M1 laptops * Pre-install numpy * Use forked DeepFaceLab with minor fixes * Use --no-single-branch when cloning DFL * Minor improvements * Minor fixes to 0_setup.sh * Update versions * Update README Co-authored-by: Oleksandr Chychkan --- README.md | 7 ++++++ requirements_3.9_arm64.txt | 13 +++++++++++ scripts/0_setup.sh | 45 +++++++++++++++++++++++++++++++++++--- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 requirements_3.9_arm64.txt diff --git a/README.md b/README.md index e6a94b7..bfde164 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ This project provides scripts inspired by [DeepFaceLab_Linux](https://github.com You'll need `git`, `ffmpeg`, `python3` and python module `virtualenv` available to be able to execute these scripts. The scripts will create a virtual env sandbox and will install all necessary dependencies there, so your main installation of `python3` will be left intact. +## NOTE: Apple M1 chip + +Currently there's limited support for Apple M1 laptops. You can do model training, but the XSeg editor currently does not work (the DeepFaceLab codebase is not compatible with PyQt6). + ## Setup **Tools** @@ -14,6 +18,9 @@ Make sure you have installed: - [Python 3](https://www.python.org/) (check with `python3 --version`) - [Virtualenv](https://github.com/pypa/virtualenv) (check with `virtualenv --version`) +For **Apple M1** laptops you also need [hdf5](https://formulae.brew.sh/formula/hdf5) lib installed. +Check if you have it with `brew ls --versions hdf5`. Install it with `brew install hdf5`. + **Clone and setup** 1. Clone this repository (`git clone https://github.com/chychkan/DeepFaceLab_MacOS.git`) diff --git a/requirements_3.9_arm64.txt b/requirements_3.9_arm64.txt new file mode 100644 index 0000000..c63501c --- /dev/null +++ b/requirements_3.9_arm64.txt @@ -0,0 +1,13 @@ +numpy==1.21.4 +opencv-python==4.5.5.62 +numexpr==2.8.1 +h5py==3.1.0 +tqdm==4.62.3 +colorama==0.4.4 +cython==0.29.26 +ffmpeg-python==0.2.0 +Pillow==8.4.0 +scikit-image==0.19.1 +scipy==1.8.0 +tensorflow-macos==2.7.0 +PyQt6==6.2.3 diff --git a/scripts/0_setup.sh b/scripts/0_setup.sh index 1908632..54b5d31 100755 --- a/scripts/0_setup.sh +++ b/scripts/0_setup.sh @@ -6,9 +6,19 @@ set -e mkdir -p .dfl mkdir -p workspace +is_arm64() { + [ "$(uname -m)" == "arm64" ] +} + +is_arm64 && echo "Running on Apple M1 chip" + if [ ! -d .dfl/DeepFaceLab ]; then echo "Cloning DeepFaceLab" - git clone --depth 1 "https://github.com/iperov/DeepFaceLab.git" .dfl/DeepFaceLab + git clone --no-single-branch --depth 1 "https://github.com/chychkan/DeepFaceLab.git" .dfl/DeepFaceLab + + if is_arm64; then + (cd .dfl/DeepFaceLab; git checkout support-arm64) + fi fi if [ ! -d .dfl/env ]; then @@ -17,14 +27,43 @@ fi source .dfl/env/bin/activate +python -m pip install --upgrade pip + version=$(python -V | cut -f 2 -d ' ' | cut -f 1,2 -d .) reqs_file='requirements.txt' +version_suffix='' if [[ ! -z "$version" && -f "requirements_$version.txt" ]]; then - reqs_file="requirements_$version.txt" + version_suffix="_$version" fi +architecture_suffix='' +if is_arm64 && [ -f "requirements${version_suffix}_arm64.txt" ]; then + architecture_suffix="_arm64" +fi + +reqs_file="requirements${version_suffix}${architecture_suffix}.txt" + echo "Using $reqs_file for $(python -V)" -pip install -r $reqs_file + +if is_arm64; then + if [[ -z "$(brew ls --versions hdf5)" ]]; then + echo "ERROR: HDF5 needs to be installed to run DeepFaceLab on M1 chip." + echo "You can install it with 'brew install hdf5'. For more details, see https://formulae.brew.sh/formula/hdf5" + echo "Once it is installed, run ./scripts/0_setup.sh again" + exit 1 + fi + + cython_pkg="$(cat $reqs_file | grep -E 'cython==.+')" + pip --no-cache-dir install "$cython_pkg" + + numpy_pkg="$(cat $reqs_file | grep -E 'numpy==.+')" + pip install "$numpy_pkg" + + h5py_pkg="$(cat $reqs_file | grep -E 'h5py==.+')" + HDF5_DIR="$(brew --prefix hdf5)" pip --no-cache-dir install --no-build-isolation "$h5py_pkg" +fi + +pip --no-cache-dir install -r $reqs_file echo "Done." From a1c6ebd2c69049b7c00a26f5776c1860a7461282 Mon Sep 17 00:00:00 2001 From: Oleksandr Chychkan Date: Tue, 22 Feb 2022 20:51:26 -0800 Subject: [PATCH 8/8] Add missing XSeg scripts (#76) --- scripts/5_XSeg_data_dst_mask_edit.sh | 6 ++++++ scripts/5_XSeg_data_dst_mask_fetch.sh | 6 ++++++ scripts/5_XSeg_data_dst_mask_remove.sh | 6 ++++++ scripts/5_XSeg_data_dst_trained_mask_apply.sh | 7 +++++++ scripts/5_XSeg_data_dst_trained_mask_remove.sh | 6 ++++++ scripts/5_XSeg_data_src_mask_edit.sh | 6 ++++++ scripts/5_XSeg_data_src_mask_fetch.sh | 6 ++++++ scripts/5_XSeg_data_src_mask_remove.sh | 6 ++++++ scripts/5_XSeg_data_src_trained_mask_apply.sh | 7 +++++++ scripts/5_XSeg_data_src_trained_mask_remove.sh | 6 ++++++ scripts/5_XSeg_train.sh | 9 +++++++++ 11 files changed, 71 insertions(+) create mode 100755 scripts/5_XSeg_data_dst_mask_edit.sh create mode 100755 scripts/5_XSeg_data_dst_mask_fetch.sh create mode 100755 scripts/5_XSeg_data_dst_mask_remove.sh create mode 100755 scripts/5_XSeg_data_dst_trained_mask_apply.sh create mode 100755 scripts/5_XSeg_data_dst_trained_mask_remove.sh create mode 100755 scripts/5_XSeg_data_src_mask_edit.sh create mode 100755 scripts/5_XSeg_data_src_mask_fetch.sh create mode 100755 scripts/5_XSeg_data_src_mask_remove.sh create mode 100755 scripts/5_XSeg_data_src_trained_mask_apply.sh create mode 100755 scripts/5_XSeg_data_src_trained_mask_remove.sh create mode 100755 scripts/5_XSeg_train.sh diff --git a/scripts/5_XSeg_data_dst_mask_edit.sh b/scripts/5_XSeg_data_dst_mask_edit.sh new file mode 100755 index 0000000..72d3e14 --- /dev/null +++ b/scripts/5_XSeg_data_dst_mask_edit.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +cd "$(dirname $0)/.." +source scripts/env.sh + +python "$DFL_MAIN" xseg editor \ + --input-dir "$WORKSPACE/data_dst/aligned" diff --git a/scripts/5_XSeg_data_dst_mask_fetch.sh b/scripts/5_XSeg_data_dst_mask_fetch.sh new file mode 100755 index 0000000..c26697f --- /dev/null +++ b/scripts/5_XSeg_data_dst_mask_fetch.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +cd "$(dirname $0)/.." +source scripts/env.sh + +python "$DFL_MAIN" xseg fetch \ + --input-dir "$WORKSPACE/data_dst/aligned" diff --git a/scripts/5_XSeg_data_dst_mask_remove.sh b/scripts/5_XSeg_data_dst_mask_remove.sh new file mode 100755 index 0000000..e6321bb --- /dev/null +++ b/scripts/5_XSeg_data_dst_mask_remove.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +cd "$(dirname $0)/.." +source scripts/env.sh + +python "$DFL_MAIN" xseg remove_labels \ + --input-dir "$WORKSPACE/data_dst/aligned" diff --git a/scripts/5_XSeg_data_dst_trained_mask_apply.sh b/scripts/5_XSeg_data_dst_trained_mask_apply.sh new file mode 100755 index 0000000..7743b48 --- /dev/null +++ b/scripts/5_XSeg_data_dst_trained_mask_apply.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +cd "$(dirname $0)/.." +source scripts/env.sh + +python "$DFL_MAIN" xseg apply \ + --input-dir "$WORKSPACE/data_dst/aligned" \ + --model-dir "$WORKSPACE/model" diff --git a/scripts/5_XSeg_data_dst_trained_mask_remove.sh b/scripts/5_XSeg_data_dst_trained_mask_remove.sh new file mode 100755 index 0000000..4ec0b35 --- /dev/null +++ b/scripts/5_XSeg_data_dst_trained_mask_remove.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +cd "$(dirname $0)/.." +source scripts/env.sh + +python "$DFL_MAIN" xseg remove \ + --input-dir "$WORKSPACE/data_dst/aligned" diff --git a/scripts/5_XSeg_data_src_mask_edit.sh b/scripts/5_XSeg_data_src_mask_edit.sh new file mode 100755 index 0000000..bc5b6a8 --- /dev/null +++ b/scripts/5_XSeg_data_src_mask_edit.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +cd "$(dirname $0)/.." +source scripts/env.sh + +python "$DFL_MAIN" xseg editor \ + --input-dir "$WORKSPACE/data_src/aligned" diff --git a/scripts/5_XSeg_data_src_mask_fetch.sh b/scripts/5_XSeg_data_src_mask_fetch.sh new file mode 100755 index 0000000..2b973b0 --- /dev/null +++ b/scripts/5_XSeg_data_src_mask_fetch.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +cd "$(dirname $0)/.." +source scripts/env.sh + +python "$DFL_MAIN" xseg fetch \ + --input-dir "$WORKSPACE/data_src/aligned" diff --git a/scripts/5_XSeg_data_src_mask_remove.sh b/scripts/5_XSeg_data_src_mask_remove.sh new file mode 100755 index 0000000..d467576 --- /dev/null +++ b/scripts/5_XSeg_data_src_mask_remove.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +cd "$(dirname $0)/.." +source scripts/env.sh + +python "$DFL_MAIN" xseg remove_labels \ + --input-dir "$WORKSPACE/data_src/aligned" diff --git a/scripts/5_XSeg_data_src_trained_mask_apply.sh b/scripts/5_XSeg_data_src_trained_mask_apply.sh new file mode 100755 index 0000000..9e1bc22 --- /dev/null +++ b/scripts/5_XSeg_data_src_trained_mask_apply.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +cd "$(dirname $0)/.." +source scripts/env.sh + +python "$DFL_MAIN" xseg apply \ + --input-dir "$WORKSPACE/data_src/aligned" \ + --model-dir "$WORKSPACE/model" diff --git a/scripts/5_XSeg_data_src_trained_mask_remove.sh b/scripts/5_XSeg_data_src_trained_mask_remove.sh new file mode 100755 index 0000000..14b9a98 --- /dev/null +++ b/scripts/5_XSeg_data_src_trained_mask_remove.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +cd "$(dirname $0)/.." +source scripts/env.sh + +python "$DFL_MAIN" xseg remove \ + --input-dir "$WORKSPACE/data_src/aligned" diff --git a/scripts/5_XSeg_train.sh b/scripts/5_XSeg_train.sh new file mode 100755 index 0000000..9965724 --- /dev/null +++ b/scripts/5_XSeg_train.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +cd "$(dirname $0)/.." +source scripts/env.sh + +python "$DFL_MAIN" train \ + --training-data-src-dir "$WORKSPACE/data_src/aligned" \ + --training-data-dst-dir "$WORKSPACE/data_dst/aligned" \ + --model-dir "$WORKSPACE/model" \ + --model XSeg