From 2f21d73dba703096de66c3ea73064316458656e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sita=20B=C3=A9r=C3=A9t=C3=A9?= Date: Fri, 27 Jun 2025 01:56:52 +0000 Subject: [PATCH] Fix can't convert cuda:0 device type tensor to numpy. --- utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.py b/utils.py index ead7b6e..a783f0a 100644 --- a/utils.py +++ b/utils.py @@ -14,7 +14,7 @@ BLUR_KERNEL_SIZE = 15 def tensor_to_pil(img_tensor, batch_index=0): # Takes a batch of images in the form of a tensor of shape [batch_size, height, width, channels] # and returns an RGB PIL Image. Assumes channels=3 - return Image.fromarray((255 * img_tensor[batch_index].numpy()).astype(np.uint8)) + return Image.fromarray((255 * img_tensor[batch_index].cpu().numpy()).astype(np.uint8)) def pil_to_tensor(image):