From 632ca154630bf6d77907884be1e57f0f5d5e09f0 Mon Sep 17 00:00:00 2001 From: noembryo Date: Wed, 1 Nov 2023 17:08:37 +0200 Subject: [PATCH] Initial commit --- README.md | 47 +++++++++++++++++++++++++++++++++++++++ __init__.py | 3 ++- terms_node.py => nodes.py | 13 ++++++----- 3 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 README.md rename terms_node.py => nodes.py (94%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..3ee3474 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +## General + + +[![made-with-python][Python]](https://www.python.org/) + +[![License: MIT][MIT]](LICENSE) + + + + + +**PromptTermList** (1-6) are some nodes that help with the creation of Prompts inside [ComfyUI](https://github.com/comfyanonymous/ComfyUI). + + +### Screenshots + +

+ + +

+ +## Usage +Everyone of the 6 nodes have a different `json` file that stores its Prompt Terms in "label"/"value" pairs. +The "label" part is what we see at the node's dropdown menu, and the "value" part is what it produces at its `Term` output when we run a generation job. + +These `json` files are located inside the `TermLists` directory, in the node's folder. +There are two ways to add a new term. +* From within ComfyUI, connect a text box to the node's `text` input. + Write the "label"/"value" part in the box using the following format: + label=bla blabla + value=blabla bla blabla blab + Enable the `store_input` switch. + Run a generation job. +* Manually, open the `json` file and add/remove/change entries. + Of course we must be very careful with this, to keep the `json` format of labels/values (with the appropriate commas), otherwise the file will not be parsed. + +This `text` input is also useful if we want to manually add something *after* our term, or as the *only* term if we select the `None` label. + + +## Installation +* cd to `ComfyUI\custom_nodes` +* git clone https://github.com/noembryo/ComfyUI-noEmbryo.git +* Restart ComfyUI + + +[Python]:https://img.shields.io/badge/Made%20with-Python-1f425f.svg +[MIT]:https://img.shields.io/badge/License-MIT-green.svg diff --git a/__init__.py b/__init__.py index 490d4a7..e047874 100644 --- a/__init__.py +++ b/__init__.py @@ -4,11 +4,12 @@ @nickname: noEmbryo @description: Some useful nodes. """ + import json import os, io from os.path import isfile, join, isdir -from .terms_node import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS, LISTS_PATH +from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS, LISTS_PATH os.makedirs(LISTS_PATH) if not isdir(LISTS_PATH) else None for i in range(len(NODE_CLASS_MAPPINGS)): diff --git a/terms_node.py b/nodes.py similarity index 94% rename from terms_node.py rename to nodes.py index a9b7e34..5e55776 100644 --- a/terms_node.py +++ b/nodes.py @@ -1,15 +1,15 @@ import io import json -# from os import walk from os.path import realpath, join -from pprint import pprint MANIFEST = {"name": "noEmbryo Nodes", - "version": (0,0,1), + "version": (0,0,1,0), "author": "noEmbryo", "project": "https://github.com/noembryo/ComfyUI-noEmbryo", "description": "Nodes for ComfyUI", } +__author__ = "noEmbryo" +__version__ = "0.0.1.0" LISTS_PATH = realpath("./custom_nodes/ComfyUI-noEmbryo/TermLists/") @@ -47,11 +47,12 @@ class PromptTermList: list_path = join(LISTS_PATH, "TermList{}.json".format(cls.idx)) cls.load_data_from_json(list_path) term_list = [i[0] for i in cls.data_labels] - return {"required": {"text": ("STRING", {"forceInput": True}), + return {"required": { "term_list": (term_list,), }, "optional": - {"store_input": ("BOOLEAN", {"default": False, + {"text": ("STRING", {"forceInput": True}), + "store_input": ("BOOLEAN", {"default": False, "label_on": True, "label_off": False},), }, @@ -93,7 +94,7 @@ class PromptTermList: CATEGORY = "conditioning/Term Nodes" FUNCTION = "run" - def run(self, text, term_list, store_input): + def run(self, term_list, store_input, text=None): selected = term_list[:len(term_list)] text_out = "" for i in self.data_labels: