Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no ComfyUI_NAI-mod node #1

Open
sekiwired opened this issue May 15, 2024 · 13 comments
Open

There is no ComfyUI_NAI-mod node #1

sekiwired opened this issue May 15, 2024 · 13 comments

Comments

@sekiwired
Copy link

The aforementioned node is nowhere to be found?

print(f"""Error. No naistyles.csv found. Put your naistyles.csv in the custom_nodes/ComfyUI_NAI-mod/CSV directory of ComfyUI. Then press "Refresh".

See the conversation there comfyanonymous/ComfyUI#3463

@Maikhool
Copy link

i've had to disable this node because it kept doing that making my workflosws slower every time as it stacks. in the custom node folder, there is a folder named CSV which has these files in them but it's not reading these files for me so it's basically useless for me sadly. needs to be patched. my issue is that it's not reading my new directory and not looking for these files where it's installed opposed to some arbitrary fixed position potentially.

@thomaswan
Copy link

cls.naifilters_csv = cls.load_naifilters_csv(os.path.join(folder_paths.base_path, "custom_nodes\\ComfyUI-NAI-styler\\CSV\\naistyles.csv"))

the path is coded with windows backslash, if you are running it on linux, it will go error.

print(f"""Error. No naistyles.csv found. Put your naistyles.csv in the custom_nodes/ComfyUI_NAI-mod/CSV directory of ComfyUI. Then press "Refresh".

and the hardcoded path on error message is not the same as actual seeking file path.

@mrlunk
Copy link

mrlunk commented Sep 3, 2024

Solution found on reddit in post:
https://www.reddit.com/r/comfyui/comments/1cqpjkf/comment/ligc0ie/

---------------QUOTE:-----------------------
in \custom_nodes\ComfyUI_NAI-mod

Modify "ComfyUI-NAI-styler" in "naistyler_nodes.py" to "ComfyUI-Universal-Styler"

Search and replace... should be 4 entries

restart comfyui - solved ;-)

@SuperFurias
Copy link

SuperFurias commented Sep 24, 2024

Solution found on reddit in post: https://www.reddit.com/r/comfyui/comments/1cqpjkf/comment/ligc0ie/

---------------QUOTE:----------------------- in \custom_nodes\ComfyUI_NAI-mod

Modify "ComfyUI-NAI-styler" in "naistyler_nodes.py" to "ComfyUI-Universal-Styler"

Search and replace... should be 4 entries

restart comfyui - solved ;-)

thanks, i did the same but my folder name was "ComfyUI-Universal-Styler" instead of "ComfyUI_NAI-mod"
i opened the ComfyUI-Universal-Styler folder, modified "ComfyUI-NAI-styler" in "naistyler_nodes.py" to "ComfyUI-Universal-Styler" and no more errors

@GotrekGurnisson
Copy link

I had to clone and rename whole folder "ComfyUI-Universal-Styler" to "ComfyUI-NAI-styler"

@jeffclayton
Copy link

jeffclayton commented Sep 28, 2024

Instead of copying the folder you can make a link to it from the command prompt to fool windows 10/11 into thinking there is a duplicate. Open cmd at that location and type this:

mklink /j ComfyUI-NAI-styler ComfyUI-Universal-Styler

That is the windows equivalent of the Linux/Mac version of symlinks:
(note the reverse order of the name and target folder)

ln -s ComfyUI-Universal-Styler ComfyUI-NAI-styler

@GotrekGurnisson
Copy link

Ha, you are right. I am using Junctions occasionally, but it didn't come to my mind in this case. Thanks!

@southbayjay
Copy link

Solution found on reddit in post: https://www.reddit.com/r/comfyui/comments/1cqpjkf/comment/ligc0ie/
---------------QUOTE:----------------------- in \custom_nodes\ComfyUI_NAI-mod
Modify "ComfyUI-NAI-styler" in "naistyler_nodes.py" to "ComfyUI-Universal-Styler"
Search and replace... should be 4 entries

restart comfyui - solved ;-)

thanks, i did the same but my folder name was "ComfyUI-Universal-Styler" instead of "ComfyUI_NAI-mod" i opened the ComfyUI-Universal-Styler folder, modified "ComfyUI-NAI-styler" in "naistyler_nodes.py" to "ComfyUI-Universal-Styler" and no more errors

This worked for me, thank you!!

@KoreTeknology
Copy link
Owner

Hi guys, nice to see you get it fixed.. i am actualy working on a ew custom node package, and this specific node will be included with some major update. thanks

@Maikhool
Copy link

