Implement CodeFormer Face Restoration (#669)

* Implement CodeFormer Face Restoration

* fix codeformer model destination path

Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
This commit is contained in:
blessedcoolant
2022-09-19 07:01:05 +12:00
committed by GitHub
parent 062f3e8f31
commit f3292a6953
8 changed files with 871 additions and 5 deletions

19
scripts/preload_models.py Executable file → Normal file
View File

@ -87,8 +87,9 @@ if gfpgan:
try:
import urllib.request
model_path = 'https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth'
model_url = 'https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth'
model_dest = 'src/gfpgan/experiments/pretrained_models/GFPGANv1.3.pth'
if not os.path.exists(model_dest):
print('downloading gfpgan model file...')
urllib.request.urlretrieve(model_path,model_dest)
@ -96,3 +97,19 @@ if gfpgan:
import traceback
print('Error loading GFPGAN:')
print(traceback.format_exc())
print('...success')
print('preloading CodeFormer model file...')
try:
import urllib.request
model_url = 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth'
model_dest = 'ldm/restoration/codeformer/weights/codeformer.pth'
if not os.path.exists(model_dest):
print('downloading codeformer model file...')
os.makedirs(os.path.dirname(model_dest), exist_ok=True)
urllib.request.urlretrieve(model_path,model_dest)
except Exception:
import traceback
print('Error loading CodeFormer:')
print(traceback.format_exc())
print('...success')