diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-12-30 19:41:53 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2023-12-30 19:41:53 +0000 |
commit | 8100e901ab0c5b04d289eebb722c8a653b8beef1 (patch) | |
tree | e2e4938167db065ef6c108e92a69cace8d37565c /modules/upscaler_utils.py | |
parent | c2fd7c034432da38fe33cee8d99b10c072f28100 (diff) | |
download | stable-diffusion-webui-gfx803-8100e901ab0c5b04d289eebb722c8a653b8beef1.tar.gz stable-diffusion-webui-gfx803-8100e901ab0c5b04d289eebb722c8a653b8beef1.tar.bz2 stable-diffusion-webui-gfx803-8100e901ab0c5b04d289eebb722c8a653b8beef1.zip |
fix error with RealESRGAN model failing to upscale fp32 image
Diffstat (limited to 'modules/upscaler_utils.py')
-rw-r--r-- | modules/upscaler_utils.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/upscaler_utils.py b/modules/upscaler_utils.py index 8bdda51c..39f78a0b 100644 --- a/modules/upscaler_utils.py +++ b/modules/upscaler_utils.py @@ -16,9 +16,13 @@ def upscale_without_tiling(model, img: Image.Image): img = img[:, :, ::-1] img = np.ascontiguousarray(np.transpose(img, (2, 0, 1))) / 255 img = torch.from_numpy(img).float() - img = img.unsqueeze(0).to(devices.device_esrgan) + + model_weight = next(iter(model.parameters())) + img = img.unsqueeze(0).to(device=model_weight.device, dtype=model_weight.dtype) + with torch.no_grad(): output = model(img) + output = output.squeeze().float().cpu().clamp_(0, 1).numpy() output = 255. * np.moveaxis(output, 0, 2) output = output.astype(np.uint8) |