Compare commits
51
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d921b8398c | ||
|
|
20aff9bac2 | ||
|
|
fe975c0890 | ||
|
|
b1ddb4a866 | ||
|
|
4d06e3776a | ||
|
|
80c2bd07ef | ||
|
|
c1abde90e4 | ||
|
|
9cb658b44f | ||
|
|
4727a4f72d | ||
|
|
7248a21331 | ||
|
|
86c4b1570f | ||
|
|
2d8eb55a7b | ||
|
|
ea03d73b69 | ||
|
|
898ac8a18e | ||
|
|
acbece304f | ||
|
|
ef526aae54 | ||
|
|
d0c7519d55 | ||
|
|
1492788de5 | ||
|
|
cf87b95a53 | ||
|
|
dbabf9c13f | ||
|
|
5a939af67a | ||
|
|
23df17061b | ||
|
|
046be62f60 | ||
|
|
fa894d702f | ||
|
|
9bc65a7786 | ||
|
|
7feacf442b | ||
|
|
5a1ace9343 | ||
|
|
d03493a490 | ||
|
|
e3b2f0aa33 | ||
|
|
96b5e8810e | ||
|
|
e19a7f1717 | ||
|
|
97095c6705 | ||
|
|
510f971329 | ||
|
|
37b187863f | ||
|
|
f82ff6c96a | ||
|
|
256d9f9b3f | ||
|
|
fca1ad7793 | ||
|
|
73d0b410c7 | ||
|
|
24f8f272e4 | ||
|
|
d7b9b1eec1 | ||
|
|
67179e5586 | ||
|
|
f4c679d2c5 | ||
|
|
962a4e897e | ||
|
|
31ebeb70df | ||
|
|
d2581cc75a | ||
|
|
1e7772284c | ||
|
|
44bc31989f | ||
|
|
fd5c6463e8 | ||
|
|
d27c68decf | ||
|
|
f262c39266 | ||
|
|
a5c4798b09 |
+2
-1
@@ -1,3 +1,4 @@
|
||||
__pycache__
|
||||
settings_nodes/
|
||||
web_alekpet_nodes/lib/idenode/**/*.json
|
||||
config.json
|
||||
web_alekpet_nodes/lib/idenode/**/*.json
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
from server import PromptServer
|
||||
from aiohttp import web
|
||||
|
||||
import argostranslate.package
|
||||
import argostranslate.translate
|
||||
try:
|
||||
import argostranslate.package
|
||||
import argostranslate.translate
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
# Find packages https://www.argosopentech.com/argospm/index/
|
||||
|
||||
|
||||
+498
-297
@@ -1,12 +1,13 @@
|
||||
# Title: ComfyUI Install Customs Nodes and javascript files
|
||||
# Author: AlekPet
|
||||
# Version: 2025.06.26
|
||||
# Version: 2024.11.02
|
||||
import os
|
||||
import importlib.util
|
||||
import subprocess
|
||||
import sys
|
||||
import shutil
|
||||
import __main__
|
||||
import json
|
||||
|
||||
# import pkgutil
|
||||
import re
|
||||
@@ -31,15 +32,155 @@ extension_dirs = [
|
||||
DEBUG = False
|
||||
|
||||
NODE_CLASS_MAPPINGS = dict() # dynamic class nodes append in mappings
|
||||
# dynamic display names nodes append mappings names
|
||||
NODE_DISPLAY_NAME_MAPPINGS = dict()
|
||||
NODE_DISPLAY_NAME_MAPPINGS = dict() # dynamic display names nodes append mappings names
|
||||
|
||||
wordsExludeSpace = "|".join(["ChatGLM"])
|
||||
humanReadableTextReg = re.compile(
|
||||
rf"({wordsExludeSpace}-?\d*)|(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])"
|
||||
)
|
||||
|
||||
humanReadableTextReg = re.compile("(?<=[a-z0-9])([A-Z])|(?<=[A-Z0-9])([A-Z][a-z]+)")
|
||||
module_name_cut_version = re.compile("[>=<]")
|
||||
renameTextUnderline = re.compile("(?<=[a-z])([A-Z])")
|
||||
|
||||
installed_modules = {}
|
||||
# installed_modules = {m[1] for m in pkgutil.iter_modules()}
|
||||
|
||||
# -- Config settings --
|
||||
CONFIG = {}
|
||||
NODES_SETTINGS = {}
|
||||
GLOBAL_SETTINGS = {}
|
||||
|
||||
DYNAMIC_NODES_ADD = True
|
||||
is_check_enabled_nodes = True
|
||||
|
||||
|
||||
# -- All nodes
|
||||
def get_classes(code):
|
||||
tree = ast.parse(code)
|
||||
return [
|
||||
n.name
|
||||
for n in ast.walk(tree)
|
||||
if isinstance(n, ast.ClassDef) and "Node" in n.name
|
||||
]
|
||||
|
||||
|
||||
def getNamesNodesInsidePyFile(nodeElement):
|
||||
node_folder = os.path.join(extension_folder, nodeElement)
|
||||
cls_names = []
|
||||
py_files = []
|
||||
for f in os.listdir(node_folder):
|
||||
ext = os.path.splitext(f)
|
||||
if (
|
||||
os.path.isfile(os.path.join(node_folder, f))
|
||||
and not f.startswith("__")
|
||||
and ext[1] == ".py"
|
||||
):
|
||||
py_files.append(f)
|
||||
with open(os.path.join(node_folder, f), "r") as pyf:
|
||||
cls_names.extend(get_classes(pyf.read()))
|
||||
return cls_names, py_files
|
||||
|
||||
|
||||
# List nodes dirs
|
||||
ALL_NODES_DIRS = {
|
||||
dir.name: dict(zip(["nodes", "py_files"], getNamesNodesInsidePyFile(dir.name)))
|
||||
for dir in os.scandir(extension_folder)
|
||||
if dir.is_dir()
|
||||
and not dir.name.startswith(".")
|
||||
and not dir.name.startswith("_")
|
||||
and dir.name != extension_dirs[0] and dir.name != "example_workflows"
|
||||
}
|
||||
|
||||
def addChangesToJson(json_data):
|
||||
isChanged = False
|
||||
|
||||
_json_data = json.loads(json.dumps(json_data))
|
||||
nodes_data = _json_data.get("nodes_settings")
|
||||
if not nodes_data and len(ALL_NODES_DIRS.keys()) == 0:
|
||||
isChanged = False
|
||||
|
||||
for node_check_folder in ALL_NODES_DIRS:
|
||||
# If folder not found, create folder key and nodes children keys
|
||||
if node_check_folder not in nodes_data:
|
||||
DEBUG and print(f" -> Folder node {node_check_folder} not exists!")
|
||||
nodes_data.update(
|
||||
{
|
||||
node_check_folder: {
|
||||
"active": True,
|
||||
"nodes": {
|
||||
node: True
|
||||
for node in ALL_NODES_DIRS[node_check_folder]["nodes"]
|
||||
},
|
||||
}
|
||||
}
|
||||
)
|
||||
isChanged = True
|
||||
|
||||
else:
|
||||
# Else check children nodes
|
||||
all_childen_nodes_in_folder = ALL_NODES_DIRS[node_check_folder]["nodes"]
|
||||
json_data_nodes_in_folder = nodes_data[node_check_folder]["nodes"]
|
||||
|
||||
for child_node in all_childen_nodes_in_folder:
|
||||
if child_node not in json_data_nodes_in_folder:
|
||||
DEBUG and print(
|
||||
f" -> Folder node {node_check_folder} children node {child_node} not exists!"
|
||||
)
|
||||
json_data_nodes_in_folder.update({child_node: True})
|
||||
isChanged = True
|
||||
|
||||
return _json_data, isChanged
|
||||
|
||||
|
||||
# end -- All nodes
|
||||
|
||||
# Directory config file
|
||||
config_path = os.path.join(extension_folder, "config.json")
|
||||
|
||||
# Load config.js file
|
||||
if not os.path.exists(config_path):
|
||||
DEBUG and print(" -> File config.js file not found! Created new config!")
|
||||
|
||||
with open(config_path, "w") as f:
|
||||
json.dump(
|
||||
{"nodes_settings": {}, "global_settings": {"check_enabled_nodes": False}}, f
|
||||
)
|
||||
|
||||
|
||||
# -- Open config check nodes
|
||||
isChanged = False
|
||||
json_data = None
|
||||
|
||||
with open(config_path, "r") as f:
|
||||
data = json.load(f)
|
||||
json_data, isChanged = addChangesToJson(data)
|
||||
|
||||
if isChanged:
|
||||
with open(config_path, "w") as f:
|
||||
json.dump(json_data, f, indent=2)
|
||||
|
||||
# -- end - Open config check nodes
|
||||
|
||||
|
||||
CONFIG = json_data
|
||||
|
||||
NODES_SETTINGS = CONFIG.get("nodes_settings")
|
||||
GLOBAL_SETTINGS = CONFIG.get("global_settings")
|
||||
|
||||
NODES_LOAD_SUCCESS = {}
|
||||
NODES_LOAD_FAILED = {}
|
||||
|
||||
# Global settings
|
||||
if GLOBAL_SETTINGS is not None:
|
||||
is_check_enabled_nodes = GLOBAL_SETTINGS.get("check_enabled_nodes", True)
|
||||
|
||||
# Nodes settings
|
||||
if NODES_SETTINGS is None:
|
||||
is_check_enabled_nodes = False
|
||||
|
||||
|
||||
# -- end - Config settings --
|
||||
|
||||
try:
|
||||
from filelock import FileLock
|
||||
except ImportError:
|
||||
@@ -59,7 +200,6 @@ def get_version_extension():
|
||||
return f" \033[1;34mv{version}\033[0m\033[1;35m"
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
return version
|
||||
|
||||
|
||||
@@ -74,7 +214,7 @@ def information(datas):
|
||||
try:
|
||||
print(info, end="\r", flush=True)
|
||||
except UnicodeError:
|
||||
safe_text = info.encode("utf-8", errors="replace").decode("utf-8", errors="replace")
|
||||
safe_text = info.encode('utf-8', errors='replace').decode('utf-8', errors='replace')
|
||||
print(safe_text, end="\r", flush=True)
|
||||
|
||||
|
||||
@@ -83,59 +223,77 @@ def printColorInfo(text, color="\033[92m"):
|
||||
print(f"{color}{text}{CLEAR}")
|
||||
|
||||
|
||||
def get_classes(code):
|
||||
tree = ast.parse(code)
|
||||
return [n.name for n in ast.walk(tree) if isinstance(n, ast.ClassDef) and "Node" in n.name]
|
||||
|
||||
|
||||
def addComfyUINodesToMapping(nodeElement):
|
||||
def addComfyUINodesToMapping(nodeElement, nodesOptions):
|
||||
log(f" -> Find class execute node <{nodeElement}>, add NODE_CLASS_MAPPINGS ...")
|
||||
node_folder = os.path.join(extension_folder, nodeElement)
|
||||
for f in os.listdir(node_folder):
|
||||
classesNames = []
|
||||
|
||||
for f in ALL_NODES_DIRS[nodeElement]["py_files"]:
|
||||
ext = os.path.splitext(f)
|
||||
# Find files extensions .py
|
||||
if (
|
||||
os.path.isfile(os.path.join(node_folder, f))
|
||||
and not f.startswith("__")
|
||||
and ext[1] == ".py"
|
||||
and ext[0] != "__init__"
|
||||
):
|
||||
# remove extensions .py
|
||||
module_without_py = f.replace(ext[1], "")
|
||||
# Import module
|
||||
spec = importlib.util.spec_from_file_location(module_without_py, os.path.join(node_folder, f))
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
# remove extensions .py
|
||||
module_without_py = f.replace(ext[1], "")
|
||||
# Import module
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
module_without_py, os.path.join(node_folder, f)
|
||||
)
|
||||
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
|
||||
try:
|
||||
spec.loader.exec_module(module)
|
||||
classes_names = list(
|
||||
filter(
|
||||
lambda p: callable(getattr(module, p)) and p.find("Node") != -1,
|
||||
dir(module),
|
||||
)
|
||||
except Exception as e:
|
||||
NODES_LOAD_FAILED[nodeElement] = e
|
||||
continue
|
||||
|
||||
classes_names = list(
|
||||
filter(
|
||||
lambda p: callable(getattr(module, p)) and p.find("Node") != -1,
|
||||
dir(module),
|
||||
)
|
||||
for class_module_name in classes_names:
|
||||
# Check module
|
||||
if class_module_name and class_module_name not in NODE_CLASS_MAPPINGS.keys():
|
||||
log(f" [*] Class node found '{class_module_name}' add to NODE_CLASS_MAPPINGS...")
|
||||
NODE_CLASS_MAPPINGS.update({class_module_name: getattr(module, class_module_name)})
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{class_module_name: humanReadableTextReg.sub(" \\1\\2", class_module_name)}
|
||||
)
|
||||
|
||||
NODES_LOAD_SUCCESS[nodeElement] = classes_names
|
||||
|
||||
for class_module_name in classes_names:
|
||||
# Check module
|
||||
if (
|
||||
class_module_name
|
||||
and class_module_name not in NODE_CLASS_MAPPINGS.keys()
|
||||
):
|
||||
|
||||
classesNames.append(class_module_name)
|
||||
|
||||
if is_check_enabled_nodes and class_module_name in nodesOptions:
|
||||
if nodesOptions[class_module_name]:
|
||||
log(
|
||||
f" [*] Class node found '{class_module_name}' add to NODE_CLASS_MAPPINGS..."
|
||||
)
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{class_module_name: getattr(module, class_module_name)}
|
||||
)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
class_module_name: humanReadableTextReg.sub(
|
||||
r" \1", class_module_name
|
||||
).strip()
|
||||
}
|
||||
)
|
||||
else:
|
||||
log(
|
||||
f" [*] Class node found '{class_module_name}' add to NODE_CLASS_MAPPINGS..."
|
||||
)
|
||||
|
||||
|
||||
def getNamesNodesInsidePyFile(nodeElement):
|
||||
node_folder = os.path.join(extension_folder, nodeElement)
|
||||
cls_names = []
|
||||
for f in os.listdir(node_folder):
|
||||
ext = os.path.splitext(f)
|
||||
if (
|
||||
os.path.isfile(os.path.join(node_folder, f))
|
||||
and not f.startswith("__")
|
||||
and ext[1] == ".py"
|
||||
and ext[0] != "__init__"
|
||||
):
|
||||
with open(os.path.join(node_folder, f), "r", encoding="utf-8", errors="replace") as pyf:
|
||||
cls_names.extend(get_classes(pyf.read()))
|
||||
return cls_names
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{class_module_name: getattr(module, class_module_name)}
|
||||
)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
class_module_name: humanReadableTextReg.sub(
|
||||
r" \1", class_module_name
|
||||
).strip()
|
||||
}
|
||||
)
|
||||
return classesNames
|
||||
|
||||
|
||||
def module_install(commands, cwd="."):
|
||||
@@ -146,8 +304,8 @@ def module_install(commands, cwd="."):
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
bufsize=1,
|
||||
encoding="utf-8",
|
||||
errors="replace",
|
||||
encoding='utf-8',
|
||||
errors='replace'
|
||||
)
|
||||
out = threading.Thread(target=information, args=(result.stdout,))
|
||||
err = threading.Thread(target=information, args=(result.stderr,))
|
||||
@@ -202,36 +360,66 @@ def checkModules(nodeElement):
|
||||
|
||||
# [Hack] argostranslate module checking install
|
||||
if nodeElement == "ArgosTranslateNode" and "argostranslate" in installed_modules and len(lines):
|
||||
if DEBUG:
|
||||
if not DEBUG:
|
||||
printColorInfo("* Argostranslate installed removed from required modules!")
|
||||
required_modules.remove(lines[0])
|
||||
|
||||
modules_to_install = required_modules - installed_modules
|
||||
|
||||
if modules_to_install:
|
||||
module_install([sys.executable, "-m", "pip", "install", *modules_to_install])
|
||||
|
||||
|
||||
nodes_list_dict = {}
|
||||
module_install(
|
||||
[sys.executable, "-m", "pip", "install", *modules_to_install]
|
||||
)
|
||||
|
||||
|
||||
def install_node(nodeElement):
|
||||
global nodes_list_dict
|
||||
# Nodes direcories and nodes in extension
|
||||
folderNodes = ALL_NODES_DIRS.get(nodeElement)
|
||||
isNotNodes = len(folderNodes.get("nodes", [])) == 0
|
||||
|
||||
log(f"* Node <{nodeElement}> is found, installing...")
|
||||
|
||||
clsNodes = getNamesNodesInsidePyFile(nodeElement)
|
||||
clsNodesText = "\033[93m" + ", ".join(clsNodes) + "\033[0m" if clsNodes else ""
|
||||
# printColorInfo(f"Node -> {nodeElement}: {clsNodesText} \033[92m[Loading] ")
|
||||
|
||||
nodes_list_dict[nodeElement].update(
|
||||
{
|
||||
"nodes": clsNodes,
|
||||
"message": f"Node -> {nodeElement}: {clsNodesText} \033[92m",
|
||||
}
|
||||
)
|
||||
|
||||
# Install dependencies
|
||||
checkModules(nodeElement)
|
||||
# addComfyUINodesToMapping(nodeElement) # dynamic class nodes append in mappings
|
||||
|
||||
if DYNAMIC_NODES_ADD:
|
||||
currentNodeSettings = NODES_SETTINGS.get(nodeElement)
|
||||
isActiveNode = True
|
||||
nodesOptions = {}
|
||||
|
||||
# Disable extensions and JavaScript files:
|
||||
# file_js = renameTextUnderline.sub("_\\1", nodeElement).lower().strip()
|
||||
# path_js = os.path.join(web_extensions_dir, f"{file_js}.js")
|
||||
# path_off = os.path.join(web_extensions_dir, f"{file_js}.off")
|
||||
|
||||
if currentNodeSettings is not None:
|
||||
isActiveNode = currentNodeSettings.get("active", True)
|
||||
nodesOptions = currentNodeSettings.get("nodes", {})
|
||||
|
||||
|
||||
if is_check_enabled_nodes and isActiveNode == False or isNotNodes:
|
||||
# stateValue = "Nodes missing" if isNotNodes else "off"
|
||||
# printColorInfo(
|
||||
# f"Node -> \033[93m{nodeElement}\033[0m: [\033[91m{stateValue}\033[0m] "
|
||||
# )
|
||||
|
||||
# Disable extensions and JavaScript files, rename extension *.js -> *.off:
|
||||
# if os.path.isfile(path_js):
|
||||
# print(file_js, "OK")
|
||||
# os.rename(path_js, path_off)
|
||||
|
||||
return
|
||||
|
||||
# Disable extensions and JavaScript files, return normal extension *.off -> *.js:
|
||||
# if os.path.isfile(path_off):
|
||||
# print(path_off, "OK")
|
||||
# os.rename(path_off, path_js)
|
||||
|
||||
log(f"* Node <{nodeElement}> is found, installing...")
|
||||
|
||||
# -- Add to mapping
|
||||
# dynamic class nodes append in mappings
|
||||
clsNames = addComfyUINodesToMapping(nodeElement, nodesOptions)
|
||||
|
||||
|
||||
def safe_rmtree(path):
|
||||
@@ -252,10 +440,8 @@ def installNodes():
|
||||
|
||||
def _installNodes_internal():
|
||||
global installed_modules
|
||||
global nodes_list_dict
|
||||
log(f"\n-------> AlekPet Node Installing [DEBUG] <-------")
|
||||
log("\n-------> AlekPet Node Installing [DEBUG] <-------")
|
||||
|
||||
# printColorInfo(f"### [START] ComfyUI AlekPet Nodes{get_version_extension()} ###", "\033[1;35m")
|
||||
# Remove files in lib directory
|
||||
libfiles = ["fabric.js"]
|
||||
for file in libfiles:
|
||||
@@ -272,20 +458,7 @@ def _installNodes_internal():
|
||||
|
||||
installed_modules = get_installed_modules()
|
||||
|
||||
nodes = []
|
||||
for nodeElement in os.listdir(extension_folder):
|
||||
if (
|
||||
not nodeElement.startswith("__")
|
||||
and nodeElement.endswith("Node")
|
||||
and os.path.isdir(os.path.join(extension_folder, nodeElement))
|
||||
):
|
||||
nodes_list_dict[nodeElement] = {
|
||||
"error": None,
|
||||
"message": f"Node -> {nodeElement}\033[92m",
|
||||
}
|
||||
nodes.append(nodeElement)
|
||||
|
||||
for n in nodes:
|
||||
for n in ALL_NODES_DIRS:
|
||||
install_node(n)
|
||||
|
||||
|
||||
@@ -296,237 +469,265 @@ WEB_DIRECTORY = f"./{extension_dirs[0]}"
|
||||
# Install nodes
|
||||
installNodes()
|
||||
|
||||
# Import classes nodes and add in mappings
|
||||
# ArgosTranslateNode
|
||||
try:
|
||||
from .ArgosTranslateNode.argos_translate_node import (
|
||||
ArgosTranslateCLIPTextEncodeNode,
|
||||
ArgosTranslateTextNode,
|
||||
)
|
||||
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"ArgosTranslateCLIPTextEncodeNode": ArgosTranslateCLIPTextEncodeNode,
|
||||
"ArgosTranslateTextNode": ArgosTranslateTextNode,
|
||||
}
|
||||
)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"ArgosTranslateCLIPTextEncodeNode": "Argos Translate CLIP Text Encode Node",
|
||||
"ArgosTranslateTextNode": "Argos Translate Text Node",
|
||||
}
|
||||
)
|
||||
# For ComfyUI Manager 😄
|
||||
if not DYNAMIC_NODES_ADD:
|
||||
# Import classes nodes and add in mappings
|
||||
# ArgosTranslateNode
|
||||
try:
|
||||
from .ArgosTranslateNode.argos_translate_node import (
|
||||
ArgosTranslateCLIPTextEncodeNode,
|
||||
ArgosTranslateTextNode,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
if "ArgosTranslateNode" in nodes_list_dict:
|
||||
nodes_list_dict["ArgosTranslateNode"]["error"] = e
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"ArgosTranslateCLIPTextEncodeNode": ArgosTranslateCLIPTextEncodeNode,
|
||||
"ArgosTranslateTextNode": ArgosTranslateTextNode,
|
||||
}
|
||||
)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"ArgosTranslateCLIPTextEncodeNode": "Argos Translate CLIP Text Encode Node",
|
||||
"ArgosTranslateTextNode": "Argos Translate Text Node",
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
NODES_LOAD_FAILED["ArgosTranslateNode"] = e
|
||||
|
||||
|
||||
# DeepTranslatorNode
|
||||
try:
|
||||
from .DeepTranslatorNode.deep_translator_node import (
|
||||
DeepTranslatorCLIPTextEncodeNode,
|
||||
DeepTranslatorTextNode,
|
||||
)
|
||||
# DeepTranslatorNode
|
||||
try:
|
||||
from .DeepTranslatorNode.deep_translator_node import (
|
||||
DeepTranslatorCLIPTextEncodeNode,
|
||||
DeepTranslatorTextNode,
|
||||
)
|
||||
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"DeepTranslatorCLIPTextEncodeNode": DeepTranslatorCLIPTextEncodeNode,
|
||||
"DeepTranslatorTextNode": DeepTranslatorTextNode,
|
||||
}
|
||||
)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"DeepTranslatorCLIPTextEncodeNode": "Deep Translator CLIP Text Encode Node",
|
||||
"DeepTranslatorTextNode": "Deep Translator Text Node",
|
||||
}
|
||||
)
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"DeepTranslatorCLIPTextEncodeNode": DeepTranslatorCLIPTextEncodeNode,
|
||||
"DeepTranslatorTextNode": DeepTranslatorTextNode,
|
||||
}
|
||||
)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"DeepTranslatorCLIPTextEncodeNode": "Deep Translator CLIP Text Encode Node",
|
||||
"DeepTranslatorTextNode": "Deep Translator Text Node",
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
if "DeepTranslatorNode" in nodes_list_dict:
|
||||
nodes_list_dict["DeepTranslatorNode"]["error"] = e
|
||||
except Exception as e:
|
||||
NODES_LOAD_FAILED["DeepTranslatorNode"] = e
|
||||
|
||||
# GoogleTranslateNode
|
||||
try:
|
||||
from .GoogleTranslateNode.google_translate_node import (
|
||||
GoogleTranslateCLIPTextEncodeNode,
|
||||
GoogleTranslateTextNode,
|
||||
)
|
||||
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"GoogleTranslateCLIPTextEncodeNode": GoogleTranslateCLIPTextEncodeNode,
|
||||
"GoogleTranslateTextNode": GoogleTranslateTextNode,
|
||||
}
|
||||
)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"GoogleTranslateCLIPTextEncodeNode": "Google Translate CLIP Text Encode Node",
|
||||
"GoogleTranslateTextNode": "Google Translate Text Node",
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
NODES_LOAD_FAILED["GoogleTranslateNode"] = e
|
||||
|
||||
# ChatGLMNode
|
||||
try:
|
||||
from .ChatGLMNode.chatglm_node import (
|
||||
ChatGLM4TranslateCLIPTextEncodeNode,
|
||||
ChatGLM4TranslateTextNode,
|
||||
ChatGLM4InstructNode,
|
||||
ChatGLM4InstructMediaNode,
|
||||
ChatGLMImageGenerateNode,
|
||||
ChatGLMVideoGenerateNode
|
||||
)
|
||||
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"ChatGLM4TranslateCLIPTextEncodeNode": ChatGLM4TranslateCLIPTextEncodeNode,
|
||||
"ChatGLM4TranslateTextNode": ChatGLM4TranslateTextNode,
|
||||
"ChatGLM4InstructNode": ChatGLM4InstructNode,
|
||||
"ChatGLM4InstructMediaNode": ChatGLM4InstructMediaNode,
|
||||
# Generate
|
||||
"ChatGLMImageGenerateNode": ChatGLMImageGenerateNode,
|
||||
"ChatGLMVideoGenerateNode": ChatGLMVideoGenerateNode,
|
||||
}
|
||||
)
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"ChatGLM4TranslateCLIPTextEncodeNode": "ChatGLM-4 Translate CLIP Text Encode Node",
|
||||
"ChatGLM4TranslateTextNode": "ChatGLM-4 Translate Text Node",
|
||||
"ChatGLM4InstructNode": "ChatGLM-4 Instruct Node",
|
||||
"ChatGLM4InstructMediaNode": "ChatGLM-4 Instruct Media Node",
|
||||
# Generate
|
||||
"ChatGLMImageGenerateNode": "Chat GLM Image Generate Node",
|
||||
"ChatGLMVideoGenerateNode": "Chat GLM Video Generate Node",
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
NODES_LOAD_FAILED["ChatGLMNode"] = e
|
||||
|
||||
|
||||
# GoogleTranslateNode
|
||||
try:
|
||||
from .GoogleTranslateNode.google_translate_node import (
|
||||
GoogleTranslateCLIPTextEncodeNode,
|
||||
GoogleTranslateTextNode,
|
||||
)
|
||||
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"GoogleTranslateCLIPTextEncodeNode": GoogleTranslateCLIPTextEncodeNode,
|
||||
"GoogleTranslateTextNode": GoogleTranslateTextNode,
|
||||
}
|
||||
)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"GoogleTranslateCLIPTextEncodeNode": "Google Translate CLIP Text Encode Node",
|
||||
"GoogleTranslateTextNode": "Google Translate Text Node",
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
if "GoogleTranslateNode" in nodes_list_dict:
|
||||
nodes_list_dict["GoogleTranslateNode"]["error"] = e
|
||||
|
||||
|
||||
# ChatGLMNode
|
||||
try:
|
||||
from .ChatGLMNode.chatglm_node import (
|
||||
ChatGLM4TranslateCLIPTextEncodeNode,
|
||||
ChatGLM4TranslateTextNode,
|
||||
ChatGLM4InstructNode,
|
||||
ChatGLM4InstructMediaNode,
|
||||
ChatGLMImageGenerateNode,
|
||||
ChatGLMVideoGenerateNode
|
||||
)
|
||||
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"ChatGLM4TranslateCLIPTextEncodeNode": ChatGLM4TranslateCLIPTextEncodeNode,
|
||||
"ChatGLM4TranslateTextNode": ChatGLM4TranslateTextNode,
|
||||
"ChatGLM4InstructNode": ChatGLM4InstructNode,
|
||||
"ChatGLM4InstructMediaNode": ChatGLM4InstructMediaNode,
|
||||
# Generate
|
||||
"ChatGLMImageGenerateNode": ChatGLMImageGenerateNode,
|
||||
"ChatGLMVideoGenerateNode": ChatGLMVideoGenerateNode,
|
||||
}
|
||||
)
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"ChatGLM4TranslateCLIPTextEncodeNode": "ChatGLM-4 Translate CLIP Text Encode Node",
|
||||
"ChatGLM4TranslateTextNode": "ChatGLM-4 Translate Text Node",
|
||||
"ChatGLM4InstructNode": "ChatGLM-4 Instruct Node",
|
||||
"ChatGLM4InstructMediaNode": "ChatGLM-4 Instruct Media Node",
|
||||
# Generate
|
||||
"ChatGLMImageGenerateNode": "Chat GLM Image Generate Node",
|
||||
"ChatGLMVideoGenerateNode": "Chat GLM Video Generate Node",
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
if "ChatGLMNode" in nodes_list_dict:
|
||||
nodes_list_dict["ChatGLMNode"]["error"] = e
|
||||
|
||||
|
||||
# ExtrasNode
|
||||
try:
|
||||
# ExtrasNode
|
||||
from .ExtrasNode.extras_node import PreviewTextNode, HexToHueNode, ColorsCorrectNode
|
||||
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"PreviewTextNode": PreviewTextNode,
|
||||
"HexToHueNode": HexToHueNode,
|
||||
"ColorsCorrectNode": ColorsCorrectNode,
|
||||
}
|
||||
)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"PreviewTextNode": "Preview Text Node",
|
||||
"HexToHueNode": "HEX to HUE Node",
|
||||
"ColorsCorrectNode": "Colors Correct Node",
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
if "ExtrasNode" in nodes_list_dict:
|
||||
nodes_list_dict["ExtrasNode"]["error"] = e
|
||||
|
||||
|
||||
# PainterNode
|
||||
try:
|
||||
# PainterNode
|
||||
from .PainterNode.painter_node import PainterNode
|
||||
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"PainterNode": PainterNode,
|
||||
}
|
||||
)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"PainterNode": "Painter Node",
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
if "PainterNode" in nodes_list_dict:
|
||||
nodes_list_dict["PainterNode"]["error"] = e
|
||||
|
||||
|
||||
# PoseNode
|
||||
try:
|
||||
# PoseNode
|
||||
from .PoseNode.pose_node import PoseNode
|
||||
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"PoseNode": PoseNode,
|
||||
}
|
||||
)
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"PoseNode": "Pose Node",
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
if "PoseNode" in nodes_list_dict:
|
||||
nodes_list_dict["PoseNode"]["error"] = e
|
||||
|
||||
|
||||
# IDENode
|
||||
try:
|
||||
# IDENode
|
||||
from .IDENode.ide_node import IDENode
|
||||
|
||||
NODE_CLASS_MAPPINGS.update(
|
||||
{
|
||||
"IDENode": IDENode,
|
||||
}
|
||||
)
|
||||
NODE_CLASS_MAPPINGS.update({
|
||||
"PreviewTextNode": PreviewTextNode,
|
||||
"HexToHueNode": HexToHueNode,
|
||||
"ColorsCorrectNode": ColorsCorrectNode,
|
||||
"PainterNode": PainterNode,
|
||||
"PoseNode": PoseNode,
|
||||
"IDENode": IDENode,
|
||||
})
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(
|
||||
{
|
||||
"IDENode": "IDE Node",
|
||||
}
|
||||
)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update({
|
||||
"PreviewTextNode": "Preview Text Node",
|
||||
"HexToHueNode": "HEX to HUE Node",
|
||||
"ColorsCorrectNode": "Colors Correct Node",
|
||||
"PainterNode": "Painter Node",
|
||||
"PoseNode": "Pose Node",
|
||||
"IDENode": "IDE Node",
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
if "IDENode" in nodes_list_dict:
|
||||
nodes_list_dict["IDENode"]["error"] = e
|
||||
else:
|
||||
# For ComfyUI Manager 😄, if DYNAMIC_NODES_ADD = True
|
||||
'''
|
||||
# Import classes nodes and add in mappings
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"ArgosTranslateCLIPTextEncodeNode": ArgosTranslateCLIPTextEncodeNode,
|
||||
"ArgosTranslateTextNode": ArgosTranslateTextNode,
|
||||
"ChatGLM4TranslateCLIPTextEncodeNode": ChatGLM4TranslateCLIPTextEncodeNode,
|
||||
"ChatGLM4TranslateTextNode": ChatGLM4TranslateTextNode,
|
||||
"ChatGLM4InstructNode": ChatGLM4InstructNode,
|
||||
"ChatGLM4InstructMediaNode": ChatGLM4InstructMediaNode,
|
||||
"ChatGLMImageGenerateNode": ChatGLMImageGenerateNode,
|
||||
"ChatGLMVideoGenerateNode": ChatGLMVideoGenerateNode,
|
||||
"DeepTranslatorCLIPTextEncodeNode": DeepTranslatorCLIPTextEncodeNode,
|
||||
"DeepTranslatorTextNode": DeepTranslatorTextNode,
|
||||
"PreviewTextNode": PreviewTextNode,
|
||||
"HexToHueNode": HexToHueNode,
|
||||
"ColorsCorrectNode": ColorsCorrectNode,
|
||||
"GoogleTranslateCLIPTextEncodeNode": GoogleTranslateCLIPTextEncodeNode,
|
||||
"GoogleTranslateTextNode": GoogleTranslateTextNode,
|
||||
"PainterNode": PainterNode,
|
||||
"PoseNode": PoseNode,
|
||||
"IDENode": IDENode,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"ArgosTranslateCLIPTextEncodeNode": "Argos Translate CLIP Text Encode Node",
|
||||
"ArgosTranslateTextNode": "Argos Translate Text Node",
|
||||
"ChatGLM4TranslateCLIPTextEncodeNode": "ChatGLM-4 Translate CLIP Text Encode Node",
|
||||
"ChatGLM4TranslateTextNode": "ChatGLM-4 Translate Text Node",
|
||||
"ChatGLM4InstructNode": "ChatGLM-4 Instruct Node",
|
||||
"ChatGLM4InstructMediaNode": "ChatGLM-4 Instruct Media Node",
|
||||
"ChatGLMImageGenerateNode": "Chat GLM Image Generate Node",
|
||||
"ChatGLMVideoGenerateNode": "Chat GLM Video Generate Node",
|
||||
"DeepTranslatorCLIPTextEncodeNode": "Deep Translator CLIP Text Encode Node",
|
||||
"DeepTranslatorTextNode": "Deep Translator Text Node",
|
||||
"PreviewTextNode": "Preview Text Node",
|
||||
"HexToHueNode": "HEX to HUE Node",
|
||||
"ColorsCorrectNode": "Colors Correct Node",
|
||||
"GoogleTranslateCLIPTextEncodeNode": "Google Translate CLIP Text Encode Node",
|
||||
"GoogleTranslateTextNode": "Google Translate Text Node",
|
||||
"PainterNode": "Painter Node",
|
||||
"PoseNode": "Pose Node",
|
||||
"IDENode": "IDE Node",
|
||||
}'''
|
||||
|
||||
|
||||
# Information
|
||||
printColorInfo(f"\n### [START] ComfyUI AlekPet Nodes{get_version_extension()} ###", "\033[1;35m")
|
||||
printColorInfo(
|
||||
f"### [START] ComfyUI AlekPet Nodes{get_version_extension()} ###", "\033[1;35m"
|
||||
)
|
||||
|
||||
failed_nodes_text = ""
|
||||
len_nodes = len(nodes_list_dict)
|
||||
for key, node in enumerate(nodes_list_dict):
|
||||
currentNode = nodes_list_dict[node]
|
||||
for nodeElement in ALL_NODES_DIRS:
|
||||
folderNodes = ALL_NODES_DIRS.get(nodeElement)
|
||||
clsNodes = folderNodes.get("nodes", [])
|
||||
isNotNodes = len(clsNodes) == 0
|
||||
|
||||
currentNodeVals = currentNode.get("error")
|
||||
# Method views nodes DYNAMIC_NODES_ADD = False
|
||||
if not DYNAMIC_NODES_ADD:
|
||||
status = "\033[1;36;40m [Success] "
|
||||
if nodeElement in NODES_LOAD_FAILED:
|
||||
status = "\033[91m [Failed] "
|
||||
|
||||
if currentNodeVals is None:
|
||||
status = "\033[92m[Loading]"
|
||||
else:
|
||||
color_error = "\033[1;31;40m"
|
||||
status = color_error + " [Failed]"
|
||||
error_message = currentNode.get("error", "Error")
|
||||
|
||||
if(len(currentNodeVals.args) == 2 and currentNodeVals.args[1] == "warning"):
|
||||
color_error = "\033[33m"
|
||||
status = color_error + "[Warning]"
|
||||
error_message = currentNodeVals.args[0]
|
||||
|
||||
failed_nodes_text += f"\033[93m{node} -> {color_error}{error_message}\033[0m\n"
|
||||
|
||||
message = currentNode.get("message", "No message available")
|
||||
printColorInfo(f"{message}{status}\033[0m")
|
||||
|
||||
if key == len_nodes - 1 and failed_nodes_text:
|
||||
printColorInfo(
|
||||
f"\n\033[1;31;40m* Nodes have been temporarily disabled due to the error or specially *\033[0m\n{failed_nodes_text}"
|
||||
clsNodesText = (
|
||||
"\033[93m" + ", ".join(clsNodes) + status
|
||||
if not isNotNodes
|
||||
else "\033[91m[Node missing]"
|
||||
)
|
||||
|
||||
printColorInfo(f"### [END] ComfyUI AlekPet Nodes ###", "\033[1;35m")
|
||||
# Show list nodes
|
||||
printColorInfo(f"Node -> {nodeElement}: {clsNodesText} \033[92m")
|
||||
else:
|
||||
|
||||
isActiveNode = True
|
||||
nodesOptions = {}
|
||||
currentNodeSettings = NODES_SETTINGS.get(nodeElement)
|
||||
|
||||
if currentNodeSettings is not None:
|
||||
isActiveNode = currentNodeSettings.get("active", True)
|
||||
nodesOptions = currentNodeSettings.get("nodes", {})
|
||||
|
||||
# Method views nodes DYNAMIC_NODES_ADD = True
|
||||
if nodeElement not in NODES_LOAD_SUCCESS:
|
||||
state = "Off" if not isActiveNode else "Failed"
|
||||
printColorInfo(f"Node -> \033[93m{nodeElement}: \033[91m[{state}]")
|
||||
continue
|
||||
|
||||
|
||||
namesNodes = NODES_LOAD_SUCCESS[nodeElement]
|
||||
lenNodesNames = len(namesNodes) - 1
|
||||
listNodes = f"Node -> \033[93m{nodeElement}\033[0m: "
|
||||
|
||||
for k, n in enumerate(namesNodes):
|
||||
sep = "" if k == lenNodesNames else ", "
|
||||
active = "off"
|
||||
if n in nodesOptions:
|
||||
active = (
|
||||
"\033[94mon" if nodesOptions[n] else "\033[91moff"
|
||||
) + "\033[0m"
|
||||
else:
|
||||
active = "\033[94mon\033[0m"
|
||||
|
||||
listNodes += f"\033[92m{n}\033[0m [{active}]{sep} "
|
||||
|
||||
listNodes += "\033[1;36;40m[Success]"
|
||||
# -- end Add to mapping
|
||||
|
||||
# Show list nodes
|
||||
printColorInfo(listNodes)
|
||||
|
||||
# View nodes failed loading
|
||||
if NODES_LOAD_FAILED.keys():
|
||||
print(
|
||||
f"\n\033[1;31;40m* Nodes have been temporarily disabled due to the error *\033[0m"
|
||||
)
|
||||
for failed_node in NODES_LOAD_FAILED:
|
||||
error_text = NODES_LOAD_FAILED[failed_node]
|
||||
print("\033[93m" + failed_node + " -> \033[1;31;40m" + str(error_text) + "\033[0m")
|
||||
|
||||
printColorInfo("### [END] ComfyUI AlekPet Nodes ###", "\033[1;35m")
|
||||
|
||||
Reference in New Issue
Block a user