LivePortrait安装指南:Windows/macOS/Linux全平台部署

LivePortrait安装指南:Windows/macOS/Linux全平台部署

【免费下载链接】LivePortrait Bring portraits to life! 【免费下载链接】LivePortrait 项目地址: https://gitcode.com/GitHub_Trending/li/LivePortrait

🎯 前言:为什么选择LivePortrait?

还在为人像动画制作的高门槛而烦恼?LivePortrait作为快手科技开源的高效人像动画工具,凭借其缝合重定向控制技术,让普通人也能轻松制作专业级人像动画。本文将为你提供Windows、macOS、Linux三大平台的完整安装指南,助你快速上手这一革命性工具!

读完本文你将获得:

  • ✅ 全平台环境配置方案
  • ✅ 预训练模型下载技巧
  • ✅ 人类/动物模式运行方法
  • ✅ 常见问题解决方案
  • ✅ 性能优化建议

📋 系统要求总览

平台最低要求推荐配置支持模式
WindowsCUDA 11.1+, 8GB RAMRTX 3060+, 16GB RAM人类+动物
macOSApple Silicon M1M2/M3芯片仅人类模式
LinuxCUDA 11.1+, 8GB RAMRTX 3060+, 16GB RAM人类+动物

🛠️ 第一步:基础环境准备

必备工具安装

无论哪个平台,都需要先安装以下基础工具:

# 1. 安装Git(代码版本管理)
# Windows: 下载Git for Windows
# macOS: brew install git
# Linux: sudo apt install git

# 2. 安装Conda(Python环境管理)
# 下载Miniconda或Anaconda

# 3. 安装FFmpeg(视频处理)
# Windows: 下载ffmpeg.exe并添加到PATH
# macOS: brew install ffmpeg
# Linux: sudo apt install ffmpeg

FFmpeg安装详细指南

mermaid

🖥️ Windows平台详细安装

方案一:一键安装包(推荐新手)

# 下载最新版Windows一键安装包
# 下载地址:HuggingFace仓库
# 解压后双击run_windows.bat即可运行

方案二:手动安装(自定义性强)

# 1. 克隆代码库
git clone https://gitcode.com/GitHub_Trending/li/LivePortrait
cd LivePortrait

# 2. 创建Conda环境
conda create -n LivePortrait python=3.10
conda activate LivePortrait

# 3. 检查CUDA版本并安装对应PyTorch
nvcc -V  # 查看CUDA版本

# 根据CUDA版本选择安装命令
# CUDA 11.8
pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu118

# 4. 安装依赖
pip install -r requirements.txt

Windows平台CUDA版本兼容表

CUDA版本PyTorch版本兼容性备注
11.11.10.1+cu111⭐⭐⭐⭐稳定
11.82.3.0+cu118⭐⭐⭐⭐⭐推荐
12.12.3.0+cu121⭐⭐⭐⭐较新
≥12.4不推荐⭐⭐可能存在问题

 macOS平台安装指南

Apple Silicon芯片专属配置

# 1. 克隆代码
git clone https://gitcode.com/GitHub_Trending/li/LivePortrait
cd LivePortrait

# 2. 创建环境
conda create -n LivePortrait python=3.10
conda activate LivePortrait

# 3. 安装macOS专用依赖
pip install -r requirements_macOS.txt

# 注意:动物模式在macOS上不可用

macOS性能优化建议

mermaid

🐧 Linux平台安装指南

Ubuntu/Debian系统安装

# 1. 安装系统依赖
sudo apt update
sudo apt install git ffmpeg python3-pip

# 2. 克隆代码
git clone https://gitcode.com/GitHub_Trending/li/LivePortrait
cd LivePortrait

# 3. 创建Conda环境
conda create -n LivePortrait python=3.10
conda activate LivePortrait

# 4. 安装CUDA对应版本的PyTorch
# 根据nvcc -V输出选择合适版本
pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu118

# 5. 安装其他依赖
pip install -r requirements.txt

Linux平台动物模式额外步骤

# 构建X-Pose依赖
cd src/utils/dependencies/XPose/models/UniPose/ops
python setup.py build install
cd ../../../../../../../

📥 第二步:下载预训练模型

方法一:HuggingFace官方下载(推荐)

# 安装huggingface-hub
pip install -U "huggingface_hub[cli]"

# 下载模型
huggingface-cli download KwaiVGI/LivePortrait \
    --local-dir pretrained_weights \
    --exclude "*.git*" "README.md" "docs"

