Upload 17 files
Browse files- .gitignore +139 -0
- .pre-commit-config.yaml +46 -0
- CODE_OF_CONDUCT.md +128 -0
- Comparisons.md +24 -0
- FAQ.md +7 -0
- LICENSE +351 -0
- MANIFEST.in +8 -0
- PaperModel.md +76 -0
- README.md +202 -3
- README_CN.md +7 -0
- VERSION +1 -0
- cog.yaml +22 -0
- cog_predict.py +161 -0
- inference_gfpgan.py +174 -0
- requirements.txt +12 -0
- setup.cfg +33 -0
- setup.py +107 -0
.gitignore
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ignored folders
|
2 |
+
datasets/*
|
3 |
+
experiments/*
|
4 |
+
results/*
|
5 |
+
tb_logger/*
|
6 |
+
wandb/*
|
7 |
+
tmp/*
|
8 |
+
|
9 |
+
version.py
|
10 |
+
|
11 |
+
# Byte-compiled / optimized / DLL files
|
12 |
+
__pycache__/
|
13 |
+
*.py[cod]
|
14 |
+
*$py.class
|
15 |
+
|
16 |
+
# C extensions
|
17 |
+
*.so
|
18 |
+
|
19 |
+
# Distribution / packaging
|
20 |
+
.Python
|
21 |
+
build/
|
22 |
+
develop-eggs/
|
23 |
+
dist/
|
24 |
+
downloads/
|
25 |
+
eggs/
|
26 |
+
.eggs/
|
27 |
+
lib/
|
28 |
+
lib64/
|
29 |
+
parts/
|
30 |
+
sdist/
|
31 |
+
var/
|
32 |
+
wheels/
|
33 |
+
pip-wheel-metadata/
|
34 |
+
share/python-wheels/
|
35 |
+
*.egg-info/
|
36 |
+
.installed.cfg
|
37 |
+
*.egg
|
38 |
+
MANIFEST
|
39 |
+
|
40 |
+
# PyInstaller
|
41 |
+
# Usually these files are written by a python script from a template
|
42 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
43 |
+
*.manifest
|
44 |
+
*.spec
|
45 |
+
|
46 |
+
# Installer logs
|
47 |
+
pip-log.txt
|
48 |
+
pip-delete-this-directory.txt
|
49 |
+
|
50 |
+
# Unit test / coverage reports
|
51 |
+
htmlcov/
|
52 |
+
.tox/
|
53 |
+
.nox/
|
54 |
+
.coverage
|
55 |
+
.coverage.*
|
56 |
+
.cache
|
57 |
+
nosetests.xml
|
58 |
+
coverage.xml
|
59 |
+
*.cover
|
60 |
+
*.py,cover
|
61 |
+
.hypothesis/
|
62 |
+
.pytest_cache/
|
63 |
+
|
64 |
+
# Translations
|
65 |
+
*.mo
|
66 |
+
*.pot
|
67 |
+
|
68 |
+
# Django stuff:
|
69 |
+
*.log
|
70 |
+
local_settings.py
|
71 |
+
db.sqlite3
|
72 |
+
db.sqlite3-journal
|
73 |
+
|
74 |
+
# Flask stuff:
|
75 |
+
instance/
|
76 |
+
.webassets-cache
|
77 |
+
|
78 |
+
# Scrapy stuff:
|
79 |
+
.scrapy
|
80 |
+
|
81 |
+
# Sphinx documentation
|
82 |
+
docs/_build/
|
83 |
+
|
84 |
+
# PyBuilder
|
85 |
+
target/
|
86 |
+
|
87 |
+
# Jupyter Notebook
|
88 |
+
.ipynb_checkpoints
|
89 |
+
|
90 |
+
# IPython
|
91 |
+
profile_default/
|
92 |
+
ipython_config.py
|
93 |
+
|
94 |
+
# pyenv
|
95 |
+
.python-version
|
96 |
+
|
97 |
+
# pipenv
|
98 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
99 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
100 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
101 |
+
# install all needed dependencies.
|
102 |
+
#Pipfile.lock
|
103 |
+
|
104 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
105 |
+
__pypackages__/
|
106 |
+
|
107 |
+
# Celery stuff
|
108 |
+
celerybeat-schedule
|
109 |
+
celerybeat.pid
|
110 |
+
|
111 |
+
# SageMath parsed files
|
112 |
+
*.sage.py
|
113 |
+
|
114 |
+
# Environments
|
115 |
+
.env
|
116 |
+
.venv
|
117 |
+
env/
|
118 |
+
venv/
|
119 |
+
ENV/
|
120 |
+
env.bak/
|
121 |
+
venv.bak/
|
122 |
+
|
123 |
+
# Spyder project settings
|
124 |
+
.spyderproject
|
125 |
+
.spyproject
|
126 |
+
|
127 |
+
# Rope project settings
|
128 |
+
.ropeproject
|
129 |
+
|
130 |
+
# mkdocs documentation
|
131 |
+
/site
|
132 |
+
|
133 |
+
# mypy
|
134 |
+
.mypy_cache/
|
135 |
+
.dmypy.json
|
136 |
+
dmypy.json
|
137 |
+
|
138 |
+
# Pyre type checker
|
139 |
+
.pyre/
|
.pre-commit-config.yaml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
repos:
|
2 |
+
# flake8
|
3 |
+
- repo: https://github.com/PyCQA/flake8
|
4 |
+
rev: 3.8.3
|
5 |
+
hooks:
|
6 |
+
- id: flake8
|
7 |
+
args: ["--config=setup.cfg", "--ignore=W504, W503"]
|
8 |
+
|
9 |
+
# modify known_third_party
|
10 |
+
- repo: https://github.com/asottile/seed-isort-config
|
11 |
+
rev: v2.2.0
|
12 |
+
hooks:
|
13 |
+
- id: seed-isort-config
|
14 |
+
|
15 |
+
# isort
|
16 |
+
- repo: https://github.com/timothycrosley/isort
|
17 |
+
rev: 5.2.2
|
18 |
+
hooks:
|
19 |
+
- id: isort
|
20 |
+
|
21 |
+
# yapf
|
22 |
+
- repo: https://github.com/pre-commit/mirrors-yapf
|
23 |
+
rev: v0.30.0
|
24 |
+
hooks:
|
25 |
+
- id: yapf
|
26 |
+
|
27 |
+
# codespell
|
28 |
+
- repo: https://github.com/codespell-project/codespell
|
29 |
+
rev: v2.1.0
|
30 |
+
hooks:
|
31 |
+
- id: codespell
|
32 |
+
|
33 |
+
# pre-commit-hooks
|
34 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
35 |
+
rev: v3.2.0
|
36 |
+
hooks:
|
37 |
+
- id: trailing-whitespace # Trim trailing whitespace
|
38 |
+
- id: check-yaml # Attempt to load all yaml files to verify syntax
|
39 |
+
- id: check-merge-conflict # Check for files that contain merge conflict strings
|
40 |
+
- id: double-quote-string-fixer # Replace double quoted strings with single quoted strings
|
41 |
+
- id: end-of-file-fixer # Make sure files end in a newline and only a newline
|
42 |
+
- id: requirements-txt-fixer # Sort entries in requirements.txt and remove incorrect entry for pkg-resources==0.0.0
|
43 |
+
- id: fix-encoding-pragma # Remove the coding pragma: # -*- coding: utf-8 -*-
|
44 |
+
args: ["--remove"]
|
45 |
+
- id: mixed-line-ending # Replace or check mixed line ending
|
46 |
+
args: ["--fix=lf"]
|
CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contributor Covenant Code of Conduct
|
2 |
+
|
3 |
+
## Our Pledge
|
4 |
+
|
5 |
+
We as members, contributors, and leaders pledge to make participation in our
|
6 |
+
community a harassment-free experience for everyone, regardless of age, body
|
7 |
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8 |
+
identity and expression, level of experience, education, socio-economic status,
|
9 |
+
nationality, personal appearance, race, religion, or sexual identity
|
10 |
+
and orientation.
|
11 |
+
|
12 |
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13 |
+
diverse, inclusive, and healthy community.
|
14 |
+
|
15 |
+
## Our Standards
|
16 |
+
|
17 |
+
Examples of behavior that contributes to a positive environment for our
|
18 |
+
community include:
|
19 |
+
|
20 |
+
* Demonstrating empathy and kindness toward other people
|
21 |
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22 |
+
* Giving and gracefully accepting constructive feedback
|
23 |
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24 |
+
and learning from the experience
|
25 |
+
* Focusing on what is best not just for us as individuals, but for the
|
26 |
+
overall community
|
27 |
+
|
28 |
+
Examples of unacceptable behavior include:
|
29 |
+
|
30 |
+
* The use of sexualized language or imagery, and sexual attention or
|
31 |
+
advances of any kind
|
32 |
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33 |
+
* Public or private harassment
|
34 |
+
* Publishing others' private information, such as a physical or email
|
35 |
+
address, without their explicit permission
|
36 |
+
* Other conduct which could reasonably be considered inappropriate in a
|
37 |
+
professional setting
|
38 |
+
|
39 |
+
## Enforcement Responsibilities
|
40 |
+
|
41 |
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42 |
+
acceptable behavior and will take appropriate and fair corrective action in
|
43 |
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44 |
+
or harmful.
|
45 |
+
|
46 |
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47 |
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48 |
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49 |
+
decisions when appropriate.
|
50 |
+
|
51 |
+
## Scope
|
52 |
+
|
53 |
+
This Code of Conduct applies within all community spaces, and also applies when
|
54 |
+
an individual is officially representing the community in public spaces.
|
55 |
+
Examples of representing our community include using an official e-mail address,
|
56 |
+
posting via an official social media account, or acting as an appointed
|
57 |
+
representative at an online or offline event.
|
58 |
+
|
59 |
+
## Enforcement
|
60 |
+
|
61 |
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62 |
+
reported to the community leaders responsible for enforcement at
|
63 |
+
xintao.wang@outlook.com or xintaowang@tencent.com.
|
64 |
+
All complaints will be reviewed and investigated promptly and fairly.
|
65 |
+
|
66 |
+
All community leaders are obligated to respect the privacy and security of the
|
67 |
+
reporter of any incident.
|
68 |
+
|
69 |
+
## Enforcement Guidelines
|
70 |
+
|
71 |
+
Community leaders will follow these Community Impact Guidelines in determining
|
72 |
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73 |
+
|
74 |
+
### 1. Correction
|
75 |
+
|
76 |
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77 |
+
unprofessional or unwelcome in the community.
|
78 |
+
|
79 |
+
**Consequence**: A private, written warning from community leaders, providing
|
80 |
+
clarity around the nature of the violation and an explanation of why the
|
81 |
+
behavior was inappropriate. A public apology may be requested.
|
82 |
+
|
83 |
+
### 2. Warning
|
84 |
+
|
85 |
+
**Community Impact**: A violation through a single incident or series
|
86 |
+
of actions.
|
87 |
+
|
88 |
+
**Consequence**: A warning with consequences for continued behavior. No
|
89 |
+
interaction with the people involved, including unsolicited interaction with
|
90 |
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91 |
+
includes avoiding interactions in community spaces as well as external channels
|
92 |
+
like social media. Violating these terms may lead to a temporary or
|
93 |
+
permanent ban.
|
94 |
+
|
95 |
+
### 3. Temporary Ban
|
96 |
+
|
97 |
+
**Community Impact**: A serious violation of community standards, including
|
98 |
+
sustained inappropriate behavior.
|
99 |
+
|
100 |
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101 |
+
communication with the community for a specified period of time. No public or
|
102 |
+
private interaction with the people involved, including unsolicited interaction
|
103 |
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104 |
+
Violating these terms may lead to a permanent ban.
|
105 |
+
|
106 |
+
### 4. Permanent Ban
|
107 |
+
|
108 |
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109 |
+
standards, including sustained inappropriate behavior, harassment of an
|
110 |
+
individual, or aggression toward or disparagement of classes of individuals.
|
111 |
+
|
112 |
+
**Consequence**: A permanent ban from any sort of public interaction within
|
113 |
+
the community.
|
114 |
+
|
115 |
+
## Attribution
|
116 |
+
|
117 |
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118 |
+
version 2.0, available at
|
119 |
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
120 |
+
|
121 |
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
122 |
+
enforcement ladder](https://github.com/mozilla/diversity).
|
123 |
+
|
124 |
+
[homepage]: https://www.contributor-covenant.org
|
125 |
+
|
126 |
+
For answers to common questions about this code of conduct, see the FAQ at
|
127 |
+
https://www.contributor-covenant.org/faq. Translations are available at
|
128 |
+
https://www.contributor-covenant.org/translations.
|
Comparisons.md
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Comparisons
|
2 |
+
|
3 |
+
## Comparisons among different model versions
|
4 |
+
|
5 |
+
Note that V1.3 is not always better than V1.2. You may need to try different models based on your purpose and inputs.
|
6 |
+
|
7 |
+
| Version | Strengths | Weaknesses |
|
8 |
+
| :---: | :---: | :---: |
|
9 |
+
|V1.3 | ✓ natural outputs<br> ✓better results on very low-quality inputs <br> ✓ work on relatively high-quality inputs <br>✓ can have repeated (twice) restorations | ✗ not very sharp <br> ✗ have a slight change on identity |
|
10 |
+
|V1.2 | ✓ sharper output <br> ✓ with beauty makeup | ✗ some outputs are unnatural|
|
11 |
+
|
12 |
+
For the following images, you may need to **zoom in** for comparing details, or **click the image** to see in the full size.
|
13 |
+
|
14 |
+
| Input | V1 | V1.2 | V1.3
|
15 |
+
| :---: | :---: | :---: | :---: |
|
16 |
+
||  |  |  |
|
17 |
+
|  |  |  | |
|
18 |
+
|  |  |  | |
|
19 |
+
|  |  |  | |
|
20 |
+
|  |  |  | |
|
21 |
+
|  |  |  | |
|
22 |
+
|  |  |  | |
|
23 |
+
|
24 |
+
<!-- | ![]() | ![]() | ![]() | ![]()| -->
|
FAQ.md
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# FAQ
|
2 |
+
|
3 |
+
1. **How to finetune the GFPGANCleanv1-NoCE-C2 (v1.2) model**
|
4 |
+
|
5 |
+
**A:** 1) The GFPGANCleanv1-NoCE-C2 (v1.2) model uses the *clean* architecture, which is more friendly for deploying.
|
6 |
+
2) This model is not directly trained. Instead, it is converted from another *bilinear* model.
|
7 |
+
3) If you want to finetune the GFPGANCleanv1-NoCE-C2 (v1.2), you need to finetune its original *bilinear* model, and then do the conversion.
|
LICENSE
ADDED
@@ -0,0 +1,351 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Tencent is pleased to support the open source community by making GFPGAN available.
|
2 |
+
|
3 |
+
Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
4 |
+
|
5 |
+
GFPGAN is licensed under the Apache License Version 2.0 except for the third-party components listed below.
|
6 |
+
|
7 |
+
|
8 |
+
Terms of the Apache License Version 2.0:
|
9 |
+
---------------------------------------------
|
10 |
+
Apache License
|
11 |
+
|
12 |
+
Version 2.0, January 2004
|
13 |
+
|
14 |
+
http://www.apache.org/licenses/
|
15 |
+
|
16 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
17 |
+
1. Definitions.
|
18 |
+
|
19 |
+
“License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
20 |
+
|
21 |
+
“Licensor” shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
22 |
+
|
23 |
+
“Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, “control” means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
24 |
+
|
25 |
+
“You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License.
|
26 |
+
|
27 |
+
“Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
28 |
+
|
29 |
+
“Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
30 |
+
|
31 |
+
“Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
32 |
+
|
33 |
+
“Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
34 |
+
|
35 |
+
“Contribution” shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as “Not a Contribution.”
|
36 |
+
|
37 |
+
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
38 |
+
|
39 |
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
40 |
+
|
41 |
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
42 |
+
|
43 |
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
44 |
+
|
45 |
+
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
46 |
+
|
47 |
+
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
48 |
+
|
49 |
+
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
50 |
+
|
51 |
+
If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
52 |
+
|
53 |
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
54 |
+
|
55 |
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
56 |
+
|
57 |
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
58 |
+
|
59 |
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
60 |
+
|
61 |
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
62 |
+
|
63 |
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
64 |
+
|
65 |
+
END OF TERMS AND CONDITIONS
|
66 |
+
|
67 |
+
|
68 |
+
|
69 |
+
Other dependencies and licenses:
|
70 |
+
|
71 |
+
|
72 |
+
Open Source Software licensed under the Apache 2.0 license and Other Licenses of the Third-Party Components therein:
|
73 |
+
---------------------------------------------
|
74 |
+
1. basicsr
|
75 |
+
Copyright 2018-2020 BasicSR Authors
|
76 |
+
|
77 |
+
|
78 |
+
This BasicSR project is released under the Apache 2.0 license.
|
79 |
+
|
80 |
+
A copy of Apache 2.0 is included in this file.
|
81 |
+
|
82 |
+
StyleGAN2
|
83 |
+
The codes are modified from the repository stylegan2-pytorch. Many thanks to the author - Kim Seonghyeon 😊 for translating from the official TensorFlow codes to PyTorch ones. Here is the license of stylegan2-pytorch.
|
84 |
+
The official repository is https://github.com/NVlabs/stylegan2, and here is the NVIDIA license.
|
85 |
+
DFDNet
|
86 |
+
The codes are largely modified from the repository DFDNet. Their license is Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
87 |
+
|
88 |
+
Terms of the Nvidia License:
|
89 |
+
---------------------------------------------
|
90 |
+
|
91 |
+
1. Definitions
|
92 |
+
|
93 |
+
"Licensor" means any person or entity that distributes its Work.
|
94 |
+
|
95 |
+
"Software" means the original work of authorship made available under
|
96 |
+
this License.
|
97 |
+
|
98 |
+
"Work" means the Software and any additions to or derivative works of
|
99 |
+
the Software that are made available under this License.
|
100 |
+
|
101 |
+
"Nvidia Processors" means any central processing unit (CPU), graphics
|
102 |
+
processing unit (GPU), field-programmable gate array (FPGA),
|
103 |
+
application-specific integrated circuit (ASIC) or any combination
|
104 |
+
thereof designed, made, sold, or provided by Nvidia or its affiliates.
|
105 |
+
|
106 |
+
The terms "reproduce," "reproduction," "derivative works," and
|
107 |
+
"distribution" have the meaning as provided under U.S. copyright law;
|
108 |
+
provided, however, that for the purposes of this License, derivative
|
109 |
+
works shall not include works that remain separable from, or merely
|
110 |
+
link (or bind by name) to the interfaces of, the Work.
|
111 |
+
|
112 |
+
Works, including the Software, are "made available" under this License
|
113 |
+
by including in or with the Work either (a) a copyright notice
|
114 |
+
referencing the applicability of this License to the Work, or (b) a
|
115 |
+
copy of this License.
|
116 |
+
|
117 |
+
2. License Grants
|
118 |
+
|
119 |
+
2.1 Copyright Grant. Subject to the terms and conditions of this
|
120 |
+
License, each Licensor grants to you a perpetual, worldwide,
|
121 |
+
non-exclusive, royalty-free, copyright license to reproduce,
|
122 |
+
prepare derivative works of, publicly display, publicly perform,
|
123 |
+
sublicense and distribute its Work and any resulting derivative
|
124 |
+
works in any form.
|
125 |
+
|
126 |
+
3. Limitations
|
127 |
+
|
128 |
+
3.1 Redistribution. You may reproduce or distribute the Work only
|
129 |
+
if (a) you do so under this License, (b) you include a complete
|
130 |
+
copy of this License with your distribution, and (c) you retain
|
131 |
+
without modification any copyright, patent, trademark, or
|
132 |
+
attribution notices that are present in the Work.
|
133 |
+
|
134 |
+
3.2 Derivative Works. You may specify that additional or different
|
135 |
+
terms apply to the use, reproduction, and distribution of your
|
136 |
+
derivative works of the Work ("Your Terms") only if (a) Your Terms
|
137 |
+
provide that the use limitation in Section 3.3 applies to your
|
138 |
+
derivative works, and (b) you identify the specific derivative
|
139 |
+
works that are subject to Your Terms. Notwithstanding Your Terms,
|
140 |
+
this License (including the redistribution requirements in Section
|
141 |
+
3.1) will continue to apply to the Work itself.
|
142 |
+
|
143 |
+
3.3 Use Limitation. The Work and any derivative works thereof only
|
144 |
+
may be used or intended for use non-commercially. The Work or
|
145 |
+
derivative works thereof may be used or intended for use by Nvidia
|
146 |
+
or its affiliates commercially or non-commercially. As used herein,
|
147 |
+
"non-commercially" means for research or evaluation purposes only.
|
148 |
+
|
149 |
+
3.4 Patent Claims. If you bring or threaten to bring a patent claim
|
150 |
+
against any Licensor (including any claim, cross-claim or
|
151 |
+
counterclaim in a lawsuit) to enforce any patents that you allege
|
152 |
+
are infringed by any Work, then your rights under this License from
|
153 |
+
such Licensor (including the grants in Sections 2.1 and 2.2) will
|
154 |
+
terminate immediately.
|
155 |
+
|
156 |
+
3.5 Trademarks. This License does not grant any rights to use any
|
157 |
+
Licensor's or its affiliates' names, logos, or trademarks, except
|
158 |
+
as necessary to reproduce the notices described in this License.
|
159 |
+
|
160 |
+
3.6 Termination. If you violate any term of this License, then your
|
161 |
+
rights under this License (including the grants in Sections 2.1 and
|
162 |
+
2.2) will terminate immediately.
|
163 |
+
|
164 |
+
4. Disclaimer of Warranty.
|
165 |
+
|
166 |
+
THE WORK IS PROVIDED "AS IS" WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
167 |
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OR CONDITIONS OF
|
168 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR
|
169 |
+
NON-INFRINGEMENT. YOU BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER
|
170 |
+
THIS LICENSE.
|
171 |
+
|
172 |
+
5. Limitation of Liability.
|
173 |
+
|
174 |
+
EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL
|
175 |
+
THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE
|
176 |
+
SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT,
|
177 |
+
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
|
178 |
+
OR RELATED TO THIS LICENSE, THE USE OR INABILITY TO USE THE WORK
|
179 |
+
(INCLUDING BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION,
|
180 |
+
LOST PROFITS OR DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER
|
181 |
+
COMMERCIAL DAMAGES OR LOSSES), EVEN IF THE LICENSOR HAS BEEN ADVISED OF
|
182 |
+
THE POSSIBILITY OF SUCH DAMAGES.
|
183 |
+
|
184 |
+
MIT License
|
185 |
+
|
186 |
+
Copyright (c) 2019 Kim Seonghyeon
|
187 |
+
|
188 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
189 |
+
of this software and associated documentation files (the "Software"), to deal
|
190 |
+
in the Software without restriction, including without limitation the rights
|
191 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
192 |
+
copies of the Software, and to permit persons to whom the Software is
|
193 |
+
furnished to do so, subject to the following conditions:
|
194 |
+
|
195 |
+
The above copyright notice and this permission notice shall be included in all
|
196 |
+
copies or substantial portions of the Software.
|
197 |
+
|
198 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
199 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
200 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
201 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
202 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
203 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
204 |
+
SOFTWARE.
|
205 |
+
|
206 |
+
|
207 |
+
|
208 |
+
Open Source Software licensed under the BSD 3-Clause license:
|
209 |
+
---------------------------------------------
|
210 |
+
1. torchvision
|
211 |
+
Copyright (c) Soumith Chintala 2016,
|
212 |
+
All rights reserved.
|
213 |
+
|
214 |
+
2. torch
|
215 |
+
Copyright (c) 2016- Facebook, Inc (Adam Paszke)
|
216 |
+
Copyright (c) 2014- Facebook, Inc (Soumith Chintala)
|
217 |
+
Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert)
|
218 |
+
Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu)
|
219 |
+
Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu)
|
220 |
+
Copyright (c) 2011-2013 NYU (Clement Farabet)
|
221 |
+
Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston)
|
222 |
+
Copyright (c) 2006 Idiap Research Institute (Samy Bengio)
|
223 |
+
Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz)
|
224 |
+
|
225 |
+
|
226 |
+
Terms of the BSD 3-Clause License:
|
227 |
+
---------------------------------------------
|
228 |
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
229 |
+
|
230 |
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
231 |
+
|
232 |
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
233 |
+
|
234 |
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
235 |
+
|
236 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
237 |
+
|
238 |
+
|
239 |
+
|
240 |
+
Open Source Software licensed under the BSD 3-Clause License and Other Licenses of the Third-Party Components therein:
|
241 |
+
---------------------------------------------
|
242 |
+
1. numpy
|
243 |
+
Copyright (c) 2005-2020, NumPy Developers.
|
244 |
+
All rights reserved.
|
245 |
+
|
246 |
+
A copy of BSD 3-Clause License is included in this file.
|
247 |
+
|
248 |
+
The NumPy repository and source distributions bundle several libraries that are
|
249 |
+
compatibly licensed. We list these here.
|
250 |
+
|
251 |
+
Name: Numpydoc
|
252 |
+
Files: doc/sphinxext/numpydoc/*
|
253 |
+
License: BSD-2-Clause
|
254 |
+
For details, see doc/sphinxext/LICENSE.txt
|
255 |
+
|
256 |
+
Name: scipy-sphinx-theme
|
257 |
+
Files: doc/scipy-sphinx-theme/*
|
258 |
+
License: BSD-3-Clause AND PSF-2.0 AND Apache-2.0
|
259 |
+
For details, see doc/scipy-sphinx-theme/LICENSE.txt
|
260 |
+
|
261 |
+
Name: lapack-lite
|
262 |
+
Files: numpy/linalg/lapack_lite/*
|
263 |
+
License: BSD-3-Clause
|
264 |
+
For details, see numpy/linalg/lapack_lite/LICENSE.txt
|
265 |
+
|
266 |
+
Name: tempita
|
267 |
+
Files: tools/npy_tempita/*
|
268 |
+
License: MIT
|
269 |
+
For details, see tools/npy_tempita/license.txt
|
270 |
+
|
271 |
+
Name: dragon4
|
272 |
+
Files: numpy/core/src/multiarray/dragon4.c
|
273 |
+
License: MIT
|
274 |
+
For license text, see numpy/core/src/multiarray/dragon4.c
|
275 |
+
|
276 |
+
|
277 |
+
|
278 |
+
Open Source Software licensed under the MIT license:
|
279 |
+
---------------------------------------------
|
280 |
+
1. facexlib
|
281 |
+
Copyright (c) 2020 Xintao Wang
|
282 |
+
|
283 |
+
2. opencv-python
|
284 |
+
Copyright (c) Olli-Pekka Heinisuo
|
285 |
+
Please note that only files in cv2 package are used.
|
286 |
+
|
287 |
+
|
288 |
+
Terms of the MIT License:
|
289 |
+
---------------------------------------------
|
290 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
291 |
+
|
292 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
293 |
+
|
294 |
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
295 |
+
|
296 |
+
|
297 |
+
|
298 |
+
Open Source Software licensed under the MIT license and Other Licenses of the Third-Party Components therein:
|
299 |
+
---------------------------------------------
|
300 |
+
1. tqdm
|
301 |
+
Copyright (c) 2013 noamraph
|
302 |
+
|
303 |
+
`tqdm` is a product of collaborative work.
|
304 |
+
Unless otherwise stated, all authors (see commit logs) retain copyright
|
305 |
+
for their respective work, and release the work under the MIT licence
|
306 |
+
(text below).
|
307 |
+
|
308 |
+
Exceptions or notable authors are listed below
|
309 |
+
in reverse chronological order:
|
310 |
+
|
311 |
+
* files: *
|
312 |
+
MPLv2.0 2015-2020 (c) Casper da Costa-Luis
|
313 |
+
[casperdcl](https://github.com/casperdcl).
|
314 |
+
* files: tqdm/_tqdm.py
|
315 |
+
MIT 2016 (c) [PR #96] on behalf of Google Inc.
|
316 |
+
* files: tqdm/_tqdm.py setup.py README.rst MANIFEST.in .gitignore
|
317 |
+
MIT 2013 (c) Noam Yorav-Raphael, original author.
|
318 |
+
|
319 |
+
[PR #96]: https://github.com/tqdm/tqdm/pull/96
|
320 |
+
|
321 |
+
|
322 |
+
Mozilla Public Licence (MPL) v. 2.0 - Exhibit A
|
323 |
+
-----------------------------------------------
|
324 |
+
|
325 |
+
This Source Code Form is subject to the terms of the
|
326 |
+
Mozilla Public License, v. 2.0.
|
327 |
+
If a copy of the MPL was not distributed with this file,
|
328 |
+
You can obtain one at https://mozilla.org/MPL/2.0/.
|
329 |
+
|
330 |
+
|
331 |
+
MIT License (MIT)
|
332 |
+
-----------------
|
333 |
+
|
334 |
+
Copyright (c) 2013 noamraph
|
335 |
+
|
336 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
337 |
+
this software and associated documentation files (the "Software"), to deal in
|
338 |
+
the Software without restriction, including without limitation the rights to
|
339 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
340 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
341 |
+
subject to the following conditions:
|
342 |
+
|
343 |
+
The above copyright notice and this permission notice shall be included in all
|
344 |
+
copies or substantial portions of the Software.
|
345 |
+
|
346 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
347 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
348 |
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
349 |
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
350 |
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
351 |
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
MANIFEST.in
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
include assets/*
|
2 |
+
include inputs/*
|
3 |
+
include scripts/*.py
|
4 |
+
include inference_gfpgan.py
|
5 |
+
include VERSION
|
6 |
+
include LICENSE
|
7 |
+
include requirements.txt
|
8 |
+
include gfpgan/weights/README.md
|
PaperModel.md
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Installation
|
2 |
+
|
3 |
+
We now provide a *clean* version of GFPGAN, which does not require customized CUDA extensions. See [here](README.md#installation) for this easier installation.<br>
|
4 |
+
If you want want to use the original model in our paper, please follow the instructions below.
|
5 |
+
|
6 |
+
1. Clone repo
|
7 |
+
|
8 |
+
```bash
|
9 |
+
git clone https://github.com/xinntao/GFPGAN.git
|
10 |
+
cd GFPGAN
|
11 |
+
```
|
12 |
+
|
13 |
+
1. Install dependent packages
|
14 |
+
|
15 |
+
As StyleGAN2 uses customized PyTorch C++ extensions, you need to **compile them during installation** or **load them just-in-time(JIT)**.
|
16 |
+
You can refer to [BasicSR-INSTALL.md](https://github.com/xinntao/BasicSR/blob/master/INSTALL.md) for more details.
|
17 |
+
|
18 |
+
**Option 1: Load extensions just-in-time(JIT)** (For those just want to do simple inferences, may have less issues)
|
19 |
+
|
20 |
+
```bash
|
21 |
+
# Install basicsr - https://github.com/xinntao/BasicSR
|
22 |
+
# We use BasicSR for both training and inference
|
23 |
+
pip install basicsr
|
24 |
+
|
25 |
+
# Install facexlib - https://github.com/xinntao/facexlib
|
26 |
+
# We use face detection and face restoration helper in the facexlib package
|
27 |
+
pip install facexlib
|
28 |
+
|
29 |
+
pip install -r requirements.txt
|
30 |
+
python setup.py develop
|
31 |
+
|
32 |
+
# remember to set BASICSR_JIT=True before your running commands
|
33 |
+
```
|
34 |
+
|
35 |
+
**Option 2: Compile extensions during installation** (For those need to train/inference for many times)
|
36 |
+
|
37 |
+
```bash
|
38 |
+
# Install basicsr - https://github.com/xinntao/BasicSR
|
39 |
+
# We use BasicSR for both training and inference
|
40 |
+
# Set BASICSR_EXT=True to compile the cuda extensions in the BasicSR - It may take several minutes to compile, please be patient
|
41 |
+
# Add -vvv for detailed log prints
|
42 |
+
BASICSR_EXT=True pip install basicsr -vvv
|
43 |
+
|
44 |
+
# Install facexlib - https://github.com/xinntao/facexlib
|
45 |
+
# We use face detection and face restoration helper in the facexlib package
|
46 |
+
pip install facexlib
|
47 |
+
|
48 |
+
pip install -r requirements.txt
|
49 |
+
python setup.py develop
|
50 |
+
```
|
51 |
+
|
52 |
+
## :zap: Quick Inference
|
53 |
+
|
54 |
+
Download pre-trained models: [GFPGANv1.pth](https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/GFPGANv1.pth)
|
55 |
+
|
56 |
+
```bash
|
57 |
+
wget https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/GFPGANv1.pth -P experiments/pretrained_models
|
58 |
+
```
|
59 |
+
|
60 |
+
- Option 1: Load extensions just-in-time(JIT)
|
61 |
+
|
62 |
+
```bash
|
63 |
+
BASICSR_JIT=True python inference_gfpgan.py --input inputs/whole_imgs --output results --version 1
|
64 |
+
|
65 |
+
# for aligned images
|
66 |
+
BASICSR_JIT=True python inference_gfpgan.py --input inputs/whole_imgs --output results --version 1 --aligned
|
67 |
+
```
|
68 |
+
|
69 |
+
- Option 2: Have successfully compiled extensions during installation
|
70 |
+
|
71 |
+
```bash
|
72 |
+
python inference_gfpgan.py --input inputs/whole_imgs --output results --version 1
|
73 |
+
|
74 |
+
# for aligned images
|
75 |
+
python inference_gfpgan.py --input inputs/whole_imgs --output results --version 1 --aligned
|
76 |
+
```
|
README.md
CHANGED
@@ -1,3 +1,202 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p align="center">
|
2 |
+
<img src="assets/gfpgan_logo.png" height=130>
|
3 |
+
</p>
|
4 |
+
|
5 |
+
## <div align="center"><b><a href="README.md">English</a> | <a href="README_CN.md">简体中文</a></b></div>
|
6 |
+
|
7 |
+
<div align="center">
|
8 |
+
<!-- <a href="https://twitter.com/_Xintao_" style="text-decoration:none;">
|
9 |
+
<img src="https://user-images.githubusercontent.com/17445847/187162058-c764ced6-952f-404b-ac85-ba95cce18e7b.png" width="4%" alt="" />
|
10 |
+
</a> -->
|
11 |
+
|
12 |
+
[](https://github.com/TencentARC/GFPGAN/releases)
|
13 |
+
[](https://pypi.org/project/gfpgan/)
|
14 |
+
[](https://github.com/TencentARC/GFPGAN/issues)
|
15 |
+
[](https://github.com/TencentARC/GFPGAN/issues)
|
16 |
+
[](https://github.com/TencentARC/GFPGAN/blob/master/LICENSE)
|
17 |
+
[](https://github.com/TencentARC/GFPGAN/blob/master/.github/workflows/pylint.yml)
|
18 |
+
[](https://github.com/TencentARC/GFPGAN/blob/master/.github/workflows/publish-pip.yml)
|
19 |
+
</div>
|
20 |
+
|
21 |
+
1. :boom: **Updated** online demo: [](https://replicate.com/tencentarc/gfpgan). Here is the [backup](https://replicate.com/xinntao/gfpgan).
|
22 |
+
1. :boom: **Updated** online demo: [](https://huggingface.co/spaces/Xintao/GFPGAN)
|
23 |
+
1. [Colab Demo](https://colab.research.google.com/drive/1sVsoBd9AjckIXThgtZhGrHRfFI6UUYOo) for GFPGAN <a href="https://colab.research.google.com/drive/1sVsoBd9AjckIXThgtZhGrHRfFI6UUYOo"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="google colab logo"></a>; (Another [Colab Demo](https://colab.research.google.com/drive/1Oa1WwKB4M4l1GmR7CtswDVgOCOeSLChA?usp=sharing) for the original paper model)
|
24 |
+
|
25 |
+
<!-- 3. Online demo: [Replicate.ai](https://replicate.com/xinntao/gfpgan) (may need to sign in, return the whole image)
|
26 |
+
4. Online demo: [Baseten.co](https://app.baseten.co/applications/Q04Lz0d/operator_views/8qZG6Bg) (backed by GPU, returns the whole image)
|
27 |
+
5. We provide a *clean* version of GFPGAN, which can run without CUDA extensions. So that it can run in **Windows** or on **CPU mode**. -->
|
28 |
+
|
29 |
+
> :rocket: **Thanks for your interest in our work. You may also want to check our new updates on the *tiny models* for *anime images and videos* in [Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN/blob/master/docs/anime_video_model.md)** :blush:
|
30 |
+
|
31 |
+
GFPGAN aims at developing a **Practical Algorithm for Real-world Face Restoration**.<br>
|
32 |
+
It leverages rich and diverse priors encapsulated in a pretrained face GAN (*e.g.*, StyleGAN2) for blind face restoration.
|
33 |
+
|
34 |
+
:question: Frequently Asked Questions can be found in [FAQ.md](FAQ.md).
|
35 |
+
|
36 |
+
:triangular_flag_on_post: **Updates**
|
37 |
+
|
38 |
+
- :white_check_mark: Add [RestoreFormer](https://github.com/wzhouxiff/RestoreFormer) inference codes.
|
39 |
+
- :white_check_mark: Add [V1.4 model](https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth), which produces slightly more details and better identity than V1.3.
|
40 |
+
- :white_check_mark: Add **[V1.3 model](https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth)**, which produces **more natural** restoration results, and better results on *very low-quality* / *high-quality* inputs. See more in [Model zoo](#european_castle-model-zoo), [Comparisons.md](Comparisons.md)
|
41 |
+
- :white_check_mark: Integrated to [Huggingface Spaces](https://huggingface.co/spaces) with [Gradio](https://github.com/gradio-app/gradio). See [Gradio Web Demo](https://huggingface.co/spaces/akhaliq/GFPGAN).
|
42 |
+
- :white_check_mark: Support enhancing non-face regions (background) with [Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN).
|
43 |
+
- :white_check_mark: We provide a *clean* version of GFPGAN, which does not require CUDA extensions.
|
44 |
+
- :white_check_mark: We provide an updated model without colorizing faces.
|
45 |
+
|
46 |
+
---
|
47 |
+
|
48 |
+
If GFPGAN is helpful in your photos/projects, please help to :star: this repo or recommend it to your friends. Thanks:blush:
|
49 |
+
Other recommended projects:<br>
|
50 |
+
:arrow_forward: [Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN): A practical algorithm for general image restoration<br>
|
51 |
+
:arrow_forward: [BasicSR](https://github.com/xinntao/BasicSR): An open-source image and video restoration toolbox<br>
|
52 |
+
:arrow_forward: [facexlib](https://github.com/xinntao/facexlib): A collection that provides useful face-relation functions<br>
|
53 |
+
:arrow_forward: [HandyView](https://github.com/xinntao/HandyView): A PyQt5-based image viewer that is handy for view and comparison<br>
|
54 |
+
|
55 |
+
---
|
56 |
+
|
57 |
+
### :book: GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior
|
58 |
+
|
59 |
+
> [[Paper](https://arxiv.org/abs/2101.04061)]   [[Project Page](https://xinntao.github.io/projects/gfpgan)]   [Demo] <br>
|
60 |
+
> [Xintao Wang](https://xinntao.github.io/), [Yu Li](https://yu-li.github.io/), [Honglun Zhang](https://scholar.google.com/citations?hl=en&user=KjQLROoAAAAJ), [Ying Shan](https://scholar.google.com/citations?user=4oXBp9UAAAAJ&hl=en) <br>
|
61 |
+
> Applied Research Center (ARC), Tencent PCG
|
62 |
+
|
63 |
+
<p align="center">
|
64 |
+
<img src="https://xinntao.github.io/projects/GFPGAN_src/gfpgan_teaser.jpg">
|
65 |
+
</p>
|
66 |
+
|
67 |
+
---
|
68 |
+
|
69 |
+
## :wrench: Dependencies and Installation
|
70 |
+
|
71 |
+
- Python >= 3.7 (Recommend to use [Anaconda](https://www.anaconda.com/download/#linux) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html))
|
72 |
+
- [PyTorch >= 1.7](https://pytorch.org/)
|
73 |
+
- Option: NVIDIA GPU + [CUDA](https://developer.nvidia.com/cuda-downloads)
|
74 |
+
- Option: Linux
|
75 |
+
|
76 |
+
### Installation
|
77 |
+
|
78 |
+
We now provide a *clean* version of GFPGAN, which does not require customized CUDA extensions. <br>
|
79 |
+
If you want to use the original model in our paper, please see [PaperModel.md](PaperModel.md) for installation.
|
80 |
+
|
81 |
+
1. Clone repo
|
82 |
+
|
83 |
+
```bash
|
84 |
+
git clone https://github.com/TencentARC/GFPGAN.git
|
85 |
+
cd GFPGAN
|
86 |
+
```
|
87 |
+
|
88 |
+
1. Install dependent packages
|
89 |
+
|
90 |
+
```bash
|
91 |
+
# Install basicsr - https://github.com/xinntao/BasicSR
|
92 |
+
# We use BasicSR for both training and inference
|
93 |
+
pip install basicsr
|
94 |
+
|
95 |
+
# Install facexlib - https://github.com/xinntao/facexlib
|
96 |
+
# We use face detection and face restoration helper in the facexlib package
|
97 |
+
pip install facexlib
|
98 |
+
|
99 |
+
pip install -r requirements.txt
|
100 |
+
python setup.py develop
|
101 |
+
|
102 |
+
# If you want to enhance the background (non-face) regions with Real-ESRGAN,
|
103 |
+
# you also need to install the realesrgan package
|
104 |
+
pip install realesrgan
|
105 |
+
```
|
106 |
+
|
107 |
+
## :zap: Quick Inference
|
108 |
+
|
109 |
+
We take the v1.3 version for an example. More models can be found [here](#european_castle-model-zoo).
|
110 |
+
|
111 |
+
Download pre-trained models: [GFPGANv1.3.pth](https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth)
|
112 |
+
|
113 |
+
```bash
|
114 |
+
wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P experiments/pretrained_models
|
115 |
+
```
|
116 |
+
|
117 |
+
**Inference!**
|
118 |
+
|
119 |
+
```bash
|
120 |
+
python inference_gfpgan.py -i inputs/whole_imgs -o results -v 1.3 -s 2
|
121 |
+
```
|
122 |
+
|
123 |
+
```console
|
124 |
+
Usage: python inference_gfpgan.py -i inputs/whole_imgs -o results -v 1.3 -s 2 [options]...
|
125 |
+
|
126 |
+
-h show this help
|
127 |
+
-i input Input image or folder. Default: inputs/whole_imgs
|
128 |
+
-o output Output folder. Default: results
|
129 |
+
-v version GFPGAN model version. Option: 1 | 1.2 | 1.3. Default: 1.3
|
130 |
+
-s upscale The final upsampling scale of the image. Default: 2
|
131 |
+
-bg_upsampler background upsampler. Default: realesrgan
|
132 |
+
-bg_tile Tile size for background sampler, 0 for no tile during testing. Default: 400
|
133 |
+
-suffix Suffix of the restored faces
|
134 |
+
-only_center_face Only restore the center face
|
135 |
+
-aligned Input are aligned faces
|
136 |
+
-ext Image extension. Options: auto | jpg | png, auto means using the same extension as inputs. Default: auto
|
137 |
+
```
|
138 |
+
|
139 |
+
If you want to use the original model in our paper, please see [PaperModel.md](PaperModel.md) for installation and inference.
|
140 |
+
|
141 |
+
## :european_castle: Model Zoo
|
142 |
+
|
143 |
+
| Version | Model Name | Description |
|
144 |
+
| :---: | :---: | :---: |
|
145 |
+
| V1.3 | [GFPGANv1.3.pth](https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth) | Based on V1.2; **more natural** restoration results; better results on very low-quality / high-quality inputs. |
|
146 |
+
| V1.2 | [GFPGANCleanv1-NoCE-C2.pth](https://github.com/TencentARC/GFPGAN/releases/download/v0.2.0/GFPGANCleanv1-NoCE-C2.pth) | No colorization; no CUDA extensions are required. Trained with more data with pre-processing. |
|
147 |
+
| V1 | [GFPGANv1.pth](https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/GFPGANv1.pth) | The paper model, with colorization. |
|
148 |
+
|
149 |
+
The comparisons are in [Comparisons.md](Comparisons.md).
|
150 |
+
|
151 |
+
Note that V1.3 is not always better than V1.2. You may need to select different models based on your purpose and inputs.
|
152 |
+
|
153 |
+
| Version | Strengths | Weaknesses |
|
154 |
+
| :---: | :---: | :---: |
|
155 |
+
|V1.3 | ✓ natural outputs<br> ✓better results on very low-quality inputs <br> ✓ work on relatively high-quality inputs <br>✓ can have repeated (twice) restorations | ✗ not very sharp <br> ✗ have a slight change on identity |
|
156 |
+
|V1.2 | ✓ sharper output <br> ✓ with beauty makeup | ✗ some outputs are unnatural |
|
157 |
+
|
158 |
+
You can find **more models (such as the discriminators)** here: [[Google Drive](https://drive.google.com/drive/folders/17rLiFzcUMoQuhLnptDsKolegHWwJOnHu?usp=sharing)], OR [[Tencent Cloud 腾讯微云](https://share.weiyun.com/ShYoCCoc)]
|
159 |
+
|
160 |
+
## :computer: Training
|
161 |
+
|
162 |
+
We provide the training codes for GFPGAN (used in our paper). <br>
|
163 |
+
You could improve it according to your own needs.
|
164 |
+
|
165 |
+
**Tips**
|
166 |
+
|
167 |
+
1. More high quality faces can improve the restoration quality.
|
168 |
+
2. You may need to perform some pre-processing, such as beauty makeup.
|
169 |
+
|
170 |
+
**Procedures**
|
171 |
+
|
172 |
+
(You can try a simple version ( `options/train_gfpgan_v1_simple.yml`) that does not require face component landmarks.)
|
173 |
+
|
174 |
+
1. Dataset preparation: [FFHQ](https://github.com/NVlabs/ffhq-dataset)
|
175 |
+
|
176 |
+
1. Download pre-trained models and other data. Put them in the `experiments/pretrained_models` folder.
|
177 |
+
1. [Pre-trained StyleGAN2 model: StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth](https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth)
|
178 |
+
1. [Component locations of FFHQ: FFHQ_eye_mouth_landmarks_512.pth](https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/FFHQ_eye_mouth_landmarks_512.pth)
|
179 |
+
1. [A simple ArcFace model: arcface_resnet18.pth](https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/arcface_resnet18.pth)
|
180 |
+
|
181 |
+
1. Modify the configuration file `options/train_gfpgan_v1.yml` accordingly.
|
182 |
+
|
183 |
+
1. Training
|
184 |
+
|
185 |
+
> python -m torch.distributed.launch --nproc_per_node=4 --master_port=22021 gfpgan/train.py -opt options/train_gfpgan_v1.yml --launcher pytorch
|
186 |
+
|
187 |
+
## :scroll: License and Acknowledgement
|
188 |
+
|
189 |
+
GFPGAN is released under Apache License Version 2.0.
|
190 |
+
|
191 |
+
## BibTeX
|
192 |
+
|
193 |
+
@InProceedings{wang2021gfpgan,
|
194 |
+
author = {Xintao Wang and Yu Li and Honglun Zhang and Ying Shan},
|
195 |
+
title = {Towards Real-World Blind Face Restoration with Generative Facial Prior},
|
196 |
+
booktitle={The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
|
197 |
+
year = {2021}
|
198 |
+
}
|
199 |
+
|
200 |
+
## :e-mail: Contact
|
201 |
+
|
202 |
+
If you have any question, please email `xintao.wang@outlook.com` or `xintaowang@tencent.com`.
|
README_CN.md
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p align="center">
|
2 |
+
<img src="assets/gfpgan_logo.png" height=130>
|
3 |
+
</p>
|
4 |
+
|
5 |
+
## <div align="center"><b><a href="README.md">English</a> | <a href="README_CN.md">简体中文</a></b></div>
|
6 |
+
|
7 |
+
还未完工,欢迎贡献!
|
VERSION
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
1.3.8
|
cog.yaml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is used for constructing replicate env
|
2 |
+
image: "r8.im/tencentarc/gfpgan"
|
3 |
+
|
4 |
+
build:
|
5 |
+
gpu: true
|
6 |
+
python_version: "3.8"
|
7 |
+
system_packages:
|
8 |
+
- "libgl1-mesa-glx"
|
9 |
+
- "libglib2.0-0"
|
10 |
+
python_packages:
|
11 |
+
- "torch==1.7.1"
|
12 |
+
- "torchvision==0.8.2"
|
13 |
+
- "numpy==1.21.1"
|
14 |
+
- "lmdb==1.2.1"
|
15 |
+
- "opencv-python==4.5.3.56"
|
16 |
+
- "PyYAML==5.4.1"
|
17 |
+
- "tqdm==4.62.2"
|
18 |
+
- "yapf==0.31.0"
|
19 |
+
- "basicsr==1.4.2"
|
20 |
+
- "facexlib==0.2.5"
|
21 |
+
|
22 |
+
predict: "cog_predict.py:Predictor"
|
cog_predict.py
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# flake8: noqa
|
2 |
+
# This file is used for deploying replicate models
|
3 |
+
# running: cog predict -i img=@inputs/whole_imgs/10045.png -i version='v1.4' -i scale=2
|
4 |
+
# push: cog push r8.im/tencentarc/gfpgan
|
5 |
+
# push (backup): cog push r8.im/xinntao/gfpgan
|
6 |
+
|
7 |
+
import os
|
8 |
+
|
9 |
+
os.system('python setup.py develop')
|
10 |
+
os.system('pip install realesrgan')
|
11 |
+
|
12 |
+
import cv2
|
13 |
+
import shutil
|
14 |
+
import tempfile
|
15 |
+
import torch
|
16 |
+
from basicsr.archs.srvgg_arch import SRVGGNetCompact
|
17 |
+
|
18 |
+
from gfpgan import GFPGANer
|
19 |
+
|
20 |
+
try:
|
21 |
+
from cog import BasePredictor, Input, Path
|
22 |
+
from realesrgan.utils import RealESRGANer
|
23 |
+
except Exception:
|
24 |
+
print('please install cog and realesrgan package')
|
25 |
+
|
26 |
+
|
27 |
+
class Predictor(BasePredictor):
|
28 |
+
|
29 |
+
def setup(self):
|
30 |
+
os.makedirs('output', exist_ok=True)
|
31 |
+
# download weights
|
32 |
+
if not os.path.exists('gfpgan/weights/realesr-general-x4v3.pth'):
|
33 |
+
os.system(
|
34 |
+
'wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth -P ./gfpgan/weights'
|
35 |
+
)
|
36 |
+
if not os.path.exists('gfpgan/weights/GFPGANv1.2.pth'):
|
37 |
+
os.system(
|
38 |
+
'wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.2.pth -P ./gfpgan/weights')
|
39 |
+
if not os.path.exists('gfpgan/weights/GFPGANv1.3.pth'):
|
40 |
+
os.system(
|
41 |
+
'wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P ./gfpgan/weights')
|
42 |
+
if not os.path.exists('gfpgan/weights/GFPGANv1.4.pth'):
|
43 |
+
os.system(
|
44 |
+
'wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth -P ./gfpgan/weights')
|
45 |
+
if not os.path.exists('gfpgan/weights/RestoreFormer.pth'):
|
46 |
+
os.system(
|
47 |
+
'wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/RestoreFormer.pth -P ./gfpgan/weights'
|
48 |
+
)
|
49 |
+
|
50 |
+
# background enhancer with RealESRGAN
|
51 |
+
model = SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu')
|
52 |
+
model_path = 'gfpgan/weights/realesr-general-x4v3.pth'
|
53 |
+
half = True if torch.cuda.is_available() else False
|
54 |
+
self.upsampler = RealESRGANer(
|
55 |
+
scale=4, model_path=model_path, model=model, tile=0, tile_pad=10, pre_pad=0, half=half)
|
56 |
+
|
57 |
+
# Use GFPGAN for face enhancement
|
58 |
+
self.face_enhancer = GFPGANer(
|
59 |
+
model_path='gfpgan/weights/GFPGANv1.4.pth',
|
60 |
+
upscale=2,
|
61 |
+
arch='clean',
|
62 |
+
channel_multiplier=2,
|
63 |
+
bg_upsampler=self.upsampler)
|
64 |
+
self.current_version = 'v1.4'
|
65 |
+
|
66 |
+
def predict(
|
67 |
+
self,
|
68 |
+
img: Path = Input(description='Input'),
|
69 |
+
version: str = Input(
|
70 |
+
description='GFPGAN version. v1.3: better quality. v1.4: more details and better identity.',
|
71 |
+
choices=['v1.2', 'v1.3', 'v1.4', 'RestoreFormer'],
|
72 |
+
default='v1.4'),
|
73 |
+
scale: float = Input(description='Rescaling factor', default=2),
|
74 |
+
) -> Path:
|
75 |
+
weight = 0.5
|
76 |
+
print(img, version, scale, weight)
|
77 |
+
try:
|
78 |
+
extension = os.path.splitext(os.path.basename(str(img)))[1]
|
79 |
+
img = cv2.imread(str(img), cv2.IMREAD_UNCHANGED)
|
80 |
+
if len(img.shape) == 3 and img.shape[2] == 4:
|
81 |
+
img_mode = 'RGBA'
|
82 |
+
elif len(img.shape) == 2:
|
83 |
+
img_mode = None
|
84 |
+
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
|
85 |
+
else:
|
86 |
+
img_mode = None
|
87 |
+
|
88 |
+
h, w = img.shape[0:2]
|
89 |
+
if h < 300:
|
90 |
+
img = cv2.resize(img, (w * 2, h * 2), interpolation=cv2.INTER_LANCZOS4)
|
91 |
+
|
92 |
+
if self.current_version != version:
|
93 |
+
if version == 'v1.2':
|
94 |
+
self.face_enhancer = GFPGANer(
|
95 |
+
model_path='gfpgan/weights/GFPGANv1.2.pth',
|
96 |
+
upscale=2,
|
97 |
+
arch='clean',
|
98 |
+
channel_multiplier=2,
|
99 |
+
bg_upsampler=self.upsampler)
|
100 |
+
self.current_version = 'v1.2'
|
101 |
+
elif version == 'v1.3':
|
102 |
+
self.face_enhancer = GFPGANer(
|
103 |
+
model_path='gfpgan/weights/GFPGANv1.3.pth',
|
104 |
+
upscale=2,
|
105 |
+
arch='clean',
|
106 |
+
channel_multiplier=2,
|
107 |
+
bg_upsampler=self.upsampler)
|
108 |
+
self.current_version = 'v1.3'
|
109 |
+
elif version == 'v1.4':
|
110 |
+
self.face_enhancer = GFPGANer(
|
111 |
+
model_path='gfpgan/weights/GFPGANv1.4.pth',
|
112 |
+
upscale=2,
|
113 |
+
arch='clean',
|
114 |
+
channel_multiplier=2,
|
115 |
+
bg_upsampler=self.upsampler)
|
116 |
+
self.current_version = 'v1.4'
|
117 |
+
elif version == 'RestoreFormer':
|
118 |
+
self.face_enhancer = GFPGANer(
|
119 |
+
model_path='gfpgan/weights/RestoreFormer.pth',
|
120 |
+
upscale=2,
|
121 |
+
arch='RestoreFormer',
|
122 |
+
channel_multiplier=2,
|
123 |
+
bg_upsampler=self.upsampler)
|
124 |
+
|
125 |
+
try:
|
126 |
+
_, _, output = self.face_enhancer.enhance(
|
127 |
+
img, has_aligned=False, only_center_face=False, paste_back=True, weight=weight)
|
128 |
+
except RuntimeError as error:
|
129 |
+
print('Error', error)
|
130 |
+
|
131 |
+
try:
|
132 |
+
if scale != 2:
|
133 |
+
interpolation = cv2.INTER_AREA if scale < 2 else cv2.INTER_LANCZOS4
|
134 |
+
h, w = img.shape[0:2]
|
135 |
+
output = cv2.resize(output, (int(w * scale / 2), int(h * scale / 2)), interpolation=interpolation)
|
136 |
+
except Exception as error:
|
137 |
+
print('wrong scale input.', error)
|
138 |
+
|
139 |
+
if img_mode == 'RGBA': # RGBA images should be saved in png format
|
140 |
+
extension = 'png'
|
141 |
+
# save_path = f'output/out.{extension}'
|
142 |
+
# cv2.imwrite(save_path, output)
|
143 |
+
out_path = Path(tempfile.mkdtemp()) / f'out.{extension}'
|
144 |
+
cv2.imwrite(str(out_path), output)
|
145 |
+
except Exception as error:
|
146 |
+
print('global exception: ', error)
|
147 |
+
finally:
|
148 |
+
clean_folder('output')
|
149 |
+
return out_path
|
150 |
+
|
151 |
+
|
152 |
+
def clean_folder(folder):
|
153 |
+
for filename in os.listdir(folder):
|
154 |
+
file_path = os.path.join(folder, filename)
|
155 |
+
try:
|
156 |
+
if os.path.isfile(file_path) or os.path.islink(file_path):
|
157 |
+
os.unlink(file_path)
|
158 |
+
elif os.path.isdir(file_path):
|
159 |
+
shutil.rmtree(file_path)
|
160 |
+
except Exception as e:
|
161 |
+
print(f'Failed to delete {file_path}. Reason: {e}')
|
inference_gfpgan.py
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import cv2
|
3 |
+
import glob
|
4 |
+
import numpy as np
|
5 |
+
import os
|
6 |
+
import torch
|
7 |
+
from basicsr.utils import imwrite
|
8 |
+
|
9 |
+
from gfpgan import GFPGANer
|
10 |
+
|
11 |
+
|
12 |
+
def main():
|
13 |
+
"""Inference demo for GFPGAN (for users).
|
14 |
+
"""
|
15 |
+
parser = argparse.ArgumentParser()
|
16 |
+
parser.add_argument(
|
17 |
+
'-i',
|
18 |
+
'--input',
|
19 |
+
type=str,
|
20 |
+
default='inputs/whole_imgs',
|
21 |
+
help='Input image or folder. Default: inputs/whole_imgs')
|
22 |
+
parser.add_argument('-o', '--output', type=str, default='results', help='Output folder. Default: results')
|
23 |
+
# we use version to select models, which is more user-friendly
|
24 |
+
parser.add_argument(
|
25 |
+
'-v', '--version', type=str, default='1.3', help='GFPGAN model version. Option: 1 | 1.2 | 1.3. Default: 1.3')
|
26 |
+
parser.add_argument(
|
27 |
+
'-s', '--upscale', type=int, default=2, help='The final upsampling scale of the image. Default: 2')
|
28 |
+
|
29 |
+
parser.add_argument(
|
30 |
+
'--bg_upsampler', type=str, default='realesrgan', help='background upsampler. Default: realesrgan')
|
31 |
+
parser.add_argument(
|
32 |
+
'--bg_tile',
|
33 |
+
type=int,
|
34 |
+
default=400,
|
35 |
+
help='Tile size for background sampler, 0 for no tile during testing. Default: 400')
|
36 |
+
parser.add_argument('--suffix', type=str, default=None, help='Suffix of the restored faces')
|
37 |
+
parser.add_argument('--only_center_face', action='store_true', help='Only restore the center face')
|
38 |
+
parser.add_argument('--aligned', action='store_true', help='Input are aligned faces')
|
39 |
+
parser.add_argument(
|
40 |
+
'--ext',
|
41 |
+
type=str,
|
42 |
+
default='auto',
|
43 |
+
help='Image extension. Options: auto | jpg | png, auto means using the same extension as inputs. Default: auto')
|
44 |
+
parser.add_argument('-w', '--weight', type=float, default=0.5, help='Adjustable weights.')
|
45 |
+
args = parser.parse_args()
|
46 |
+
|
47 |
+
args = parser.parse_args()
|
48 |
+
|
49 |
+
# ------------------------ input & output ------------------------
|
50 |
+
if args.input.endswith('/'):
|
51 |
+
args.input = args.input[:-1]
|
52 |
+
if os.path.isfile(args.input):
|
53 |
+
img_list = [args.input]
|
54 |
+
else:
|
55 |
+
img_list = sorted(glob.glob(os.path.join(args.input, '*')))
|
56 |
+
|
57 |
+
os.makedirs(args.output, exist_ok=True)
|
58 |
+
|
59 |
+
# ------------------------ set up background upsampler ------------------------
|
60 |
+
if args.bg_upsampler == 'realesrgan':
|
61 |
+
if not torch.cuda.is_available(): # CPU
|
62 |
+
import warnings
|
63 |
+
warnings.warn('The unoptimized RealESRGAN is slow on CPU. We do not use it. '
|
64 |
+
'If you really want to use it, please modify the corresponding codes.')
|
65 |
+
bg_upsampler = None
|
66 |
+
else:
|
67 |
+
from basicsr.archs.rrdbnet_arch import RRDBNet
|
68 |
+
from realesrgan import RealESRGANer
|
69 |
+
model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=2)
|
70 |
+
bg_upsampler = RealESRGANer(
|
71 |
+
scale=2,
|
72 |
+
model_path='https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth',
|
73 |
+
model=model,
|
74 |
+
tile=args.bg_tile,
|
75 |
+
tile_pad=10,
|
76 |
+
pre_pad=0,
|
77 |
+
half=True) # need to set False in CPU mode
|
78 |
+
else:
|
79 |
+
bg_upsampler = None
|
80 |
+
|
81 |
+
# ------------------------ set up GFPGAN restorer ------------------------
|
82 |
+
if args.version == '1':
|
83 |
+
arch = 'original'
|
84 |
+
channel_multiplier = 1
|
85 |
+
model_name = 'GFPGANv1'
|
86 |
+
url = 'https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/GFPGANv1.pth'
|
87 |
+
elif args.version == '1.2':
|
88 |
+
arch = 'clean'
|
89 |
+
channel_multiplier = 2
|
90 |
+
model_name = 'GFPGANCleanv1-NoCE-C2'
|
91 |
+
url = 'https://github.com/TencentARC/GFPGAN/releases/download/v0.2.0/GFPGANCleanv1-NoCE-C2.pth'
|
92 |
+
elif args.version == '1.3':
|
93 |
+
arch = 'clean'
|
94 |
+
channel_multiplier = 2
|
95 |
+
model_name = 'GFPGANv1.3'
|
96 |
+
url = 'https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth'
|
97 |
+
elif args.version == '1.4':
|
98 |
+
arch = 'clean'
|
99 |
+
channel_multiplier = 2
|
100 |
+
model_name = 'GFPGANv1.4'
|
101 |
+
url = 'https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth'
|
102 |
+
elif args.version == 'RestoreFormer':
|
103 |
+
arch = 'RestoreFormer'
|
104 |
+
channel_multiplier = 2
|
105 |
+
model_name = 'RestoreFormer'
|
106 |
+
url = 'https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/RestoreFormer.pth'
|
107 |
+
else:
|
108 |
+
raise ValueError(f'Wrong model version {args.version}.')
|
109 |
+
|
110 |
+
# determine model paths
|
111 |
+
model_path = os.path.join('experiments/pretrained_models', model_name + '.pth')
|
112 |
+
if not os.path.isfile(model_path):
|
113 |
+
model_path = os.path.join('gfpgan/weights', model_name + '.pth')
|
114 |
+
if not os.path.isfile(model_path):
|
115 |
+
# download pre-trained models from url
|
116 |
+
model_path = url
|
117 |
+
|
118 |
+
restorer = GFPGANer(
|
119 |
+
model_path=model_path,
|
120 |
+
upscale=args.upscale,
|
121 |
+
arch=arch,
|
122 |
+
channel_multiplier=channel_multiplier,
|
123 |
+
bg_upsampler=bg_upsampler)
|
124 |
+
|
125 |
+
# ------------------------ restore ------------------------
|
126 |
+
for img_path in img_list:
|
127 |
+
# read image
|
128 |
+
img_name = os.path.basename(img_path)
|
129 |
+
print(f'Processing {img_name} ...')
|
130 |
+
basename, ext = os.path.splitext(img_name)
|
131 |
+
input_img = cv2.imread(img_path, cv2.IMREAD_COLOR)
|
132 |
+
|
133 |
+
# restore faces and background if necessary
|
134 |
+
cropped_faces, restored_faces, restored_img = restorer.enhance(
|
135 |
+
input_img,
|
136 |
+
has_aligned=args.aligned,
|
137 |
+
only_center_face=args.only_center_face,
|
138 |
+
paste_back=True,
|
139 |
+
weight=args.weight)
|
140 |
+
|
141 |
+
# save faces
|
142 |
+
for idx, (cropped_face, restored_face) in enumerate(zip(cropped_faces, restored_faces)):
|
143 |
+
# save cropped face
|
144 |
+
save_crop_path = os.path.join(args.output, 'cropped_faces', f'{basename}_{idx:02d}.png')
|
145 |
+
imwrite(cropped_face, save_crop_path)
|
146 |
+
# save restored face
|
147 |
+
if args.suffix is not None:
|
148 |
+
save_face_name = f'{basename}_{idx:02d}_{args.suffix}.png'
|
149 |
+
else:
|
150 |
+
save_face_name = f'{basename}_{idx:02d}.png'
|
151 |
+
save_restore_path = os.path.join(args.output, 'restored_faces', save_face_name)
|
152 |
+
imwrite(restored_face, save_restore_path)
|
153 |
+
# save comparison image
|
154 |
+
cmp_img = np.concatenate((cropped_face, restored_face), axis=1)
|
155 |
+
imwrite(cmp_img, os.path.join(args.output, 'cmp', f'{basename}_{idx:02d}.png'))
|
156 |
+
|
157 |
+
# save restored img
|
158 |
+
if restored_img is not None:
|
159 |
+
if args.ext == 'auto':
|
160 |
+
extension = ext[1:]
|
161 |
+
else:
|
162 |
+
extension = args.ext
|
163 |
+
|
164 |
+
if args.suffix is not None:
|
165 |
+
save_restore_path = os.path.join(args.output, 'restored_imgs', f'{basename}_{args.suffix}.{extension}')
|
166 |
+
else:
|
167 |
+
save_restore_path = os.path.join(args.output, 'restored_imgs', f'{basename}.{extension}')
|
168 |
+
imwrite(restored_img, save_restore_path)
|
169 |
+
|
170 |
+
print(f'Results are in the [{args.output}] folder.')
|
171 |
+
|
172 |
+
|
173 |
+
if __name__ == '__main__':
|
174 |
+
main()
|
requirements.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
basicsr>=1.4.2
|
2 |
+
facexlib>=0.2.5
|
3 |
+
lmdb
|
4 |
+
numpy
|
5 |
+
opencv-python
|
6 |
+
pyyaml
|
7 |
+
scipy
|
8 |
+
tb-nightly
|
9 |
+
torch>=1.7
|
10 |
+
torchvision
|
11 |
+
tqdm
|
12 |
+
yapf
|
setup.cfg
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[flake8]
|
2 |
+
ignore =
|
3 |
+
# line break before binary operator (W503)
|
4 |
+
W503,
|
5 |
+
# line break after binary operator (W504)
|
6 |
+
W504,
|
7 |
+
max-line-length=120
|
8 |
+
|
9 |
+
[yapf]
|
10 |
+
based_on_style = pep8
|
11 |
+
column_limit = 120
|
12 |
+
blank_line_before_nested_class_or_def = true
|
13 |
+
split_before_expression_after_opening_paren = true
|
14 |
+
|
15 |
+
[isort]
|
16 |
+
line_length = 120
|
17 |
+
multi_line_output = 0
|
18 |
+
known_standard_library = pkg_resources,setuptools
|
19 |
+
known_first_party = gfpgan
|
20 |
+
known_third_party = basicsr,cv2,facexlib,numpy,pytest,torch,torchvision,tqdm,yaml
|
21 |
+
no_lines_before = STDLIB,LOCALFOLDER
|
22 |
+
default_section = THIRDPARTY
|
23 |
+
|
24 |
+
[codespell]
|
25 |
+
skip = .git,./docs/build
|
26 |
+
count =
|
27 |
+
quiet-level = 3
|
28 |
+
|
29 |
+
[aliases]
|
30 |
+
test=pytest
|
31 |
+
|
32 |
+
[tool:pytest]
|
33 |
+
addopts=tests/
|
setup.py
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
|
3 |
+
from setuptools import find_packages, setup
|
4 |
+
|
5 |
+
import os
|
6 |
+
import subprocess
|
7 |
+
import time
|
8 |
+
|
9 |
+
version_file = 'gfpgan/version.py'
|
10 |
+
|
11 |
+
|
12 |
+
def readme():
|
13 |
+
with open('README.md', encoding='utf-8') as f:
|
14 |
+
content = f.read()
|
15 |
+
return content
|
16 |
+
|
17 |
+
|
18 |
+
def get_git_hash():
|
19 |
+
|
20 |
+
def _minimal_ext_cmd(cmd):
|
21 |
+
# construct minimal environment
|
22 |
+
env = {}
|
23 |
+
for k in ['SYSTEMROOT', 'PATH', 'HOME']:
|
24 |
+
v = os.environ.get(k)
|
25 |
+
if v is not None:
|
26 |
+
env[k] = v
|
27 |
+
# LANGUAGE is used on win32
|
28 |
+
env['LANGUAGE'] = 'C'
|
29 |
+
env['LANG'] = 'C'
|
30 |
+
env['LC_ALL'] = 'C'
|
31 |
+
out = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
|
32 |
+
return out
|
33 |
+
|
34 |
+
try:
|
35 |
+
out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
|
36 |
+
sha = out.strip().decode('ascii')
|
37 |
+
except OSError:
|
38 |
+
sha = 'unknown'
|
39 |
+
|
40 |
+
return sha
|
41 |
+
|
42 |
+
|
43 |
+
def get_hash():
|
44 |
+
if os.path.exists('.git'):
|
45 |
+
sha = get_git_hash()[:7]
|
46 |
+
else:
|
47 |
+
sha = 'unknown'
|
48 |
+
|
49 |
+
return sha
|
50 |
+
|
51 |
+
|
52 |
+
def write_version_py():
|
53 |
+
content = """# GENERATED VERSION FILE
|
54 |
+
# TIME: {}
|
55 |
+
__version__ = '{}'
|
56 |
+
__gitsha__ = '{}'
|
57 |
+
version_info = ({})
|
58 |
+
"""
|
59 |
+
sha = get_hash()
|
60 |
+
with open('VERSION', 'r') as f:
|
61 |
+
SHORT_VERSION = f.read().strip()
|
62 |
+
VERSION_INFO = ', '.join([x if x.isdigit() else f'"{x}"' for x in SHORT_VERSION.split('.')])
|
63 |
+
|
64 |
+
version_file_str = content.format(time.asctime(), SHORT_VERSION, sha, VERSION_INFO)
|
65 |
+
with open(version_file, 'w') as f:
|
66 |
+
f.write(version_file_str)
|
67 |
+
|
68 |
+
|
69 |
+
def get_version():
|
70 |
+
with open(version_file, 'r') as f:
|
71 |
+
exec(compile(f.read(), version_file, 'exec'))
|
72 |
+
return locals()['__version__']
|
73 |
+
|
74 |
+
|
75 |
+
def get_requirements(filename='requirements.txt'):
|
76 |
+
here = os.path.dirname(os.path.realpath(__file__))
|
77 |
+
with open(os.path.join(here, filename), 'r') as f:
|
78 |
+
requires = [line.replace('\n', '') for line in f.readlines()]
|
79 |
+
return requires
|
80 |
+
|
81 |
+
|
82 |
+
if __name__ == '__main__':
|
83 |
+
write_version_py()
|
84 |
+
setup(
|
85 |
+
name='gfpgan',
|
86 |
+
version=get_version(),
|
87 |
+
description='GFPGAN aims at developing Practical Algorithms for Real-world Face Restoration',
|
88 |
+
long_description=readme(),
|
89 |
+
long_description_content_type='text/markdown',
|
90 |
+
author='Xintao Wang',
|
91 |
+
author_email='xintao.wang@outlook.com',
|
92 |
+
keywords='computer vision, pytorch, image restoration, super-resolution, face restoration, gan, gfpgan',
|
93 |
+
url='https://github.com/TencentARC/GFPGAN',
|
94 |
+
include_package_data=True,
|
95 |
+
packages=find_packages(exclude=('options', 'datasets', 'experiments', 'results', 'tb_logger', 'wandb')),
|
96 |
+
classifiers=[
|
97 |
+
'Development Status :: 4 - Beta',
|
98 |
+
'License :: OSI Approved :: Apache Software License',
|
99 |
+
'Operating System :: OS Independent',
|
100 |
+
'Programming Language :: Python :: 3',
|
101 |
+
'Programming Language :: Python :: 3.7',
|
102 |
+
'Programming Language :: Python :: 3.8',
|
103 |
+
],
|
104 |
+
license='Apache License Version 2.0',
|
105 |
+
setup_requires=['cython', 'numpy'],
|
106 |
+
install_requires=get_requirements(),
|
107 |
+
zip_safe=False)
|