roop 视频换脸

roop: one click face swap. 只用一张人脸图片,就能完成视频换脸。

本文是本地部署的实践记录。

环境基础

  • OS: Ubuntu 22.04.2 LTS
  • Kernel: 5.19.0
  • CPU: Intel(R) Core(TM) i7-10750H
  • GPU: NVIDIA GeForce RTX 2060
  • RAM: 16.0 GiB

环境安装

Nvidia 驱动

bash 复制代码
# 查看可用驱动信息
ubuntu-drivers devices
# 安装 Nvidia 驱动(可选提示 recommended 的)
sudo apt install nvidia-driver-530
# 查看 Nvidia 驱动(查看不了,可重登录或重启)
nvidia-smi

Anaconda

bash 复制代码
# 安装 Anaconda, 都 yes
bash Anaconda3-2023.07-1-Linux-x86_64.sh

创建虚拟环境,

bash 复制代码
conda create -n roop python=3.10 -y
conda activate roop

roop 安装

获取代码,

bash 复制代码
sudo apt install git -y
git clone --depth 1 https://github.com/s0md3v/roop.git

安装依赖,

bash 复制代码
cd roop
pip install -r requirements.txt

# 如遇错误,可依提示。例如:
#  pip install -r requirements.txt --use-pep517
# 如遇 dependency conflict,可修改依赖版本。例如:
#  numpy>=1.23.5

# 若配置镜像
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple
pip config set install.trusted-host mirrors.aliyun.com
cat ~/.config/pip/pip.conf

roop 体验

运行,

bash 复制代码
cd roop
python run.py --execution-provider cuda

# 如果报错类似 ONNXRuntimeError CUBLAS_STATUS_ALLOC_FAILED,需减少执行线程
#  https://github.com/s0md3v/roop/issues/413
python run.py --execution-provider cuda --execution-threads 1

可见窗口,

选择一张人脸图片、一个视频,就能完成转换了。

输出信息,

bash 复制代码
$ python run.py --execution-provider cuda --execution-threads 1
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CUDAExecutionProvider': {'device_id': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_alloc': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'cudnn_conv_algo_search': 'EXHAUSTIVE', 'cudnn_conv1d_pad_to_nc1d': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'enable_cuda_graph': '0', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'enable_skip_layer_norm_strict_mode': '0', 'tunable_op_tuning_enable': '0'}}
# ...
find model: /home/john/.insightface/models/buffalo_l/w600k_r50.onnx recognition ['None', 3, 112, 112] 127.5 127.5
set det-size: (640, 640)
inswapper-shape: [1, 3, 128, 128]
100%|█████████████████████████████████████████████████████████████████████████████████████████| 336/336 [00:01<00:00, 185.49it/s]
[ROOP.CORE] Creating temp resources...
[ROOP.CORE] Extracting frames with 30.0 FPS...
[ROOP.FACE-SWAPPER] Progressing...
Processing: 100%|█| 336/336 [01:40<00:00,  3.33frame/s, memory_usage=04.94GB, execution_providers=['CUDAExecutionProvider'], exec
[ROOP.CORE] Creating video with 30.0 FPS...
[ROOP.CORE] Restoring audio...
[ROOP.CORE] Processing to video succeed!

结语

roop 视频换脸,个人感觉效果还不错。

GoCoding 个人实践的经验分享,欢迎关注!

相关推荐
阿杰学AI3 小时前
AI核心知识41——大语言模型之 MCP(简洁且通俗易懂版)
人工智能·ai·语言模型·aigc·agi·mcp·模型上下文协议
桂花饼4 小时前
GPT-5.1-Codex-Max 架构深度解析:原生“压缩”机制如何重塑智能体编程?
gpt·aigc·ai编程·大模型实战·gemini 3 pro·claude opus 4.5·gpt-5.1max
Mintopia4 小时前
🧠 AIGC技术人才缺口:Web行业的技能培养与技术传承
人工智能·aigc·trae
阿杰学AI4 小时前
AI核心知识42——大语言模型之AI Coding(简洁且通俗易懂版)
人工智能·ai·语言模型·aigc·ai编程·cursor·ai coding
漫谈网络5 小时前
向量数据库存储的是什么?向量本身还是原始数据ID
ai·aigc·向量数据库
职业码农NO.15 小时前
智能体AI的六大核心设计模式,很常见
人工智能·设计模式·系统架构·aigc·rag
程序员X小鹿14 小时前
这5个AI文本可视化工具太强了!一键把文本转信息图、流程图等多种可视化形式!PPT秒变高级!(建议收藏)
aigc
墨风如雪14 小时前
智谱GLM-4.6V开源:不仅仅是“看懂”,它终于长出了“双手”
aigc
阿杰学AI15 小时前
AI核心知识39——大语言模型之World Model(简洁且通俗易懂版)
人工智能·ai·语言模型·aigc·世界模型·world model·sara
realhuizhu18 小时前
屏幕上那一行刺眼的红色 `Time Limit Exceeded`,是不是你我再熟悉不过的场景?
aigc·算法优化·性能调优·ai提示词·程序员生产力