From 8f01245ef40e607c294a6a6c19e0e5fc608bccfe Mon Sep 17 00:00:00 2001 From: HavocsCall Date: Wed, 9 Apr 2025 10:04:38 -0400 Subject: [PATCH] Removed the Prompt Styler nodes --- .gitignore | 3 +- CHANGELOG.md | 3 -- README.md | 21 -------- __init__.py | 9 ---- nodes/Prompt_Styler_Nodes.py | 98 ---------------------------------- nodes/styler_data/Example.json | 12 ----- 6 files changed, 1 insertion(+), 145 deletions(-) delete mode 100644 nodes/Prompt_Styler_Nodes.py delete mode 100644 nodes/styler_data/Example.json diff --git a/.gitignore b/.gitignore index 062766a..264daca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -*__pycache__ -*/Styler_Data/*/* \ No newline at end of file +*__pycache__ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c327016..5aad9e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,6 @@ - Int to Float - Int to String -### Prompt Styler Nodes -- Prompt Stylers - ### Switch Nodes - Clip Switch - Conditioning Switch diff --git a/README.md b/README.md index 8af4ee4..d614ee4 100644 --- a/README.md +++ b/README.md @@ -21,27 +21,6 @@ git clone https://github.com/HavocsCall/comfyui_HavocsCall_Custom_Nodes.git - Int to Float - Converts an `INTEGER` to a `FLOAT`. - Int to String - Converts an `INTEGER` to a `STRING`. -### Prompt Styler Nodes -- json based Prompt Styler - Create a .json file in the `Styler_Data` folder formatted like this: -```json -[ - { - "name": "None", - "positive_prompt": "{prompt}", - "negative_prompt": "{prompt}" - }, - { - "name": "Example", - "positive_prompt": "{prompt}, Example", - "negative_prompt": "Example, {prompt}" - }, - { - etc... - } -] -``` -Each .json file will create it's own node with the name of the .json file + Styler. - ### Switch Nodes - Clip Switch - Switches between two `CLIPS`. - Conditioning Switch - Switches between two `CONDITIONING`. diff --git a/__init__.py b/__init__.py index 16a46d9..32aa30a 100644 --- a/__init__.py +++ b/__init__.py @@ -1,6 +1,5 @@ from .nodes.Basic_Nodes import * from .nodes.Conversion_Nodes import * -from .nodes.Prompt_Styler_Nodes import * from .nodes.Switch_Nodes import * NODE_CLASS_MAPPINGS = { @@ -18,10 +17,6 @@ NODE_CLASS_MAPPINGS = { "Float to String": HC_Float_to_String, "Int to Float": HC_Int_to_Float, "Int to String": HC_Int_to_String, - - #------------------------------------------------------------------------------------------# - #-----Prompt Styler Nodes----- - **{name.replace(' ', ''): type(name.replace(' ', ''), (SDXLPromptStyler, ), {'menus': menus}) for name, menus in NODES.items()}, #------------------------------------------------------------------------------------------# #-----Switch Nodes----- @@ -49,10 +44,6 @@ NODE_DISPLAY_NAME_MAPPINGS = { "Float to String": "Float to String", "Int to Float": "Int to Float", "Int to String": "Int to String", - - #------------------------------------------------------------------------------------------# - #-----Prompt Styler Nodes----- - **{name.replace(' ', ''): name for name in NODES.keys()}, #------------------------------------------------------------------------------------------# #-----Switch Nodes----- diff --git a/nodes/Prompt_Styler_Nodes.py b/nodes/Prompt_Styler_Nodes.py deleted file mode 100644 index a574bdf..0000000 --- a/nodes/Prompt_Styler_Nodes.py +++ /dev/null @@ -1,98 +0,0 @@ -import json -import pathlib -from collections import defaultdict - -#------------------------------------------------------------------------------------------# -#-----Prompt Styler----- -# This is copied from https://github.com/TripleHeadedMonkey/ComfyUI_MileHighStyler, thank you very much. -# I am learning about this and will recreate it in the future. -class Template: - def __init__(self, positive_prompt, negative_prompt, **kwargs): - self.positive_prompt = positive_prompt - self.negative_prompt = negative_prompt - - def replace_prompts(self, positive_prompt, negative_prompt): - positive_result = self.positive_prompt.replace('{prompt}', positive_prompt) - negative_result = self.negative_prompt.replace('{prompt}', negative_prompt) - return positive_result, negative_result - - -class StylerData: - def __init__(self, datadir=None): - - self._data = defaultdict(dict) - datadir = pathlib.Path(__file__).parent / 'styler_data' - - for j in datadir.glob('*/*.json'): - try: - with j.open('r') as f: - content = json.load(f) - group = j.parent.name - for template in content: - self._data[group][template['name']] = Template(**template) - except PermissionError: - print(f"Warning: No read permissions for file {j}") - except KeyError: - print(f"Warning: Malformed data in {j}") - - def __getitem__(self, item): - return self._data[item] - - def keys(self): - return self._data.keys() - -styler_data = StylerData() - -class SDXLPromptStyler: - menus = () - - @classmethod - def INPUT_TYPES(cls): - - menus = {menu: (list(styler_data[menu].keys()), ) for menu in cls.menus} - - inputs = { - "required": { - "text_positive": ("STRING", {"default": "", "forceInput": True}), - "text_negative": ("STRING", {"default": "", "forceInput": True}), - **menus, - }, - } - return inputs - - RETURN_TYPES = ('STRING','STRING',) - RETURN_NAMES = ('text_positive','text_negative',) - - FUNCTION = 'prompt_styler' - - CATEGORY = 'HavocsCall/Prompt Stylers' - - def prompt_styler(self, text_positive, text_negative, **kwargs): - text_positive_styled, text_negative_styled = text_positive, text_negative - for menu, selection in kwargs.items(): - text_positive_styled, text_negative_styled = styler_data[menu][selection].replace_prompts(text_positive_styled, text_negative_styled) - return text_positive_styled, text_negative_styled - -NODES = { - # define your nodes here - # first the friendly name, then a sequence of strings - # corresponding to subdirectories of the data dir. - - # individual stylers have one menu item - # build them automatically from the scanned directories - **{f'{name.title()} Styler': (name, ) for name in styler_data.keys()}, - - # alternatively you can list every single-menu node like this: - # 'Camera Styler': ('camera', ), - # etc... - - # perfection styler has everything except artist and milehigh - # we can define it by excluding those - # downside of this method is you have no control over the order - #'Perfection Styler': [x for x in styler_data.keys() if x not in ('artist', 'milehigh')], - - # alternatively define it manually, and you can reorder the items -} - -for k, v in NODES.items(): - assert not isinstance(v, str), f"Error: {k} has a string instead of a sequence for its menu list. Did you forget a comma?" \ No newline at end of file diff --git a/nodes/styler_data/Example.json b/nodes/styler_data/Example.json deleted file mode 100644 index 15c5f9c..0000000 --- a/nodes/styler_data/Example.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "name": "None", - "positive_prompt": "{prompt}", - "negative_prompt": "{prompt}" - }, - { - "name": "Example", - "positive_prompt": "{prompt}, Example", - "negative_prompt": "Example, {prompt}" - } -]