From 04a3ab197a42ec0f308efcebac856bfbe700d07a Mon Sep 17 00:00:00 2001 From: Aconex Date: Fri, 3 Jan 2025 17:41:39 +0100 Subject: [PATCH] Added new nodes: Triple_Prompt, Embedding_Selector, Sampler_Settings, Image_Dimensions --- __init__.py | 2 +- nodes/__init__.py | 2 +- nodes/embedding_selector.py | 62 +++++++++++++++++++++++++++++++++++++ nodes/image_dimensions.py | 47 ++++++++++++++++++++++++++++ nodes/nodes.py | 12 +++++++ nodes/sampler_settings.py | 56 +++++++++++++++++++++++++++++++++ nodes/triple_prompt.py | 41 ++++++++++++++++++++++++ pyproject.toml | 2 +- 8 files changed, 221 insertions(+), 3 deletions(-) create mode 100644 nodes/embedding_selector.py create mode 100644 nodes/image_dimensions.py create mode 100644 nodes/sampler_settings.py create mode 100644 nodes/triple_prompt.py diff --git a/__init__.py b/__init__.py index 4721bd6..c327dae 100644 --- a/__init__.py +++ b/__init__.py @@ -5,5 +5,5 @@ from ComfyUI_GOAT_Nodes.nodes.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAM __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] -__version__ = '1.0.0' +__version__ = '1.1.0' __author__ = 'Aconex' \ No newline at end of file diff --git a/nodes/__init__.py b/nodes/__init__.py index 9cad93d..666ea4a 100644 --- a/nodes/__init__.py +++ b/nodes/__init__.py @@ -1,2 +1,2 @@ -__version__ = '1.0.0' +__version__ = '1.1.0' __author__ = 'Aconex' \ No newline at end of file diff --git a/nodes/embedding_selector.py b/nodes/embedding_selector.py new file mode 100644 index 0000000..2b44d79 --- /dev/null +++ b/nodes/embedding_selector.py @@ -0,0 +1,62 @@ +from pathlib import Path +import folder_paths + +class Embedding_Selector: + @classmethod + def INPUT_TYPES(s): + # Get the list of available embeddings + embeddings = folder_paths.get_filename_list("embeddings") + + return { + "required": { + "embedding": ((embeddings),), # Dropdown for selecting embeddings + "strength": ( + "FLOAT", + { + "default": 1.0, + "min": 0.0, + "max": 2.0, + "step": 0.05, + }, + ), + }, + } + + RETURN_TYPES = ("STRING",) + RETURN_NAMES = ("text",) + FUNCTION = "exec" + CATEGORY = '🐐 GOAT Nodes/Input' + DESCRIPTION = ''' + Picks an embedding and returns it as a string with the chosen strength. + ''' + + + def exec(self, embedding, strength): + # If emphasis is too low, return the original text + if strength < 0.05: + return ("",) + + else: + # Extract the embedding name (without file extension) + embedding_name = Path(embedding).stem + + # Format the embedding with strength if not 1.0 + if strength != 1.0: + embedding_formatted = f"({embedding_name}:{strength:.3f})" + else: + embedding_formatted = embedding_name + + # Combine the embedding and text + embedding_string = f"{embedding_formatted}, " + + return (embedding_string,) + + +NODE_CLASS_MAPPINGS = { + "Embedding_Selector": Embedding_Selector +} + + +NODE_DISPLAY_NAME_MAPPINGS = { + "Embedding_Selector": "🐐 Embedding Selector" +} \ No newline at end of file diff --git a/nodes/image_dimensions.py b/nodes/image_dimensions.py new file mode 100644 index 0000000..ec62694 --- /dev/null +++ b/nodes/image_dimensions.py @@ -0,0 +1,47 @@ +class Image_Dimensions: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "width": ( + "INT", + { + "default": 1024, + "min": 64, + "max": 8192, + "step": 1, + }, + ), + "height": ( + "INT", + { + "default": 1024, + "min": 64, + "max": 8192, + "step": 1, + }, + ), + }, + } + + RETURN_TYPES = ("INT", "INT",) + RETURN_NAMES = ("width", "height",) + FUNCTION = "exec" + CATEGORY = '🐐 GOAT Nodes/Input' + DESCRIPTION = ''' + Allows selection or manual input of image dimensions (width and height). \n + Outputs the selected values. + ''' + + + def exec(self, width, height): + return (width, height,) + + +NODE_CLASS_MAPPINGS = { + "Image_Dimensions": Image_Dimensions +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "Image_Dimensions": "🐐 Image Dimensions" +} \ No newline at end of file diff --git a/nodes/nodes.py b/nodes/nodes.py index 6e5912a..fb2bf83 100644 --- a/nodes/nodes.py +++ b/nodes/nodes.py @@ -6,6 +6,10 @@ from ComfyUI_GOAT_Nodes.nodes.int_divide_rounded import Int_Divide_Rounded # typ from ComfyUI_GOAT_Nodes.nodes.fast_film_grain import Fast_Film_Grain # type: ignore from ComfyUI_GOAT_Nodes.nodes.advanced_upscale_image_using_model import Advanced_Upscale_Image_Using_Model # type: ignore from ComfyUI_GOAT_Nodes.nodes.fast_color_match import Fast_Color_Match # type: ignore +from ComfyUI_GOAT_Nodes.nodes.triple_prompt import Triple_Prompt # type: ignore +from ComfyUI_GOAT_Nodes.nodes.embedding_selector import Embedding_Selector # type: ignore +from ComfyUI_GOAT_Nodes.nodes.sampler_settings import Sampler_Settings # type: ignore +from ComfyUI_GOAT_Nodes.nodes.image_dimensions import Image_Dimensions # type: ignore NODE_CLASS_MAPPINGS = { @@ -18,6 +22,10 @@ NODE_CLASS_MAPPINGS = { "Fast_Film_Grain": Fast_Film_Grain, "Advanced_Upscale_Image_Using_Model": Advanced_Upscale_Image_Using_Model, "Fast_Color_Match": Fast_Color_Match, + "Triple_Prompt": Triple_Prompt, + "Embedding_Selector": Embedding_Selector, + "Sampler_Settings": Sampler_Settings, + "Image_Dimensions": Image_Dimensions, } @@ -31,4 +39,8 @@ NODE_DISPLAY_NAME_MAPPINGS = { "Fast_Film_Grain": "🐐 Fast Film Grain", "Advanced_Upscale_Image_Using_Model": "🐐 Advanced Upscale Image (using Model)", "Fast_Color_Match": "🐐 Fast Color Match", + "Triple_Prompt": "🐐 Triple Prompt", + "Embedding_Selector": "🐐 Embedding Selector", + "Sampler_Settings": "🐐 Sampler Settings", + "Image_Dimensions": "🐐 Image Dimensions", } diff --git a/nodes/sampler_settings.py b/nodes/sampler_settings.py new file mode 100644 index 0000000..b09ba69 --- /dev/null +++ b/nodes/sampler_settings.py @@ -0,0 +1,56 @@ +class Sampler_Settings: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "steps": ( + "INT", + { + "default": 20, + "min": 0, + "max": 100, + "step": 1, + }, + ), + "cfg": ( + "FLOAT", + { + "default": 4.0, + "min": 0.0, + "max": 100.0, + "step": 0.5, + }, + ), + "denoise": ( + "FLOAT", + { + "default": 1.0, + "min": 0.0, + "max": 1.0, + "step": 0.01, + }, + ), + }, + } + + RETURN_TYPES = ("INT", "FLOAT", "FLOAT",) + RETURN_NAMES = ("steps", "cfg", "denoise",) + FUNCTION = "exec" + CATEGORY = '🐐 GOAT Nodes/Input' + DESCRIPTION = ''' + Allows selection of sampler settings: steps, CFG, and denoise. \n + Outputs the selected values. + ''' + + + def exec(self, steps, cfg, denoise): + return (steps, cfg, denoise,) + + +NODE_CLASS_MAPPINGS = { + "Sampler_Settings": Sampler_Settings +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "Sampler_Settings": "🐐 Sampler Settings" +} \ No newline at end of file diff --git a/nodes/triple_prompt.py b/nodes/triple_prompt.py new file mode 100644 index 0000000..f3e50a4 --- /dev/null +++ b/nodes/triple_prompt.py @@ -0,0 +1,41 @@ +class Triple_Prompt: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "text1": ("STRING", {"default": "", "multiline": True}), + "text2": ("STRING", {"default": "", "multiline": True}), + "text3": ("STRING", {"default": "", "multiline": True}), + }, + } + + RETURN_TYPES = ("STRING", "STRING", "STRING", "STRING",) + RETURN_NAMES = ("text1", "text1", "text1", "concatenated_text",) + FUNCTION = "exec" + CATEGORY = '🐐 GOAT Nodes/Input' + DESCRIPTION = ''' + Takes three text inputs and outputs them either separately or as a concatenated version with automatic comma separation handling. + ''' + + def exec(self, text1, text2, text3): + # Ensure each non-empty text ends with a comma if it doesn't already + if text1 and not text1.endswith(','): + text1 += ',' + if text2 and not text2.endswith(','): + text2 += ',' + if text3 and not text3.endswith(','): + text3 += ',' + + # Concatenate the texts, skipping empty ones + concatenated_text = ''.join([text for text in [text1, text2, text3] if text]) + + return (text1, text2, text3, concatenated_text,) + + +NODE_CLASS_MAPPINGS = { + "Triple_Prompt": Triple_Prompt +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "Triple_Prompt": "🐐 Triple Prompt" +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index c48f440..c0b2a44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui_goat_nodes" description = "Nodes to level up your workflows performance and streamline specific functions." -version = "1.0.0" +version = "1.1.0" license = {file = "LICENSE"} dependencies = []