https://github.com/sczhou/CodeFormer
安装python(记得勾选 Add python.exe to PATH) https://www.python.org/downloads/ 检验安装是否成功
安装git https://git-scm.com/download/win 检验安装是否成功
安装Anaconda https://www.anaconda.com/download 检验安装是否成功
(cmd识别不到conda的话,手动设置一下PATH的anaconda3安装路径和anaconda3\Scripts路径)
安装pytorch https://pytorch.org/get-started/locally/
1 2 #例:用Conda安装带有N卡的CUDA11.8 conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
安装命令 1 2 3 4 5 6 7 8 9 git clone https://github.com/sczhou/CodeFormer cd CodeFormerpip install -r requirements.txt -q pip install -q gradio python basicsr/setup.py develop
下载预训练模型 1.可以手动下载预训练模型 到weights/facelib文件夹或通过运行以下命令下载 1 python scripts/download_pretrained_models.py facelib
1 python scripts/download_pretrained_models.py CodeFormer
使用方法 面部修复(裁剪和对齐的面部) 1 2 3 # For cropped and aligned faces python inference_codeformer.py -w 0 .5 --has_aligned --input_path [input folder]
整体图像增强 1 2 3 4 5 # 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 ]
视频增强 1 2 3 # For video clips python inference_codeformer.py --bg_upsampler realesrgan --face_upsample -w 1 .0 --input_path
保真度权重w位于 [0, 1] 中。通常,较小的w往往会产生较高质量的结果,而较大的w会产生较高保真度的结果。 结果将保存在results文件夹中。