Spaces:
Runtime error
Runtime error
ganeshblank
commited on
Commit
β’
30f37fa
1
Parent(s):
dd6463f
assets
Browse filesThis view is limited to 50 files because it contains too many changes. Β
See raw diff
- .gitattributes +9 -0
- assets/.gitignore +2 -0
- assets/docs/changelog/2024-07-10.md +22 -0
- assets/docs/inference.gif +0 -0
- assets/docs/showcase.gif +3 -0
- assets/docs/showcase2.gif +3 -0
- assets/examples/driving/d0.mp4 +3 -0
- assets/examples/driving/d0.pkl +3 -0
- assets/examples/driving/d1.pkl +3 -0
- assets/examples/driving/d10.mp4 +3 -0
- assets/examples/driving/d10.pkl +3 -0
- assets/examples/driving/d11.mp4 +0 -0
- assets/examples/driving/d11.pkl +3 -0
- assets/examples/driving/d12.mp4 +0 -0
- assets/examples/driving/d12.pkl +3 -0
- assets/examples/driving/d13.mp4 +3 -0
- assets/examples/driving/d14.mp4 +0 -0
- assets/examples/driving/d18.mp4 +0 -0
- assets/examples/driving/d19.mp4 +0 -0
- assets/examples/driving/d2.pkl +3 -0
- assets/examples/driving/d3.mp4 +3 -0
- assets/examples/driving/d3.pkl +3 -0
- assets/examples/driving/d5.pkl +3 -0
- assets/examples/driving/d6.mp4 +3 -0
- assets/examples/driving/d6.pkl +3 -0
- assets/examples/driving/d7.pkl +3 -0
- assets/examples/driving/d8.pkl +3 -0
- assets/examples/driving/d9.mp4 +3 -0
- assets/examples/driving/d9.pkl +3 -0
- assets/examples/source/s0.jpg +0 -0
- assets/examples/source/s1.jpg +0 -0
- assets/examples/source/s10.jpg +0 -0
- assets/examples/source/s11.jpg +0 -0
- assets/examples/source/s12.jpg +0 -0
- assets/examples/source/s2.jpg +0 -0
- assets/examples/source/s3.jpg +0 -0
- assets/examples/source/s4.jpg +0 -0
- assets/examples/source/s5.jpg +0 -0
- assets/examples/source/s6.jpg +0 -0
- assets/examples/source/s7.jpg +0 -0
- assets/examples/source/s8.jpg +0 -0
- assets/examples/source/s9.jpg +0 -0
- assets/gradio_description_animation.md +16 -0
- assets/gradio_description_retargeting.md +4 -0
- assets/gradio_description_upload.md +2 -0
- assets/gradio_title.md +11 -0
- pretrained_weights/.gitattributes +45 -0
- pretrained_weights/.gitignore +18 -0
- pretrained_weights/.gitkeep +0 -0
- pretrained_weights/README.md +148 -0
.gitattributes
CHANGED
@@ -33,3 +33,12 @@ 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 |
+
assets/docs/showcase.gif filter=lfs diff=lfs merge=lfs -text
|
37 |
+
assets/docs/showcase2.gif filter=lfs diff=lfs merge=lfs -text
|
38 |
+
assets/examples/driving/d0.mp4 filter=lfs diff=lfs merge=lfs -text
|
39 |
+
assets/examples/driving/d10.mp4 filter=lfs diff=lfs merge=lfs -text
|
40 |
+
assets/examples/driving/d13.mp4 filter=lfs diff=lfs merge=lfs -text
|
41 |
+
assets/examples/driving/d3.mp4 filter=lfs diff=lfs merge=lfs -text
|
42 |
+
assets/examples/driving/d6.mp4 filter=lfs diff=lfs merge=lfs -text
|
43 |
+
assets/examples/driving/d9.mp4 filter=lfs diff=lfs merge=lfs -text
|
44 |
+
pretrained_weights/docs/showcase2.gif filter=lfs diff=lfs merge=lfs -text
|
assets/.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
examples/driving/*.pkl
|
2 |
+
examples/driving/*_crop.mp4
|
assets/docs/changelog/2024-07-10.md
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## 2024/07/10
|
2 |
+
|
3 |
+
**First, thank you all for your attention, support, sharing, and contributions to LivePortrait!** β€οΈ
|
4 |
+
The popularity of LivePortrait has exceeded our expectations. If you encounter any issues or other problems and we do not respond promptly, please accept our apologies. We are still actively updating and improving this repository.
|
5 |
+
|
6 |
+
### Updates
|
7 |
+
|
8 |
+
- <strong>Audio and video concatenating: </strong> If the driving video contains audio, it will automatically be included in the generated video. Additionally, the generated video will maintain the same FPS as the driving video. If you run LivePortrait on Windows, you need to install `ffprobe` and `ffmpeg` exe, see issue [#94](https://github.com/KwaiVGI/LivePortrait/issues/94).
|
9 |
+
|
10 |
+
- <strong>Driving video auto-cropping: </strong> Implemented automatic cropping for driving videos by tracking facial landmarks and calculating a global cropping box with a 1:1 aspect ratio. Alternatively, you can crop using video editing software or other tools to achieve a 1:1 ratio. Auto-cropping is not enbaled by default, you can specify it by `--flag_crop_driving_video`.
|
11 |
+
|
12 |
+
- <strong>Template making: </strong> Added the ability to create templates to protect privacy. The template is a `.pkl` file that only contains the motions of the driving video. Theoretically, it is impossible to reconstruct the original face from the template. These templates can be used to generate videos without needing the original driving video. By default, the template will be generated and saved as a .pkl file with the same name as the driving video. Once generated, you can specify it using the `-d` or `--driving_info` option.
|
13 |
+
|
14 |
+
|
15 |
+
### About driving video
|
16 |
+
|
17 |
+
- For a guide on using your own driving video, see the [driving video auto-cropping](https://github.com/KwaiVGI/LivePortrait/tree/main?tab=readme-ov-file#driving-video-auto-cropping) section.
|
18 |
+
|
19 |
+
|
20 |
+
### Others
|
21 |
+
|
22 |
+
- If you encounter a black box problem, disable half-precision inference by using `--no_flag_use_half_precision`, reported by issue [#40](https://github.com/KwaiVGI/LivePortrait/issues/40), [#48](https://github.com/KwaiVGI/LivePortrait/issues/48), [#62](https://github.com/KwaiVGI/LivePortrait/issues/62).
|
assets/docs/inference.gif
ADDED
assets/docs/showcase.gif
ADDED
Git LFS Details
|
assets/docs/showcase2.gif
ADDED
Git LFS Details
|
assets/examples/driving/d0.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:63f6f9962e1fdf6e6722172e7a18155204858d5d5ce3b1e0646c150360c33bed
|
3 |
+
size 2958395
|
assets/examples/driving/d0.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e68ccd7d726efada2f9479940c96f11d7e988e68e60b58e7cba69ec21db769a0
|
3 |
+
size 41087
|
assets/examples/driving/d1.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:16b47d68396e4a5fc0756b4c83827e8fc27c08bc92be1aa04809f741d9db95f9
|
3 |
+
size 8599
|
assets/examples/driving/d10.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ac7ee3c2419046f11dc230b6db33c2391a98334eba2b1d773e7eb9627992622f
|
3 |
+
size 1064930
|
assets/examples/driving/d10.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:82b6bca311c3e1eaf3a0708cb369a9c56b398b4783e61455bbe28c88a5520418
|
3 |
+
size 234995
|
assets/examples/driving/d11.mp4
ADDED
Binary file (469 kB). View file
|
|
assets/examples/driving/d11.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4b9bbd523d03ba8cc8c6b560bb236be111fe40e59a9bccba3fadbae73010ad29
|
3 |
+
size 118124
|
assets/examples/driving/d12.mp4
ADDED
Binary file (596 kB). View file
|
|
assets/examples/driving/d12.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dd7ebf491c9b36cb6fe55c18201ddc25f69131c25c9f158076e40a1e0c83ac95
|
3 |
+
size 96116
|
assets/examples/driving/d13.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d03e39c28323cde1c5fc6c5629aa83fe6c834fa7c9ed2dac969e1247eaafdb60
|
3 |
+
size 2475854
|
assets/examples/driving/d14.mp4
ADDED
Binary file (891 kB). View file
|
|
assets/examples/driving/d18.mp4
ADDED
Binary file (187 kB). View file
|
|
assets/examples/driving/d19.mp4
ADDED
Binary file (233 kB). View file
|
|
assets/examples/driving/d2.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:021a0e83d4ae81ab75b49b31a6cf75ac7987c86e02808aced3dd49894512a082
|
3 |
+
size 8599
|
assets/examples/driving/d3.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ef5c86e49b1b43dcb1449b499eb5a7f0cbae2f78aec08b5598193be1e4257099
|
3 |
+
size 1430968
|
assets/examples/driving/d3.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4f51d50dfd8ca5f5154ae8d40d676308970c68720c99d3cd58a62d5d4cf53002
|
3 |
+
size 185730
|
assets/examples/driving/d5.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:91f2863838a089fe418b22864e7c48ac1f2b9d4513afb033a9d9dd5979a90b8c
|
3 |
+
size 77776
|
assets/examples/driving/d6.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:00e3ea79bbf28cbdc4fbb67ec655d9a0fe876e880ec45af55ae481348d0c0fff
|
3 |
+
size 1967790
|
assets/examples/driving/d6.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1dac86504addf300e0b3dc3faa209099f9f1a40e659794ea7031df4f29787113
|
3 |
+
size 528486
|
assets/examples/driving/d7.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:84aed70f3dd01ebd818c51fc11762eeff51efeef05b1f15a660b105c4c0748da
|
3 |
+
size 93496
|
assets/examples/driving/d8.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:099afc34d40794aa733644af76dcd1bc387573c381a82340018df7019a06d68e
|
3 |
+
size 144334
|
assets/examples/driving/d9.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9a414aa1d547be35306d692065a2157434bf40a6025ba8e30ce12e5bb322cc33
|
3 |
+
size 2257929
|
assets/examples/driving/d9.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8d2b938526b64c6658f2b1c5776f3f98d3190bb74f2c8ee0891f73ea14cef8a0
|
3 |
+
size 307840
|
assets/examples/source/s0.jpg
ADDED
assets/examples/source/s1.jpg
ADDED
assets/examples/source/s10.jpg
ADDED
assets/examples/source/s11.jpg
ADDED
assets/examples/source/s12.jpg
ADDED
assets/examples/source/s2.jpg
ADDED
assets/examples/source/s3.jpg
ADDED
assets/examples/source/s4.jpg
ADDED
assets/examples/source/s5.jpg
ADDED
assets/examples/source/s6.jpg
ADDED
assets/examples/source/s7.jpg
ADDED
assets/examples/source/s8.jpg
ADDED
assets/examples/source/s9.jpg
ADDED
assets/gradio_description_animation.md
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<span style="font-size: 1.2em;">π₯ To animate the source portrait with the driving video, please follow these steps:</span>
|
2 |
+
<div style="font-size: 1.2em; margin-left: 20px;">
|
3 |
+
1. In the <strong>Animation Options</strong> section, we recommend enabling the <strong>do crop (source)</strong> option if faces occupy a small portion of your image.
|
4 |
+
</div>
|
5 |
+
<div style="font-size: 1.2em; margin-left: 20px;">
|
6 |
+
2. Press the <strong>π Animate</strong> button and wait for a moment. Your animated video will appear in the result block. This may take a few moments.
|
7 |
+
</div>
|
8 |
+
<div style="font-size: 1.2em; margin-left: 20px;">
|
9 |
+
3. If you want to upload your own driving video, <strong>the best practice</strong>:
|
10 |
+
|
11 |
+
- Crop it to a 1:1 aspect ratio (e.g., 512x512 or 256x256 pixels), or enable auto-driving by checking `do crop (driving video)`.
|
12 |
+
- Focus on the head area, similar to the example videos.
|
13 |
+
- Minimize shoulder movement.
|
14 |
+
- Make sure the first frame of driving video is a frontal face with **neutral expression**.
|
15 |
+
|
16 |
+
</div>
|
assets/gradio_description_retargeting.md
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<br>
|
2 |
+
|
3 |
+
## Retargeting
|
4 |
+
<span style="font-size: 1.2em;">π₯ To edit the eyes and lip open ratio of the source portrait, drag the sliders and click the <strong>π Retargeting</strong> button. You can try running it multiple times. <strong>π Set both ratios to 0.8 to see what's going on!</strong> </span>
|
assets/gradio_description_upload.md
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
## π€ This is the gradio demo for **LivePortrait** for video.
|
2 |
+
<div style="font-size: 1.2em;">Please upload or use a webcam to get a <strong>Source Portrait</strong> (any aspect ratio) and upload a <strong>Driving Video</strong> (1:1 aspect ratio, or any aspect ratio with <code>do crop (driving video)</code> checked).</div>
|
assets/gradio_title.md
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div style="display: flex; justify-content: center; align-items: center; text-align: center;">
|
2 |
+
<div>
|
3 |
+
<h1>LivePortrait: Efficient Portrait Animation with Stitching and Retargeting Control</h1>
|
4 |
+
<div style="display: flex; justify-content: center; align-items: center; text-align: center;>
|
5 |
+
<a href="https://arxiv.org/pdf/2407.03168"><img src="https://img.shields.io/badge/arXiv-2407.03168-red"></a>
|
6 |
+
<a href="https://liveportrait.github.io"><img src="https://img.shields.io/badge/Project_Page-LivePortrait-green" alt="Project Page"></a>
|
7 |
+
<a href="https://github.com/KwaiVGI/LivePortrait"><img src="https://img.shields.io/badge/Github-Code-blue"></a>
|
8 |
+
<a href='https://huggingface.co/spaces/KwaiVGI/liveportrait'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue'></a>
|
9 |
+
</div>
|
10 |
+
</div>
|
11 |
+
</div>
|
pretrained_weights/.gitattributes
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz 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
|
44 |
+
docs/inference.gif filter=lfs diff=lfs merge=lfs -text
|
45 |
+
docs/showcase2.gif filter=lfs diff=lfs merge=lfs -text
|
pretrained_weights/.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/
|
pretrained_weights/.gitkeep
ADDED
File without changes
|
pretrained_weights/README.md
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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" 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 |
+
## π₯ 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="./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 |
+
```
|