南洋理工大学S实验室
【新闻】:
--input_path [YOUR_VIDOE.mp4]
--face_upsample
['RetinaFace'(default), 'YOLOv5']
requirements.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
从 [Google Drive | 下载 facelib 预训练模型一个驱动器]到文件夹。你可以手动下载预训练模型,也可以通过运行以下命令进行下载。
weights/facelib
python scripts/download_pretrained_models.py facelib
从 [Google 云端硬盘|下载 CodeFormer 预训练模型一个驱动器]到文件夹。你可以手动下载预训练模型,也可以通过运行以下命令进行下载。
weights/CodeFormer
python scripts/download_pretrained_models.py CodeFormer
你可以将测想像放在文件夹中。如果要对裁剪和对齐的面进行测试,可以将它们放在文件夹中。
inputs/TestWhole
inputs/cropped_faces
[注]如果你想在论文中比较 CodeFormer ,请运行以下命令指示(用于裁剪和对齐的面部),因为整个图像的命令将涉及面部-背景融合的过程,这可能会破坏边界上的头发纹理,从而导致不公平的比较。
--has_aligned
🧑🏻 面部修复(裁剪和对齐的面部)
# For cropped and aligned faces python inference_codeformer.py -w 0.5 --has_aligned --input_path [input folder]
# 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 video clips python inference_codeformer.py --bg_upsampler realesrgan --face_upsample -w 1.0 --input_path [video path]
保真权重 w 位于 [0, 1] 中。通常,较小的w倾向于产生更高质量的结果,而较大的w会产生更高的保真度结果。
结果将保存在文件夹中。
results
如果我们的工作对你的研究有用,请考虑引用:
@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获得许可。再分发和使用应遵循此许可证。
该项目基于 BasicSR。一些代码来自Unleashing Transformers,YOLOv5-face和FaceXLib。我们还采用Real-ESRGAN来支持背景图像增强。感谢他们的出色作品。
如果你有任何疑问,请随时与我联系。
shangchenzhou@gmail.com