diff --git a/README.md b/README.md index bbbd7e7..68ee561 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,7 @@ You can also get the node from comfy manager under the name of More math. - `reshape(tensor, shape)` or `rshp`: Reshapes the tensor to a new shape. (e.g., `rshp(a, [S0*S1, S2, S3])`) - `blur(x, sigma)` or `gaussian`: Applies a Gaussian blur with given `sigma` along last two or spatial dimensions (toggleable by optional parameter) - default use last 2 dimensions. - `edge(x)`: Applies a Sobel edge detection filter along the last two dimension or spatial dimensions (Height and Width) - can be selected by optional value (0 or missing = use last 2 dimensions). +- `batch_shuffle(tensor, indices)` or `shuffle` or `select`: Reorders or gathers slices along the 0th dimension of a tensor based on a list of indices. (e.g., `shuffle(V0, [0, 0, 1])` repeats the first frame twice and then the second). ### FFT (Tensor Only) diff --git a/more_math/AudioMathNode.py b/more_math/AudioMathNode.py index d7cdf8b..3700bcb 100644 --- a/more_math/AudioMathNode.py +++ b/more_math/AudioMathNode.py @@ -51,7 +51,7 @@ class AudioMathNode(io.ComfyNode): ) @classmethod - def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack=dict()): + def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack={}): input_stream = InputStream(Expression) lexer = MathExprLexer(input_stream) @@ -83,7 +83,7 @@ class AudioMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, V, F, Expression, length_mismatch="tile",stack=dict()): + def execute(cls, V, F, Expression, length_mismatch="tile",stack={}): # Identify all present audio inputs and their keys tensor_keys = [k for k, v in V.items() if v is not None and isinstance(v, dict) and "waveform" in v] if not tensor_keys: diff --git a/more_math/ClipMathNode.py b/more_math/ClipMathNode.py index 24316e6..50226fc 100644 --- a/more_math/ClipMathNode.py +++ b/more_math/ClipMathNode.py @@ -39,7 +39,7 @@ class CLIPMathNode(io.ComfyNode): tooltip = cleandoc(__doc__) @classmethod - def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack=dict()): + def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack={}): input_stream = InputStream(Expression) lexer = MathExprLexer(input_stream) @@ -71,7 +71,7 @@ class CLIPMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, V, F, Expression, length_mismatch="tile",stack=dict()) -> io.NodeOutput: + def execute(cls, V, F, Expression, length_mismatch="tile",stack={}) -> io.NodeOutput: # Determine reference CLIP a = V.get("V0") if a is None: diff --git a/more_math/ConditioningMathNode.py b/more_math/ConditioningMathNode.py index 5d8aff1..8c55bd6 100644 --- a/more_math/ConditioningMathNode.py +++ b/more_math/ConditioningMathNode.py @@ -46,7 +46,7 @@ class ConditioningMathNode(io.ComfyNode): ) @classmethod - def check_lazy_status(cls, Expression,Expression_pi, V, F,batching, length_mismatch="tile",stack=dict()): + def check_lazy_status(cls, Expression,Expression_pi, V, F,batching, length_mismatch="tile",stack={}): input_stream = InputStream(Expression) lexer = MathExprLexer(input_stream) @@ -83,7 +83,7 @@ class ConditioningMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, V, F, Expression, Expression_pi,batching, length_mismatch="tile",stack=dict()): + def execute(cls, V, F, Expression, Expression_pi,batching, length_mismatch="tile",stack={}): # Identify all present conditioning inputs tensor_keys = [k for k, v in V.items() if v is not None and isinstance(v, list) and len(v) > 0] if not tensor_keys: diff --git a/more_math/FloatMathNode.py b/more_math/FloatMathNode.py index 66cf0e7..bd3ea6c 100644 --- a/more_math/FloatMathNode.py +++ b/more_math/FloatMathNode.py @@ -41,7 +41,7 @@ class FloatMathNode(io.ComfyNode): tooltip = cleandoc(__doc__) @classmethod - def check_lazy_status(cls, FloatFunc, V,stack=dict()): + def check_lazy_status(cls, FloatFunc, V,stack={}): input_stream = InputStream(FloatFunc) lexer = MathExprLexer(input_stream) stream = CommonTokenStream(lexer) @@ -72,7 +72,7 @@ class FloatMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, FloatFunc, V,stack=dict()): + def execute(cls, FloatFunc, V,stack={}): variables = {} # Populate aliases diff --git a/more_math/GuiderMathNode.py b/more_math/GuiderMathNode.py index 1390537..eb1c129 100644 --- a/more_math/GuiderMathNode.py +++ b/more_math/GuiderMathNode.py @@ -47,7 +47,7 @@ class GuiderMathNode(io.ComfyNode): ) @classmethod - def check_lazy_status(cls, Expression,Expression1, V, F,stack=dict()): + def check_lazy_status(cls, Expression,Expression1, V, F,stack={}): input_stream = InputStream(Expression) input_stream1 = InputStream(Expression1) lexer = MathExprLexer(input_stream) @@ -82,12 +82,12 @@ class GuiderMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, V, F, Expression,Expression1,stack=dict()): + def execute(cls, V, F, Expression,Expression1,stack={}): return (MathGuider(V, F, Expression,Expression1),stack) class MathGuider: - def __init__(self, V, F, expression,expression1,stack=dict()): + def __init__(self, V, F, expression,expression1,stack={}): self.V = V self.F = F self.expression = expression diff --git a/more_math/ImageMathNode.py b/more_math/ImageMathNode.py index db425fe..5bb970a 100644 --- a/more_math/ImageMathNode.py +++ b/more_math/ImageMathNode.py @@ -42,7 +42,7 @@ class ImageMathNode(io.ComfyNode): ) @classmethod - def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack=dict()): + def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack={}): input_stream = InputStream(Expression) lexer = MathExprLexer(input_stream) @@ -74,7 +74,7 @@ class ImageMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, V, F, Expression, length_mismatch="error",stack=dict()): + def execute(cls, V, F, Expression, length_mismatch="error",stack={}): # I and F are Autogrow.Type which is dict[str, Any] # Identify all present tensors and their keys diff --git a/more_math/LatentMathNode.py b/more_math/LatentMathNode.py index dae399d..1a918c0 100644 --- a/more_math/LatentMathNode.py +++ b/more_math/LatentMathNode.py @@ -57,7 +57,7 @@ class LatentMathNode(io.ComfyNode): tooltip = cleandoc(__doc__) @classmethod - def check_lazy_status(cls, Expression, V, F,batching, length_mismatch="tile",stack=dict()): + def check_lazy_status(cls, Expression, V, F,batching, length_mismatch="tile",stack={}): input_stream = InputStream(Expression) lexer = MathExprLexer(input_stream) @@ -89,7 +89,7 @@ class LatentMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, V, F, Expression,batching, length_mismatch="tile",stack=dict()) -> io.NodeOutput: + def execute(cls, V, F, Expression,batching, length_mismatch="tile",stack={}) -> io.NodeOutput: # Determine reference latent ref_latent = None for lat in V.values(): diff --git a/more_math/MaskMathNode.py b/more_math/MaskMathNode.py index 0d4b996..d9f23b5 100644 --- a/more_math/MaskMathNode.py +++ b/more_math/MaskMathNode.py @@ -43,7 +43,7 @@ class MaskMathNode(io.ComfyNode): ) @classmethod - def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack=dict()): + def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack={}): input_stream = InputStream(Expression) lexer = MathExprLexer(input_stream) @@ -75,7 +75,7 @@ class MaskMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, V, F, Expression, length_mismatch="tile",stack=dict()): + def execute(cls, V, F, Expression, length_mismatch="tile",stack={}): # Identify all present tensors and their keys tensor_keys = [k for k, v in V.items() if v is not None] if not tensor_keys: diff --git a/more_math/ModelMathNode.py b/more_math/ModelMathNode.py index 7e9fd64..01b4653 100644 --- a/more_math/ModelMathNode.py +++ b/more_math/ModelMathNode.py @@ -40,7 +40,7 @@ class ModelMathNode(io.ComfyNode): tooltip = cleandoc(__doc__) @classmethod - def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack=dict()): + def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack={}): input_stream = InputStream(Expression) lexer = MathExprLexer(input_stream) @@ -72,7 +72,7 @@ class ModelMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, V, F, Expression, length_mismatch="tile",stack=dict()) -> io.NodeOutput: + def execute(cls, V, F, Expression, length_mismatch="tile",stack={}) -> io.NodeOutput: # Determine reference model for cloning a = V.get("V0") if a is None: diff --git a/more_math/NoiseMathNode.py b/more_math/NoiseMathNode.py index 19e05e2..d2a5af1 100644 --- a/more_math/NoiseMathNode.py +++ b/more_math/NoiseMathNode.py @@ -42,7 +42,7 @@ class NoiseMathNode(io.ComfyNode): ) @classmethod - def check_lazy_status(cls, Noise, V, F,stack=dict()): + def check_lazy_status(cls, Noise, V, F,stack={}): input_stream = InputStream(Noise) lexer = MathExprLexer(input_stream) stream = CommonTokenStream(lexer) @@ -73,7 +73,7 @@ class NoiseMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, Noise, V,F,stack=dict()): + def execute(cls, Noise, V,F,stack={}): return (NoiseExecutor(V,F, Noise,stack),) diff --git a/more_math/SigmasMathNode.py b/more_math/SigmasMathNode.py index c73a379..0db5e68 100644 --- a/more_math/SigmasMathNode.py +++ b/more_math/SigmasMathNode.py @@ -42,7 +42,7 @@ class SigmasMathNode(io.ComfyNode): ) @classmethod - def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack=dict()): + def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack={}): input_stream = InputStream(Expression) lexer = MathExprLexer(input_stream) @@ -74,7 +74,7 @@ class SigmasMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, V, F, Expression, length_mismatch="tile",stack=dict()): + def execute(cls, V, F, Expression, length_mismatch="tile",stack={}): # I and F are Autogrow.Type which is dict[str, Any] # Determine reference image for zero-initialization (fallback for a,b,c,d) diff --git a/more_math/VaeMathNode.py b/more_math/VaeMathNode.py index 1ec1ec5..0d194fe 100644 --- a/more_math/VaeMathNode.py +++ b/more_math/VaeMathNode.py @@ -40,7 +40,7 @@ class VAEMathNode(io.ComfyNode): tooltip = cleandoc(__doc__) @classmethod - def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack=dict()): + def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",stack={}): input_stream = InputStream(Expression) lexer = MathExprLexer(input_stream) @@ -72,7 +72,7 @@ class VAEMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, V, F, Expression, length_mismatch="tile",stack=dict()) -> io.NodeOutput: + def execute(cls, V, F, Expression, length_mismatch="tile",stack={}) -> io.NodeOutput: # Determine reference VAE a = V.get("V0") if a is None: diff --git a/more_math/VideoMathNode.py b/more_math/VideoMathNode.py index 83aff38..d61bf26 100644 --- a/more_math/VideoMathNode.py +++ b/more_math/VideoMathNode.py @@ -43,7 +43,7 @@ class VideoMathNode(io.ComfyNode): ) @classmethod - def check_lazy_status(cls, Expression,Expression_pi, V, F, length_mismatch="tile",stack=dict()): + def check_lazy_status(cls, Expression,Expression_pi, V, F, length_mismatch="tile",stack={}): input_stream = InputStream(Expression) lexer = MathExprLexer(input_stream) @@ -80,7 +80,7 @@ class VideoMathNode(io.ComfyNode): return needed1 @classmethod - def execute(cls, V, F, Expression, Expression_pi, length_mismatch="tile",stack=dict()): + def execute(cls, V, F, Expression, Expression_pi, length_mismatch="tile",stack={}): tensor_keys = [k for k, v in V.items() if v is not None] if not tensor_keys: raise ValueError("At least one input is required.")