-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__init__.py
More file actions
186 lines (162 loc) · 7.39 KB
/
Copy path__init__.py
File metadata and controls
186 lines (162 loc) · 7.39 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
"""
Augment - ComfyUI Custom Node Pack
Resilient loader: each node imports independently so one failure won't block the rest.
"""
import traceback
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
_failed = []
def _register(module_path, imports, mappings):
"""
Try to import `imports` from `module_path` and register each into the global dicts.
imports: list of (ClassName,) — names to import from the module
mappings: dict of { "NodeID": ("ClassName", "Display Name") }
"""
try:
mod = __import__(module_path, fromlist=[c for c in imports])
except Exception as e:
for node_id, (cls_name, display) in mappings.items():
_failed.append((node_id, e))
print(f"[augment] ⚠ {node_id} unavailable: {e}")
return
for node_id, (cls_name, display) in mappings.items():
cls = getattr(mod, cls_name, None)
if cls is None:
_failed.append((node_id, f"{cls_name} not found in {module_path}"))
print(f"[augment] ⚠ {node_id} unavailable: {cls_name} not found in {module_path}")
continue
NODE_CLASS_MAPPINGS[node_id] = cls
NODE_DISPLAY_NAME_MAPPINGS[node_id] = display
# ── Executor Override (must import first to patch ComfyUI) ──
try:
__import__("custom_nodes.augment.py.executor")
except Exception as e:
print(f"[augment] ⚠ Executor patch unavailable: {e}")
# ── Image Processing & Cropping ──
_register("custom_nodes.augment.py.face_crop", ["FaceCrop"], {
"AugmentFaceCrop": ("FaceCrop", "Face Crop"),
})
_register("custom_nodes.augment.py.image_crop", ["ImageCrop"], {
"AugmentImageCrop": ("ImageCrop", "Image Crop"),
})
_register("custom_nodes.augment.py.image_place", ["ImagePlaceNode"], {
"AugmentImagePlace": ("ImagePlaceNode", "Image Place"),
})
_register("custom_nodes.augment.py.invert_image", ["InvertImageNode"], {
"AugmentInvertImage": ("InvertImageNode", "Invert Image"),
})
_register("custom_nodes.augment.py.image_rotate", ["ImageRotateNode"], {
"AugmentImageRotate": ("ImageRotateNode", "Image Rotate"),
})
_register("custom_nodes.augment.py.image_flip", ["ImageFlipNode"], {
"AugmentImageFlip": ("ImageFlipNode", "Image Flip"),
})
_register("custom_nodes.augment.py.logo_mask", ["LogoMask"], {
"AugmentLogoMask": ("LogoMask", "Logo Mask"),
})
_register("custom_nodes.augment.py.mask_bounding_box", ["MaskBoundingBox"], {
"AugmentMaskBoundingBox": ("MaskBoundingBox", "Mask Bounding Box"),
})
# ── Grid & Construction Lines ──
_register("custom_nodes.augment.py.grid", ["GridGenerator"], {
"AugmentGridGenerator": ("GridGenerator", "Grid Generator"),
})
_register("custom_nodes.augment.py.grid_coords", ["GridCoordsNode"], {
"AugmentGridCoords": ("GridCoordsNode", "Grid Coords"),
})
_register("custom_nodes.augment.py.draw_line", ["LineDrawNode"], {
"AugmentLineDraw": ("LineDrawNode", "Line Draw"),
})
_register("custom_nodes.augment.py.circle_draw", ["CircleDrawNode"], {
"AugmentCircleDraw": ("CircleDrawNode", "Circle Draw"),
})
_register("custom_nodes.augment.py.fib", ["FibonacciSpiralNode"], {
"AugmentFibonacciSpiral": ("FibonacciSpiralNode", "Fibonacci Spiral"),
})
_register("custom_nodes.augment.py.construction_lines", ["ConstructionLineOverlay"], {
"AugmentConstructionLineOverlay": ("ConstructionLineOverlay", "Construction Line Overlay"),
})
_register("custom_nodes.augment.py.edge_detect", ["ShapeEdgeDetect"], {
"AugmentShapeEdgeDetect": ("ShapeEdgeDetect", "Shape Edge Detect"),
})
# ── Color & Effects ──
_register("custom_nodes.augment.py.recolor", ["RecolorNode"], {
"AugmentRecolor": ("RecolorNode", "Recolor (Mask)"),
})
_register("custom_nodes.augment.py.blur_average", ["BlurAverageNode"], {
"AugmentBlurAverage": ("BlurAverageNode", "Blur Average (Dominant Color)"),
})
# ── Primitives ──
_register("custom_nodes.augment.py.prim_node", ["IntNode", "FloatNode", "StringNode", "BoolNode"], {
"AugmentIntPrim": ("IntNode", "Int"),
"AugmentFloatPrim": ("FloatNode", "Float"),
"AugmentStringPrim": ("StringNode", "String"),
"AugmentBoolPrim": ("BoolNode", "Bool"),
})
# ── Variables ──
_register("custom_nodes.augment.py.variables", [
"NumberVarSetNode", "NumberVarGetNode", "NumberVarIncrementNode",
"NumberVarDecrementNode", "NumberVarResetNode",
"StringVarSetNode", "StringVarGetNode", "StringVarDeleteNode",
], {
"AugmentNumberVarSet": ("NumberVarSetNode", "Variable Set (Number)"),
"AugmentNumberVarGet": ("NumberVarGetNode", "Variable Get (Number)"),
"AugmentNumberVarIncrement": ("NumberVarIncrementNode", "Variable Increment (Number)"),
"AugmentNumberVarDecrement": ("NumberVarDecrementNode", "Variable Decrement (Number)"),
"AugmentNumberVarReset": ("NumberVarResetNode", "Variable Reset (Number)"),
"AugmentStringVarSet": ("StringVarSetNode", "Variable Set (String)"),
"AugmentStringVarGet": ("StringVarGetNode", "Variable Get (String)"),
"AugmentStringVarDelete": ("StringVarDeleteNode", "Variable Delete (String)"),
})
# ── Flow Control ──
try:
from .py.trigger import make_wait_node, WAIT_TYPES
for _name, _type_str in WAIT_TYPES.items():
_cls_name = f"AugmentWait{_name}"
try:
NODE_CLASS_MAPPINGS[_cls_name] = make_wait_node(_name, _type_str)
NODE_DISPLAY_NAME_MAPPINGS[_cls_name] = f"{_name} (Improved)"
except Exception as e:
_failed.append((_cls_name, e))
print(f"[augment] ⚠ {_cls_name} unavailable: {e}")
except Exception as e:
_failed.append(("Wait nodes", e))
print(f"[augment] ⚠ Flow control nodes unavailable: {e}")
# PAID
_register("custom_nodes.augment.py.svg_tools", ["AugmentSVGToPNG", "AugmentPNGToSVG"], {
"AugmentSVGToPNG": ("AugmentSVGToPNG", "Augment SVG to PNG"),
"AugmentPNGToSVG": ("AugmentPNGToSVG", "Augment PNG to SVG"),
})
# ── Crypto & Utilities ──
_register("custom_nodes.augment.py.crypto", ["SHA256Node", "RandomNumberNode", "UUIDNode"], {
"AugmentSHA256": ("SHA256Node", "SHA-256 Hash"),
"AugmentRandomNumber": ("RandomNumberNode", "Random Number"),
"AugmentUUID": ("UUIDNode", "UUID Generator"),
})
_register("custom_nodes.augment.py.json_viewer", ["JsonViewerNode"], {
"AugmentJsonViewer": ("JsonViewerNode", "JSON Viewer"),
})
_register("custom_nodes.augment.py.json_extract", ["JsonExtractNode"], {
"AugmentJsonExtract": ("JsonExtractNode", "JSON Extract"),
})
# ── Preview & Save ──
_register("custom_nodes.augment.py.preview", ["AugmentPreviewImage", "AugmentSaveImage", "AugmentPreviewAny"], {
"AugmentPreviewImage": ("AugmentPreviewImage", "Preview Image"),
"AugmentSaveImage": ("AugmentSaveImage", "Save Image (Improved)"),
"AugmentPreviewAny": ("AugmentPreviewAny", "Preview Any"),
})
_register("custom_nodes.augment.py.load_image", ["AugmentLoadImage"], {
"AugmentLoadImage": ("AugmentLoadImage", "Load Image (Improved)"),
})
_register("custom_nodes.augment.py.switch", ["SwitchNode"], {
"AugmentSwitchNode": ("SwitchNode", "Switch Improved"),
})
# ── Summary ──
WEB_DIRECTORY = "./web/js"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
if _failed:
print(f"[augment] ✓ Registered {len(NODE_CLASS_MAPPINGS)} nodes ({len(_failed)} failed)")
for node_id, err in _failed:
print(f"[augment] ✗ {node_id}: {err}")
else:
print(f"[augment] ✓ Registered {len(NODE_CLASS_MAPPINGS)} nodes")