fix: ensure casting to torch.uint8

Fixes https://github.com/comfyanonymous/ComfyUI/issues/3539
This commit is contained in:
Dennis Al Baihaqi Walangadi 2024-05-24 13:40:11 +07:00 committed by GitHub
parent b02bcced05
commit 8e26f4269a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,7 +44,9 @@ class Latent2RGBPreviewer(LatentPreviewer):
latents_ubyte = (((latent_image + 1) / 2)
.clamp(0, 1) # change scale from -1..1 to 0..1
.mul(0xFF) # to 0..255
).to(device="cpu", dtype=torch.uint8, non_blocking=comfy.model_management.device_supports_non_blocking(latent_image.device))
)
latents_ubyte = latents_ubyte.to(dtype=torch.uint8)
latents_ubyte = latents_ubyte.to(device="cpu", dtype=torch.uint8, non_blocking=comfy.model_management.device_supports_non_blocking(latent_image.device))
return Image.fromarray(latents_ubyte.numpy())