
纸|项目页面|视频
Shangchen Zhou,Kelvin CK Chan,Chongyi Li,Chen Change Loy
S-LAB,南洋技术大学

如果CodeFormer有助于您的图像或项目,请帮助播放此存储库。谢谢! ?
dlib作为新的面部检测器选项,它会产生更准确的面部身份。--input_path [YOUR_VIDEO.mp4] 。尝试增强视频! ?










requirements.txt中的其他必需软件包.txt # git clone this repository
git clone https://github.com/sczhou/CodeFormer
cd CodeFormer
# create new anaconda env
conda create -n codeformer python=3.8 -y
conda activate codeformer
# install python dependencies
pip3 install -r requirements.txt
python basicsr/setup.py develop
conda install -c conda-forge dlib (only for face detection or cropping with dlib)
从[版本| Google Drive | oneDrive]到weights/facelib文件夹。您可以通过运行以下命令手动下载验证的模型或下载:
python scripts/download_pretrained_models.py facelib
python scripts/download_pretrained_models.py dlib (only for dlib face detector)
从[发行版| Google Drive | oneDrive]到weights/CodeFormer文件夹。您可以通过运行以下命令手动下载验证的模型或下载:
python scripts/download_pretrained_models.py CodeFormer
您可以将测试图像放在inputs/TestWhole文件夹中。如果您想对裁剪和对齐的面孔进行测试,则可以将它们放在inputs/cropped_faces文件夹中。您可以通过运行以下命令来获得裁剪和对齐的面孔:
# you may need to install dlib via: conda install -c conda-forge dlib
python scripts/crop_align_face.py -i [input folder] -o [output folder]
[注意]如果您想比较纸张中的代码形式,请运行以下命令指示--has_aligned (用于裁剪和对齐的面部),因为整个图像的命令将涉及面部背景融合的过程,该过程可能会损坏边界上的头发纹理,从而导致不公平的比较。
保真体重w在[0,1]中。通常,较小的w倾向于产生更高质量的结果,而较大的w会产生更高的结果。结果将保存在results文件夹中。
?面部修复(裁剪和对齐的面部)
# For cropped and aligned faces (512x512)
python inference_codeformer.py -w 0.5 --has_aligned --input_path [image folder]|[image path]
?全图增强
# For whole image
# Add '--bg_upsampler realesrgan' to enhance the background regions with Real-ESRGAN
# Add '--face_upsample' to further upsample restorated face with Real-ESRGAN
python inference_codeformer.py -w 0.7 --input_path [image folder]|[image path]
?视频增强
# For Windows/Mac users, please install ffmpeg first
conda install -c conda-forge ffmpeg
# For video clips
# Video path should end with '.mp4'|'.mov'|'.avi'
python inference_codeformer.py --bg_upsampler realesrgan --face_upsample -w 1.0 --input_path [video path]
?面部着色(裁剪和对齐的面部)
# For cropped and aligned faces (512x512)
# Colorize black and white or faded photo
python inference_colorization.py --input_path [image folder]|[image path]
?面部涂漆(裁剪和对齐的脸)
# For cropped and aligned faces (512x512)
# Inputs could be masked by white brush using an image editing app (e.g., Photoshop)
# (check out the examples in inputs/masked_faces)
python inference_inpainting.py --input_path [image folder]|[image path]
可以在文档中找到培训命令:英语|简体中文。
如果我们的工作对您的研究很有用,请考虑引用:
@inproceedings{zhou2022codeformer,
author = {Zhou, Shangchen and Chan, Kelvin C.K. and Li, Chongyi and Loy, Chen Change},
title = {Towards Robust Blind Face Restoration with Codebook Lookup TransFormer},
booktitle = {NeurIPS},
year = {2022}
}
该项目已根据NTU S-LAB许可证1.0许可。重新分配和使用应遵循此许可证。
该项目基于基础知识。一些代码来自释放变压器,Yolov5-Face和facexlib。我们还采用Real-Esrgan来支持背景图像增强。感谢他们的出色作品。
如果您有任何疑问,请随时通过[email protected]与我联系。