Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gfpgan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GFPGANer():
bg_upsampler (nn.Module): The upsampler for the background. Default: None.
"""

def __init__(self, model_path, upscale=2, arch='clean', channel_multiplier=2, bg_upsampler=None, device=None):
def __init__(self, model_path, upscale=2, arch='clean', channel_multiplier=2, bg_upsampler=None, device=None, model_dir=None):
self.upscale = upscale
self.bg_upsampler = bg_upsampler

Expand Down Expand Up @@ -84,11 +84,11 @@ def __init__(self, model_path, upscale=2, arch='clean', channel_multiplier=2, bg
save_ext='png',
use_parse=True,
device=self.device,
model_rootpath='gfpgan/weights')
model_rootpath=model_dir or 'gfpgan/weights')

if model_path.startswith('https://'):
model_path = load_file_from_url(
url=model_path, model_dir=os.path.join(ROOT_DIR, 'gfpgan/weights'), progress=True, file_name=None)
url=model_path, model_dir=model_dir or os.path.join(ROOT_DIR, 'gfpgan/weights'), progress=True, file_name=None)
loadnet = torch.load(model_path)
if 'params_ema' in loadnet:
keyname = 'params_ema'
Expand Down