feat: Mask TO SEGS For AnimateDiff

fix: Mask To SEGS - crash when batch mask
This commit is contained in:
Dr.Lt.Data
2023-11-27 21:16:05 +09:00
parent 3f60d32fa9
commit d0f990becf
5 changed files with 39 additions and 3 deletions
+1
View File
@@ -57,6 +57,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
* DetailerDebug (SEGS) - Refines the image based on SEGS. Additionally, it provides the ability to monitor the cropped image and the refined image of the cropped image.
* To prevent regeneration caused by the seed that does not change every time when using 'external_seed', please disable the 'seed random generate' option in the 'Detailer...' node.
* MASK to SEGS - Generates SEGS based on the mask.
* MASK to SEGS For AnimateDiff - Generates SEGS based on the mask for AnimateDiff.
* MediaPipe FaceMesh to SEGS - Separate each landmark from the mediapipe facemesh image to create labeled SEGS.
* Usually, the size of images created through the MediaPipe facemesh preprocessor is downscaled. It resizes the MediaPipe facemesh image to the original size given as reference_image_opt for matching sizes during processing.
* ToBinaryMask - Separates the mask generated with alpha values between 0 and 255 into 0 and 255. The non-zero parts are always set to 255.
+2
View File
@@ -173,6 +173,7 @@ NODE_CLASS_MAPPINGS = {
"MediaPipeFaceMeshToSEGS": MediaPipeFaceMeshToSEGS,
"MaskToSEGS": MaskToSEGS,
"MaskToSEGS_for_AnimateDiff": MaskToSEGS_for_AnimateDiff,
"ToBinaryMask": ToBinaryMask,
"MasksToMaskList": MasksToMaskList,
"MaskListToMaskBatch": MaskListToMaskBatch,
@@ -295,6 +296,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"SegsToCombinedMask": "SEGS to MASK (combined)",
"MediaPipeFaceMeshToSEGS": "MediaPipe FaceMesh to SEGS",
"MaskToSEGS": "MASK to SEGS",
"MaskToSEGS_for_AnimateDiff": "MASK to SEGS for AnimateDiff",
"BitwiseAndMaskForEach": "Bitwise(SEGS & SEGS)",
"SubtractMaskForEach": "Bitwise(SEGS - SEGS)",
"ImpactSegsAndMask": "Bitwise(SEGS & MASK)",
+1 -1
View File
@@ -2,7 +2,7 @@ import configparser
import os
version = "V4.34.2"
version = "V4.35"
dependency_version = 19
-2
View File
@@ -915,8 +915,6 @@ def mask_to_segs(mask, combined, crop_factor, bbox_fill, drop_size=1, label='A',
if len(mask.shape) == 2:
mask = np.expand_dims(mask, axis=0)
else:
mask = np.squeeze(mask, axis=1)
for i in range(mask.shape[0]):
mask_i = mask[i]
+35
View File
@@ -11,6 +11,7 @@ from nodes import MAX_RESOLUTION
from impact.utils import *
import impact.core as core
from impact.core import SEG
import impact.utils as utils
class SEGSDetailer:
@classmethod
@@ -926,6 +927,40 @@ class MaskToSEGS:
return (result, )
class MaskToSEGS_for_AnimateDiff:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"mask": ("MASK",),
"combined": ("BOOLEAN", {"default": False, "label_on": "True", "label_off": "False"}),
"crop_factor": ("FLOAT", {"default": 3.0, "min": 1.0, "max": 100, "step": 0.1}),
"bbox_fill": ("BOOLEAN", {"default": False, "label_on": "enabled", "label_off": "disabled"}),
"drop_size": ("INT", {"min": 1, "max": MAX_RESOLUTION, "step": 1, "default": 10}),
}
}
RETURN_TYPES = ("SEGS",)
FUNCTION = "doit"
CATEGORY = "ImpactPack/Operation"
def doit(self, mask, combined, crop_factor, bbox_fill, drop_size):
if len(mask.shape) == 3:
mask = mask.squeeze(0)
segs = core.mask_to_segs(mask, combined, crop_factor, bbox_fill, drop_size)
all_masks = SEGSToMaskList().doit(segs)[0]
result_mask = all_masks[0]
for mask in all_masks[1:]:
result_mask += mask
result_mask = utils.to_binary_mask(result_mask, 0.1)
return MaskToSEGS().doit(result_mask, False, crop_factor, False, drop_size)
class ControlNetApplySEGS:
@classmethod
def INPUT_TYPES(s):