Skip to content

Commit

Permalink
fix: ensure casting to torch.uint8
Browse files Browse the repository at this point in the history
  • Loading branch information
dnswd authored May 24, 2024
1 parent b02bcce commit 8e26f42
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion latent_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def decode_latent_to_preview(self, x0):
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())

Expand Down

0 comments on commit 8e26f42

Please sign in to comment.