diff options
author | brkirch <brkirch@users.noreply.github.com> | 2022-11-08 01:12:31 +0000 |
---|---|---|
committer | brkirch <brkirch@users.noreply.github.com> | 2022-11-12 08:34:13 +0000 |
commit | f4a488f585c09b420dc05199240e68f8fb74337f (patch) | |
tree | a686d85fa1f90d174e67396c1df22cd9ba2af45d /modules/codeformer_model.py | |
parent | 804d9fb83d0c63ca3acd36378707ce47b8f12599 (diff) | |
download | stable-diffusion-webui-gfx803-f4a488f585c09b420dc05199240e68f8fb74337f.tar.gz stable-diffusion-webui-gfx803-f4a488f585c09b420dc05199240e68f8fb74337f.tar.bz2 stable-diffusion-webui-gfx803-f4a488f585c09b420dc05199240e68f8fb74337f.zip |
Set device for facelib/facexlib and gfpgan
* FaceXLib/FaceLib doesn't pass the device argument to RetinaFace but instead chooses one itself and sets it to a global - in order to use a device other than its internally chosen default it is necessary to manually replace the default value
* The GFPGAN constructor needs the device argument to work with MPS or a CUDA device ID that differs from the default
Diffstat (limited to 'modules/codeformer_model.py')
-rw-r--r-- | modules/codeformer_model.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/codeformer_model.py b/modules/codeformer_model.py index e6d9fa4f..ab40d842 100644 --- a/modules/codeformer_model.py +++ b/modules/codeformer_model.py @@ -36,6 +36,7 @@ def setup_model(dirname): from basicsr.utils.download_util import load_file_from_url
from basicsr.utils import imwrite, img2tensor, tensor2img
from facelib.utils.face_restoration_helper import FaceRestoreHelper
+ from facelib.detection.retinaface import retinaface
from modules.shared import cmd_opts
net_class = CodeFormer
@@ -65,6 +66,8 @@ def setup_model(dirname): net.load_state_dict(checkpoint)
net.eval()
+ if hasattr(retinaface, 'device'):
+ retinaface.device = devices.device_codeformer
face_helper = FaceRestoreHelper(1, face_size=512, crop_ratio=(1, 1), det_model='retinaface_resnet50', save_ext='png', use_parse=True, device=devices.device_codeformer)
self.net = net
|