From de4f7658783277673ca28502253b9a2fccbe8e61 Mon Sep 17 00:00:00 2001 From: Rishon Date: Sat, 14 Dec 2024 16:47:07 +0800 Subject: [PATCH] Update face_enhancer.py for apple silicon mps --- modules/processors/frame/face_enhancer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/processors/frame/face_enhancer.py b/modules/processors/frame/face_enhancer.py index 7874e35..bb4031f 100644 --- a/modules/processors/frame/face_enhancer.py +++ b/modules/processors/frame/face_enhancer.py @@ -49,7 +49,10 @@ def get_face_enhancer() -> Any: with THREAD_LOCK: if FACE_ENHANCER is None: model_path = os.path.join(models_dir, 'GFPGANv1.4.pth') - FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined] + mps_device = None + 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] return FACE_ENHANCER