Fix ImageColorToMask not returning right mask values.

This commit is contained in:
comfyanonymous 2025-07-02 15:33:46 -04:00
parent 111f583e00
commit 33444c6198

View File

@ -152,7 +152,7 @@ class ImageColorToMask:
def image_to_mask(self, image, color): def image_to_mask(self, image, color):
temp = (torch.clamp(image, 0, 1.0) * 255.0).round().to(torch.int) temp = (torch.clamp(image, 0, 1.0) * 255.0).round().to(torch.int)
temp = torch.bitwise_left_shift(temp[:,:,:,0], 16) + torch.bitwise_left_shift(temp[:,:,:,1], 8) + temp[:,:,:,2] temp = torch.bitwise_left_shift(temp[:,:,:,0], 16) + torch.bitwise_left_shift(temp[:,:,:,1], 8) + temp[:,:,:,2]
mask = torch.where(temp == color, 255, 0).float() mask = torch.where(temp == color, 1.0, 0).float()
return (mask,) return (mask,)
class SolidMask: class SolidMask: