Spaces:
Runtime error
Runtime error
Commit
·
fa3f4ac
0
Parent(s):
update readme.
Browse files- .gitignore +120 -0
- README.md +101 -0
- assets/CodeFormer_logo.png +0 -0
- assets/color_enhancement_result1.png +0 -0
- assets/color_enhancement_result2.png +0 -0
- assets/inpainting_result1.png +0 -0
- assets/inpainting_result2.png +0 -0
- assets/network.jpg +0 -0
- assets/restoration_result1.png +0 -0
- assets/restoration_result2.png +0 -0
- assets/restoration_result3.png +0 -0
- assets/restoration_result4.png +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.vscode
|
| 2 |
+
|
| 3 |
+
# ignored files
|
| 4 |
+
version.py
|
| 5 |
+
|
| 6 |
+
# ignored files with suffix
|
| 7 |
+
*.html
|
| 8 |
+
# *.png
|
| 9 |
+
# *.jpeg
|
| 10 |
+
# *.jpg
|
| 11 |
+
*.gif
|
| 12 |
+
*.pth
|
| 13 |
+
*.zip
|
| 14 |
+
|
| 15 |
+
# template
|
| 16 |
+
|
| 17 |
+
# Byte-compiled / optimized / DLL files
|
| 18 |
+
__pycache__/
|
| 19 |
+
*.py[cod]
|
| 20 |
+
*$py.class
|
| 21 |
+
|
| 22 |
+
# C extensions
|
| 23 |
+
*.so
|
| 24 |
+
|
| 25 |
+
# Distribution / packaging
|
| 26 |
+
.Python
|
| 27 |
+
build/
|
| 28 |
+
develop-eggs/
|
| 29 |
+
dist/
|
| 30 |
+
downloads/
|
| 31 |
+
eggs/
|
| 32 |
+
.eggs/
|
| 33 |
+
lib/
|
| 34 |
+
lib64/
|
| 35 |
+
parts/
|
| 36 |
+
sdist/
|
| 37 |
+
var/
|
| 38 |
+
wheels/
|
| 39 |
+
*.egg-info/
|
| 40 |
+
.installed.cfg
|
| 41 |
+
*.egg
|
| 42 |
+
MANIFEST
|
| 43 |
+
|
| 44 |
+
# PyInstaller
|
| 45 |
+
# Usually these files are written by a python script from a template
|
| 46 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
| 47 |
+
*.manifest
|
| 48 |
+
*.spec
|
| 49 |
+
|
| 50 |
+
# Installer logs
|
| 51 |
+
pip-log.txt
|
| 52 |
+
pip-delete-this-directory.txt
|
| 53 |
+
|
| 54 |
+
# Unit test / coverage reports
|
| 55 |
+
htmlcov/
|
| 56 |
+
.tox/
|
| 57 |
+
.coverage
|
| 58 |
+
.coverage.*
|
| 59 |
+
.cache
|
| 60 |
+
nosetests.xml
|
| 61 |
+
coverage.xml
|
| 62 |
+
*.cover
|
| 63 |
+
.hypothesis/
|
| 64 |
+
.pytest_cache/
|
| 65 |
+
|
| 66 |
+
# Translations
|
| 67 |
+
*.mo
|
| 68 |
+
*.pot
|
| 69 |
+
|
| 70 |
+
# Django stuff:
|
| 71 |
+
*.log
|
| 72 |
+
local_settings.py
|
| 73 |
+
db.sqlite3
|
| 74 |
+
|
| 75 |
+
# Flask stuff:
|
| 76 |
+
instance/
|
| 77 |
+
.webassets-cache
|
| 78 |
+
|
| 79 |
+
# Scrapy stuff:
|
| 80 |
+
.scrapy
|
| 81 |
+
|
| 82 |
+
# Sphinx documentation
|
| 83 |
+
docs/_build/
|
| 84 |
+
|
| 85 |
+
# PyBuilder
|
| 86 |
+
target/
|
| 87 |
+
|
| 88 |
+
# Jupyter Notebook
|
| 89 |
+
.ipynb_checkpoints
|
| 90 |
+
|
| 91 |
+
# pyenv
|
| 92 |
+
.python-version
|
| 93 |
+
|
| 94 |
+
# celery beat schedule file
|
| 95 |
+
celerybeat-schedule
|
| 96 |
+
|
| 97 |
+
# SageMath parsed files
|
| 98 |
+
*.sage.py
|
| 99 |
+
|
| 100 |
+
# Environments
|
| 101 |
+
.env
|
| 102 |
+
.venv
|
| 103 |
+
env/
|
| 104 |
+
venv/
|
| 105 |
+
ENV/
|
| 106 |
+
env.bak/
|
| 107 |
+
venv.bak/
|
| 108 |
+
|
| 109 |
+
# Spyder project settings
|
| 110 |
+
.spyderproject
|
| 111 |
+
.spyproject
|
| 112 |
+
|
| 113 |
+
# Rope project settings
|
| 114 |
+
.ropeproject
|
| 115 |
+
|
| 116 |
+
# mkdocs documentation
|
| 117 |
+
/site
|
| 118 |
+
|
| 119 |
+
# mypy
|
| 120 |
+
.mypy_cache/
|
README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<p align="center">
|
| 2 |
+
<img src="assets/CodeFormer_logo.png" height=110>
|
| 3 |
+
</p>
|
| 4 |
+
|
| 5 |
+
## Towards Robust Blind Face Restoration with Codebook Lookup Transformer
|
| 6 |
+
|
| 7 |
+
[Paper](https://arxiv.org/abs/xxx) | [Project Page](https://shangchenzhou.com/projects/CodeFormer/) | [Video](https://youtu.be/d3VDpkXlueI)
|
| 8 |
+
|
| 9 |
+
<!-- <a href="https://colab.research.google.com/drive/1m52PNveE4PBhYrecj34cnpEeiHcC5LTb?usp=sharing"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="google colab logo"></a> -->
|
| 10 |
+
|
| 11 |
+
[Shangchen Zhou](https://shangchenzhou.com/), [Kelvin C.K. Chan](https://ckkelvinchan.github.io/), [Chongyi Li](https://li-chongyi.github.io/), [Chen Change Loy](https://www.mmlab-ntu.com/person/ccloy/)
|
| 12 |
+
S-Lab, Nanyang Technological University
|
| 13 |
+
|
| 14 |
+
<img src="assets/network.jpg" width="800px"/>
|
| 15 |
+
|
| 16 |
+
### Updates
|
| 17 |
+
|
| 18 |
+
<!-- Test code and Colab demo for Face Restoration is available now. -->
|
| 19 |
+
- **2022.07.02**: :star:We will release the test code and model by July 15th. Thanks for your attention! :blush:
|
| 20 |
+
- **2022.06.21**: This repo is created.
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
#### Face Restoration
|
| 25 |
+
|
| 26 |
+
<img src="assets/restoration_result1.png" width="400px"/> <img src="assets/restoration_result2.png" width="400px"/>
|
| 27 |
+
<img src="assets/restoration_result3.png" width="400px"/> <img src="assets/restoration_result4.png" width="400px"/>
|
| 28 |
+
|
| 29 |
+
#### Face Color Enhancement and Restoration
|
| 30 |
+
|
| 31 |
+
<img src="assets/color_enhancement_result1.png" width="400px"/> <img src="assets/color_enhancement_result2.png" width="400px"/>
|
| 32 |
+
|
| 33 |
+
#### Face Inpainting
|
| 34 |
+
|
| 35 |
+
<img src="assets/inpainting_result1.png" width="400px"/> <img src="assets/inpainting_result2.png" width="400px"/>
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
<!-- ### Dependencies and Installation
|
| 40 |
+
|
| 41 |
+
- Pytorch >= 1.7.1
|
| 42 |
+
- CUDA >= 10.1
|
| 43 |
+
- Other required packages in `requirements.txt`
|
| 44 |
+
```
|
| 45 |
+
# git clone this repository
|
| 46 |
+
git clone https://github.com/sczhou/CodeFormer
|
| 47 |
+
cd CodeFormer
|
| 48 |
+
|
| 49 |
+
# create new anaconda env
|
| 50 |
+
conda create -n codeformer python=3.8 -y
|
| 51 |
+
source activate codeformer
|
| 52 |
+
|
| 53 |
+
# install python dependencies
|
| 54 |
+
pip3 install -r requirements.txt
|
| 55 |
+
python basicsr/setup.py develop
|
| 56 |
+
conda install -c conda-forge dlib
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### Quick Inference
|
| 60 |
+
|
| 61 |
+
##### Download Pre-trained Models:
|
| 62 |
+
Download the dlib pretrained models from [[Google Drive]([xx](https://drive.google.com/drive/folders/1f24f1UqNY8OyeE9aWxswCKQbR7fe8yz4?usp=sharing)) | [OneDrive](xx)] to the `weights/dlib` folder.
|
| 63 |
+
You can download by run the following command OR manually download the pretrained models.
|
| 64 |
+
```
|
| 65 |
+
python scripts/download_pretrained_models.py dlib
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
Download the CodeFormer pretrained models from [[Google Drive]([xx](https://drive.google.com/drive/folders/1f24f1UqNY8OyeE9aWxswCKQbR7fe8yz4?usp=sharing)) | [OneDrive](xx)] to the `weights/CodeFormer` folder.
|
| 69 |
+
You can download by run the following command OR manually download the pretrained models.
|
| 70 |
+
```
|
| 71 |
+
python scripts/download_pretrained_models.py CodeFormer
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
##### Prepare Testing Data:
|
| 75 |
+
You can put the testing images in the `inputs/TestWhole` folder. If you would like to test on cropped and aligned faces, you can put them in the `inputs/cropped_faces` folder.
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
##### Testing for Face Restoration:
|
| 79 |
+
```
|
| 80 |
+
python inference_codeformer.py --w 0.5 --test_path [input folder]
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
NOTE that we set *w* to -->
|
| 84 |
+
|
| 85 |
+
### Citation
|
| 86 |
+
If our work is useful for your research, please consider citing:
|
| 87 |
+
|
| 88 |
+
@article{zhou2022codeformer,
|
| 89 |
+
author = {Zhou, Shangchen and Chan, Kelvin C.K. and Li, Chongyi and Loy, Chen Change},
|
| 90 |
+
title = {Towards Robust Blind Face Restoration with Codebook Lookup TransFormer},
|
| 91 |
+
journal = {arXiv preprint arXiv:2206.11253},
|
| 92 |
+
year = {2022}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
### License
|
| 96 |
+
|
| 97 |
+
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
|
| 98 |
+
|
| 99 |
+
### Acknowledgement
|
| 100 |
+
|
| 101 |
+
This project is based on [BasicSR](https://github.com/XPixelGroup/BasicSR).
|
assets/CodeFormer_logo.png
ADDED
|
assets/color_enhancement_result1.png
ADDED
|
assets/color_enhancement_result2.png
ADDED
|
assets/inpainting_result1.png
ADDED
|
assets/inpainting_result2.png
ADDED
|
assets/network.jpg
ADDED
|
assets/restoration_result1.png
ADDED
|
assets/restoration_result2.png
ADDED
|
assets/restoration_result3.png
ADDED
|
assets/restoration_result4.png
ADDED
|