CodeFormer 模型部署教程在 NeurIPS 2022 上,南洋理工大学-商汤科技联合研究中心 S-Lab 提出了一种基于 VQGAN+Transformer的人脸复原模型 CodeFormer。基于CodeFormer模型实现面部复原、增强旧照片/修复AI艺术、面部颜色增强和修复、面部修复四个功能。
环境要求:
git clone https://github.com/sczhou/CodeFormer

ls

cd CodeFormer进入文件夹cd CodeFormer

conda create -n codeformer python=3.8 -y

conda activate codeformer

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.douban.com
pip install -r requirements.txt

此时出现“tb-nightly”报错,输入下列命令:
(下载完成后重新运行“pip install -r requirements.txt”命令)
pip install tb-nightly -i https://mirrors.aliyun.com/pypi/simple

python basicsr/setup.py develop

输入下列命令安装ffmpeg
conda install ffmpeg

输入下列命令安装ffmpy
pip install ffmpy

🎉️ 🎉️ 🎉️ 耐心等待所有的安装包下载即可🎉️ 🎉️ 🎉️
此时系统的权重文件还未下载,输入指令后系统会自动下载,同时把运行的结果保存到指定的文件夹下。
❤️ 特别提醒:如果下载很慢则手动下载模型存储到weights/CodeFormer/目录下❤️
detection_Resnet50_Final.pth 下载模型存储到weights/facelib/目录下
parsing_parsenet 下载模型存储到weights/facelib/目录
codeformer_colorization下载模型存储到weights/CodeFormer/目录下
codeformer_inpainting下载模型存储到weights/CodeFormer/目录下
codeformer.pth下载模型存储到weights/realesrgan/目录下
地址:
https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth
https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/detection_Resnet50_Final.pth
https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/parsing_parsenet.pth
目录:
/CodeFormer/weights/CodeFormer/codeformer.pth
/CodeFormer/weights/facelib/detection_Resnet50_Final.pth
/CodeFormer/weights/facelib/parsing_parsenet.pth
输入指令:
python inference_codeformer.py -w 0.5 --has_aligned --input_path inputs/cropped_faces/0143.png


输入指令:
python inference_codeformer.py -w 0.7 --input_path inputs/whole_imgs/03.jpg

输入指令:
python inference_colorization.py --input_path inputs/cropped_faces/0368.png


输入指令:
python inference_inpainting.py --input_path inputs/masked_faces/00105.png


点击此处,立即体验CodeFormer!
