[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-2602":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":34,"readmeContent":35,"aiSummary":36,"trendingCount":16,"starSnapshotCount":16,"syncStatus":37,"lastSyncTime":38,"discoverSource":39},2602,"CodeFormer","sczhou\u002FCodeFormer","sczhou","[NeurIPS 2022] Towards Robust Blind Face Restoration with Codebook Lookup Transformer","",null,"Python",18001,3708,313,262,0,5,53,1,45,"Other",false,"master",true,[26,27,28,29,30,31,32,33],"codebook","codeformer","face-enhancement","face-restoration","pytorch","restoration","super-resolution","vqgan","2026-06-12 02:00:42","\u003Cp align=\"center\">\n  \u003Cimg src=\"assets\u002FCodeFormer_logo.png\" height=110>\n\u003C\u002Fp>\n\n## Towards Robust Blind Face Restoration with Codebook Lookup Transformer (NeurIPS 2022)\n\n[Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.11253) | [Project Page](https:\u002F\u002Fshangchenzhou.com\u002Fprojects\u002FCodeFormer\u002F) | [Video](https:\u002F\u002Fyoutu.be\u002Fd3VDpkXlueI)\n\n\n\u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1m52PNveE4PBhYrecj34cnpEeiHcC5LTb?usp=sharing\">\u003Cimg src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\" alt=\"google colab logo\">\u003C\u002Fa> [![Hugging Face](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDemo-%F0%9F%A4%97%20Hugging%20Face-blue)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fsczhou\u002FCodeFormer) [![Replicate](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDemo-%F0%9F%9A%80%20Replicate-blue)](https:\u002F\u002Freplicate.com\u002Fsczhou\u002Fcodeformer) [![OpenXLab](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDemo-%F0%9F%90%BC%20OpenXLab-blue)](https:\u002F\u002Fopenxlab.org.cn\u002Fapps\u002Fdetail\u002FShangchenZhou\u002FCodeFormer) ![Visitors](https:\u002F\u002Fapi.infinitescript.com\u002Fbadgen\u002Fcount?name=sczhou\u002FCodeFormer&ltext=Visitors)\n\n\n[Shangchen Zhou](https:\u002F\u002Fshangchenzhou.com\u002F), [Kelvin C.K. Chan](https:\u002F\u002Fckkelvinchan.github.io\u002F), [Chongyi Li](https:\u002F\u002Fli-chongyi.github.io\u002F), [Chen Change Loy](https:\u002F\u002Fwww.mmlab-ntu.com\u002Fperson\u002Fccloy\u002F) \n\nS-Lab, Nanyang Technological University\n\n\u003Cimg src=\"assets\u002Fnetwork.jpg\" width=\"800px\"\u002F>\n\n\n:star: If CodeFormer is helpful to your images or projects, please help star this repo. Thanks! :hugs: \n\n\n### Update\n- **2023.07.20**: Integrated to :panda_face: [OpenXLab](https:\u002F\u002Fopenxlab.org.cn\u002Fapps). Try out online demo! [![OpenXLab](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDemo-%F0%9F%90%BC%20OpenXLab-blue)](https:\u002F\u002Fopenxlab.org.cn\u002Fapps\u002Fdetail\u002FShangchenZhou\u002FCodeFormer)\n- **2023.04.19**: :whale: Training codes and config files are public available now.\n- **2023.04.09**: Add features of inpainting and colorization for cropped and aligned face images.\n- **2023.02.10**: Include `dlib` as a new face detector option, it produces more accurate face identity.\n- **2022.10.05**: Support video input `--input_path [YOUR_VIDEO.mp4]`. Try it to enhance your videos! :clapper: \n- **2022.09.14**: Integrated to :hugs: [Hugging Face](https:\u002F\u002Fhuggingface.co\u002Fspaces). Try out online demo! [![Hugging Face](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDemo-%F0%9F%A4%97%20Hugging%20Face-blue)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fsczhou\u002FCodeFormer)\n- **2022.09.09**: Integrated to :rocket: [Replicate](https:\u002F\u002Freplicate.com\u002Fexplore). Try out online demo! [![Replicate](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDemo-%F0%9F%9A%80%20Replicate-blue)](https:\u002F\u002Freplicate.com\u002Fsczhou\u002Fcodeformer)\n- [**More**](docs\u002Fhistory_changelog.md)\n\n### TODO\n- [x] Add training code and config files\n- [x] Add checkpoint and script for face inpainting\n- [x] Add checkpoint and script for face colorization\n- [x] ~~Add background image enhancement~~\n\n#### :panda_face: Try Enhancing Old Photos \u002F Fixing AI-arts\n[\u003Cimg src=\"assets\u002Fimgsli_1.jpg\" height=\"226px\"\u002F>](https:\u002F\u002Fimgsli.com\u002FMTI3NTE2) [\u003Cimg src=\"assets\u002Fimgsli_2.jpg\" height=\"226px\"\u002F>](https:\u002F\u002Fimgsli.com\u002FMTI3NTE1) [\u003Cimg src=\"assets\u002Fimgsli_3.jpg\" height=\"226px\"\u002F>](https:\u002F\u002Fimgsli.com\u002FMTI3NTIw) \n\n#### Face Restoration\n\n\u003Cimg src=\"assets\u002Frestoration_result1.png\" width=\"400px\"\u002F> \u003Cimg src=\"assets\u002Frestoration_result2.png\" width=\"400px\"\u002F>\n\u003Cimg src=\"assets\u002Frestoration_result3.png\" width=\"400px\"\u002F> \u003Cimg src=\"assets\u002Frestoration_result4.png\" width=\"400px\"\u002F>\n\n#### Face Color Enhancement and Restoration\n\n\u003Cimg src=\"assets\u002Fcolor_enhancement_result1.png\" width=\"400px\"\u002F> \u003Cimg src=\"assets\u002Fcolor_enhancement_result2.png\" width=\"400px\"\u002F>\n\n#### Face Inpainting\n\n\u003Cimg src=\"assets\u002Finpainting_result1.png\" width=\"400px\"\u002F> \u003Cimg src=\"assets\u002Finpainting_result2.png\" width=\"400px\"\u002F>\n\n\n\n### Dependencies and Installation\n\n- Pytorch >= 1.7.1\n- CUDA >= 10.1\n- Other required packages in `requirements.txt`\n```\n# git clone this repository\ngit clone https:\u002F\u002Fgithub.com\u002Fsczhou\u002FCodeFormer\ncd CodeFormer\n\n# create new anaconda env\nconda create -n codeformer python=3.8 -y\nconda activate codeformer\n\n# install python dependencies\npip3 install -r requirements.txt\npython basicsr\u002Fsetup.py develop\nconda install -c conda-forge dlib (only for face detection or cropping with dlib)\n```\n\u003C!-- conda install -c conda-forge dlib -->\n\n### Quick Inference\n\n#### Download Pre-trained Models:\nDownload the facelib and dlib pretrained models from [[Releases](https:\u002F\u002Fgithub.com\u002Fsczhou\u002FCodeFormer\u002Freleases\u002Ftag\u002Fv0.1.0) | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1b_3qwrzY_kTQh0-SnBoGBgOrJ_PLZSKm?usp=sharing) | [OneDrive](https:\u002F\u002Fentuedu-my.sharepoint.com\u002F:f:\u002Fg\u002Fpersonal\u002Fs200094_e_ntu_edu_sg\u002FEvDxR7FcAbZMp_MA9ouq7aQB8XTppMb3-T0uGZ_2anI2mg?e=DXsJFo)] to the `weights\u002Ffacelib` folder. You can manually download the pretrained models OR download by running the following command:\n```\npython scripts\u002Fdownload_pretrained_models.py facelib\npython scripts\u002Fdownload_pretrained_models.py dlib (only for dlib face detector)\n```\n\nDownload the CodeFormer pretrained models from [[Releases](https:\u002F\u002Fgithub.com\u002Fsczhou\u002FCodeFormer\u002Freleases\u002Ftag\u002Fv0.1.0) | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1CNNByjHDFt0b95q54yMVp6Ifo5iuU6QS?usp=sharing) | [OneDrive](https:\u002F\u002Fentuedu-my.sharepoint.com\u002F:f:\u002Fg\u002Fpersonal\u002Fs200094_e_ntu_edu_sg\u002FEoKFj4wo8cdIn2-TY2IV6CYBhZ0pIG4kUOeHdPR_A5nlbg?e=AO8UN9)] to the `weights\u002FCodeFormer` folder. You can manually download the pretrained models OR download by running the following command:\n```\npython scripts\u002Fdownload_pretrained_models.py CodeFormer\n```\n\n#### Prepare Testing Data:\nYou can put the testing images in the `inputs\u002FTestWhole` folder. If you would like to test on cropped and aligned faces, you can put them in the `inputs\u002Fcropped_faces` folder. You can get the cropped and aligned faces by running the following command:\n```\n# you may need to install dlib via: conda install -c conda-forge dlib\npython scripts\u002Fcrop_align_face.py -i [input folder] -o [output folder]\n```\n\n\n#### Testing:\n[Note] If you want to compare CodeFormer in your paper, please run the following command indicating `--has_aligned` (for cropped and aligned face), as the command for the whole image will involve a process of face-background fusion that may damage hair texture on the boundary, which leads to unfair comparison.\n\nFidelity weight *w* lays in [0, 1]. Generally, smaller *w* tends to produce a higher-quality result, while larger *w* yields a higher-fidelity result. The results will be saved in the `results` folder.\n\n\n🧑🏻 Face Restoration (cropped and aligned face)\n```\n# For cropped and aligned faces (512x512)\npython inference_codeformer.py -w 0.5 --has_aligned --input_path [image folder]|[image path]\n```\n\n:framed_picture: Whole Image Enhancement\n```\n# For whole image\n# Add '--bg_upsampler realesrgan' to enhance the background regions with Real-ESRGAN\n# Add '--face_upsample' to further upsample restorated face with Real-ESRGAN\npython inference_codeformer.py -w 0.7 --input_path [image folder]|[image path]\n```\n\n:clapper: Video Enhancement\n```\n# For Windows\u002FMac users, please install ffmpeg first\nconda install -c conda-forge ffmpeg\n```\n```\n# For video clips\n# Video path should end with '.mp4'|'.mov'|'.avi'\npython inference_codeformer.py --bg_upsampler realesrgan --face_upsample -w 1.0 --input_path [video path]\n```\n\n🌈 Face Colorization (cropped and aligned face)\n```\n# For cropped and aligned faces (512x512)\n# Colorize black and white or faded photo\npython inference_colorization.py --input_path [image folder]|[image path]\n```\n\n🎨 Face Inpainting (cropped and aligned face)\n```\n# For cropped and aligned faces (512x512)\n# Inputs could be masked by white brush using an image editing app (e.g., Photoshop) \n# (check out the examples in inputs\u002Fmasked_faces)\npython inference_inpainting.py --input_path [image folder]|[image path]\n```\n### Training:\nThe training commands can be found in the documents: [English](docs\u002Ftrain.md) **|** [简体中文](docs\u002Ftrain_CN.md).\n\n### License\n\nThis project is licensed under \u003Ca rel=\"license\" href=\"https:\u002F\u002Fgithub.com\u002Fsczhou\u002FCodeFormer\u002Fblob\u002Fmaster\u002FLICENSE\">NTU S-Lab License 1.0\u003C\u002Fa>. Redistribution and use should follow this license.\n\n---\n### 🐼 Ecosystem Applications & Deployments\n\nCodeFormer has been widely adopted and deployed across a broad range (>20) of online applications, platforms, API services, and independent websites, and has also been integrated into many open-source projects and toolkits.\n\n> Only demos on **Hugging Face Space**, **Replicate**, and **OpenXLab** are official deployments **maintained by the authors**. All other demos, APIs, apps, websites, and integrations listed below are **third-party (non-official)** and are not affiliated with the CodeFormer authors. Please verify their legitimacy to avoid potential financial loss.\n\n\n#### Websites (Non-official)\n\n⚠️⚠️⚠️ The following websites are **not official and are not operated by us**. They use our models without any license or authorization. Please verify their legitimacy to avoid potential financial loss.\n\n\n| Website | Link | Notes |\n|---------|------|--------|\n| CodeFormer.net | https:\u002F\u002Fcodeformer.net\u002F | Non-official website |\n| CodeFormer.cn | https:\u002F\u002Fwww.codeformer.cn\u002F | Non-official website |\n| CodeFormerAI.com | https:\u002F\u002Fcodeformerai.com\u002F | Non-official website |\n\n#### Online Demos \u002F API Platforms\n\n| Platform | Link | Notes |\n|----------|------|--------|\n| Hugging Face | https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fsczhou\u002FCodeFormer | Maintained by Authors |\n| Replicate | https:\u002F\u002Freplicate.com\u002Fsczhou\u002Fcodeformer | Maintained by Authors |\n| OpenXLab | https:\u002F\u002Fopenxlab.org.cn\u002Fapps\u002Fdetail\u002FShangchenZhou\u002FCodeFormer |Maintained by Authors |\n| Segmind | https:\u002F\u002Fwww.segmind.com\u002Fmodels\u002Fcodeformer | Non-official |\n| Sieve | https:\u002F\u002Fwww.sievedata.com\u002Ffunctions\u002Fsieve\u002Fcodeformer | Non-official |\n| Fal.ai | https:\u002F\u002Ffal.ai\u002Fmodels\u002Ffal-ai\u002Fcodeformer | Non-official |\n| VaikerAI | https:\u002F\u002Fvaikerai.com\u002Fsczhou\u002Fcodeformer | Non-official |\n| Scade.pro | https:\u002F\u002Fwww.scade.pro\u002Fprocessors\u002Flucataco-codeformer | Non-official |\n| Grandline | https:\u002F\u002Fwww.grandline.ai\u002Fmodel\u002Fcodeformer | Non-official |\n| AI Demos | https:\u002F\u002Faidemos.com\u002Ftools\u002Fcodeformer | Non-official |\n| Synexa | https:\u002F\u002Fsynexa.ai\u002Fexplore\u002Fsczhou\u002Fcodeformer | Non-official |\n| RentPrompts | https:\u002F\u002Frentprompts.ai\u002Fmodels\u002FCodeformer | Non-official |\n| ElevaticsAI | https:\u002F\u002Felevatics.ai\u002Fmodels\u002Fsuper-resolution\u002Fcodeformer | Non-official |\n| Anakin.ai | https:\u002F\u002Fanakin.ai\u002Fapps\u002Fcodeformer-online-face-restoration-by-codeformer-19343 | Non-official |\n| Relayto | https:\u002F\u002Frelayto.com\u002Fexplore\u002Fcodeformer-yf9rj8kwc7zsr | Non-official |\n\n\n#### Open-Source Projects & Toolkits\n\n| Project \u002F Toolkit | Link | Notes |\n|-------------------|------|--------|\n| Stable Diffusion GUI | https:\u002F\u002Fnmkd.itch.io\u002Ft2i-gui | Integration |\n| Stable Diffusion WebUI | https:\u002F\u002Fgithub.com\u002FAUTOMATIC1111\u002Fstable-diffusion-webui | Integration |\n| ChaiNNer | https:\u002F\u002Fgithub.com\u002FchaiNNer-org\u002FchaiNNer | Integration |\n| PyPI | https:\u002F\u002Fpypi.org\u002Fproject\u002Fcodeformer\u002F ; https:\u002F\u002Fpypi.org\u002Fproject\u002Fcodeformer-pip\u002F | Python packages |\n| ComfyUI | https:\u002F\u002Fstable-diffusion-art.com\u002Fcodeformer\u002F | Integration |\n\n---\n### Acknowledgement\n\nThis project is based on [BasicSR](https:\u002F\u002Fgithub.com\u002FXPixelGroup\u002FBasicSR). Some codes are brought from [Unleashing Transformers](https:\u002F\u002Fgithub.com\u002Fsamb-t\u002Funleashing-transformers), [YOLOv5-face](https:\u002F\u002Fgithub.com\u002Fdeepcam-cn\u002Fyolov5-face), and [FaceXLib](https:\u002F\u002Fgithub.com\u002Fxinntao\u002Ffacexlib). We also adopt [Real-ESRGAN](https:\u002F\u002Fgithub.com\u002Fxinntao\u002FReal-ESRGAN) to support background image enhancement. Thanks for their awesome works.\n\n### Citation\nIf our work is useful for your research, please consider citing:\n\n    @inproceedings{zhou2022codeformer,\n        author = {Zhou, Shangchen and Chan, Kelvin C.K. and Li, Chongyi and Loy, Chen Change},\n        title = {Towards Robust Blind Face Restoration with Codebook Lookup TransFormer},\n        booktitle = {NeurIPS},\n        year = {2022}\n    }\n\n\n### Contact\nIf you have any questions, please feel free to reach me out at `shangchenzhou@gmail.com`. \n","CodeFormer 是一个用于盲脸恢复的项目，通过代码本查找变换器技术实现对人脸图像的增强与修复。其核心功能包括使用 PyTorch 框架下的 VQGAN 和 Codebook Lookup Transformer 技术来提高人脸图像的质量，支持从低分辨率、模糊或损坏的人脸图片中恢复出高质量、高分辨率的人脸图像，并且还具备视频处理能力。此外，该项目提供了多种在线演示平台（如Hugging Face, Replicate等），便于用户直接体验其效果。适用于需要改善历史照片质量、AI艺术作品修正以及视频中的人脸清晰度提升等多种场景。",2,"2026-06-11 02:50:30","top_language"]