forked from lcolok/ComfyUI-MagicAI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
111 lines (94 loc) · 2.8 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
"""
@author: LogicAI
@title: ComfyUI-MagicAI
@nickname: 🧠 LogicAI
"""
import os
import sys
# from .setup import setup_all
# setup_all() # 每次启动Comfy都会执行setup_all(),这样非常耗时,所以注释掉
current_path = os.path.abspath(os.path.dirname(__file__))
modules_path = os.path.join(current_path, "modules")
if os.path.isdir(modules_path):
sys.path.insert(0, modules_path)
from .modules.magicai.nodes.Composite import *
from .modules.magicai.nodes.Exec import *
from .modules.magicai.nodes.IO import *
from .modules.magicai.nodes.Operation import *
from .modules.magicai.nodes.String import *
from .modules.magicai.utils.mappings import *
# Category Composite
composite_mappings = [
(AlphaMatte, "🎨 AlphaMatte (MagicAI)", "🎨 Alpha Matte (MagicAI)"),
]
# Category Exec
exec_mappings = [
(
PythonExecutionNode,
"🐍 PythonExecution (MagicAI)",
"🐍 Python Execution (MagicAI)",
),
]
string_mappings = [
(
ExtractJSONFromTextNode,
"📄🔍 ExtractJSONFromTextNode (MagicAI)",
"📄🔍 Extract JSON From Text Node(MagicAI)",
),
(
GetValueFromJsonString,
"📄🔑 GetValueFromJsonString (MagicAI)",
"📄🔑 Get Value From Json String (MagicAI)",
),
(
JinjaTemplateRenderer,
"📄 JinjaTemplateRenderer (MagicAI)",
"📄 Jinja Template Renderer (MagicAI)",
),
(
JsonKeyValueInjector,
"📄🔑 JsonKeyValueInjector (MagicAI)",
"📄🔑 Json Key Value Injector (MagicAI)",
),
]
# Category IO
io_mappings = [
(TextBox, "✍🏻 TextBox (MagicAI)", "✍🏻 Text Box (MagicAI)"),
(MaskToPreviewImage, "👹 PreviewMask (MagicAI)", "👹 Preview Mask (MagicAI)"),
]
# Category Operation
operation_mappings = [
(
MaskSizeCalculator,
"👹🖩 Mask Size Calculator (MagicAI)",
"👹🖩 Mask Size Calculator (MagicAI)",
),
(
UniversalMaskConverter,
"🔀 UniversalMaskConverter (MagicAI)",
"🔀 Universal Mask Converter (MagicAI)",
),
(
ChromaKeyToMask,
"🎨👹 ChromaKeyToMask (MagicAI)",
"🎨👹 Chroma Key To Mask (MagicAI)",
),
(PasteByMask, "📋🔲 PasteByMask (MagicAI)", "📋🔲 Paste By Mask (MagicAI)"),
]
# Define mappings as a list of category mappings
mappings = [
composite_mappings,
io_mappings,
operation_mappings,
string_mappings,
exec_mappings,
]
# Combine all mappings into a single list
all_mappings = []
for category in mappings:
all_mappings.extend(category)
# Generate mappings and assign to variables
NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS = generate_mappings(all_mappings)
# web ui的节点功能
WEB_DIRECTORY = "./web"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]