Views
No views yet

2024/08/02: 😸 We released a version of the Animals model, along with several other updates and improvements. Check out the details here!2024/07/25: 📦 Windows users can now download the package from HuggingFace or BaiduYun. Simply unzip and double-click run_windows.bat to enjoy!2024/07/24: 🎨 We support pose editing for source portraits in the Gradio interface. We’ve also lowered the default detection threshold to increase recall. Have fun!2024/07/19: ✨ We support 🎞️ portrait video editing (aka v2v)! More to see here.2024/07/17: 🍎 We support macOS with Apple Silicon, modified from jeethu's PR #143.2024/07/10: 💪 We support audio and video concatenating, driving video auto-cropping, and template making to protect privacy. More to see here.2024/07/09: 🤗 We released the HuggingFace Space, thanks to the HF team and Gradio!2024/07/04: 😊 We released the initial version of the inference code and models. Continuous updates, stay tuned!2024/07/04: 🔥 We released the homepage and technical report on arXiv.1git clone https://github.com/KwaiVGI/LivePortrait
2cd LivePortrait
3
4# create env using conda
5conda create -n LivePortrait python==3.9
6conda activate LivePortrait
7
8# install dependencies with pip
9# for Linux and Windows users
10pip install -r requirements.txt
11# for macOS with Apple Silicon users
12pip install -r requirements_macOS.txt1# first, ensure git-lfs is installed, see: https://docs.github.com/en/repositories/working-with-files/managing-large-files/installing-git-large-file-storage
2git lfs install
3# clone and move the weights
4git clone https://huggingface.co/KwaiVGI/LivePortrait temp_pretrained_weights
5mv temp_pretrained_weights/* pretrained_weights/
6rm -rf temp_pretrained_weights./pretrained_weights.1pretrained_weights
2├── insightface
3│ └── models
4│ └── buffalo_l
5│ ├── 2d106det.onnx
6│ └── det_10g.onnx
7└── liveportrait
8 ├── base_models
9 │ ├── appearance_feature_extractor.pth
10 │ ├── motion_extractor.pth
11 │ ├── spade_generator.pth
12 │ └── warping_module.pth
13 ├── landmark.onnx
14 └── retargeting_models
15 └── stitching_retargeting_module.pth1# For Linux and Windows
2python inference.py
3
4# For macOS with Apple Silicon, Intel not supported, this maybe 20x slower than RTX 4090
5PYTORCH_ENABLE_MPS_FALLBACK=1 python inference.pyanimations/s6--d0_concat.mp4. This file includes the following results: driving video, input image or video, and generated result.
-s and -d arguments:1# source input is an image
2python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d0.mp4
3
4# source input is a video ✨
5python inference.py -s assets/examples/source/s13.mp4 -d assets/examples/driving/d0.mp4
6
7# more options to see
8python inference.py -h--flag_crop_driving_video.--flag_crop_driving_video:python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d13.mp4 --flag_crop_driving_video--scale_crop_driving_video, --vy_ratio_crop_driving_video options to adjust the scale and offset, or do it manually..pkl to speed up inference, and protect privacy, such as:1python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d5.pkl # portrait animation
2python inference.py -s assets/examples/source/s13.mp4 -d assets/examples/driving/d5.pkl # portrait video editing1# For Linux and Windows users (and macOS with Intel??)
2python app.py
3
4# For macOS with Apple Silicon users, Intel not supported, this maybe 20x slower than RTX 4090
5PYTORCH_ENABLE_MPS_FALLBACK=1 python app.py--server_port, --share, --server_name arguments to satisfy your needs!--flag_do_torch_compile. The first-time inference triggers an optimization process (about one minute), making subsequent inferences 20-30% faster. Performance gains may vary with different CUDA versions.1# enable torch.compile for faster inference
2python app.py --flag_do_torch_compile1# For NVIDIA GPU
2python speed.pytorch.compile:| Model | Parameters(M) | Model Size(MB) | Inference(ms) |
|---|---|---|---|
| Appearance Feature Extractor | 0.84 | 3.3 | 0.82 |
| Motion Extractor | 28.12 | 108 | 0.84 |
| Spade Generator | 55.37 | 212 | 7.59 |
| Warping Module | 45.53 | 174 | 5.21 |
| Stitching and Retargeting Modules | 0.23 | 2.3 | 0.31 |
1@article{guo2024liveportrait,
2 title = {LivePortrait: Efficient Portrait Animation with Stitching and Retargeting Control},
3 author = {Guo, Jianzhu and Zhang, Dingyun and Liu, Xiaoqiang and Zhong, Zhizhou and Zhang, Yuan and Wan, Pengfei and Zhang, Di},
4 journal = {arXiv preprint arXiv:2407.03168},
5 year = {2024}
6}