chore: upload weights
Browse files- .gitattributes +8 -0
- .gitignore +18 -0
- README.md +148 -3
- insightface/models/buffalo_l/2d106det.onnx +3 -0
- insightface/models/buffalo_l/det_10g.onnx +3 -0
- liveportrait/base_models/appearance_feature_extractor.pth +3 -0
- liveportrait/base_models/motion_extractor.pth +3 -0
- liveportrait/base_models/spade_generator.pth +3 -0
- liveportrait/base_models/warping_module.pth +3 -0
- liveportrait/landmark.onnx +3 -0
- liveportrait/retargeting_models/stitching_retargeting_module.pth +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,11 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
liveportrait/retargeting_models/stitching_retargeting_module.pth filter=lfs diff=lfs merge=lfs -text
|
37 |
+
liveportrait/base_models/appearance_feature_extractor.pth filter=lfs diff=lfs merge=lfs -text
|
38 |
+
liveportrait/base_models/motion_extractor.pth filter=lfs diff=lfs merge=lfs -text
|
39 |
+
liveportrait/base_models/spade_generator.pth filter=lfs diff=lfs merge=lfs -text
|
40 |
+
liveportrait/base_models/warping_module.pth filter=lfs diff=lfs merge=lfs -text
|
41 |
+
insightface/models/buffalo_l/2d106det.onnx filter=lfs diff=lfs merge=lfs -text
|
42 |
+
insightface/models/buffalo_l/det_10g.onnx filter=lfs diff=lfs merge=lfs -text
|
43 |
+
liveportrait/landmark.onnx filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
**/__pycache__/
|
4 |
+
*.py[cod]
|
5 |
+
**/*.py[cod]
|
6 |
+
*$py.class
|
7 |
+
|
8 |
+
# Model weights
|
9 |
+
#**/*.pth
|
10 |
+
#**/*.onnx
|
11 |
+
|
12 |
+
# Ipython notebook
|
13 |
+
*.ipynb
|
14 |
+
|
15 |
+
# Temporary files or benchmark resources
|
16 |
+
animations/*
|
17 |
+
tmp/*
|
18 |
+
gradio_cached_examples/
|
README.md
CHANGED
@@ -1,3 +1,148 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
---
|
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> 
|
9 |
+
<a href='https://github.com/KwaiVGI' target='_blank'><strong>Dingyun Zhang</strong></a><sup> 1,2</sup> 
|
10 |
+
<a href='https://github.com/KwaiVGI' target='_blank'><strong>Xiaoqiang Liu</strong></a><sup> 1</sup> 
|
11 |
+
<a href='https://github.com/KwaiVGI' target='_blank'><strong>Zhizhou Zhong</strong></a><sup> 1,3</sup> 
|
12 |
+
<a href='https://scholar.google.com.hk/citations?user=_8k1ubAAAAAJ' target='_blank'><strong>Yuan Zhang</strong></a><sup> 1</sup> 
|
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> 
|
17 |
+
<a href='https://openreview.net/profile?id=~Di_ZHANG3' target='_blank'><strong>Di Zhang</strong></a><sup> 1</sup> 
|
18 |
+
</div>
|
19 |
+
|
20 |
+
<div align='center'>
|
21 |
+
<sup>1 </sup>Kuaishou Technology  <sup>2 </sup>University of Science and Technology of China  <sup>3 </sup>Fudan University 
|
22 |
+
</div>
|
23 |
+
|
24 |
+
<br>
|
25 |
+
<div align="center">
|
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="./assets/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 |
+
## π₯ Updates
|
42 |
+
- **`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 |
+
## Introduction
|
46 |
+
This 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).
|
47 |
+
We 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 Started
|
50 |
+
### 1. Clone the code and prepare the environment
|
51 |
+
```bash
|
52 |
+
git clone https://github.com/KwaiVGI/LivePortrait
|
53 |
+
cd LivePortrait
|
54 |
+
|
55 |
+
# create env using conda
|
56 |
+
conda create -n LivePortrait python==3.9.18
|
57 |
+
conda activate LivePortrait
|
58 |
+
# install dependencies with pip
|
59 |
+
pip install -r requirements.txt
|
60 |
+
```
|
61 |
+
|
62 |
+
### 2. Download pretrained weights
|
63 |
+
Download 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 |
+
```text
|
65 |
+
pretrained_weights
|
66 |
+
βββ insightface
|
67 |
+
β βββ models
|
68 |
+
β βββ buffalo_l
|
69 |
+
β βββ 2d106det.onnx
|
70 |
+
β βββ det_10g.onnx
|
71 |
+
βββ liveportrait
|
72 |
+
βββ base_models
|
73 |
+
β βββ appearance_feature_extractor.pth
|
74 |
+
β βββ motion_extractor.pth
|
75 |
+
β βββ spade_generator.pth
|
76 |
+
β βββ warping_module.pth
|
77 |
+
βββ landmark.onnx
|
78 |
+
βββ retargeting_models
|
79 |
+
βββ stitching_retargeting_module.pth
|
80 |
+
```
|
81 |
+
|
82 |
+
### 3. Inference π
|
83 |
+
|
84 |
+
```bash
|
85 |
+
python inference.py
|
86 |
+
```
|
87 |
+
|
88 |
+
If 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="./assets/docs/inference.gif" alt="image">
|
92 |
+
</p>
|
93 |
+
|
94 |
+
Or, you can change the input by specifying the `-s` and `-d` arguments:
|
95 |
+
|
96 |
+
```bash
|
97 |
+
python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d0.mp4
|
98 |
+
|
99 |
+
# or disable pasting back
|
100 |
+
python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d0.mp4 --no_flag_pasteback
|
101 |
+
|
102 |
+
# more options to see
|
103 |
+
python inference.py -h
|
104 |
+
```
|
105 |
+
|
106 |
+
**More interesting results can be found in our [Homepage](https://liveportrait.github.io)** π
|
107 |
+
|
108 |
+
### 4. Gradio interface
|
109 |
+
|
110 |
+
We also provide a Gradio interface for a better experience, just run by:
|
111 |
+
|
112 |
+
```bash
|
113 |
+
python app.py
|
114 |
+
```
|
115 |
+
|
116 |
+
### 5. Inference speed evaluation πππ
|
117 |
+
We have also provided a script to evaluate the inference speed of each module:
|
118 |
+
|
119 |
+
```bash
|
120 |
+
python speed.py
|
121 |
+
```
|
122 |
+
|
123 |
+
Below 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 |
+
## Acknowledgements
|
137 |
+
We 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 π
|
140 |
+
If you find LivePortrait useful for your research, welcome to π this repo and cite our work using the following BibTeX:
|
141 |
+
```bibtex
|
142 |
+
@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 |
+
```
|
insightface/models/buffalo_l/2d106det.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f001b856447c413801ef5c42091ed0cd516fcd21f2d6b79635b1e733a7109dbf
|
3 |
+
size 5030888
|
insightface/models/buffalo_l/det_10g.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5838f7fe053675b1c7a08b633df49e7af5495cee0493c7dcf6697200b85b5b91
|
3 |
+
size 16923827
|
liveportrait/base_models/appearance_feature_extractor.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5279bb8654293dbdf327030b397f107237dd9212fb11dd75b83dfb635211ceb5
|
3 |
+
size 3387959
|
liveportrait/base_models/motion_extractor.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:251e6a94ad667a1d0c69526d292677165110ef7f0cf0f6d199f0e414e8aa0ca5
|
3 |
+
size 112545506
|
liveportrait/base_models/spade_generator.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4780afc7909a9f84e24c01d73b31a555ef651521a1fe3b2429bd04534d992aee
|
3 |
+
size 221813590
|
liveportrait/base_models/warping_module.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2f61a6f265fe344f14132364859a78bdbbc2068577170693da57fb96d636e282
|
3 |
+
size 182180086
|
liveportrait/landmark.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:31d22a5041326c31f19b78886939a634a5aedcaa5ab8b9b951a1167595d147db
|
3 |
+
size 114666491
|
liveportrait/retargeting_models/stitching_retargeting_module.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3652d5a3f95099141a56986aaddec92fadf0a73c87a20fac9a2c07c32b28b611
|
3 |
+
size 2393098
|