From 8e26f4269af3c1bffc4c0fc15ddba907578321ec Mon Sep 17 00:00:00 2001 From: Dennis Al Baihaqi Walangadi <53461759+dnswd@users.noreply.github.com> Date: Fri, 24 May 2024 13:40:11 +0700 Subject: [PATCH] fix: ensure casting to torch.uint8 Fixes https://github.com/comfyanonymous/ComfyUI/issues/3539 --- latent_preview.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/latent_preview.py b/latent_preview.py index dae9beb60..4f4b35a47 100644 --- a/latent_preview.py +++ b/latent_preview.py @@ -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())