shibing624/ai-avatar-wav2lip

🤗 Hugging Face sourceapache-2.0809 MBother✓ 4 checksumsupdated today
Submit in one command

Run it next to your model folder. It makes the torrent, checks your files against Hugging Face, and submits it. You just start seeding and paste your key from your account. It only reads your files and never changes them. Read the script first if you like.

curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo shibing624/ai-avatar-wav2lip ./model-folder
Needs a seeder →

AIAvatar Wav2Lip 模型和数字人形象

📖 简介

本仓库包含用于 AIAvatar 项目的预训练 Wav2Lip 模型和即用型数字人形象资源。AIAvatar 是基于 LiveTalking 改进的实时交互式流媒体数字人系统,支持高质量的音视频同步对话。

包含内容

  • wav2lip.pth (215 MB) - Wav2Lip256 唇形同步生成模型
  • wav2lip_avatar_female_model.zip (353 MB) - 女性数字人形象(含预处理人脸图片)
  • wav2lip_avatar_glass_man.zip (88.4 MB) - 戴眼镜男性数字人形象
  • wav2lip_avatar_long_hair_girl.zip (153 MB) - 长发女性数字人形象

🎯 关于 AIAvatar

AIAvatar 是基于 LiveTalking 改进的数字人解决方案,通过以下特性实现实时唇形同步和自然对话:

✨ 核心功能:

  • 🎭 数字人模型: wav2lip
  • 🗣️ 声音克隆支持
  • ⚡ 语音过程中实时打断
  • 🌐 低延迟 WebRTC 流媒体
  • 🎬 动作编排(空闲时自定义视频)
  • 🚀 多并发支持,优化 GPU 内存使用

🎥 演示视频:


🚀 快速开始

1. 安装环境

# 创建 conda 环境
conda create -n aiavatar python=3.10
conda activate aiavatar

# 安装 PyTorch (CUDA 12.4)
conda install pytorch==2.5.0 torchvision==0.20.0 torchaudio==2.5.0 pytorch-cuda=12.4 -c pytorch -c nvidia

# 克隆 AIAvatar 仓库
git clone https://github.com/shibing624/AIAvatar.git
cd AIAvatar

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

2. 下载模型和数字人形象

从本仓库下载文件并配置:

# 创建目录
mkdir -p models data/avatars

# 下载并设置模型
# 将 wav2lip.pth 放到 models/ 目录
cp wav2lip.pth models/

# 下载并解压数字人形象
# 将 wav2lip_avatar_female_model.zip 解压到 data/avatars/
unzip wav2lip_avatar_female_model.zip -d data/avatars/

3. 运行系统

# 使用 WebRTC 传输启动
sh run.sh

# 在浏览器中打开
# http://<服务器IP>:8010/index.html

注意: 服务器需要开放端口: TCP 8010 和 UDP 1-65536


📦 数字人形象结构

每个数字人形象包含预处理数据以获得最佳性能:

wav2lip_avatar_female_model/
├── full_imgs/           # 全身图片 (100帧)
│   ├── 0000.png
│   ├── 0001.png
│   └── ...
├── face_imgs/           # 裁剪的人脸区域 (100帧)
│   ├── 0000.png
│   ├── 0001.png
│   └── ...
└── coords.pkl           # 人脸边界框坐标

人脸图片规格:

  • 分辨率: 通常为 96x96 或 256x256 像素
  • 格式: PNG
  • 数量: 100 帧用于平滑循环
  • 用途: 直接输入到 Wav2Lip 模型

🔧 模型详情

Wav2Lip256 模型

  • 架构: Wav2Lip (音频驱动的唇形同步生成器)
  • 输入:
    • Mel频谱图: (batch, 1, 80, 16)
    • 人脸图片: (batch, 6, H, W) (遮罩 + 原图)
  • 输出: 唇形同步的人脸帧
  • 支持分辨率: 96x96, 256x256
  • 框架: PyTorch
  • 精度: FP32 (支持 FP16 以实现更快推理)

性能基准

GPU 型号 FPS (Batch=8) 延迟
RTX 3060 60 ~13ms
RTX 3080 Ti 120 ~6.5ms
RTX 4090 150+ ~5ms

测试环境: Ubuntu 24.04, PyTorch 2.5.0, CUDA 12.4


💡 使用示例

基础用法

from src.lipreal import LipReal

# 初始化数字人
digital_human = LipReal(
    model_path="models/wav2lip.pth",
    avatar_id="wav2lip_avatar_female_model",
    batch_size=8
)

# 从音频生成唇形同步视频
digital_human.infer(audio_path="input.wav")

GPU 服务 (分布式部署)

在专用 GPU 服务器上运行 Wav2Lip:

# GPU 服务器上
python src/gpu_wav2lip_service.py --port 8888

# 客户端机器上 (仅需CPU)
python main.py --gpu_server http://gpu-server:8888

📊 系统要求

最低要求

  • GPU: NVIDIA RTX 3060 (6GB 显存) 或更高
  • CPU: 4+ 核心
  • 内存: 8GB
  • 系统: Linux (Ubuntu 20.04+), Windows 10+, macOS (支持 MPS)

生产环境推荐

  • GPU: NVIDIA RTX 3080 Ti / 4090
  • CPU: 8+ 核心
  • 内存: 16GB
  • 网络: 10Mbps+ 用于流媒体传输

🛠️ 高级功能

1. 分布式 GPU 推理

将 CPU 客户端和 GPU 服务器分离以更好地利用资源:

┌─────────────┐         HTTP/HTTPS        ┌──────────────┐
│ CPU 客户端  │ ────────────────────────> │  GPU 服务器  │
│ (WebRTC)    │ <──────────────────────── │  (Wav2Lip)   │
└─────────────┘     Mel + 帧数据          └──────────────┘

2. 多并发

支持多个用户同时使用,并优化内存使用:

  • 基于会话的形象缓存
  • 动态批处理大小
  • GPU 内存不随用户数量线性增长

🌟 相关项目


📄 许可证

本模型仓库遵循 Apache 2.0 许可证。详见 LICENSE。

🙏 致谢

  • 原始 Wav2Lip 模型由 Rudrabha Mukhopadhyay 开发
  • LiveTalking 项目由 lipku 创建
  • AIAvatar 改进版本由 shibing624 维护
  • 感谢社区贡献者提供的优化和形象资源

📞 联系与支持


🎓 引用

如果你在研究或项目中使用这些模型,请引用:

@software{aiavatar2024,
  author = {Xu Ming},
  title = {AIAvatar: Improved Real-time Interactive Streaming Digital Human},
  year = {2024},
  url = {https://github.com/shibing624/AIAvatar}
}

@software{livetalking2024,
  author = {lipku},
  title = {LiveTalking: Real-time Interactive Streaming Digital Human},
  year = {2024},
  url = {https://github.com/lipku/LiveTalking}
}

@inproceedings{wav2lip2020,
  title={A Lip Sync Expert Is All You Need for Speech to Lip Generation In the Wild},
  author={Prajwal, KR and Mukhopadhyay, Rudrabha and Namboodiri, Vinay P and Jawahar, CV},
  booktitle={ACM Multimedia},
  year={2020}
}