diff --git a/README.md b/README.md index f62a350..b5565cf 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ The core functionality is taken from [comfyui-mixlab-nodes](https://github.com/s There are a few more nodes in this package that have some unusual uses: * Google Translate +* Count Objects - counts the number of objects that were fed to the input (this can be a list or one single object). Accepts any type of input. * Preview Image Bridge - only output an image to the screen if there is a connection to the output node. Useful in loops and conditions where the execution of this node is not required due to current conditions (variables). * Show Text Bridge - only output text to the screen if there is a connection to the output node. Useful in loops and conditions where the execution of this node is not required due to current conditions (variables). * Show Text - output text to the screen with mandatory execution. The node is executed in any case, whether the output is connected or not. diff --git a/node_list.json b/node_list.json index e5c2001..4c02e1f 100644 --- a/node_list.json +++ b/node_list.json @@ -57,5 +57,6 @@ "Text Replace [LP]":"Text Replace", "Pipe [LP]":"Pipe", "Pipe In [LP]":"Pipe In", - "Pipe Out [LP]":"Pipe Out" + "Pipe Out [LP]":"Pipe Out", + "Count Objects [LP]":"Count Objects - counts the number of objects that were fed to the input (this can be a list or one single object). Accepts any type of input." } \ No newline at end of file diff --git a/nodes/utils/utils_LP.py b/nodes/utils/utils_LP.py index 3f2ff79..f693170 100644 --- a/nodes/utils/utils_LP.py +++ b/nodes/utils/utils_LP.py @@ -236,11 +236,37 @@ class Pipe: return (pipe, new_model, new_pos, new_neg, new_latent, new_vae, new_clip, new_controlnet, new_image, new_seed, new_any1, new_any2, new_any3, new_any4, new_any5,) +class CountObjects: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "input": (any,), + "base_value": ("INT", {"default": 0, "min": 0}), + } + } + + RETURN_TYPES = ("INT",) + INPUT_IS_LIST = True + FUNCTION = "count_objects" + CATEGORY = "LevelPixel/Image" + + def count_objects(self, input, base_value): + if input is None: + count = 0 + elif isinstance(input, list): + count = len(input) + else: + count = 1 + + return (base_value[0] + count,) + NODE_CLASS_MAPPINGS = { "Delay|LP": Delay, "PipeOut|LP": PipeOut, "PipeIn|LP": PipeIn, "Pipe|LP": Pipe, + "CountObjects|LP": CountObjects } NODE_DISPLAY_NAME_MAPPINGS = { @@ -248,5 +274,6 @@ NODE_DISPLAY_NAME_MAPPINGS = { "PipeOut|LP": "Pipe Out [LP]", "PipeIn|LP": "Pipe In [LP]", "Pipe|LP": "Pipe [LP]", + "CountObjects|LP": "Count Objects [LP]" } diff --git a/pyproject.toml b/pyproject.toml index 196a854..056c4f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-levelpixel" description = "Main nodes of the Level Pixel company (aka levelpixel, LP). Includes convenient nodes for working with images from folders; counting files in a folder; cleaning memory; tag filters. Model Unloader, Free memory, Tag Filters, Tag Category Filters, Tag Choice Parser, File counter, Image Loader From Path (with counters), Google Translator, Language Translator, Override Device, Delay, Lora Tag Loader. Repository: https://github.com/LevelPixel/ComfyUI-LevelPixel" -version = "1.2.4" +version = "1.2.5" license = { file = "LICENSE" } dependencies = [ "torch>=2.0.1",