mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-10 13:32:36 +08:00
smooth image from LoadImage
This commit is contained in:
parent
7cc8c48302
commit
e9f9a50d6e
15
nodes.py
15
nodes.py
@ -1332,7 +1332,7 @@ class LoadImage:
|
|||||||
|
|
||||||
CATEGORY = "image"
|
CATEGORY = "image"
|
||||||
|
|
||||||
RETURN_TYPES = ("IMAGE", "MASK")
|
RETURN_TYPES = ("IMAGE", "MASK", "IMAGE")
|
||||||
FUNCTION = "load_image"
|
FUNCTION = "load_image"
|
||||||
def load_image(self, image):
|
def load_image(self, image):
|
||||||
image_path = folder_paths.get_annotated_filepath(image)
|
image_path = folder_paths.get_annotated_filepath(image)
|
||||||
@ -1341,12 +1341,21 @@ class LoadImage:
|
|||||||
image = i.convert("RGB")
|
image = i.convert("RGB")
|
||||||
image = np.array(image).astype(np.float32) / 255.0
|
image = np.array(image).astype(np.float32) / 255.0
|
||||||
image = torch.from_numpy(image)[None,]
|
image = torch.from_numpy(image)[None,]
|
||||||
|
|
||||||
|
smooth_image = image.copy()
|
||||||
if 'A' in i.getbands():
|
if 'A' in i.getbands():
|
||||||
mask = np.array(i.getchannel('A')).astype(np.float32) / 255.0
|
mask = np.array(i.getchannel('A')).astype(np.float32) / 255.0
|
||||||
mask = 1. - torch.from_numpy(mask)
|
mask = torch.from_numpy(mask)
|
||||||
|
|
||||||
|
mask1 = torch.ones_like(image)
|
||||||
|
mask1[0, :, :, 0] = mask
|
||||||
|
mask1[0, :, :, 1] = mask
|
||||||
|
mask1[0, :, :, 2] = mask
|
||||||
|
smooth_image = smooth_image * mask
|
||||||
|
mask = 1.0 - mask
|
||||||
else:
|
else:
|
||||||
mask = torch.zeros((64,64), dtype=torch.float32, device="cpu")
|
mask = torch.zeros((64,64), dtype=torch.float32, device="cpu")
|
||||||
return (image, mask)
|
return (image, mask, smooth_image)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def IS_CHANGED(s, image):
|
def IS_CHANGED(s, image):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user