From 85a972a823ded31cab010d1afa0a6ff88397e3fb Mon Sep 17 00:00:00 2001 From: noembryo Date: Tue, 4 Jun 2024 01:42:49 +0300 Subject: [PATCH] Initial Comfy Registry upload --- .gitignore | 9 ++++++++- README.md | 16 ++++++++++++---- __init__.py | 2 +- nodes.py | 25 ++++++++++++++++++++----- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 916b1fe..94164e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,9 @@ # Project exclude paths -/XTRA/ \ No newline at end of file +XTRA +__pycache__ +.idea +js +TermList* +___backup.pyw +ComfyUI.iml +load_image_from_dir.py \ No newline at end of file diff --git a/README.md b/README.md index 0c608db..de9ad27 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,16 @@ # noEmbryo Nodes +A diverse set of nodes for ComfyUI. +* [PromptTermList (1-6)](#PromptTermList) +* [Resolution Scale](#ResolutionScale) +* [Regex Text Chopper](#RegexTextChopper) + +You can access them through "Add node > noEmbryo" submenu. [![made-with-python][Python]](https://www.python.org/) [![License: MIT][MIT]](LICENSE) --- -## PromptTermList (1-6) +## PromptTermList (1-6) These are some nodes that help with the creation of Prompts inside [ComfyUI](https://github.com/comfyanonymous/ComfyUI). @@ -45,12 +51,14 @@ label=The label to be deleted value= ``` --- -## Resolution Scale +## Resolution Scale ![Demo workflow](https://raw.githubusercontent.com/noembryo/ComfyUI-noEmbryo/master/stuff/res_scale1.png) -A simple node that outputs the resolution of an image using the dimensions of an input image or custom user-defined dimensions using a Scale Factor. +A simple node that outputs the resolution of an image using the dimensions of an input image or some custom user-defined dimensions, using a Scale Factor. + +If there is an input image connected, setting either `width` or `height` to 0 will use the other dimension to scale the image (but always multiple of 4). --- -## Regex Text Chopper +## Regex Text Chopper ![Demo workflow](https://raw.githubusercontent.com/noembryo/ComfyUI-noEmbryo/master/stuff/regex_text.png) A node that "chops" a text using a regular expression and outputs the chopped parts of the text. diff --git a/__init__.py b/__init__.py index ba12ae0..fe2db13 100644 --- a/__init__.py +++ b/__init__.py @@ -1,6 +1,6 @@ """ @author: noEmbryo -@title: noEmbryo nodes for ComfyUI +@title: noEmbryo nodes @nickname: noEmbryo @description: Some useful nodes for ComfyUI """ diff --git a/nodes.py b/nodes.py index add0f5a..b56fdd8 100644 --- a/nodes.py +++ b/nodes.py @@ -3,9 +3,13 @@ import re import json from os.path import realpath, join -MANIFEST = {"name": "noEmbryo Nodes", "version": (0, 0, 1, 0), "author": "noEmbryo", +MANIFEST = {"name": "noEmbryo Nodes", + "version": (0, 0, 1, 0), + "author": "noEmbryo", "project": "https://github.com/noembryo/ComfyUI-noEmbryo", - "description": "Nodes for ComfyUI", } + "description": "Nodes for ComfyUI", + "license": "MIT", + } __author__ = "noEmbryo" __version__ = "0.0.2.1" @@ -41,7 +45,7 @@ class PromptTermList: # noinspection PyMethodParameters @classmethod def INPUT_TYPES(cls): - list_path = join(LISTS_PATH, "TermList{}.json".format(cls.idx)) + list_path = join(LISTS_PATH, f"TermList{cls.idx}.json") cls.load_data_from_json(list_path) term_list = [i[0] for i in cls.data_labels] return {"required": {"terms": (term_list,), }, @@ -126,7 +130,7 @@ class PromptTermList: text_out = f"{text_out}, {text}" else: text_out = text - return (text_out,) + return (text_out, ) class PromptTermList1(PromptTermList): @@ -182,7 +186,18 @@ class ResolutionScale: def run(self, width, height, scale_factor, image=None): if image is not None: - _, height, width, _ = image.shape + _, img_height, img_width, _ = image.shape + if width == 0: + ratio = img_width / img_height + width = height * ratio + width = int(width / 4) * 4 + elif height == 0: + ratio = img_height / img_width + height = width * ratio + height = int(height / 4) * 4 + else: + width = img_width + height = img_height new_width = int(width * scale_factor) new_height = int(height * scale_factor)