aboutsummaryrefslogtreecommitdiff
path: root/modules/upscaler_utils.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-12-30 22:41:53 +0300
committerAUTOMATIC1111 <16777216c@gmail.com>2023-12-30 22:41:53 +0300
commit8100e901ab0c5b04d289eebb722c8a653b8beef1 (patch)
treee2e4938167db065ef6c108e92a69cace8d37565c /modules/upscaler_utils.py
parentc2fd7c034432da38fe33cee8d99b10c072f28100 (diff)
fix error with RealESRGAN model failing to upscale fp32 image
Diffstat (limited to 'modules/upscaler_utils.py')
-rw-r--r--modules/upscaler_utils.py6
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)