Solution found on reddit in post: https://www.reddit.com/r/comfyui/comments/1cqpjkf/comment/ligc0ie/
---------------QUOTE:----------------------- in \custom_nodes\ComfyUI_NAI-mod
Modify "ComfyUI-NAI-styler" in "naistyler_nodes.py" to "ComfyUI-Universal-Styler"
Search and replace... should be 4 entries

restart comfyui - solved ;-)

thanks, i did the same but my folder name was "ComfyUI-Universal-Styler" instead of "ComfyUI_NAI-mod" i opened the ComfyUI-Universal-Styler folder, modified "ComfyUI-NAI-styler" in "naistyler_nodes.py" to "ComfyUI-Universal-Styler" and no more errors

This was huge. Thank you, solved the problem instantly.

@SuperFurias
Copy link

SuperFurias commented Nov 14, 2024

Hi guys i'm answering now because i found out about it only recently, but you DONT NEED this.
you get the error "Error. No naistyles.csv found. Put your naistyles.csv in the custom_nodes/ComfyUI_NAI-mod/CSV directory of ComfyUI. Then press "Refresh"." because this repo is just a "not so good edited" copy of ComfyUI-Custom-Scripts
if you install ComfyUI-Custom-Scripts and delete ComfyUI-Universal-Styler you will have no messages that say that you are missing "ComfyUI-Universal-Styler" or "ComfyUI-NAI-styler" when you put a new workflow inside comfyui.
because ComfyUI-Universal-Styler is just a copy of ComfyUI-Custom-Scripts

i don't know why comfyui when you are missing the nodes gives you an error that you are missing this copied repo instead of the original ComfyUI-Custom-Scripts

to sum everything up, you don't need either ComfyUI-Universal-Styler nor ComfyUI-NAI-styler, uninstall them, and install ComfyUI-Custom-Scripts

and there you have it. every node that needed ComfyUI-Universal-Styler now works without any problem.

pythongosssss/ComfyUI-Custom-Scripts#338

(i'm trying my best to edit the message without putting too much hate speech)

@karmo667
Copy link

Solution found on reddit in post: https://www.reddit.com/r/comfyui/comments/1cqpjkf/comment/ligc0ie/

---------------QUOTE:----------------------- in \custom_nodes\ComfyUI_NAI-mod

Modify "ComfyUI-NAI-styler" in "naistyler_nodes.py" to "ComfyUI-Universal-Styler"

Search and replace... should be 4 entries

restart comfyui - solved ;-)

Thank you so much dude!!

@Jeremy8776
Copy link

Jeremy8776 commented Dec 8, 2024

Here is fix all the paths and class names were jumbled.

Replace the code in naistyler_nodes.py with the one below.

import os
import re
import folder_paths
from pathlib import Path

# DEBUG pathlib (to replace folder_path from OS)
print(Path.cwd())
print("############################################")
BASE_DIR = Path.cwd()
DATAPATH = BASE_DIR.joinpath("custom_nodes", "ComfyUI-Universal-Styler", "CSV")
print(DATAPATH)
print("############################################")
my_database = [str(file) for file in DATAPATH.glob("*.csv")]
print(my_database)
print("############################################")

################
# Show Text v0.3 ##########################################################################
################

class ShowText:
    @classmethod
    def INPUT_TYPES(s):
        return {
            "required": {
                "text": ("STRING", {"forceInput": True}),
            },
            "hidden": {
                "unique_id": "UNIQUE_ID",
                "extra_pnginfo": "EXTRA_PNGINFO",
            },
        }

    INPUT_IS_LIST = True
    RETURN_TYPES = ("STRING",)
    FUNCTION = "notify"
    OUTPUT_NODE = True
    OUTPUT_IS_LIST = (True,)

    CATEGORY = "✴️ Universal NAI Nodes"

    def notify(self, text, unique_id=None, extra_pnginfo=None):
        if unique_id is not None and extra_pnginfo is not None:
            if not isinstance(extra_pnginfo, list):
                print("Error: extra_pnginfo is not a list")
            elif (
                not isinstance(extra_pnginfo[0], dict)
                or "workflow" not in extra_pnginfo[0]
            ):
                print("Error: extra_pnginfo[0] is not a dict or missing 'workflow' key")
            else:
                workflow = extra_pnginfo[0]["workflow"]
                node = next(
                    (x for x in workflow["nodes"] if str(x["id"]) == str(unique_id[0])),
                    None,
                )
                if node:
                    node["widgets_values"] = [text]

        return {"ui": {"text": text}, "result": (text,)}

