From 5ed09898bbe44bbc05bded85a9b952428f816b38 Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Tue, 31 Dec 2024 15:13:23 -0600 Subject: [PATCH] Convert latents_ubyte to 8-bit unsigned int before converting to CPU --- latent_preview.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/latent_preview.py b/latent_preview.py index 07f9cc68..b099e4f9 100644 --- a/latent_preview.py +++ b/latent_preview.py @@ -12,7 +12,9 @@ MAX_PREVIEW_RESOLUTION = args.preview_size def preview_to_image(latent_image): latents_ubyte = (((latent_image + 1.0) / 2.0).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())