fix: add match statement

Added for optimization

Co-Authored-By: Zephira <zephira58@protonmail.com>
pull/846/head
Pedro Santos 2024-12-23 06:29:36 +00:00
parent 41c6916273
commit 7472dfb694
1 changed files with 11 additions and 7 deletions

View File

@ -54,13 +54,17 @@ def get_face_enhancer() -> Any:
with THREAD_LOCK: with THREAD_LOCK:
if FACE_ENHANCER is None: if FACE_ENHANCER is None:
model_path = os.path.join(models_dir, "GFPGANv1.4.pth") model_path = os.path.join(models_dir, "GFPGANv1.4.pth")
if platform.system() == "Darwin": # Mac OS
mps_device = None match platform.system():
if torch.backends.mps.is_available(): case "Darwin": # Mac OS
mps_device = torch.device("mps") if torch.backends.mps.is_available():
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1, device=mps_device) # type: ignore[attr-defined] mps_device = torch.device("mps")
else: # Other OS FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1, device=mps_device) # type: ignore[attr-defined]
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined] else:
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined]
case _: # Other OS
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined]
return FACE_ENHANCER return FACE_ENHANCER