################
# Nai Styler Complex CSV Loader v0.3 ##########################################################################
################

class NaiStylerComplexCSVLoader:

    @staticmethod
    def load_naistyles_csv(naistyles_path: str):
        """Loads naistyles CSV file, ignoring the first row (header)."""
        naistyles = {"Error loading naistyles.csv, check the console": ["", ""]}
        if not os.path.exists(naistyles_path):
            print(f"""Error. No naistyles.csv found. Put your naistyles.csv in the custom_nodes/ComfyUI-Universal-Styler/CSV directory of ComfyUI. Then press "Refresh".
                  Your current root directory is: {folder_paths.base_path}
            """)
            return naistyles
        try:
            with open(naistyles_path, "r", encoding="utf-8") as f:
                naistyles = [[x.replace('"', '').replace('\n', '') for x in re.split(',(?=(?:[^"]*"[^"]*")*[^"]*$)', line)] for line in f.readlines()[1:]]
                naistyles = {x[0]: [x[1], x[2]] for x in naistyles}
        except Exception as e:
            print(f"""Error loading naistyles.csv. Make sure it is in the custom_nodes/ComfyUI-Universal-Styler/CSV directory of ComfyUI. Then press "Refresh".
                    Your current root directory is: {folder_paths.base_path}
                    Error: {e}
            """)
        return naistyles

    @classmethod
    def INPUT_TYPES(cls):
        cls.naistyles_csv = cls.load_naistyles_csv(os.path.join(folder_paths.base_path, "custom_nodes", "ComfyUI-Universal-Styler", "CSV", "naistyles.csv"))
        return {
            "required": {
                "naistyles": (list(cls.naistyles_csv.keys()),),
            },
        }

    RETURN_TYPES = ("STRING",)
    FUNCTION = "execute"
    CATEGORY = "✴️ Universal NAI Nodes"

    def execute(self, naistyles):
        return (self.naistyles_csv[naistyles][0],)

################
# Nai Styler v0.1 ##########################################################################
################

class NaiStyler:
    """A custom node for styling."""

    @classmethod
    def INPUT_TYPES(s):
        return {
            "required": {
                "clip": ("CLIP",),
                "mute": (["On", "Off"],),
                "mix": ("INT", {
                    "default": 50,
                    "min": 0,
                    "max": 100,
                    "step": 1,
                    "display": "slider"
                }),
                "float_field": ("FLOAT", {
                    "default": 0.5,
                    "min": 0.0,
                    "max": 1.0,
                    "step": 0.01,
                    "round": 0.001,
                    "display": "slider"
                }),
                "string_field": ("STRING", {
                    "multiline": True,
                    "default": "Define Object"
                }),
                "string_field2": ("STRING", {
                    "multiline": True,
                    "default": "Define Background"
                }),
            },
        }

    RETURN_TYPES = ("CONDITIONING", "STRING", "STRING", "INT")
    RETURN_NAMES = ("Compiled prompt", "Value", "Value2", "mix")
    FUNCTION = "test"
    CATEGORY = "✴️ Universal NAI Nodes"

    def test(self, string_field, string_field2, mix, float_field, mute):
        if mute == "On":
            print(f"""Your input contains:
                string_field: {string_field}
                int_field: {mix}
                float_field: {float_field}
            """)

################
# Concatenate Fields v0.1 ##########################################################################
################

class ConcatenateFields:
    @classmethod
    def INPUT_TYPES(cls):
        return {
            "required": {
                "text1": ("STRING", {"multiline": False, "default": "Hello"}),
                "text2": ("STRING", {"multiline": False, "default": "World"}),
            }
        }

    RETURN_TYPES = ("STRING",)
    FUNCTION = "concatenate_text"
    CATEGORY = "✴️ Universal NAI Nodes"

    def concatenate_text(self, text1, text2):
        return (text1 + " " + text2,)

################
# Node Class and Display Name Mappings ##########################################################################
################

NODE_CLASS_MAPPINGS = {
    "ShowText": ShowText,
    "NaiStylerComplexCSVLoader": NaiStylerComplexCSVLoader,
    "NaiStyler": NaiStyler,
    "ConcatenateFields": ConcatenateFields,
}

NODE_DISPLAY_NAME_MAPPINGS = {
    "ShowText": "✴️ U-NAI Get Text",
    "NaiStylerComplexCSVLoader": "✴️ U-NAI Styles Launcher",
    "NaiStyler": "✴️ U-NAI Styler - v0.2.1",
    "ConcatenateFields": "✴️ U-NAI Fields Concatenate",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests