CoolFace
Apppublic

faraidun/LivePortrait

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
readme.md149 linesDownload Raw Back to root
1---2license: mit3---4 5<h1 align="center">LivePortrait: Efficient Portrait Animation with Stitching and Retargeting Control</h1>6 7<div align='center'>8    <a href='https://github.com/cleardusk' target='_blank'><strong>Jianzhu Guo</strong></a><sup> 1โ€ </sup>&emsp;9    <a href='https://github.com/KwaiVGI' target='_blank'><strong>Dingyun Zhang</strong></a><sup> 1,2</sup>&emsp;10    <a href='https://github.com/KwaiVGI' target='_blank'><strong>Xiaoqiang Liu</strong></a><sup> 1</sup>&emsp;11    <a href='https://github.com/KwaiVGI' target='_blank'><strong>Zhizhou Zhong</strong></a><sup> 1,3</sup>&emsp;12    <a href='https://scholar.google.com.hk/citations?user=_8k1ubAAAAAJ' target='_blank'><strong>Yuan Zhang</strong></a><sup> 1</sup>&emsp;13</div>14 15<div align='center'>16    <a href='https://scholar.google.com/citations?user=P6MraaYAAAAJ' target='_blank'><strong>Pengfei Wan</strong></a><sup> 1</sup>&emsp;17    <a href='https://openreview.net/profile?id=~Di_ZHANG3' target='_blank'><strong>Di Zhang</strong></a><sup> 1</sup>&emsp;18</div>19 20<div align='center'>21    <sup>1 </sup>Kuaishou Technology&emsp; <sup>2 </sup>University of Science and Technology of China&emsp; <sup>3 </sup>Fudan University&emsp;22</div>23 24<br>25<div align="center" style="display: flex; justify-content: center; flex-wrap: wrap;">26  <!-- <a href='LICENSE'><img src='https://img.shields.io/badge/license-MIT-yellow'></a> -->27  <a href='https://arxiv.org/pdf/2407.03168'><img src='https://img.shields.io/badge/arXiv-LivePortrait-red'></a>28  <a href='https://liveportrait.github.io'><img src='https://img.shields.io/badge/Project-LivePortrait-green'></a>29  <a href='https://huggingface.co/spaces/KwaiVGI/liveportrait'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue'></a>30</div>31<br>32 33<p align="center">34  <img src="./docs/showcase2.gif" alt="showcase">35  <br>36  ๐Ÿ”ฅ For more results, visit our <a href="https://liveportrait.github.io/"><strong>homepage</strong></a> ๐Ÿ”ฅ37</p>38 39 40 41## ๐Ÿ”ฅ Updates42- **`2024/07/04`**: ๐Ÿ”ฅ We released the initial version of the inference code and models. Continuous updates, stay tuned!43- **`2024/07/04`**: ๐Ÿ˜Š We released the [homepage](https://liveportrait.github.io) and technical report on [arXiv](https://arxiv.org/pdf/2407.03168).44 45## Introduction46This repo, named **LivePortrait**, contains the official PyTorch implementation of our paper [LivePortrait: Efficient Portrait Animation with Stitching and Retargeting Control](https://arxiv.org/pdf/2407.03168).47We are actively updating and improving this repository. If you find any bugs or have suggestions, welcome to raise issues or submit pull requests (PR) ๐Ÿ’–.48 49## ๐Ÿ”ฅ Getting Started50### 1. Clone the code and prepare the environment51```bash52git clone https://github.com/KwaiVGI/LivePortrait53cd LivePortrait54 55# create env using conda56conda create -n LivePortrait python==3.9.1857conda activate LivePortrait58# install dependencies with pip59pip install -r requirements.txt60```61 62### 2. Download pretrained weights63Download our pretrained LivePortrait weights and face detection models of InsightFace from [Google Drive](https://drive.google.com/drive/folders/1UtKgzKjFAOmZkhNK-OYT0caJ_w2XAnib) or [Baidu Yun](https://pan.baidu.com/s/1MGctWmNla_vZxDbEp2Dtzw?pwd=z5cn). We have packed all weights in one directory ๐Ÿ˜Š. Unzip and place them in `./pretrained_weights` ensuring the directory structure is as follows:64```text65pretrained_weights66โ”œโ”€โ”€ insightface67โ”‚   โ””โ”€โ”€ models68โ”‚       โ””โ”€โ”€ buffalo_l69โ”‚           โ”œโ”€โ”€ 2d106det.onnx70โ”‚           โ””โ”€โ”€ det_10g.onnx71โ””โ”€โ”€ liveportrait72    โ”œโ”€โ”€ base_models73    โ”‚   โ”œโ”€โ”€ appearance_feature_extractor.pth74    โ”‚   โ”œโ”€โ”€ motion_extractor.pth75    โ”‚   โ”œโ”€โ”€ spade_generator.pth76    โ”‚   โ””โ”€โ”€ warping_module.pth77    โ”œโ”€โ”€ landmark.onnx78    โ””โ”€โ”€ retargeting_models79        โ””โ”€โ”€ stitching_retargeting_module.pth80```81 82### 3. Inference ๐Ÿš€83 84```bash85python inference.py86```87 88If the script runs successfully, you will get an output mp4 file named `animations/s6--d0_concat.mp4`. This file includes the following results: driving video, input image, and generated result.89 90<p align="center">91  <img src="./docs/inference.gif" alt="image">92</p>93 94Or, you can change the input by specifying the `-s` and `-d` arguments:95 96```bash97python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d0.mp498 99# or disable pasting back100python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d0.mp4 --no_flag_pasteback101 102# more options to see103python inference.py -h104```105 106**More interesting results can be found in our [Homepage](https://liveportrait.github.io)** ๐Ÿ˜Š107 108### 4. Gradio interface109 110We also provide a Gradio interface for a better experience, just run by:111 112```bash113python app.py114```115 116### 5. Inference speed evaluation ๐Ÿš€๐Ÿš€๐Ÿš€117We have also provided a script to evaluate the inference speed of each module:118 119```bash120python speed.py121```122 123Below are the results of inferring one frame on an RTX 4090 GPU using the native PyTorch framework with `torch.compile`:124 125| Model                             | Parameters(M) | Model Size(MB) | Inference(ms) |126|-----------------------------------|:-------------:|:--------------:|:-------------:|127| Appearance Feature Extractor      |     0.84      |       3.3      |     0.82      |128| Motion Extractor                  |     28.12     |       108      |     0.84      |129| Spade Generator                   |     55.37     |       212      |     7.59      |130| Warping Module                    |     45.53     |       174      |     5.21      |131| Stitching and Retargeting Modules|     0.23      |       2.3      |     0.31      |132 133*Note: the listed values of Stitching and Retargeting Modules represent the combined parameter counts and the total sequential inference time of three MLP networks.*134 135 136## Acknowledgements137We would like to thank the contributors of [FOMM](https://github.com/AliaksandrSiarohin/first-order-model), [Open Facevid2vid](https://github.com/zhanglonghao1992/One-Shot_Free-View_Neural_Talking_Head_Synthesis), [SPADE](https://github.com/NVlabs/SPADE), [InsightFace](https://github.com/deepinsight/insightface) repositories, for their open research and contributions.138 139## Citation ๐Ÿ’–140If you find LivePortrait useful for your research, welcome to ๐ŸŒŸ this repo and cite our work using the following BibTeX:141```bibtex142@article{guo2024live,143  title   = {LivePortrait: Efficient Portrait Animation with Stitching and Retargeting Control},144  author  = {Jianzhu Guo and Dingyun Zhang and Xiaoqiang Liu and Zhizhou Zhong and Yuan Zhang and Pengfei Wan and Di Zhang},145  year    = {2024},146  journal = {arXiv preprint:2407.03168},147}148```149