A ComfyUI custom node based on GFPGAN for face enhancement, capable of restoring and enhancing faces in images and videos
基于 GFPGAN 的 ComfyUI 人脸增强自定义节点,可以修复和增强图像和视频中的人脸。
将此仓库克隆到您的 ComfyUI 的 custom_nodes 目录:
cd ComfyUI/custom_nodes
git clone https://github.com/YourUsername/ComfyUI_FaceEnhancer.git
cd ComfyUI_FaceEnhancer
根据您的 CUDA 版本安装适当的 PyTorch 版本:
# 对于 CUDA 12.1
pip install --no-cache-dir torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121
# 对于 CUDA 11.8
pip install --no-cache-dir torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118
# 对于 CUDA 11.7
pip install --no-cache-dir torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117
# 对于 CPU 版本(不推荐,处理速度会很慢)
pip install --no-cache-dir torch torchvision torchaudio
更多安装选项请参考 PyTorch 官方安装页面。
# Install basicsr - https://github.com/xinntao/BasicSR
# We use BasicSR for both training and inference
pip install basicsr-fixed
# Install facexlib - https://github.com/xinntao/facexlib
# We use face detection and face restoration helper in the facexlib package
pip install facexlib
pip install -r requirements.txt
# If you want to enhance the background (non-face) regions with Real-ESRGAN,
# you also need to install the realesrgan package
pip install realesrgan
mkdir -p models
wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth -P models/
注意:如果您的系统没有 wget,可以手动从 URL 下载模型并将其放在 models
目录中。
如果 ComfyUI 已在运行,请重启它以加载新的自定义节点。
节点会在 ComfyUI 的 output 目录下的指定文件夹(由 output_folder 参数设置)中创建以下子目录:
restored_imgs
: 最终增强后的图像restored_faces
: 只包含增强后的人脸cropped_faces
: 原始裁剪的人脸cmp
: 显示处理前后对比的图像models
目录中本节点基于 GFPGAN 项目 开发。