InvokeAI/ldm/invoke/restoration/base.py

39 lines
1.3 KiB
Python
Raw Normal View History

class Restoration():
2022-09-23 07:40:31 +00:00
def __init__(self) -> None:
pass
2022-09-23 10:20:05 +00:00
def load_face_restore_models(self, gfpgan_dir='./src/gfpgan', gfpgan_model_path='experiments/pretrained_models/GFPGANv1.4.pth'):
# Load GFPGAN
2022-09-23 07:40:31 +00:00
gfpgan = self.load_gfpgan(gfpgan_dir, gfpgan_model_path)
if gfpgan.gfpgan_model_exists:
print('>> GFPGAN Initialized')
2022-09-23 07:40:31 +00:00
else:
print('>> GFPGAN Disabled')
gfpgan = None
# Load CodeFormer
codeformer = self.load_codeformer()
if codeformer.codeformer_model_exists:
print('>> CodeFormer Initialized')
2022-09-23 07:40:31 +00:00
else:
print('>> CodeFormer Disabled')
codeformer = None
return gfpgan, codeformer
# Face Restore Models
2022-09-23 07:40:31 +00:00
def load_gfpgan(self, gfpgan_dir, gfpgan_model_path):
from ldm.invoke.restoration.gfpgan import GFPGAN
2022-09-23 07:40:31 +00:00
return GFPGAN(gfpgan_dir, gfpgan_model_path)
def load_codeformer(self):
from ldm.invoke.restoration.codeformer import CodeFormerRestoration
return CodeFormerRestoration()
# Upscale Models
2022-09-23 07:40:31 +00:00
def load_esrgan(self, esrgan_bg_tile=400):
from ldm.invoke.restoration.realesrgan import ESRGAN
2022-09-23 07:40:31 +00:00
esrgan = ESRGAN(esrgan_bg_tile)
print('>> ESRGAN Initialized')
2022-09-19 17:59:43 +00:00
return esrgan;