Skip to content

Commit

Permalink
Merge pull request #846 from pedrodanielsantos/main
Browse files Browse the repository at this point in the history
Fix "Update face_enhancer.py"
  • Loading branch information
hacksider authored Dec 23, 2024
2 parents ed7a216 + 7472dfb commit 3a85884
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions modules/processors/frame/face_enhancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@ def get_face_enhancer() -> Any:
with THREAD_LOCK:
if FACE_ENHANCER is None:
model_path = os.path.join(models_dir, "GFPGANv1.4.pth")
elif platform.system() == "Darwin": # Mac OS
mps_device = None
elif torch.backends.mps.is_available():
mps_device = torch.device("mps")
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1, device=mps_device) # type: ignore[attr-defined]
elif: # Other OS
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined]

match platform.system():
case "Darwin": # Mac OS
if torch.backends.mps.is_available():
mps_device = torch.device("mps")
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1, device=mps_device) # 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


Expand Down

0 comments on commit 3a85884

Please sign in to comment.