
紙|項目頁面|視頻
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]與我聯繫。