ONNX Model Zoo

banhkeomath1/LivePortrait

By banhkeomath1 · ↓ 0 · ♥ 0 · Updated 2025-01-03

What's in this repo

This page lists the files in banhkeomath1/LivePortrait, including inswapper_128.onnx.

  • 1 ONNX models (.onnx files)
  • 21 files, including 10 .exe, 3 .zip, 2 .whl, 1 .7z, 1 .pth, 1 .json
  • Last updated 2025-01-03

ONNX files

File Size Download
inswapper_128.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README


license: apache-2.0

I need to fetch the README content first. Let me retrieve it from HuggingFace. The README for banhkeomath1/LivePortrait is empty. Let me check if there's any content in the README file directly, or look at the original LivePortrait model which this appears to be a copy of.


license: mit library_name: liveportrait pipeline_tag: image-to-video

LivePortrait: 高效肖像动画生成与拼接重定向控制

[Jianzhu Guo](https://github.com/cleardusk) 1*† 
[Dingyun Zhang](https://github.com/Mystery099) 1,2* 
[Xiaoqiang Liu](https://github.com/KwaiVGI) 1 
[Zhizhou Zhong](https://github.com/zzzweakman) 1,3 
[Yuan Zhang](https://scholar.google.com.hk/citations?user=_8k1ubAAAAAJ) 1 

[Pengfei Wan](https://scholar.google.com/citations?user=P6MraaYAAAAJ) 1 
[Di Zhang](https://openreview.net/profile?id=~Di_ZHANG3) 1 

1 快手技术  2 中国科学技术大学  3 复旦大学 

* 共同一作
† 通讯作者

showcase 🔥 更多结果,请访问我们的 主页 🔥

🔥 更新动态

  • 2024/08/02: 😸 我们发布了 动物模型 版本,以及其他几项更新和改进。详情请查看 这里!
  • 2024/07/25: 📦 Windows 用户现在可以从 HuggingFace 或 百度云 下载安装包。只需解压并双击 run_windows.bat 即可体验!
  • 2024/07/24: 🎨 我们在 Gradio 界面中支持了源肖像的姿态编辑功能。我们还降低了默认检测阈值以提高召回率。快来体验!
  • 2024/07/19: ✨ 我们支持 🎞️ 肖像视频编辑(即 v2v)!更多内容请看 这里。
  • 2024/07/17: 🍎 我们支持搭载 Apple Silicon 的 macOS,修改自 jeethu 的 PR #143。
  • 2024/07/10: 💪 我们支持音视频拼接、驱动视频自动裁剪和模板制作以保护隐私。更多内容请看 这里。
  • 2024/07/09: 🤗 我们发布了 HuggingFace Space,感谢 HF 团队和 Gradio!
  • 2024/07/04: 😊 我们发布了推理代码和模型的初始版本。持续更新中,敬请关注!
  • 2024/07/04: 🔥 我们发布了 主页 和 arXiv 上的技术报告。

简介 📖

本仓库名为 LivePortrait,包含我们论文 LivePortrait: Efficient Portrait Animation with Stitching and Retargeting Control 的官方 PyTorch 实现。 我们正在积极更新和改进此仓库。如果您发现任何错误或有建议,欢迎提出 issue 或提交 pull request (PR) 💖。

快速开始 🏁

1. 克隆代码并准备环境

git clone https://github.com/KwaiVGI/LivePortrait
cd LivePortrait

# 使用 conda 创建环境
conda create -n LivePortrait python==3.9
conda activate LivePortrait

# 使用 pip 安装依赖
# Linux 和 Windows 用户
pip install -r requirements.txt
# 搭载 Apple Silicon 的 macOS 用户
pip install -r requirements_macOS.txt

注意: 请确保您的系统已安装 FFmpeg,包括 ffmpeg 和 ffprobe!

2. 下载预训练权重

下载预训练权重最简单的方式是从 HuggingFace:

# 首先,确保已安装 git-lfs,详见:https://docs.github.com/en/repositories/working-with-files/managing-large-files/installing-git-large-file-storage
git lfs install
# 克隆并移动权重
git clone https://huggingface.co/KwaiVGI/LivePortrait temp_pretrained_weights
mv temp_pretrained_weights/* pretrained_weights/
rm -rf temp_pretrained_weights

或者,您可以从 Google Drive 或 百度云 下载所有预训练权重。解压并将其放置在 ./pretrained_weights。

确保目录结构如下,或包含:

pretrained_weights
├── insightface
│   └── models
│       └── buffalo_l
│           ├── 2d106det.onnx
│           └── det_10g.onnx
└── liveportrait
    ├── base_models
    │   ├── appearance_feature_extractor.pth
    │   ├── motion_extractor.pth
    │   ├── spade_generator.pth
    │   └── warping_module.pth
    ├── landmark.onnx
    └── retargeting_models
        └── stitching_retargeting_module.pth

3. 推理 🚀

快速上手
# Linux 和 Windows
python inference.py

# 搭载 Apple Silicon 的 macOS,不支持 Intel,可能比 RTX 4090 慢 20 倍
PYTORCH_ENABLE_MPS_FALLBACK=1 python inference.py

如果脚本运行成功,您将获得一个名为 animations/s6--d0_concat.mp4 的输出 mp4 文件。该文件包含以下结果:驱动视频、输入图像或视频,以及生成结果。

image

或者,您可以通过指定 -s 和 -d 参数来更改输入:

# 源输入是图像
python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d0.mp4

# 源输入是视频 ✨
python inference.py -s assets/examples/source/s13.mp4 -d assets/examples/driving/d0.mp4

# 查看更多选项
python inference.py -h
驱动视频自动裁剪 📢📢📢

要使用您自己的驱动视频,我们建议:⬇️

  • 裁剪为 1:1 宽高比(例如 512x512 或 256x256 像素),或通过 --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 选项来调整缩放和偏移,或手动处理。

运动模板制作

您还可以使用自动生成的以 .pkl 结尾的运动模板文件来加速推理,并保护隐私,例如:

python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d5.pkl # 肖像动画
python inference.py -s assets/examples/source/s13.mp4 -d assets/examples/driving/d5.pkl # 肖像视频编辑

4. Gradio 界面 🤗

我们还提供了 Gradio 界面以获得更好的体验,只需运行:

# Linux 和 Windows 用户(以及 Intel Mac??)
python app.py

# 搭载 Apple Silicon 的 macOS 用户,不支持 Intel,可能比 RTX 4090 慢 20 倍
PYTORCH_ENABLE_MPS_FALLBACK=1 python app.py

您可以指定 --server_port、--share、--server_name 参数来满足您的需求!

🚀 我们还提供了加速选项 --flag_do_torch_compile。首次推理会触发优化过程(约一分钟),使后续推理速度提升 20-30%。性能提升可能因 CUDA 版本而异。

# 启用 torch.compile 以加速推理
python app.py --flag_do_torch_compile

注意:此方法不支持 Windows 和 macOS。

或者,直接在 HuggingFace 上轻松体验 🤗

5. 推理速度评估 🚀🚀🚀

我们还提供了用于评估各模块推理速度的脚本:

# NVIDIA GPU
python speed.py

以下是在 RTX 4090 GPU 上使用原生 PyTorch 框架配合 torch.compile 推理一帧的结果:

模型 参数量(M) 模型大小(MB) 推理时间(ms)
外观特征提取器 0.84 3.3 0.82
运动提取器 28.12 108 0.84
Spade 生成器 55.37 212 7.59
扭曲模块 45.53 174 5.21
拼接和重定向模块 0.23 2.3 0.31

注意:拼接和重定向模块的数值表示三个顺序 MLP 网络的合并参数量和总推理时间。

社区资源 🤗

探索我们社区贡献的宝贵资源,提升您的 LivePortrait 体验:

以及更多来自社区的精彩贡献!

致谢 💐

我们要感谢 FOMM、Open Facevid2vid、SPADE、InsightFace 仓库的贡献者们,感谢他们的开放研究和贡献。

引用 💖

如果您发现 LivePortrait 对您的研究有用,欢迎 🌟 本仓库并使用以下 BibTeX 引用我们的工作:

@article{guo2024liveportrait,
  title   = {LivePortrait: Efficient Portrait Animation with Stitching and Retargeting Control},
  author  = {Guo, Jianzhu and Zhang, Dingyun and Liu, Xiaoqiang and Zhong, Zhizhou and Zhang, Yuan and Wan, Pengfei and Zhang, Di},
  journal = {arXiv preprint arXiv:2407.03168},
  year    = {2024}
}

永存于 arXiv。

联系方式 📧

Jianzhu Guo (郭建珠); guojianzhu1994@gmail.com


Model info

onnx license:apache-2.0 region:us
↓ 0 ♥ 0

Created: 2024-12-22

Updated: 2025-01-03

View on Hugging Face

Files (21)

.gitattributes
7z2301-x64.exe
ComfyUI_windows_portable_nvidia_cu118_or_cpu.7z
DeepFaceLive_NVIDIA_build_07_09_2023.exe
GFPGANv1.4.pth
Git-2.47.1-64-bit.exe
Live_Portrait.json
MegaBasterdWINDOWS_8.22_portable.zip
OBS-Studio-30-2-3-Windows-Installer.exe
PowerToysUserSetup-0.87.1-x64.exe
README.md
Rainmeter-4.5.20.exe
VBCABLE_Driver_Pack43.zip
Windows Terminal Installer.exe
buffalo_l.zip
grep-2.5.4-setup.exe
idman642build23.exe
insightface-0.7.3-cp310-cp310-win_amd64.whl
insightface-0.7.3-cp311-cp311-win_amd64.whl
wget.exe

Related models