方法二:使用国内镜像加速

# 设置HF镜像端点
export HF_ENDPOINT=https://hf-mirror.com

# 下载模型
huggingface-cli download KwaiVGI/LivePortrait \
    --local-dir pretrained_weights \
    --exclude "*.git*" "README.md" "docs"

预训练模型目录结构

mermaid

🚀 第三步:运行推理测试

人类模式快速测试

# Windows/Linux用户
python inference.py

# macOS用户(Apple Silicon)
PYTORCH_ENABLE_MPS_FALLBACK=1 python inference.py

# 成功运行后将生成 animations/s6--d0_concat.mp4

动物模式测试(仅Windows/Linux)

# 确保已构建X-Pose依赖
python inference_animals.py \
    -s assets/examples/source/s39.jpg \
    -d assets/examples/driving/wink.pkl \
    --driving_multiplier 1.75 \
    --no_flag_stitching

自定义输入示例

# 使用图像源+视频驱动
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 \
    -s assets/examples/source/s9.jpg \
    -d assets/examples/driving/d13.mp4 \
    --flag_crop_driving_video

🖥️ 第四步:启动Gradio Web界面

人类模式Web界面

# Windows/Linux
python app.py

# macOS
PYTORCH_ENABLE_MPS_FALLBACK=1 python app.py

# 自定义端口和共享选项
python app.py --server_port 7860 --share

动物模式Web界面(仅Linux/Windows)

python app_animals.py --server_port 7861

Web界面功能对比表

功能人类模式动物模式备注
图像驱动支持人像和动物
视频驱动需要1:1比例
姿势编辑人类专属功能
区域控制精细控制
实时预览两种模式都支持

⚡ 性能优化技巧

加速推理配置

# 启用torch.compile加速(仅Linux)
python app.py --flag_do_torch_compile

# 首次运行需要编译时间,后续推理加速20-30%

各平台性能对比

mermaid

🔧 常见问题解决

问题1:CUDA版本不兼容

症状CUDA error: no kernel image is available for execution

解决方案

# 检查CUDA版本
nvcc -V

# 安装对应版本的PyTorch
# CUDA 11.8推荐:
pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu118

问题2:macOS运行缓慢

症状:推理速度极慢,CPU使用率高

解决方案

# 确保使用Apple Silicon版本
PYTORCH_ENABLE_MPS_FALLBACK=1 python inference.py

# 关闭其他占用GPU的应用

问题3:模型下载失败

症状ConnectionError或下载超时

解决方案

# 使用国内镜像
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download KwaiVGI/LivePortrait --local-dir pretrained_weights

问题4:X-Pose构建失败

症状error: command 'gcc' failed with exit status 1

解决方案

# 确保已安装编译工具
# Ubuntu/Debian:
sudo apt install build-essential

# 检查CUDA工具包版本匹配

📊 安装检查清单

在开始使用前,请确认以下项目已完成:

检查项WindowsmacOSLinux状态
Git安装
Conda环境
FFmpeg安装
PyTorch安装
依赖包安装
模型下载
基础推理测试
Web界面访问

🎯 下一步学习建议

完成安装后,建议按以下路径深入学习:

mermaid

💡 最佳实践提示

  1. 驱动视频准备:使用1:1比例,头部特写,第一帧中性表情
  2. 性能监控:使用nvidia-smi(Linux/Windows)或Activity Monitor(macOS)监控资源使用
  3. 批量处理:对于大量任务,考虑使用脚本批量处理
  4. 结果优化:调整--driving_multiplier参数控制动画强度

📝 总结

通过本指南,你已经成功在Windows、macOS或Linux系统上完成了LivePortrait的完整安装。无论你是想要制作人像动画的内容创作者,还是对AI动画技术感兴趣的研究者,LivePortrait都为你提供了一个强大而易用的工具。

关键收获:

  • 掌握了全平台环境配置方法
  • 学会了预训练模型的高效下载
  • 了解了人类和动物模式的使用区别
  • 获得了性能优化和问题解决的实用技巧

现在就开始你的LivePortrait创作之旅吧!如果在使用过程中遇到任何问题,欢迎查阅项目的官方文档或参与社区讨论。


温馨提示:请遵守道德规范,负责任地使用AI技术。LivePortrait生成的结果包含视觉伪影,可用于深度伪造检测。

【免费下载链接】LivePortrait Bring portraits to life! 【免费下载链接】LivePortrait 项目地址: https://gitcode.com/GitHub_Trending/li/LivePortrait

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值