diff --git a/animation/SadTalker/.gitignore b/animation/SadTalker/.gitignore new file mode 100644 index 0000000..73c66b6 --- /dev/null +++ b/animation/SadTalker/.gitignore @@ -0,0 +1,174 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ + +examples/results/* +gfpgan/* +checkpoints/* +assets/* +results/* +Dockerfile +start_docker.sh +start.sh + +checkpoints + +# Mac +.DS_Store diff --git a/animation/SadTalker/LICENSE b/animation/SadTalker/LICENSE new file mode 100644 index 0000000..b2a615a --- /dev/null +++ b/animation/SadTalker/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Tencent AI Lab + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/animation/SadTalker/README.md b/animation/SadTalker/README.md new file mode 100644 index 0000000..c330bdc --- /dev/null +++ b/animation/SadTalker/README.md @@ -0,0 +1,268 @@ +
+
+
+
+
+
+
+- 🔥 Several new mode, eg, `still mode`, `reference mode`, `resize mode` are online for better and custom applications.
+
+- 🔥 Happy to see more community demos at [bilibili](https://search.bilibili.com/all?keyword=sadtalker&from_source=webtop_search&spm_id_from=333.1007&search_source=3
+), [Youtube](https://www.youtube.com/results?search_query=sadtalker&sp=CAM%253D) and [twitter #sadtalker](https://twitter.com/search?q=%23sadtalker&src=typed_query).
+
+## 📋 Changelog (Previous changelog can be founded [here](docs/changlelog.md))
+
+- __[2023.06.12]__: add more new features in WEBUI extension, see the discussion [here](https://github.com/OpenTalker/SadTalker/discussions/386).
+
+- __[2023.06.05]__: release a new 512 beta face model. Fixed some bugs and improve the performance.
+
+- __[2023.04.15]__: Adding automatic1111 colab by @camenduru, thanks for this awesome colab: [](https://colab.research.google.com/github/camenduru/stable-diffusion-webui-colab/blob/main/video/stable/stable_diffusion_1_5_video_webui_colab.ipynb).
+
+- __[2023.04.12]__: adding a more detailed sd-webui installation document, fixed reinstallation problem.
+
+- __[2023.04.12]__: Fixed the sd-webui safe issues becasue of the 3rd packages, optimize the output path in `sd-webui-extension`.
+
+- __[2023.04.08]__: ❗️❗️❗️ In v0.0.2, we add a logo watermark to the generated video to prevent abusing since it is very realistic.
+
+- __[2023.04.08]__: v0.0.2, full image animation, adding baidu driver for download checkpoints. Optimizing the logic about enhancer.
+
+
+## 🚧 TODO: See the Discussion https://github.com/OpenTalker/SadTalker/issues/280
+
+## If you have any problem, please view our [FAQ](docs/FAQ.md) before opening an issue.
+
+
+
+## ⚙️ 1. Installation.
+
+Tutorials from communities: [中文windows教程](https://www.bilibili.com/video/BV1Dc411W7V6/) | [日本語コース](https://br-d.fanbox.cc/posts/5685086?utm_campaign=manage_post_page&utm_medium=share&utm_source=twitter)
+
+### Linux:
+
+1. Installing [anaconda](https://www.anaconda.com/), python and git.
+
+2. Creating the env and install the requirements.
+ ```bash
+ git clone https://github.com/Winfredy/SadTalker.git
+
+ cd SadTalker
+
+ conda create -n sadtalker python=3.8
+
+ conda activate sadtalker
+
+ 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
+
+ conda install ffmpeg
+
+ pip install -r requirements.txt
+
+ ### tts is optional for gradio demo.
+ ### pip install TTS
+
+ ```
+### Windows ([中文windows教程](https://www.bilibili.com/video/BV1Dc411W7V6/)):
+
+1. Install [Python 3.10.6](https://www.python.org/downloads/windows/), checking "Add Python to PATH".
+2. Install [git](https://git-scm.com/download/win) manually (OR `scoop install git` via [scoop](https://scoop.sh/)).
+3. Install `ffmpeg`, following [this instruction](https://www.wikihow.com/Install-FFmpeg-on-Windows) (OR using `scoop install ffmpeg` via [scoop](https://scoop.sh/)).
+4. Download our SadTalker repository, for example by running `git clone https://github.com/Winfredy/SadTalker.git`.
+5. Download the `checkpoint` and `gfpgan` [below↓](https://github.com/Winfredy/SadTalker#-2-download-trained-models).
+5. Run `start.bat` from Windows Explorer as normal, non-administrator, user, a gradio WebUI demo will be started.
+
+### Macbook:
+
+More tips about installnation on Macbook and the Docker file can be founded [here](docs/install.md)
+
+## 📥 2. Download Trained Models.
+
+You can run the following script to put all the models in the right place.
+
+```bash
+bash scripts/download_models.sh
+```
+
+Other alternatives:
+> we also provide an offline patch (`gfpgan/`), thus, no model will be downloaded when generating.
+
+**Google Driver**: download our pre-trained model from [ this link (main checkpoints)](https://drive.google.com/file/d/1gwWh45pF7aelNP_P78uDJL8Sycep-K7j/view?usp=sharing) and [ gfpgan (offline patch)](https://drive.google.com/file/d/19AIBsmfcHW6BRJmeqSFlG5fL445Xmsyi?usp=sharing)
+
+**Github Release Page**: download all the files from the [lastest github release page](https://github.com/Winfredy/SadTalker/releases), and then, put it in ./checkpoints.
+
+**百度云盘**: we provided the downloaded model in [checkpoints, 提取码: sadt.](https://pan.baidu.com/s/1P4fRgk9gaSutZnn8YW034Q?pwd=sadt) And [gfpgan, 提取码: sadt.](https://pan.baidu.com/s/1kb1BCPaLOWX1JJb9Czbn6w?pwd=sadt)
+
+
+
+
+
+
+
|  |  |
+
+
+ In `resize` mode, we resize the whole images to generate the fully talking head video. Thus, an image similar to the ID photo can be produced. ⚠️ It will produce bad results for full person images.
+
+
+
+
+|
|
|
+|:--------------------: |:--------------------: |
+| ❌ not suitable for resize mode | ✅ good for resize mode |
+|
|
|
+
+In `full` mode, our model will automatically process the croped region and paste back to the original image. Remember to use `--still` to keep the original head pose.
+
+| input | `--still` | `--still` & `enhancer` |
+|:--------------------: |:--------------------: | :--:|
+|
|
|
+
+
+### About `--enhancer`
+
+For better facial quality, we intergate [gfpgan](https://github.com/TencentARC/GFPGAN) and [real-esrgan](https://github.com/xinntao/Real-ESRGAN) for different purpose. Just adding `--enhancer
| |
+
+> Kindly ensure to activate the audio as the default audio playing is incompatible with GitHub.
+
+
+
+#### reference eye-link mode.
+
+| Input, w/ reference video , reference video |
+|:-------------: |
+| |
+| If the reference video is shorter than the input audio, we will loop the reference video .
+
+
+
+#### Generating 4D free-view talking examples from audio and a single image
+
+We use `input_yaw`, `input_pitch`, `input_roll` to control head pose. For example, `--input_yaw -20 30 10` means the input head yaw degree changes from -20 to 30 and then changes from 30 to 10.
+```bash
+python inference.py --driven_audio
+
+2. Download the checkpoints manually, for Linux and Mac:
+
+ ```bash
+
+ cd SOMEWHERE_YOU_LIKE
+
+ bash <(wget -qO- https://raw.githubusercontent.com/Winfredy/SadTalker/main/scripts/download_models.sh)
+ ```
+
+ For windows, you can download all the checkpoints from [google drive](https://drive.google.com/drive/folders/1Wd88VDoLhVzYsQ30_qDVluQr_Xm46yHT?usp=sharing) or [百度云盘](https://pan.baidu.com/s/1nXuVNd0exUl37ISwWqbFGA?pwd=sadt) 提取码: sadt.
+
+3.1. options 1: put the checkpoint in `stable-diffusion-webui/models/SadTalker` or `stable-diffusion-webui/extensions/SadTalker/checkpoints/`, the checkpoints will be detected automatically.
+
+3.2. Options 2: Set the path of `SADTALKTER_CHECKPOINTS` in `webui_user.sh`(linux) or `webui_user.bat`(windows) by:
+
+ > only works if you are directly starting webui from `webui_user.sh` or `webui_user.bat`.
+
+ ```bash
+ # windows (webui_user.bat)
+ set SADTALKER_CHECKPOINTS=D:\SadTalker\checkpoints
+
+ # linux (webui_user.sh)
+ export SADTALKER_CHECKPOINTS=/path/to/SadTalker/checkpoints
+ ```
+
+4. Then, starting the webui via `webui.sh or webui_user.sh(linux)` or `webui_user.bat(windows)` or any other methods, the SadTalker can be used in stable-diffusion-webui directly.
+
+
+
+## Questsions
+
+1. if you are running on CPU, you need to specific `--disable-safe-unpickle` in `webui_user.sh` or `webui_user.bat`.
+
+ ```bash
+ # windows (webui_user.bat)
+ set COMMANDLINE_ARGS="--disable-safe-unpickle"
+
+ # linux (webui_user.sh)
+ export COMMANDLINE_ARGS="--disable-safe-unpickle"
+ ```
+
+
+
+(Some [important discussion](https://github.com/Winfredy/SadTalker/issues/78) if you are unable to use `full` mode).
diff --git a/animation/SadTalker/examples/driven_audio/RD_Radio31_000.wav b/animation/SadTalker/examples/driven_audio/RD_Radio31_000.wav
new file mode 100644
index 0000000..3b04940
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/RD_Radio31_000.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/RD_Radio34_002.wav b/animation/SadTalker/examples/driven_audio/RD_Radio34_002.wav
new file mode 100644
index 0000000..6813e81
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/RD_Radio34_002.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/RD_Radio36_000.wav b/animation/SadTalker/examples/driven_audio/RD_Radio36_000.wav
new file mode 100644
index 0000000..c73adfe
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/RD_Radio36_000.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/RD_Radio40_000.wav b/animation/SadTalker/examples/driven_audio/RD_Radio40_000.wav
new file mode 100644
index 0000000..88ce964
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/RD_Radio40_000.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/bus_chinese.wav b/animation/SadTalker/examples/driven_audio/bus_chinese.wav
new file mode 100644
index 0000000..8886477
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/bus_chinese.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/chinese_news.wav b/animation/SadTalker/examples/driven_audio/chinese_news.wav
new file mode 100644
index 0000000..168e92b
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/chinese_news.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/chinese_poem1.wav b/animation/SadTalker/examples/driven_audio/chinese_poem1.wav
new file mode 100644
index 0000000..17c0871
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/chinese_poem1.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/chinese_poem2.wav b/animation/SadTalker/examples/driven_audio/chinese_poem2.wav
new file mode 100644
index 0000000..e3b294e
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/chinese_poem2.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/deyu.wav b/animation/SadTalker/examples/driven_audio/deyu.wav
new file mode 100644
index 0000000..1a6bf3e
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/deyu.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/eluosi.wav b/animation/SadTalker/examples/driven_audio/eluosi.wav
new file mode 100644
index 0000000..1ffe3c9
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/eluosi.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/fayu.wav b/animation/SadTalker/examples/driven_audio/fayu.wav
new file mode 100644
index 0000000..e3c67d8
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/fayu.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/imagine.wav b/animation/SadTalker/examples/driven_audio/imagine.wav
new file mode 100644
index 0000000..08a5dc7
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/imagine.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/itosinger1.wav b/animation/SadTalker/examples/driven_audio/itosinger1.wav
new file mode 100644
index 0000000..4937dbb
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/itosinger1.wav differ
diff --git a/animation/SadTalker/examples/driven_audio/japanese.wav b/animation/SadTalker/examples/driven_audio/japanese.wav
new file mode 100644
index 0000000..0b6146f
Binary files /dev/null and b/animation/SadTalker/examples/driven_audio/japanese.wav differ
diff --git a/animation/SadTalker/examples/ref_video/WDA_AlexandriaOcasioCortez_000.mp4 b/animation/SadTalker/examples/ref_video/WDA_AlexandriaOcasioCortez_000.mp4
new file mode 100644
index 0000000..5c06ff5
Binary files /dev/null and b/animation/SadTalker/examples/ref_video/WDA_AlexandriaOcasioCortez_000.mp4 differ
diff --git a/animation/SadTalker/examples/ref_video/WDA_KatieHill_000.mp4 b/animation/SadTalker/examples/ref_video/WDA_KatieHill_000.mp4
new file mode 100644
index 0000000..1e295d5
Binary files /dev/null and b/animation/SadTalker/examples/ref_video/WDA_KatieHill_000.mp4 differ
diff --git a/animation/SadTalker/examples/source_image/art_0.png b/animation/SadTalker/examples/source_image/art_0.png
new file mode 100644
index 0000000..d8d9764
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_0.png differ
diff --git a/animation/SadTalker/examples/source_image/art_1.png b/animation/SadTalker/examples/source_image/art_1.png
new file mode 100644
index 0000000..4388abe
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_1.png differ
diff --git a/animation/SadTalker/examples/source_image/art_10.png b/animation/SadTalker/examples/source_image/art_10.png
new file mode 100644
index 0000000..5f6568b
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_10.png differ
diff --git a/animation/SadTalker/examples/source_image/art_11.png b/animation/SadTalker/examples/source_image/art_11.png
new file mode 100644
index 0000000..4caf17c
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_11.png differ
diff --git a/animation/SadTalker/examples/source_image/art_12.png b/animation/SadTalker/examples/source_image/art_12.png
new file mode 100644
index 0000000..e15306c
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_12.png differ
diff --git a/animation/SadTalker/examples/source_image/art_13.png b/animation/SadTalker/examples/source_image/art_13.png
new file mode 100644
index 0000000..1293741
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_13.png differ
diff --git a/animation/SadTalker/examples/source_image/art_14.png b/animation/SadTalker/examples/source_image/art_14.png
new file mode 100644
index 0000000..0f0489b
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_14.png differ
diff --git a/animation/SadTalker/examples/source_image/art_15.png b/animation/SadTalker/examples/source_image/art_15.png
new file mode 100644
index 0000000..a0af242
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_15.png differ
diff --git a/animation/SadTalker/examples/source_image/art_16.png b/animation/SadTalker/examples/source_image/art_16.png
new file mode 100644
index 0000000..7489eec
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_16.png differ
diff --git a/animation/SadTalker/examples/source_image/art_17.png b/animation/SadTalker/examples/source_image/art_17.png
new file mode 100644
index 0000000..acec2b9
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_17.png differ
diff --git a/animation/SadTalker/examples/source_image/art_18.png b/animation/SadTalker/examples/source_image/art_18.png
new file mode 100644
index 0000000..96358e0
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_18.png differ
diff --git a/animation/SadTalker/examples/source_image/art_19.png b/animation/SadTalker/examples/source_image/art_19.png
new file mode 100644
index 0000000..4f477a1
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_19.png differ
diff --git a/animation/SadTalker/examples/source_image/art_2.png b/animation/SadTalker/examples/source_image/art_2.png
new file mode 100644
index 0000000..9560673
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_2.png differ
diff --git a/animation/SadTalker/examples/source_image/art_20.png b/animation/SadTalker/examples/source_image/art_20.png
new file mode 100644
index 0000000..de1ea5c
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_20.png differ
diff --git a/animation/SadTalker/examples/source_image/art_3.png b/animation/SadTalker/examples/source_image/art_3.png
new file mode 100644
index 0000000..a67667d
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_3.png differ
diff --git a/animation/SadTalker/examples/source_image/art_4.png b/animation/SadTalker/examples/source_image/art_4.png
new file mode 100644
index 0000000..99cb57f
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_4.png differ
diff --git a/animation/SadTalker/examples/source_image/art_5.png b/animation/SadTalker/examples/source_image/art_5.png
new file mode 100644
index 0000000..81f73c4
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_5.png differ
diff --git a/animation/SadTalker/examples/source_image/art_6.png b/animation/SadTalker/examples/source_image/art_6.png
new file mode 100644
index 0000000..e9f6d8f
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_6.png differ
diff --git a/animation/SadTalker/examples/source_image/art_7.png b/animation/SadTalker/examples/source_image/art_7.png
new file mode 100644
index 0000000..d8cc380
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_7.png differ
diff --git a/animation/SadTalker/examples/source_image/art_8.png b/animation/SadTalker/examples/source_image/art_8.png
new file mode 100644
index 0000000..b407fc9
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_8.png differ
diff --git a/animation/SadTalker/examples/source_image/art_9.png b/animation/SadTalker/examples/source_image/art_9.png
new file mode 100644
index 0000000..3ac52d5
Binary files /dev/null and b/animation/SadTalker/examples/source_image/art_9.png differ
diff --git a/animation/SadTalker/examples/source_image/full3.png b/animation/SadTalker/examples/source_image/full3.png
new file mode 100644
index 0000000..40cd6d6
Binary files /dev/null and b/animation/SadTalker/examples/source_image/full3.png differ
diff --git a/animation/SadTalker/examples/source_image/full4.jpeg b/animation/SadTalker/examples/source_image/full4.jpeg
new file mode 100644
index 0000000..79f17f5
Binary files /dev/null and b/animation/SadTalker/examples/source_image/full4.jpeg differ
diff --git a/animation/SadTalker/examples/source_image/full_body_1.png b/animation/SadTalker/examples/source_image/full_body_1.png
new file mode 100644
index 0000000..4fca65c
Binary files /dev/null and b/animation/SadTalker/examples/source_image/full_body_1.png differ
diff --git a/animation/SadTalker/examples/source_image/full_body_2.png b/animation/SadTalker/examples/source_image/full_body_2.png
new file mode 100644
index 0000000..b7bc622
Binary files /dev/null and b/animation/SadTalker/examples/source_image/full_body_2.png differ
diff --git a/animation/SadTalker/examples/source_image/happy.png b/animation/SadTalker/examples/source_image/happy.png
new file mode 100644
index 0000000..9d194ba
Binary files /dev/null and b/animation/SadTalker/examples/source_image/happy.png differ
diff --git a/animation/SadTalker/examples/source_image/happy1.png b/animation/SadTalker/examples/source_image/happy1.png
new file mode 100644
index 0000000..b702974
Binary files /dev/null and b/animation/SadTalker/examples/source_image/happy1.png differ
diff --git a/animation/SadTalker/examples/source_image/people_0.png b/animation/SadTalker/examples/source_image/people_0.png
new file mode 100644
index 0000000..8895eeb
Binary files /dev/null and b/animation/SadTalker/examples/source_image/people_0.png differ
diff --git a/animation/SadTalker/examples/source_image/sad.png b/animation/SadTalker/examples/source_image/sad.png
new file mode 100644
index 0000000..6584467
Binary files /dev/null and b/animation/SadTalker/examples/source_image/sad.png differ
diff --git a/animation/SadTalker/examples/source_image/sad1.png b/animation/SadTalker/examples/source_image/sad1.png
new file mode 100644
index 0000000..341e0cb
Binary files /dev/null and b/animation/SadTalker/examples/source_image/sad1.png differ
diff --git a/animation/SadTalker/inference.py b/animation/SadTalker/inference.py
new file mode 100644
index 0000000..a0b0079
--- /dev/null
+++ b/animation/SadTalker/inference.py
@@ -0,0 +1,145 @@
+from glob import glob
+import shutil
+import torch
+from time import strftime
+import os, sys, time
+from argparse import ArgumentParser
+
+from src.utils.preprocess import CropAndExtract
+from src.test_audio2coeff import Audio2Coeff
+from src.facerender.animate import AnimateFromCoeff
+from src.generate_batch import get_data
+from src.generate_facerender_batch import get_facerender_data
+from src.utils.init_path import init_path
+
+def main(args):
+ #torch.backends.cudnn.enabled = False
+
+ pic_path = args.source_image
+ audio_path = args.driven_audio
+ save_dir = os.path.join(args.result_dir, strftime("%Y_%m_%d_%H.%M.%S"))
+ os.makedirs(save_dir, exist_ok=True)
+ pose_style = args.pose_style
+ device = args.device
+ batch_size = args.batch_size
+ input_yaw_list = args.input_yaw
+ input_pitch_list = args.input_pitch
+ input_roll_list = args.input_roll
+ ref_eyeblink = args.ref_eyeblink
+ ref_pose = args.ref_pose
+
+ current_root_path = os.path.split(sys.argv[0])[0]
+
+ sadtalker_paths = init_path(args.checkpoint_dir, os.path.join(current_root_path, 'src/config'), args.size, args.old_version, args.preprocess)
+
+ #init model
+ preprocess_model = CropAndExtract(sadtalker_paths, device)
+
+ audio_to_coeff = Audio2Coeff(sadtalker_paths, device)
+
+ animate_from_coeff = AnimateFromCoeff(sadtalker_paths, device)
+
+ #crop image and extract 3dmm from image
+ first_frame_dir = os.path.join(save_dir, 'first_frame_dir')
+ os.makedirs(first_frame_dir, exist_ok=True)
+ print('3DMM Extraction for source image')
+ first_coeff_path, crop_pic_path, crop_info = preprocess_model.generate(pic_path, first_frame_dir, args.preprocess,\
+ source_image_flag=True, pic_size=args.size)
+ if first_coeff_path is None:
+ print("Can't get the coeffs of the input")
+ return
+
+ if ref_eyeblink is not None:
+ ref_eyeblink_videoname = os.path.splitext(os.path.split(ref_eyeblink)[-1])[0]
+ ref_eyeblink_frame_dir = os.path.join(save_dir, ref_eyeblink_videoname)
+ os.makedirs(ref_eyeblink_frame_dir, exist_ok=True)
+ print('3DMM Extraction for the reference video providing eye blinking')
+ ref_eyeblink_coeff_path, _, _ = preprocess_model.generate(ref_eyeblink, ref_eyeblink_frame_dir, args.preprocess, source_image_flag=False)
+ else:
+ ref_eyeblink_coeff_path=None
+
+ if ref_pose is not None:
+ if ref_pose == ref_eyeblink:
+ ref_pose_coeff_path = ref_eyeblink_coeff_path
+ else:
+ ref_pose_videoname = os.path.splitext(os.path.split(ref_pose)[-1])[0]
+ ref_pose_frame_dir = os.path.join(save_dir, ref_pose_videoname)
+ os.makedirs(ref_pose_frame_dir, exist_ok=True)
+ print('3DMM Extraction for the reference video providing pose')
+ ref_pose_coeff_path, _, _ = preprocess_model.generate(ref_pose, ref_pose_frame_dir, args.preprocess, source_image_flag=False)
+ else:
+ ref_pose_coeff_path=None
+
+ #audio2ceoff
+ batch = get_data(first_coeff_path, audio_path, device, ref_eyeblink_coeff_path, still=args.still)
+ coeff_path = audio_to_coeff.generate(batch, save_dir, pose_style, ref_pose_coeff_path)
+
+ # 3dface render
+ if args.face3dvis:
+ from src.face3d.visualize import gen_composed_video
+ gen_composed_video(args, device, first_coeff_path, coeff_path, audio_path, os.path.join(save_dir, '3dface.mp4'))
+
+ #coeff2video
+ data = get_facerender_data(coeff_path, crop_pic_path, first_coeff_path, audio_path,
+ batch_size, input_yaw_list, input_pitch_list, input_roll_list,
+ expression_scale=args.expression_scale, still_mode=args.still, preprocess=args.preprocess, size=args.size)
+
+ result = animate_from_coeff.generate(data, save_dir, pic_path, crop_info, \
+ enhancer=args.enhancer, background_enhancer=args.background_enhancer, preprocess=args.preprocess, img_size=args.size)
+
+ shutil.move(result, save_dir+'.mp4')
+ print('The generated video is named:', save_dir+'.mp4')
+
+ if not args.verbose:
+ shutil.rmtree(save_dir)
+
+
+if __name__ == '__main__':
+
+ parser = ArgumentParser()
+ parser.add_argument("--driven_audio", default='./examples/driven_audio/bus_chinese.wav', help="path to driven audio")
+ parser.add_argument("--source_image", default='./examples/source_image/full_body_1.png', help="path to source image")
+ parser.add_argument("--ref_eyeblink", default=None, help="path to reference video providing eye blinking")
+ parser.add_argument("--ref_pose", default=None, help="path to reference video providing pose")
+ parser.add_argument("--checkpoint_dir", default='./checkpoints', help="path to output")
+ parser.add_argument("--result_dir", default='./results', help="path to output")
+ parser.add_argument("--pose_style", type=int, default=0, help="input pose style from [0, 46)")
+ parser.add_argument("--batch_size", type=int, default=2, help="the batch size of facerender")
+ parser.add_argument("--size", type=int, default=256, help="the image size of the facerender")
+ parser.add_argument("--expression_scale", type=float, default=1., help="the batch size of facerender")
+ parser.add_argument('--input_yaw', nargs='+', type=int, default=None, help="the input yaw degree of the user ")
+ parser.add_argument('--input_pitch', nargs='+', type=int, default=None, help="the input pitch degree of the user")
+ parser.add_argument('--input_roll', nargs='+', type=int, default=None, help="the input roll degree of the user")
+ parser.add_argument('--enhancer', type=str, default=None, help="Face enhancer, [gfpgan, RestoreFormer]")
+ parser.add_argument('--background_enhancer', type=str, default=None, help="background enhancer, [realesrgan]")
+ parser.add_argument("--cpu", dest="cpu", action="store_true")
+ parser.add_argument("--face3dvis", action="store_true", help="generate 3d face and 3d landmarks")
+ parser.add_argument("--still", action="store_true", help="can crop back to the original videos for the full body aniamtion")
+ parser.add_argument("--preprocess", default='crop', choices=['crop', 'extcrop', 'resize', 'full', 'extfull'], help="how to preprocess the images" )
+ parser.add_argument("--verbose",action="store_true", help="saving the intermedia output or not" )
+ parser.add_argument("--old_version",action="store_true", help="use the pth other than safetensor version" )
+
+
+ # net structure and parameters
+ parser.add_argument('--net_recon', type=str, default='resnet50', choices=['resnet18', 'resnet34', 'resnet50'], help='useless')
+ parser.add_argument('--init_path', type=str, default=None, help='Useless')
+ parser.add_argument('--use_last_fc',default=False, help='zero initialize the last fc')
+ parser.add_argument('--bfm_folder', type=str, default='./checkpoints/BFM_Fitting/')
+ parser.add_argument('--bfm_model', type=str, default='BFM_model_front.mat', help='bfm model')
+
+ # default renderer parameters
+ parser.add_argument('--focal', type=float, default=1015.)
+ parser.add_argument('--center', type=float, default=112.)
+ parser.add_argument('--camera_d', type=float, default=10.)
+ parser.add_argument('--z_near', type=float, default=5.)
+ parser.add_argument('--z_far', type=float, default=15.)
+
+ args = parser.parse_args()
+
+ if torch.cuda.is_available() and not args.cpu:
+ args.device = "cuda"
+ else:
+ args.device = "cpu"
+
+ main(args)
+
diff --git a/animation/SadTalker/launcher.py b/animation/SadTalker/launcher.py
new file mode 100644
index 0000000..17ce9f1
--- /dev/null
+++ b/animation/SadTalker/launcher.py
@@ -0,0 +1,204 @@
+# this scripts installs necessary requirements and launches main program in webui.py
+# borrow from : https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/launch.py
+import subprocess
+import os
+import sys
+import importlib.util
+import shlex
+import platform
+import json
+
+python = sys.executable
+git = os.environ.get('GIT', "git")
+index_url = os.environ.get('INDEX_URL', "")
+stored_commit_hash = None
+skip_install = False
+dir_repos = "repositories"
+script_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+
+if 'GRADIO_ANALYTICS_ENABLED' not in os.environ:
+ os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
+
+
+def check_python_version():
+ is_windows = platform.system() == "Windows"
+ major = sys.version_info.major
+ minor = sys.version_info.minor
+ micro = sys.version_info.micro
+
+ if is_windows:
+ supported_minors = [10]
+ else:
+ supported_minors = [7, 8, 9, 10, 11]
+
+ if not (major == 3 and minor in supported_minors):
+
+ raise (f"""
+INCOMPATIBLE PYTHON VERSION
+This program is tested with 3.10.6 Python, but you have {major}.{minor}.{micro}.
+If you encounter an error with "RuntimeError: Couldn't install torch." message,
+or any other error regarding unsuccessful package (library) installation,
+please downgrade (or upgrade) to the latest version of 3.10 Python
+and delete current Python and "venv" folder in WebUI's directory.
+You can download 3.10 Python from here: https://www.python.org/downloads/release/python-3109/
+{"Alternatively, use a binary release of WebUI: https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases" if is_windows else ""}
+Use --skip-python-version-check to suppress this warning.
+""")
+
+
+def commit_hash():
+ global stored_commit_hash
+
+ if stored_commit_hash is not None:
+ return stored_commit_hash
+
+ try:
+ stored_commit_hash = run(f"{git} rev-parse HEAD").strip()
+ except Exception:
+ stored_commit_hash = "