fix error with RealESRGAN model failing to upscale fp32 image
This commit is contained in:
parent
c2fd7c0344
commit
8100e901ab
|
@ -16,9 +16,13 @@ def upscale_without_tiling(model, img: Image.Image):
|
||||||
img = img[:, :, ::-1]
|
img = img[:, :, ::-1]
|
||||||
img = np.ascontiguousarray(np.transpose(img, (2, 0, 1))) / 255
|
img = np.ascontiguousarray(np.transpose(img, (2, 0, 1))) / 255
|
||||||
img = torch.from_numpy(img).float()
|
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():
|
with torch.no_grad():
|
||||||
output = model(img)
|
output = model(img)
|
||||||
|
|
||||||
output = output.squeeze().float().cpu().clamp_(0, 1).numpy()
|
output = output.squeeze().float().cpu().clamp_(0, 1).numpy()
|
||||||
output = 255. * np.moveaxis(output, 0, 2)
|
output = 255. * np.moveaxis(output, 0, 2)
|
||||||
output = output.astype(np.uint8)
|
output = output.astype(np.uint8)
|
||||||
|
|
Loading…
Reference in New Issue