Skip to content

Commit

Permalink
fix error with RealESRGAN model failing to upscale fp32 image
Browse files Browse the repository at this point in the history
  • Loading branch information
AUTOMATIC1111 committed Dec 30, 2023
1 parent c2fd7c0 commit 8100e90
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/upscaler_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8100e90

Please sign in to comment.