From de61127b69c8277bbe99682149e278f0c6e07981 Mon Sep 17 00:00:00 2001 From: jstit Date: Tue, 27 Aug 2024 11:56:12 +0700 Subject: [PATCH] update --- nodes/image_crop_circle.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nodes/image_crop_circle.py b/nodes/image_crop_circle.py index 201113f..55bc2a6 100644 --- a/nodes/image_crop_circle.py +++ b/nodes/image_crop_circle.py @@ -18,8 +18,16 @@ class ImageCropCircle: CATEGORY = "image/crop" def crop_circle(self, image): + # Ensure image is in the correct format + if len(image.shape) == 4: + image = image.squeeze(0) # Remove batch dimension if present + + if image.shape[0] == 1: + # If it's a grayscale image, repeat it to create an RGB image + image = image.repeat(3, 1, 1) + # Convert the input tensor to a PIL Image - image = Image.fromarray(image.squeeze().permute(1, 2, 0).byte().numpy()) + image = Image.fromarray(image.permute(1, 2, 0).byte().numpy()) width, height = image.size size = min(width, height)