Skip to content

Commit

Permalink
Only convert to unint8 if directml_enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
shenanigansd authored Jan 10, 2025
1 parent 5ed0989 commit 79c526f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion latent_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ 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
)
latents_ubyte = latents_ubyte.to(dtype=torch.uint8)
if comfy.model_management.directml_enabled:
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 79c526f

Please sign in to comment.