deneesk commited on
Commit
2a4e68a
1 Parent(s): 785b0bc

Upload 272 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. custom_nodes/ComfyUI-Impact-Pack/.github/workflows/publish.yml +21 -0
  3. custom_nodes/ComfyUI-Impact-Pack/.gitignore +9 -0
  4. custom_nodes/ComfyUI-Impact-Pack/.gitmodules +3 -0
  5. custom_nodes/ComfyUI-Impact-Pack/LICENSE.txt +674 -0
  6. custom_nodes/ComfyUI-Impact-Pack/README.md +490 -0
  7. custom_nodes/ComfyUI-Impact-Pack/__init__.py +499 -0
  8. custom_nodes/ComfyUI-Impact-Pack/__pycache__/__init__.cpython-310.pyc +0 -0
  9. custom_nodes/ComfyUI-Impact-Pack/custom_wildcards/put_wildcards_here +0 -0
  10. custom_nodes/ComfyUI-Impact-Pack/disable.py +38 -0
  11. custom_nodes/ComfyUI-Impact-Pack/impact-pack.ini +8 -0
  12. custom_nodes/ComfyUI-Impact-Pack/impact_subpack/.gitignore +5 -0
  13. custom_nodes/ComfyUI-Impact-Pack/impact_subpack/LICENSE +661 -0
  14. custom_nodes/ComfyUI-Impact-Pack/impact_subpack/README.md +18 -0
  15. custom_nodes/ComfyUI-Impact-Pack/impact_subpack/impact/__pycache__/subcore.cpython-310.pyc +0 -0
  16. custom_nodes/ComfyUI-Impact-Pack/impact_subpack/impact/__pycache__/subpack_nodes.cpython-310.pyc +0 -0
  17. custom_nodes/ComfyUI-Impact-Pack/impact_subpack/impact/subcore.py +234 -0
  18. custom_nodes/ComfyUI-Impact-Pack/impact_subpack/impact/subpack_nodes.py +45 -0
  19. custom_nodes/ComfyUI-Impact-Pack/impact_subpack/install.py +39 -0
  20. custom_nodes/ComfyUI-Impact-Pack/impact_subpack/requirements.txt +2 -0
  21. custom_nodes/ComfyUI-Impact-Pack/install.py +299 -0
  22. custom_nodes/ComfyUI-Impact-Pack/js/comboBoolMigration.js +35 -0
  23. custom_nodes/ComfyUI-Impact-Pack/js/common.js +95 -0
  24. custom_nodes/ComfyUI-Impact-Pack/js/impact-image-util.js +229 -0
  25. custom_nodes/ComfyUI-Impact-Pack/js/impact-pack.js +815 -0
  26. custom_nodes/ComfyUI-Impact-Pack/js/impact-sam-editor.js +637 -0
  27. custom_nodes/ComfyUI-Impact-Pack/js/impact-segs-picker.js +182 -0
  28. custom_nodes/ComfyUI-Impact-Pack/js/impact-wildcard.js +16 -0
  29. custom_nodes/ComfyUI-Impact-Pack/latent.png +0 -0
  30. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/animatediff_nodes.cpython-310.pyc +0 -0
  31. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/bridge_nodes.cpython-310.pyc +0 -0
  32. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/config.cpython-310.pyc +0 -0
  33. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/core.cpython-310.pyc +0 -0
  34. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/defs.cpython-310.pyc +0 -0
  35. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/detectors.cpython-310.pyc +0 -0
  36. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/hf_nodes.cpython-310.pyc +0 -0
  37. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/hook_nodes.cpython-310.pyc +0 -0
  38. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/hooks.cpython-310.pyc +0 -0
  39. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/impact_pack.cpython-310.pyc +0 -0
  40. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/impact_sampling.cpython-310.pyc +0 -0
  41. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/impact_server.cpython-310.pyc +0 -0
  42. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/logics.cpython-310.pyc +0 -0
  43. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/pipe.cpython-310.pyc +0 -0
  44. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/sample_error_enhancer.cpython-310.pyc +0 -0
  45. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/segs_nodes.cpython-310.pyc +0 -0
  46. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/segs_upscaler.cpython-310.pyc +0 -0
  47. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/special_samplers.cpython-310.pyc +0 -0
  48. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/util_nodes.cpython-310.pyc +0 -0
  49. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/utils.cpython-310.pyc +0 -0
  50. custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/wildcards.cpython-310.pyc +0 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ custom_nodes/ComfyUI-Inpaint-CropAndStitch/inpaint-cropandstitch_example_workflow.png filter=lfs diff=lfs merge=lfs -text
custom_nodes/ComfyUI-Impact-Pack/.github/workflows/publish.yml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Publish to Comfy registry
2
+ on:
3
+ workflow_dispatch:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - "pyproject.toml"
9
+
10
+ jobs:
11
+ publish-node:
12
+ name: Publish Custom Node to registry
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Check out code
16
+ uses: actions/checkout@v4
17
+ - name: Publish Custom Node
18
+ uses: Comfy-Org/publish-node-action@main
19
+ with:
20
+ ## Add your own personal access token to your Github Repository secrets and reference it here.
21
+ personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
custom_nodes/ComfyUI-Impact-Pack/.gitignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__
2
+ *.ini
3
+ wildcards/**
4
+ .vscode/
5
+ .idea/
6
+ subpack
7
+ impact_subpack
8
+ *.txt
9
+ *.yaml
custom_nodes/ComfyUI-Impact-Pack/.gitmodules ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [submodule "subpack"]
2
+ path = subpack
3
+ url = https://github.com/ltdrdata/ComfyUI-Impact-Subpack
custom_nodes/ComfyUI-Impact-Pack/LICENSE.txt ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <https://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <https://www.gnu.org/licenses/why-not-lgpl.html>.
custom_nodes/ComfyUI-Impact-Pack/README.md ADDED
@@ -0,0 +1,490 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [![Youtube Badge](https://img.shields.io/badge/Youtube-FF0000?style=for-the-badge&logo=Youtube&logoColor=white&link=https://www.youtube.com/watch?v=AccoxDZIg3Y&list=PL_Ej2RDzjQLGfEeizq4GISeY3FtVyFmGP)](https://www.youtube.com/watch?v=AccoxDZIg3Y&list=PL_Ej2RDzjQLGfEeizq4GISeY3FtVyFmGP)
2
+
3
+ # ComfyUI-Impact-Pack
4
+
5
+ **Custom nodes pack for ComfyUI**
6
+ This custom node helps to conveniently enhance images through Detector, Detailer, Upscaler, Pipe, and more.
7
+
8
+
9
+ ## NOTICE
10
+ * V7.0: Supports Switch based on Execution Model Inversion.
11
+ * V6.0: Supports FLUX.1 model in Impact KSampler, Detailers, PreviewBridgeLatent
12
+ * V5.0: It is no longer compatible with versions of ComfyUI before 2024.04.08.
13
+ * V4.87.4: Update to a version of ComfyUI after 2024.04.08 for proper functionality.
14
+ * V4.85: Incompatible with the outdated **ComfyUI IPAdapter Plus**. (A version dated March 24th or later is required.)
15
+ * V4.77: Compatibility patch applied. Requires ComfyUI version (Oct. 8th) or later.
16
+ * V4.73.3: ControlNetApply (SEGS) supports AnimateDiff
17
+ * V4.20.1: Due to the feature update in `RegionalSampler`, the parameter order has changed, causing malfunctions in previously created `RegionalSamplers`. Please adjust the parameters accordingly.
18
+ * V4.12: `MASKS` is changed to `MASK`.
19
+ * V4.7.2 isn't compatible with old version of `ControlNet Auxiliary Preprocessor`. If you will use `MediaPipe FaceMesh to SEGS` update to latest version(Sep. 17th).
20
+ * Selection weight syntax is changed(: -> ::) since V3.16. ([tutorial](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/ImpactWildcardProcessor.md))
21
+ * Starting from V3.6, requires latest version(Aug 8, 9ccc965) of ComfyUI.
22
+ * **In versions below V3.3.1, there was an issue with the image quality generated after using the UltralyticsDetectorProvider. Please make sure to upgrade to a newer version.**
23
+ * Starting from V3.0, nodes related to `mmdet` are optional nodes that are activated only based on the configuration settings.
24
+ - Through ComfyUI-Impact-Subpack, you can utilize UltralyticsDetectorProvider to access various detection models.
25
+ * Between versions 2.22 and 2.21, there is partial compatibility loss regarding the Detailer workflow. If you continue to use the existing workflow, errors may occur during execution. An additional output called "enhanced_alpha_list" has been added to Detailer-related nodes.
26
+ * The permission error related to cv2 that occurred during the installation of Impact Pack has been patched in version 2.21.4. However, please note that the latest versions of ComfyUI and ComfyUI-Manager are required.
27
+ * The "PreviewBridge" feature may not function correctly on ComfyUI versions released before July 1, 2023.
28
+ * Attempting to load the "ComfyUI-Impact-Pack" on ComfyUI versions released before June 27, 2023, will result in a failure.
29
+ * With the addition of wildcard support in FaceDetailer, the structure of DETAILER_PIPE-related nodes and Detailer nodes has changed. There may be malfunctions when using the existing workflow.
30
+
31
+
32
+ ## Custom Nodes
33
+ ### [Detector nodes](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/detectors.md)
34
+ * `SAMLoader` - Loads the SAM model.
35
+ * `UltralyticsDetectorProvider` - Loads the Ultralystics model to provide SEGM_DETECTOR, BBOX_DETECTOR.
36
+ - Unlike `MMDetDetectorProvider`, for segm models, `BBOX_DETECTOR` is also provided.
37
+ - The various models available in UltralyticsDetectorProvider can be downloaded through **ComfyUI-Manager**.
38
+ * `ONNXDetectorProvider` - Loads the ONNX model to provide BBOX_DETECTOR.
39
+ * `CLIPSegDetectorProvider` - Wrapper for CLIPSeg to provide BBOX_DETECTOR.
40
+ * You need to install the ComfyUI-CLIPSeg node extension.
41
+ * `SEGM Detector (combined)` - Detects segmentation and returns a mask from the input image.
42
+ * `BBOX Detector (combined)` - Detects bounding boxes and returns a mask from the input image.
43
+ * `SAMDetector (combined)` - Utilizes the SAM technology to extract the segment at the location indicated by the input SEGS on the input image and outputs it as a unified mask.
44
+ * `SAMDetector (Segmented)` - It is similar to `SAMDetector (combined)`, but it separates and outputs the detected segments. Multiple segments can be found for the same detected area, and currently, a policy is in place to group them arbitrarily in sets of three. This aspect is expected to be improved in the future.
45
+ * As a result, it outputs the `combined_mask`, which is a unified mask, and `batch_masks`, which are multiple masks grouped together in batch form.
46
+ * While `batch_masks` may not be completely separated, it provides functionality to perform some level of segmentation.
47
+ * `Simple Detector (SEGS)` - Operating primarily with `BBOX_DETECTOR`, and with the additional provision of `SAM_MODEL` or `SEGM_DETECTOR`, this node internally generates improved SEGS through mask operations on both *bbox* and *silhouette*. It serves as a convenient tool to simplify a somewhat intricate workflow.
48
+
49
+ ### ControlNet, IPAdapter
50
+ * `ControlNetApply (SEGS)` - To apply ControlNet in SEGS, you need to use the Preprocessor Provider node from the Inspire Pack to utilize this node.
51
+ * `segs_preprocessor` and `control_image` can be selectively applied. If an `control_image` is given, `segs_preprocessor` will be ignored.
52
+ * If set to `control_image`, you can preview the cropped cnet image through `SEGSPreview (CNET Image)`. Images generated by `segs_preprocessor` should be verified through the `cnet_images` output of each Detailer.
53
+ * The `segs_preprocessor` operates by applying preprocessing on-the-fly based on the cropped image during the detailing process, while `control_image` will be cropped and used as input to `ControlNetApply (SEGS)`.
54
+ * `ControlNetClear (SEGS)` - Clear applied ControlNet in SEGS
55
+ * `IPAdapterApply (SEGS)` - To apply IPAdapter in SEGS, you need to use the Preprocessor Provider node from the Inspire Pack to utilize this node.
56
+
57
+ ### Mask operation
58
+ * `Pixelwise(SEGS & SEGS)` - Performs a 'pixelwise and' operation between two SEGS.
59
+ * `Pixelwise(SEGS - SEGS)` - Subtracts one SEGS from another.
60
+ * `Pixelwise(SEGS & MASK)` - Performs a pixelwise AND operation between SEGS and MASK.
61
+ * `Pixelwise(SEGS & MASKS ForEach)` - Performs a pixelwise AND operation between SEGS and MASKS.
62
+ * Please note that this operation is performed with batches of MASKS, not just a single MASK.
63
+ * `Pixelwise(MASK & MASK)` - Performs a 'pixelwise and' operation between two masks.
64
+ * `Pixelwise(MASK - MASK)` - Subtracts one mask from another.
65
+ * `Pixelwise(MASK + MASK)` - Combine two masks.
66
+ * `SEGM Detector (SEGS)` - Detects segmentation and returns SEGS from the input image.
67
+ * `BBOX Detector (SEGS)` - Detects bounding boxes and returns SEGS from the input image.
68
+ * `Dilate Mask` - Dilate Mask.
69
+ * Support erosion for negative value.
70
+ * `Gaussian Blur Mask` - Apply Gaussian Blur to Mask. You can utilize this for mask feathering.
71
+
72
+ ### [Detailer nodes](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/detailers.md)
73
+ * `Detailer (SEGS)` - Refines the image based on SEGS.
74
+ * `DetailerDebug (SEGS)` - Refines the image based on SEGS. Additionally, it provides the ability to monitor the cropped image and the refined image of the cropped image.
75
+ * To prevent regeneration caused by the seed that does not change every time when using 'external_seed', please disable the 'seed random generate' option in the 'Detailer...' node.
76
+ * `MASK to SEGS` - Generates SEGS based on the mask.
77
+ * `MASK to SEGS For AnimateDiff` - Generates SEGS based on the mask for AnimateDiff.
78
+ * When using a single mask, convert it to SEGS to apply it to the entire frame.
79
+ * When using a batch mask, the contour fill feature is disabled.
80
+ * `MediaPipe FaceMesh to SEGS` - Separate each landmark from the mediapipe facemesh image to create labeled SEGS.
81
+ * Usually, the size of images created through the MediaPipe facemesh preprocessor is downscaled. It resizes the MediaPipe facemesh image to the original size given as reference_image_opt for matching sizes during processing.
82
+ * `ToBinaryMask` - Separates the mask generated with alpha values between 0 and 255 into 0 and 255. The non-zero parts are always set to 255.
83
+ * `Masks to Mask List` - This node converts the MASKS in batch form to a list of individual masks.
84
+ * `Mask List to Masks` - This node converts the MASK list to MASK batch form.
85
+ * `EmptySEGS` - Provides an empty SEGS.
86
+ * `MaskPainter` - Provides a feature to draw masks.
87
+ * `FaceDetailer` - Easily detects faces and improves them.
88
+ * `FaceDetailer (pipe)` - Easily detects faces and improves them (for multipass).
89
+ * `MaskDetailer (pipe)` - This is a simple inpaint node that applies the Detailer to the mask area.
90
+
91
+ * `FromDetailer (SDXL/pipe)`, `BasicPipe -> DetailerPipe (SDXL)`, `Edit DetailerPipe (SDXL)` - These are pipe functions used in Detailer for utilizing the refiner model of SDXL.
92
+
93
+ ### SEGS Manipulation nodes
94
+ * `SEGSDetailer` - Performs detailed work on SEGS without pasting it back onto the original image.
95
+ * `SEGSPaste` - Pastes the results of SEGS onto the original image.
96
+ * If `ref_image_opt` is present, the images contained within SEGS are ignored. Instead, the image within `ref_image_opt` corresponding to the crop area of SEGS is taken and pasted. The size of the image in `ref_image_opt` should be the same as the original image size.
97
+ * This node can be used in conjunction with the processing results of AnimateDiff.
98
+ * `SEGSPreview` - Provides a preview of SEGS.
99
+ * This option is used to preview the improved image through `SEGSDetailer` before merging it into the original. Prior to going through ```SEGSDetailer```, SEGS only contains mask information without image information. If fallback_image_opt is connected to the original image, SEGS without image information will generate a preview using the original image. However, if SEGS already contains image information, fallback_image_opt will be ignored.
100
+ * This node can be used in conjunction with the processing results of AnimateDiff.
101
+ * `SEGSPreview (CNET Image)` - Show images configured with `ControlNetApply (SEGS)` for debugging purposes.
102
+ * `SEGSToImageList` - Convert SEGS To Image List
103
+ * `SEGSToMaskList` - Convert SEGS To Mask List
104
+ * `SEGS Filter (label)` - This node filters SEGS based on the label of the detected areas.
105
+ * `SEGS Filter (ordered)` - This node sorts SEGS based on size and position and retrieves SEGs within a certain range.
106
+ * `SEGS Filter (range)` - This node retrieves only SEGs from SEGS that have a size and position within a certain range.
107
+ * `SEGS Assign (label)` - Assign labels sequentially to SEGS. This node is useful when used with `[LAB]` of FaceDetailer.
108
+ * `SEGSConcat` - Concatenate segs1 and segs2. If source shape of segs1 and segs2 are different from segs2 will be ignored.
109
+ * `Picker (SEGS)` - Among the input SEGS, you can select a specific SEG through a dialog. If no SEG is selected, it outputs an empty SEGS. Increasing the batch_size of SEGSDetailer can be used for the purpose of selecting from the candidates.
110
+ * `Set Default Image For SEGS` - Set a default image for SEGS. SEGS with images set this way do not need to have a fallback image set. When override is set to false, the original image is preserved.
111
+ * `Remove Image from SEGS` - Remove the image set for the SEGS that has been configured by "Set Default Image for SEGS" or SEGSDetailer. When the image for the SEGS is removed, the Detailer node will operate based on the currently processed image instead of the SEGS.
112
+ * `Make Tile SEGS` - [experimental] Create SEGS in the form of tiles from an image to facilitate experiments for Tiled Upscale using the Detailer.
113
+ * The `filter_in_segs_opt` and `filter_out_segs_opt` are optional inputs. If these inputs are provided, when creating the tiles, the mask for each tile is generated by overlapping with the mask of `filter_in_segs_opt` and excluding the overlap with the mask of `filter_out_segs_opt`. Tiles with an empty mask will not be created as SEGS.
114
+ * `Dilate Mask (SEGS)` - Dilate/Erosion Mask in SEGS
115
+ * `Gaussian Blur Mask (SEGS)` - Apply Gaussian Blur to Mask in SEGS
116
+ * `SEGS_ELT Manipulation` - experimental nodes
117
+ * `DecomposeSEGS` - Decompose SEGS to allow for detailed manipulation.
118
+ * `AssembleSEGS` - Reassemble the decomposed SEGS.
119
+ * `From SEG_ELT` - Extract detailed information from SEG_ELT.
120
+ * `Edit SEG_ELT` - Modify some of the information in SEG_ELT.
121
+ * `Dilate SEG_ELT` - Dilate the mask of SEG_ELT.
122
+ * `From SEG_ELT` bbox - Extract coordinate from bbox in SEG_ELT
123
+ * `From SEG_ELT` crop_region - Extract coordinate from crop_region in SEG_ELT
124
+ * `Count Elt in SEGS` - Number of Elts ins SEGS
125
+
126
+ ### Pipe nodes
127
+ * `ToDetailerPipe`, `FromDetailerPipe` - These nodes are used to bundle multiple inputs used in the detailer, such as models and vae, ..., into a single DETAILER_PIPE or extract the elements that are bundled in the DETAILER_PIPE.
128
+ * `ToBasicPipe`, `FromBasicPipe` - These nodes are used to bundle model, clip, vae, positive conditioning, and negative conditioning into a single BASIC_PIPE, or extract each element from the BASIC_PIPE.
129
+ * `EditBasicPipe`, `EditDetailerPipe` - These nodes are used to replace some elements in BASIC_PIPE or DETAILER_PIPE.
130
+ * `FromDetailerPipe_v2`, `FromBasicPipe_v2` - It has the same functionality as `FromDetailerPipe` and `FromBasicPipe`, but it has an additional output that directly exports the input pipe. It is useful when editing EditBasicPipe and EditDetailerPipe.
131
+ * `Latent Scale (on Pixel Space)` - This node converts latent to pixel space, upscales it, and then converts it back to latent.
132
+ * If upscale_model_opt is provided, it uses the model to upscale the pixel and then downscales it using the interpolation method provided in scale_method to the target resolution.
133
+ * `PixelKSampleUpscalerProvider` - An upscaler is provided that converts latent to pixels using VAEDecode, performs upscaling, converts back to latent using VAEEncode, and then performs k-sampling. This upscaler can be attached to nodes such as `Iterative Upscale` for use.
134
+ * Similar to `Latent Scale (on Pixel Space)`, if upscale_model_opt is provided, it performs pixel upscaling using the model.
135
+ * `PixelTiledKSampleUpscalerProvider` - It is similar to `PixelKSampleUpscalerProvider`, but it uses `ComfyUI_TiledKSampler` and Tiled VAE Decoder/Encoder to avoid GPU VRAM issues at high resolutions.
136
+ * You need to install the [BlenderNeko/ComfyUI_TiledKSampler](https://github.com/BlenderNeko/ComfyUI_TiledKSampler) node extension.
137
+
138
+ ### PK_HOOK
139
+ * `DenoiseScheduleHookProvider` - IterativeUpscale provides a hook that gradually changes the denoise to target_denoise as the iterative-step progresses.
140
+ * `CfgScheduleHookProvider` - IterativeUpscale provides a hook that gradually changes the cfg to target_cfg as the iterative-step progresses.
141
+ * `StepsScheduleHookProvider` - IterativeUpscale provides a hook that gradually changes the sampling-steps to target_steps as the iterative-step progresses.
142
+ * `NoiseInjectionHookProvider` - During each iteration of IterativeUpscale, noise is injected into the latent space while varying the strength according to a schedule.
143
+ * You need to install the [BlenderNeko/ComfyUI_Noise](https://github.com/BlenderNeko/ComfyUI_Noise) node extension.
144
+ * The seed serves as the initial value required for generating noise, and it increments by 1 with each iteration as the process unfolds.
145
+ * The source determines the types of CPU noise and GPU noise to be configured.
146
+ * Currently, there is only a simple schedule available, where the strength of the noise varies from start_strength to end_strength during the progression of each iteration.
147
+ * `UnsamplerHookProvider` - Apply Unsampler during each iteration. To use this node, ComfyUI_Noise must be installed.
148
+ * `PixelKSampleHookCombine` - This is used to connect two PK_HOOKs. hook1 is executed first and then hook2 is executed.
149
+ * If you want to simultaneously change cfg and denoise, you can combine the PK_HOOKs of CfgScheduleHookProvider and PixelKSampleHookCombine.
150
+
151
+ ### DETAILER_HOOK
152
+ * `NoiseInjectionDetailerHookProvider` - The `detailer_hook` is a hook in the `Detailer` that injects noise during the processing of each SEGS.
153
+ * `UnsamplerDetailerHookProvider` - Apply Unsampler during each cycle. To use this node, ComfyUI_Noise must be installed.
154
+ * `DenoiseSchedulerDetailerHookProvider` - During the progress of the cycle, the detailer's denoise is altered up to the `target_denoise`.
155
+ * `CoreMLDetailerHookProvider` - CoreML supports only 512x512, 512x768, 768x512, 768x768 size sampling. CoreMLDetailerHookProvider precisely fixes the upscale of the crop_region to this size. When using this hook, it will always be selected size, regardless of the guide_size. However, if the guide_size is too small, skipping will occur.
156
+ * `DetailerHookCombine` - This is used to connect two DETAILER_HOOKs. Similar to PixelKSampleHookCombine.
157
+ * `SEGSOrderedFilterDetailerHook`, SEGSRangeFilterDetailerHook, SEGSLabelFilterDetailerHook - There are a wrapper node that provides SEGSFilter nodes to be applied in FaceDetailer or Detector by creating DETAILER_HOOK.
158
+ * `PreviewDetailerHook` - Connecting this hook node helps provide assistance for viewing previews whenever SEGS Detailing tasks are completed. When working with a large number of SEGS, such as Make Tile SEGS, it allows for monitoring the situation as improvements progress incrementally.
159
+ * Since this is the hook applied when pasting onto the original image, it has no effect on nodes like `SEGSDetailer`.
160
+ * `VariationNoiseDetailerHookProvider` - Apply variation seed to the detailer. It can be applied in multiple stages through combine.
161
+
162
+ ### Iterative Upscale nodes
163
+ * `Iterative Upscale (Latent/on Pixel Space)` - The upscaler takes the input upscaler and splits the scale_factor into steps, then iteratively performs upscaling.
164
+ This takes latent as input and outputs latent as the result.
165
+ * `Iterative Upscale (Image)` - The upscaler takes the input upscaler and splits the scale_factor into steps, then iteratively performs upscaling. This takes image as input and outputs image as the result.
166
+ * Internally, this node uses 'Iterative Upscale (Latent)'.
167
+
168
+ ### TwoSamplers nodes
169
+ * `TwoSamplersForMask` - This node can apply two samplers depending on the mask area. The base_sampler is applied to the area where the mask is 0, while the mask_sampler is applied to the area where the mask is 1.
170
+ * Note: The latent encoded through VAEEncodeForInpaint cannot be used.
171
+ * `KSamplerProvider` - This is a wrapper that enables KSampler to be used in TwoSamplersForMask TwoSamplersForMaskUpscalerProvider.
172
+ * `TiledKSamplerProvider` - ComfyUI_TiledKSampler is a wrapper that provides KSAMPLER.
173
+ * You need to install the [BlenderNeko/ComfyUI_TiledKSampler](https://github.com/BlenderNeko/ComfyUI_TiledKSampler) node extension.
174
+
175
+ * `TwoAdvancedSamplersForMask` - TwoSamplersForMask is similar to TwoAdvancedSamplersForMask, but they differ in their operation. TwoSamplersForMask performs sampling in the mask area only after all the samples in the base area are finished. On the other hand, TwoAdvancedSamplersForMask performs sampling in both the base area and the mask area sequentially at each step.
176
+ * `KSamplerAdvancedProvider` - This is a wrapper that enables KSampler to be used in TwoAdvancedSamplersForMask, RegionalSampler.
177
+ * sigma_factor: By multiplying the denoise schedule by the sigma_factor, you can adjust the amount of denoising based on the configured denoise.
178
+
179
+ * `TwoSamplersForMaskUpscalerProvider` - This is an Upscaler that extends TwoSamplersForMask to be used in Iterative Upscale.
180
+ * TwoSamplersForMaskUpscalerProviderPipe - pipe version of TwoSamplersForMaskUpscalerProvider.
181
+
182
+ ### Image Utils
183
+ * `PreviewBridge (image)` - This custom node can be used with a bridge for image when using the MaskEditor feature of Clipspace.
184
+ * `PreviewBridge (latent)` - This custom node can be used with a bridge for latent image when using the MaskEditor feature of Clipspace.
185
+ * If a latent with a mask is provided as input, it displays the mask. Additionally, the mask output provides the mask set in the latent.
186
+ * If a latent without a mask is provided as input, it outputs the original latent as is, but the mask output provides an output with the entire region set as a mask.
187
+ * When set mask through MaskEditor, a mask is applied to the latent, and the output includes the stored mask. The same mask is also output as the mask output.
188
+ * When connected to `vae_opt`, it takes higher priority than the `preview_method`.
189
+ * `ImageSender`, `ImageReceiver` - The images generated in ImageSender are automatically sent to the ImageReceiver with the same link_id.
190
+ * `LatentSender`, `LatentReceiver` - The latent generated in LatentSender are automatically sent to the LatentReceiver with the same link_id.
191
+ * Furthermore, LatentSender is implemented with PreviewLatent, which stores the latent in payload form within the image thumbnail.
192
+ * Due to the current structure of ComfyUI, it is unable to distinguish between SDXL latent and SD1.5/SD2.1 latent. Therefore, it generates thumbnails by decoding them using the SD1.5 method.
193
+
194
+ ### Switch nodes
195
+ * `Switch (image,mask)`, `Switch (latent)`, `Switch (SEGS)` - Among multiple inputs, it selects the input designated by the selector and outputs it. The first input must be provided, while the others are optional. However, if the input specified by the selector is not connected, an error may occur.
196
+ * `Switch (Any)` - This is a Switch node that takes an arbitrary number of inputs and produces a single output. Its type is determined when connected to any node, and connecting inputs increases the available slots for connections.
197
+ * `Inversed Switch (Any)` - In contrast to `Switch (Any)`, it takes a single input and outputs one of many.
198
+ * NOTE: See this [tutorial](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/switch.md)
199
+
200
+ ### [Wildcards](http://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/ImpactWildcard.md) nodes
201
+ * These are nodes that supports syntax in the form of `__wildcard-name__` and dynamic prompt syntax like `{a|b|c}`.
202
+ * Wildcard files can be used by placing `.txt` or `.yaml` files under either `ComfyUI-Impact-Pack/wildcards` or `ComfyUI-Impact-Pack/custom_wildcards` paths.
203
+ * You can download and use [Wildcard YAML](https://civitai.com/models/138970/billions-of-wildcards-all-in-one) files in this format.
204
+ * After the first execution, you can change the custom wildcards path in the `custom_wildcards` entry within the `ComfyUI-Impact-Pack/impact-pack.ini` file created.
205
+ * `ImpactWildcardProcessor` - The text is generated by processing the wildcard in the Text. If the mode is set to "populate", a dynamic prompt is generated with each execution and the input is filled in the second textbox. If the mode is set to "fixed", the content of the second textbox remains unchanged.
206
+ * When an image is generated with the "fixed" mode, the prompt used for that particular generation is stored in the metadata.
207
+ * `ImpactWildcardEncode` - Similar to ImpactWildcardProcessor, this provides the loading functionality of LoRAs (e.g. `<lora:some_awesome_lora:0.7:1.2>`). Populated prompts are encoded using the clip after all the lora loading is done.
208
+ * If the `Inspire Pack` is installed, you can use **Lora Block Weight** in the form of `LBW=lbw spec;`
209
+ * `<lora:chunli:1.0:1.0:LBW=B11:0,0,0,0,0,0,0,0,0,0,A,0,0,0,0,0,0;A=0.;>`, `<lora:chunli:1.0:1.0:LBW=0,0,0,0,0,0,0,0,0,0,A,B,0,0,0,0,0;A=0.5;B=0.2;>`, `<lora:chunli:1.0:1.0:LBW=SD-MIDD;>`
210
+
211
+ ### Regional Sampling
212
+ * These nodes offer the capability to divide regions and perform partial sampling using a mask. Unlike TwoSamplersForMask, sampling for each region is applied during each step.
213
+ * `RegionalPrompt` - This node combines a **mask** for specifying regions and the **sampler** to apply to each region to create `REGIONAL_PROMPTS`.
214
+ * `CombineRegionalPrompts` - Combine multiple `REGIONAL_PROMPTS` to create a single `REGIONAL_PROMPTS`.
215
+ * `RegionalSampler` - This node performs sampling using a base sampler and regional prompts. Sampling by the base sampler is executed at each step, while sampling for each region is performed through the sampler bound to each region.
216
+ * overlap_factor - Specifies the amount of overlap for each region to blend well with the area outside the mask.
217
+ * restore_latent - When sampling each region, restore the areas outside the mask to the base latent, preventing additional noise from being introduced outside the mask during region sampling.
218
+ * `RegionalSamplerAdvanced` - This is the Advanced version of the RegionalSampler. You can control it using `step` instead of `denoise`.
219
+ > NOTE: The `sde` sampler and `uni_pc` sampler introduce additional noise during each step of the sampling process. To mitigate this, when sampling each region, the `uni_pc` sampler applies additional `dpmpp_fast`, and the sde sampler applies the `dpmpp_2m` sampler as an additional measure.
220
+
221
+
222
+ ### Impact KSampler
223
+ * These samplers support basic_pipe and AYS scheduler
224
+ * `KSampler (pipe)` - pipe version of KSampler
225
+ * `KSampler (advanced/pipe)` - pipe version of KSamplerAdvacned
226
+ * When converting the scheduler widget to input, refer to the `Impact Scheduler Adapter` node to resolve compatibility issues.
227
+ * `GITSScheduler Func Provider` - provider scheduler function for GITSScheduler
228
+
229
+
230
+ ### Batch/List Util
231
+ * `Image batch To Image List` - Convert Image batch to Image List
232
+ - You can use images generated in a multi batch to handle them
233
+ * `Make Image List` - Convert multiple images into a single image list
234
+ * `Make Image Batch` - Convert multiple images into a single image batch
235
+ - The input of images can be scaled up as needed
236
+
237
+
238
+ ### Logics (experimental)
239
+ * These nodes are experimental nodes designed to implement the logic for loops and dynamic switching.
240
+ * `ImpactCompare`, `ImpactConditionalBranch`, `ImpactConditionalBranchSelMode`, `ImpactInt`, `ImpactValueSender`, `ImpactValueReceiver`, `ImpactImageInfo`, `ImpactMinMax`, `ImpactNeg`, `ImpactConditionalStopIteration`
241
+ * `ImpactIsNotEmptySEGS` - This node returns `true` only if the input SEGS is not empty.
242
+ * `ImpactIfNone` - Returns `true` if any_input is None, and returns `false` if it is not None.
243
+ * `Queue Trigger` - When this node is executed, it adds a new queue to assist with repetitive tasks. It will only execute if the signal's status changes.
244
+ * `Queue Trigger (Countdown)` - Like the Queue Trigger, it adds a queue, but only adds it if it's greater than 1, and decrements the count by one each time it runs.
245
+ * `Sleep` - Waits for the specified time (in seconds).
246
+ * `Set Widget Value` - This node sets one of the optional inputs to the specified node's widget. An error may occur if the types do not match.
247
+ * `Set Mute State` - This node changes the mute state of a specific node.
248
+ * `Control Bridge` - This node modifies the state of the connected control nodes based on the `mode` and `behavior` . If there are nodes that require a change, the current execution is paused, the mute status is updated, and a new prompt queue is inserted.
249
+ * When the `mode` is `active`, it makes the connected control nodes active regardless of the behavior.
250
+ * When the `mode` is `Bypass/Mute`, it changes the state of the connected nodes based on whether the behavior is `Bypass` or `Mute`.
251
+ * **Limitation**: Due to these characteristics, it does not function correctly when the batch count exceeds 1. Additionally, it does not guarantee proper operation when the seed is randomized or when the state of nodes is altered by actions such as `Queue Trigger`, `Set Widget Value`, `Set Mute`, before the Control Bridge.
252
+ * When utilizing this node, please structure the workflow in such a way that `Queue Trigger`, `Set Widget Value`, `Set Mute State`, and similar actions are executed at the end of the workflow.
253
+ * If you want to change the value of the seed at each iteration, please ensure that Set Widget Value is executed at the end of the workflow instead of using randomization.
254
+ * It is not a problem if the seed changes due to randomization as long as it occurs after the Control Bridge section.
255
+ * `Remote Boolean (on prompt)`, `Remote Int (on prompt)` - At the start of the prompt, this node forcibly sets the `widget_value` of `node_id`. It is disregarded if the target widget type is different.
256
+ * You can find the `node_id` by checking through [ComfyUI-Manager](https://github.com/ltdrdata/ComfyUI-Manager) using the format `Badge: #ID Nickname`.
257
+ * Experimental set of nodes for implementing loop functionality (tutorial to be prepared later / [example workflow](test/loop-test.json)).
258
+
259
+ ### HuggingFace nodes
260
+ * These nodes provide functionalities based on HuggingFace repository models.
261
+ * The path where the HuggingFace model cache is stored can be changed through the `HF_HOME` environment variable.
262
+ * `HF Transformers Classifier Provider` - This is a node that provides a classifier based on HuggingFace's transformers models.
263
+ * The 'repo id' parameter should contain HuggingFace's repo id. When `preset_repo_id` is set to `Manual repo id`, use the manually entered repo id in `manual_repo_id`.
264
+ * e.g. 'rizvandwiki/gender-classification-2' is a repository that provides a model for gender classification.
265
+ * `SEGS Classify` - This node utilizes the `TRANSFORMERS_CLASSIFIER` loaded with 'HF Transformers Classifier Provider' to classify `SEGS`.
266
+ * The 'expr' allows for forms like `label > number`, and in the case of `preset_expr` being `Manual expr`, it uses the expression entered in `manual_expr`.
267
+ * For example, in the case of `male <= 0.4`, if the score of the `male` label in the classification result is less than or equal to 0.4, it is categorized as `filtered_SEGS`, otherwise, it is categorized as `remained_SEGS`.
268
+ * For supported labels, please refer to the `config.json` of the respective HuggingFace repository.
269
+ * `#Female` and `#Male` are symbols that group multiple labels such as `Female, women, woman, ...`, for convenience, rather than being single labels.
270
+
271
+ ### Etc nodes
272
+ * `Impact Scheduler Adapter` - With the addition of AYS to the scheduler of the Impact Pack and Inspire Pack, there is an issue of incompatibility when the existing scheduler widget is converted to input. The Impact Scheduler Adapter allows for an indirect connection to be possible.
273
+ * `StringListToString` - Convert String List to String
274
+ * `WildcardPromptFromString` - Create labeled wildcard for detailer from string.
275
+ * This node works well when used with MakeTileSEGS. [[Link](https://github.com/ltdrdata/ComfyUI-Impact-Pack/pull/536#discussion_r1586060779)]
276
+
277
+ * `String Selector` - It selects and returns a portion of the string. When `multiline` mode is disabled, it simply returns the string of the line pointed to by the selector. When `multiline` mode is enabled, it divides the string based on lines that start with `#` and returns them. If the `select` value is larger than the number of items, it will start counting from the first line again and return accordingly.
278
+ * `Combine Conditionings` - It takes multiple conditionings as input and combines them into a single conditioning.
279
+ * `Concat Conditionings` - It takes multiple conditionings as input and concat them into a single conditioning.
280
+ * `Negative Cond Placeholder` - Models like FLUX.1 do not use Negative Conditioning. This is a placeholder node for them. You can use FLUX.1 by replacing the Negative Conditioning used in Impact KSampler, KSampler (Inspire), and Detailer with this node.
281
+ * `Execution Order Controller` - A helper node that can forcibly control the execution order of nodes.
282
+ * Connect the output of the node that should be executed first to the signal, and make the input of the node that should be executed later pass through this node.
283
+
284
+
285
+ ## MMDet nodes (DEPRECATED) - Don't use these nodes
286
+ * MMDetDetectorProvider - Loads the MMDet model to provide BBOX_DETECTOR and SEGM_DETECTOR.
287
+ * To use the existing MMDetDetectorProvider, you need to enable the MMDet usage configuration.
288
+
289
+
290
+ ## Feature
291
+ * `Interactive SAM Detector (Clipspace)` - When you right-click on a node that has 'MASK' and 'IMAGE' outputs, a context menu will open. From this menu, you can either open a dialog to create a SAM Mask using 'Open in SAM Detector', or copy the content (likely mask data) using 'Copy (Clipspace)' and generate a mask using 'Impact SAM Detector' from the clipspace menu, and then paste it using 'Paste (Clipspace)'.
292
+ * Providing a feature to detect errors that occur when mixing models and clips from checkpoints such as `SDXL Base`, `SDXL Refiner`, `SD1.x`, `SD2.x` during sample execution, and reporting appropriate errors.
293
+
294
+
295
+ ## Deprecated
296
+ * The following nodes have been kept only for compatibility with existing workflows, and are no longer supported. Please replace them with new nodes.
297
+ * ONNX Detector (SEGS) - BBOX Detector (SEGS)
298
+ * MMDetLoader -> MMDetDetectorProvider
299
+ * SegsMaskCombine -> SEGS to MASK (combined)
300
+ * BboxDetectorForEach -> BBOX Detector (SEGS)
301
+ * SegmDetectorForEach -> SEGM Detector (SEGS)
302
+ * BboxDetectorCombined -> BBOX Detector (combined)
303
+ * SegmDetectorCombined -> SEGM Detector (combined)
304
+ * MaskPainter -> PreviewBridge
305
+ * To use the existing deprecated legacy nodes, you need to enable the MMDet usage configuration.
306
+
307
+
308
+ ## Ultralytics models
309
+ * huggingface.co/Bingsu/[adetailer](https://github.com/ultralytics/assets/releases/) - You can download face, people detection models, and clothing detection models.
310
+ * ultralytics/[assets](https://github.com/ultralytics/assets/releases/) - You can download various types of detection models other than faces or people.
311
+ * civitai/[adetailer](https://civitai.com/search/models?sortBy=models_v5&query=adetailer) - You can download various types detection models....Many models are associated with NSFW content.
312
+
313
+ ## How to activate 'MMDet usage' (DEPRECATED)
314
+ * Upon the initial execution, an `impact-pack.ini` file will be generated in the custom_nodes/ComfyUI-Impact-Pack directory.
315
+ ```
316
+ [default]
317
+ dependency_version = 2
318
+ mmdet_skip = True
319
+ ```
320
+ * Change `mmdet_skip = True` to `mmdet_skip = False`
321
+ ```
322
+ [default]
323
+ dependency_version = 2
324
+ mmdet_skip = False
325
+ ```
326
+ * Restart ComfyUI
327
+
328
+
329
+ ## Installation
330
+
331
+ 1. `cd custom_nodes`
332
+ 2. `git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack.git`
333
+ 3. `cd ComfyUI-Impact-Pack`
334
+ 4. (optional) `git clone https://github.com/ltdrdata/ComfyUI-Impact-Subpack impact_subpack`
335
+ * Impact Pack will automatically download subpack during its initial launch.
336
+ 5. (optional) `python install.py`
337
+ * Impact Pack will automatically install its dependencies during its initial launch.
338
+ * For the portable version, you should execute the command `..\..\..\python_embeded\python.exe install.py` to run the installation script.
339
+
340
+
341
+ 6. Restart ComfyUI
342
+
343
+ * NOTE1: If an error occurs during the installation process, please refer to [Troubleshooting Page](troubleshooting/TROUBLESHOOTING.md) for assistance.
344
+ * NOTE2: You can use this colab notebook [colab notebook](https://colab.research.google.com/github/ltdrdata/ComfyUI-Impact-Pack/blob/Main/notebook/comfyui_colab_impact_pack.ipynb) to launch it. This notebook automatically downloads the impact pack to the custom_nodes directory, installs the tested dependencies, and runs it.
345
+ * NOTE3: If you create an empty file named `skip_download_model` in the `ComfyUI/custom_nodes/` directory, it will skip the model download step during the installation of the impact pack.
346
+
347
+ ## Package Dependencies (If you need to manual setup.)
348
+
349
+ * pip install
350
+ * openmim
351
+ * segment-anything
352
+ * ultralytics
353
+ * scikit-image
354
+ * piexif
355
+ * (optional) pycocotools
356
+ * (optional) onnxruntime
357
+
358
+ * mim install (deprecated)
359
+ * mmcv==2.0.0, mmdet==3.0.0, mmengine==0.7.2
360
+
361
+ * linux packages (ubuntu)
362
+ * libgl1-mesa-glx
363
+ * libglib2.0-0
364
+
365
+
366
+ ## Config example
367
+ * Once you run the Impact Pack for the first time, an `impact-pack.ini` file will be automatically generated in the Impact Pack directory. You can modify this configuration file to customize the default behavior.
368
+ * `dependency_version` - don't touch this
369
+ * `mmdet_skip` - disable MMDet based nodes and legacy nodes if `True`
370
+ * `sam_editor_cpu` - use cpu for `SAM editor` instead of gpu
371
+ * sam_editor_model: Specify the SAM model for the SAM editor.
372
+ * You can download various SAM models using ComfyUI-Manager.
373
+ * Path to SAM model: `ComfyUI/models/sams`
374
+ ```
375
+ [default]
376
+ dependency_version = 9
377
+ mmdet_skip = True
378
+ sam_editor_cpu = False
379
+ sam_editor_model = sam_vit_b_01ec64.pth
380
+ ```
381
+
382
+
383
+ ## Other Materials (auto-download on initial startup)
384
+
385
+ * ComfyUI/models/mmdets/bbox <= https://huggingface.co/dustysys/ddetailer/resolve/main/mmdet/bbox/mmdet_anime-face_yolov3.pth
386
+ * ComfyUI/models/mmdets/bbox <= https://raw.githubusercontent.com/Bing-su/dddetailer/master/config/mmdet_anime-face_yolov3.py
387
+ * ComfyUI/models/sams <= https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth
388
+
389
+ ## Troubleshooting page
390
+ * [Troubleshooting Page](troubleshooting/TROUBLESHOOTING.md)
391
+
392
+
393
+ ## How to use (DDetailer feature)
394
+
395
+ #### 1. Basic auto face detection and refine exapmle.
396
+ ![simple](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/simple.png)
397
+ * The face that has been damaged due to low resolution is restored with high resolution by generating and synthesizing it, in order to restore the details.
398
+ * The FaceDetailer node is a combination of a Detector node for face detection and a Detailer node for image enhancement. See the [Advanced Tutorial](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/tutorial/advanced.md) for a more detailed explanation.
399
+ * Pass the MMDetLoader 's bbox model and the detection model loaded by SAMLoader to FaceDetailer . Since it performs the function of KSampler for image enhancement, it overlaps with KSampler's options.
400
+ * The MASK output of FaceDetailer provides a visualization of where the detected and enhanced areas are.
401
+
402
+ ![simple-orig](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/simple-original.png) ![simple-refined](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/simple-refined.png)
403
+ * You can see that the face in the image on the left has increased detail as in the image on the right.
404
+
405
+ #### 2. 2Pass refine (restore a severely damaged face)
406
+ ![2pass-workflow-example](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/2pass-simple.png)
407
+ * Although two FaceDetailers can be attached together for a 2-pass configuration, various common inputs used in KSampler can be passed through DETAILER_PIPE, so FaceDetailerPipe can be used to configure easily.
408
+ * In 1pass, only rough outline recovery is required, so restore with a reasonable resolution and low options. However, if you increase the dilation at this time, not only the face but also the surrounding parts are included in the recovery range, so it is useful when you need to reshape the face other than the facial part.
409
+
410
+ ![2pass-example-original](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/2pass-original.png) ![2pass-example-middle](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/2pass-1pass.png) ![2pass-example-result](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/2pass-2pass.png)
411
+ * In the first stage, the severely damaged face is restored to some extent, and in the second stage, the details are restored
412
+
413
+ #### 3. Face Bbox(bounding box) + Person silhouette segmentation (prevent distortion of the background.)
414
+ ![combination-workflow-example](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/combination.jpg)
415
+ ![combination-example-original](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/combination-original.png) ![combination-example-refined](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/combination-refined.png)
416
+
417
+ * Facial synthesis that emphasizes details is delicately aligned with the contours of the face, and it can be observed that it does not affect the image outside of the face.
418
+
419
+ * The BBoxDetectorForEach node is used to detect faces, and the SAMDetectorCombined node is used to find the segment related to the detected face. By using the Segs & Mask node with the two masks obtained in this way, an accurate mask that intersects based on segs can be generated. If this generated mask is input to the DetailerForEach node, only the target area can be created in high resolution from the image and then composited.
420
+
421
+ #### 4. Iterative Upscale
422
+ ![upscale-workflow-example](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/upscale-workflow.png)
423
+
424
+ * The IterativeUpscale node is a node that enlarges an image/latent by a scale_factor. In this process, the upscale is carried out progressively by dividing it into steps.
425
+ * IterativeUpscale takes an Upscaler as an input, similar to a plugin, and uses it during each iteration. PixelKSampleUpscalerProvider is an Upscaler that converts the latent representation to pixel space and applies ksampling.
426
+ * The upscale_model_opt is an optional parameter that determines whether to use the upscale function of the model base if available. Using the upscale function of the model base can significantly reduce the number of iterative steps required. If an x2 upscaler is used, the image/latent is first upscaled by a factor of 2 and then downscaled to the target scale at each step before further processing is done.
427
+
428
+ * The following image is an image of 304x512 pixels and the same image scaled up to three times its original size using IterativeUpscale.
429
+
430
+ ![combination-example-original](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/upscale-original.png) ![combination-example-refined](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/upscale-3x.png)
431
+
432
+
433
+ #### 5. Interactive SAM Detector (Clipspace)
434
+
435
+ * When you right-click on the node that outputs 'MASK' and 'IMAGE', a menu called "Open in SAM Detector" appears, as shown in the following picture. Clicking on the menu opens a dialog in SAM's functionality, allowing you to generate a segment mask.
436
+ ![samdetector-menu](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/SAMDetector-menu.png)
437
+
438
+ * By clicking the left mouse button on a coordinate, a positive prompt in blue color is entered, indicating the area that should be included. Clicking the right mouse button on a coordinate enters a negative prompt in red color, indicating the area that should be excluded. Positive prompts represent the areas that should be included, while negative prompts represent the areas that should be excluded.
439
+ * You can remove the points that were added by using the "undo" button. After selecting the points, pressing the "detect" button generates the mask. Additionally, you can adjust the fidelity slider to determine the extent to which the mask belongs to the confidence region.
440
+
441
+ ![samdetector-dialog](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/SAMDetector-dialog.jpg)
442
+
443
+ * If you opened the dialog through "Open in SAM Detector" from the node, you can directly apply the changes by clicking the "Save to node" button. However, if you opened the dialog through the "clipspace" menu, you can save it to clipspace by clicking the "Save" button.
444
+
445
+ ![samdetector-result](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/SAMDetector-result.jpg)
446
+
447
+ * When you execute using the reflected mask in the node, you can observe that the image and mask are displayed separately.
448
+
449
+
450
+ ## Others Tutorials
451
+ * [ComfyUI-extension-tutorials/ComfyUI-Impact-Pack](https://github.com/ltdrdata/ComfyUI-extension-tutorials/tree/Main/ComfyUI-Impact-Pack) - You can find various tutorials and workflows on this page.
452
+ * [Advanced Tutorial](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/advanced.md)
453
+ * [SAM Application](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/sam.md)
454
+ * [PreviewBridge](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/previewbridge.md)
455
+ * [Mask Pointer](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/maskpointer.md)
456
+ * [ONNX Tutorial](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/ONNX.md)
457
+ * [CLIPSeg Tutorial](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/clipseg.md)
458
+ * [Extreme Highresolution Upscale](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/extreme-upscale.md)
459
+ * [TwoSamplersForMask](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/TwoSamplers.md)
460
+ * [TwoAdvancedSamplersForMask](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/TwoAdvancedSamplers.md)
461
+ * [Advanced Iterative Upscale: PK_HOOK](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/pk_hook.md)
462
+ * [Advanced Iterative Upscale: TwoSamplersForMask Upscale Provider](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/TwoSamplersUpscale.md)
463
+ * [Interactive SAM + PreviewBridge](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/sam_with_preview_bridge.md)
464
+ * [ImageSender/ImageReceiver/LatentSender/LatentReceiver](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/sender_receiver.md)
465
+ * [ImpactWildcardProcessor](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/ImpactWildcardProcessor.md)
466
+
467
+
468
+ ## Credits
469
+
470
+ ComfyUI/[ComfyUI](https://github.com/comfyanonymous/ComfyUI) - A powerful and modular stable diffusion GUI.
471
+
472
+ dustysys/[ddetailer](https://github.com/dustysys/ddetailer) - DDetailer for Stable-diffusion-webUI extension.
473
+
474
+ Bing-su/[dddetailer](https://github.com/Bing-su/dddetailer) - The anime-face-detector used in ddetailer has been updated to be compatible with mmdet 3.0.0, and we have also applied a patch to the pycocotools dependency for Windows environment in ddetailer.
475
+
476
+ facebook/[segment-anything](https://github.com/facebookresearch/segment-anything) - Segmentation Anything!
477
+
478
+ hysts/[anime-face-detector](https://github.com/hysts/anime-face-detector) - Creator of `anime-face_yolov3`, which has impressive performance on a variety of art styles.
479
+
480
+ open-mmlab/[mmdetection](https://github.com/open-mmlab/mmdetection) - Object detection toolset. `dd-person_mask2former` was trained via transfer learning using their [R-50 Mask2Former instance segmentation model](https://github.com/open-mmlab/mmdetection/tree/master/configs/mask2former#instance-segmentation) as a base.
481
+
482
+ biegert/[ComfyUI-CLIPSeg](https://github.com/biegert/ComfyUI-CLIPSeg) - This is a custom node that enables the use of CLIPSeg technology, which can find segments through prompts, in ComfyUI.
483
+
484
+ BlenderNeok/[ComfyUI-TiledKSampler](https://github.com/BlenderNeko/ComfyUI_TiledKSampler) - The tile sampler allows high-resolution sampling even in places with low GPU VRAM.
485
+
486
+ BlenderNeok/[ComfyUI_Noise](https://github.com/BlenderNeko/ComfyUI_Noise) - The noise injection feature relies on this function and slerp code for noise variation
487
+
488
+ WASasquatch/[was-node-suite-comfyui](https://github.com/WASasquatch/was-node-suite-comfyui) - A powerful custom node extensions of ComfyUI.
489
+
490
+ Trung0246/[ComfyUI-0246](https://github.com/Trung0246/ComfyUI-0246) - Nice bypass hack!
custom_nodes/ComfyUI-Impact-Pack/__init__.py ADDED
@@ -0,0 +1,499 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ @author: Dr.Lt.Data
3
+ @title: Impact Pack
4
+ @nickname: Impact Pack
5
+ @description: This extension offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler.
6
+ """
7
+
8
+ import shutil
9
+ import folder_paths
10
+ import os
11
+ import sys
12
+ import traceback
13
+
14
+ comfy_path = os.path.dirname(folder_paths.__file__)
15
+ impact_path = os.path.join(os.path.dirname(__file__))
16
+ subpack_path = os.path.join(os.path.dirname(__file__), "impact_subpack")
17
+ modules_path = os.path.join(os.path.dirname(__file__), "modules")
18
+
19
+ sys.path.append(modules_path)
20
+
21
+ import impact.config
22
+ import impact.sample_error_enhancer
23
+ print(f"### Loading: ComfyUI-Impact-Pack ({impact.config.version})")
24
+
25
+
26
+ def do_install():
27
+ import importlib
28
+ spec = importlib.util.spec_from_file_location('impact_install', os.path.join(os.path.dirname(__file__), 'install.py'))
29
+ impact_install = importlib.util.module_from_spec(spec)
30
+ spec.loader.exec_module(impact_install)
31
+
32
+
33
+ # ensure dependency
34
+ if not os.path.exists(os.path.join(subpack_path, ".git")) and os.path.exists(subpack_path):
35
+ print(f"### CompfyUI-Impact-Pack: corrupted subpack detected.")
36
+ shutil.rmtree(subpack_path)
37
+
38
+ if impact.config.get_config()['dependency_version'] < impact.config.dependency_version or not os.path.exists(subpack_path):
39
+ print(f"### ComfyUI-Impact-Pack: Updating dependencies [{impact.config.get_config()['dependency_version']} -> {impact.config.dependency_version}]")
40
+ do_install()
41
+
42
+ sys.path.append(subpack_path)
43
+
44
+ # Core
45
+ # recheck dependencies for colab
46
+ try:
47
+ import impact.subpack_nodes # This import must be done before cv2.
48
+
49
+ import folder_paths
50
+ import torch
51
+ import cv2
52
+ from cv2 import setNumThreads
53
+ import numpy as np
54
+ import comfy.samplers
55
+ import comfy.sd
56
+ import warnings
57
+ from PIL import Image, ImageFilter
58
+ from skimage.measure import label, regionprops
59
+ from collections import namedtuple
60
+ import piexif
61
+
62
+ if not impact.config.get_config()['mmdet_skip']:
63
+ import mmcv
64
+ from mmdet.apis import (inference_detector, init_detector)
65
+ from mmdet.evaluation import get_classes
66
+ except:
67
+ import importlib
68
+ print("### ComfyUI-Impact-Pack: Reinstall dependencies (several dependencies are missing.)")
69
+ do_install()
70
+
71
+
72
+ import impact.impact_server # to load server api
73
+
74
+ from .modules.impact.impact_pack import *
75
+ from .modules.impact.detectors import *
76
+ from .modules.impact.pipe import *
77
+ from .modules.impact.logics import *
78
+ from .modules.impact.util_nodes import *
79
+ from .modules.impact.segs_nodes import *
80
+ from .modules.impact.special_samplers import *
81
+ from .modules.impact.hf_nodes import *
82
+ from .modules.impact.bridge_nodes import *
83
+ from .modules.impact.hook_nodes import *
84
+ from .modules.impact.animatediff_nodes import *
85
+ from .modules.impact.segs_upscaler import *
86
+
87
+ import threading
88
+
89
+
90
+ threading.Thread(target=impact.wildcards.wildcard_load).start()
91
+
92
+
93
+ NODE_CLASS_MAPPINGS = {
94
+ "SAMLoader": SAMLoader,
95
+ "CLIPSegDetectorProvider": CLIPSegDetectorProvider,
96
+ "ONNXDetectorProvider": ONNXDetectorProvider,
97
+
98
+ "BitwiseAndMaskForEach": BitwiseAndMaskForEach,
99
+ "SubtractMaskForEach": SubtractMaskForEach,
100
+
101
+ "DetailerForEach": DetailerForEach,
102
+ "DetailerForEachDebug": DetailerForEachTest,
103
+ "DetailerForEachPipe": DetailerForEachPipe,
104
+ "DetailerForEachDebugPipe": DetailerForEachTestPipe,
105
+ "DetailerForEachPipeForAnimateDiff": DetailerForEachPipeForAnimateDiff,
106
+
107
+ "SAMDetectorCombined": SAMDetectorCombined,
108
+ "SAMDetectorSegmented": SAMDetectorSegmented,
109
+
110
+ "FaceDetailer": FaceDetailer,
111
+ "FaceDetailerPipe": FaceDetailerPipe,
112
+ "MaskDetailerPipe": MaskDetailerPipe,
113
+
114
+ "ToDetailerPipe": ToDetailerPipe,
115
+ "ToDetailerPipeSDXL": ToDetailerPipeSDXL,
116
+ "FromDetailerPipe": FromDetailerPipe,
117
+ "FromDetailerPipe_v2": FromDetailerPipe_v2,
118
+ "FromDetailerPipeSDXL": FromDetailerPipe_SDXL,
119
+ "ToBasicPipe": ToBasicPipe,
120
+ "FromBasicPipe": FromBasicPipe,
121
+ "FromBasicPipe_v2": FromBasicPipe_v2,
122
+ "BasicPipeToDetailerPipe": BasicPipeToDetailerPipe,
123
+ "BasicPipeToDetailerPipeSDXL": BasicPipeToDetailerPipeSDXL,
124
+ "DetailerPipeToBasicPipe": DetailerPipeToBasicPipe,
125
+ "EditBasicPipe": EditBasicPipe,
126
+ "EditDetailerPipe": EditDetailerPipe,
127
+ "EditDetailerPipeSDXL": EditDetailerPipeSDXL,
128
+
129
+ "LatentPixelScale": LatentPixelScale,
130
+ "PixelKSampleUpscalerProvider": PixelKSampleUpscalerProvider,
131
+ "PixelKSampleUpscalerProviderPipe": PixelKSampleUpscalerProviderPipe,
132
+ "IterativeLatentUpscale": IterativeLatentUpscale,
133
+ "IterativeImageUpscale": IterativeImageUpscale,
134
+ "PixelTiledKSampleUpscalerProvider": PixelTiledKSampleUpscalerProvider,
135
+ "PixelTiledKSampleUpscalerProviderPipe": PixelTiledKSampleUpscalerProviderPipe,
136
+ "TwoSamplersForMaskUpscalerProvider": TwoSamplersForMaskUpscalerProvider,
137
+ "TwoSamplersForMaskUpscalerProviderPipe": TwoSamplersForMaskUpscalerProviderPipe,
138
+
139
+ "PixelKSampleHookCombine": PixelKSampleHookCombine,
140
+ "DenoiseScheduleHookProvider": DenoiseScheduleHookProvider,
141
+ "StepsScheduleHookProvider": StepsScheduleHookProvider,
142
+ "CfgScheduleHookProvider": CfgScheduleHookProvider,
143
+ "NoiseInjectionHookProvider": NoiseInjectionHookProvider,
144
+ "UnsamplerHookProvider": UnsamplerHookProvider,
145
+ "CoreMLDetailerHookProvider": CoreMLDetailerHookProvider,
146
+ "PreviewDetailerHookProvider": PreviewDetailerHookProvider,
147
+
148
+ "DetailerHookCombine": DetailerHookCombine,
149
+ "NoiseInjectionDetailerHookProvider": NoiseInjectionDetailerHookProvider,
150
+ "UnsamplerDetailerHookProvider": UnsamplerDetailerHookProvider,
151
+ "DenoiseSchedulerDetailerHookProvider": DenoiseSchedulerDetailerHookProvider,
152
+ "SEGSOrderedFilterDetailerHookProvider": SEGSOrderedFilterDetailerHookProvider,
153
+ "SEGSRangeFilterDetailerHookProvider": SEGSRangeFilterDetailerHookProvider,
154
+ "SEGSLabelFilterDetailerHookProvider": SEGSLabelFilterDetailerHookProvider,
155
+ "VariationNoiseDetailerHookProvider": VariationNoiseDetailerHookProvider,
156
+ # "CustomNoiseDetailerHookProvider": CustomNoiseDetailerHookProvider,
157
+
158
+ "BitwiseAndMask": BitwiseAndMask,
159
+ "SubtractMask": SubtractMask,
160
+ "AddMask": AddMask,
161
+ "ImpactSegsAndMask": SegsBitwiseAndMask,
162
+ "ImpactSegsAndMaskForEach": SegsBitwiseAndMaskForEach,
163
+ "EmptySegs": EmptySEGS,
164
+
165
+ "MediaPipeFaceMeshToSEGS": MediaPipeFaceMeshToSEGS,
166
+ "MaskToSEGS": MaskToSEGS,
167
+ "MaskToSEGS_for_AnimateDiff": MaskToSEGS_for_AnimateDiff,
168
+ "ToBinaryMask": ToBinaryMask,
169
+ "MasksToMaskList": MasksToMaskList,
170
+ "MaskListToMaskBatch": MaskListToMaskBatch,
171
+ "ImageListToImageBatch": ImageListToImageBatch,
172
+ "SetDefaultImageForSEGS": DefaultImageForSEGS,
173
+ "RemoveImageFromSEGS": RemoveImageFromSEGS,
174
+
175
+ "BboxDetectorSEGS": BboxDetectorForEach,
176
+ "SegmDetectorSEGS": SegmDetectorForEach,
177
+ "ONNXDetectorSEGS": BboxDetectorForEach,
178
+ "ImpactSimpleDetectorSEGS_for_AD": SimpleDetectorForAnimateDiff,
179
+ "ImpactSimpleDetectorSEGS": SimpleDetectorForEach,
180
+ "ImpactSimpleDetectorSEGSPipe": SimpleDetectorForEachPipe,
181
+ "ImpactControlNetApplySEGS": ControlNetApplySEGS,
182
+ "ImpactControlNetApplyAdvancedSEGS": ControlNetApplyAdvancedSEGS,
183
+ "ImpactControlNetClearSEGS": ControlNetClearSEGS,
184
+ "ImpactIPAdapterApplySEGS": IPAdapterApplySEGS,
185
+
186
+ "ImpactDecomposeSEGS": DecomposeSEGS,
187
+ "ImpactAssembleSEGS": AssembleSEGS,
188
+ "ImpactFrom_SEG_ELT": From_SEG_ELT,
189
+ "ImpactEdit_SEG_ELT": Edit_SEG_ELT,
190
+ "ImpactDilate_Mask_SEG_ELT": Dilate_SEG_ELT,
191
+ "ImpactDilateMask": DilateMask,
192
+ "ImpactGaussianBlurMask": GaussianBlurMask,
193
+ "ImpactDilateMaskInSEGS": DilateMaskInSEGS,
194
+ "ImpactGaussianBlurMaskInSEGS": GaussianBlurMaskInSEGS,
195
+ "ImpactScaleBy_BBOX_SEG_ELT": SEG_ELT_BBOX_ScaleBy,
196
+ "ImpactFrom_SEG_ELT_bbox": From_SEG_ELT_bbox,
197
+ "ImpactFrom_SEG_ELT_crop_region": From_SEG_ELT_crop_region,
198
+ "ImpactCount_Elts_in_SEGS": Count_Elts_in_SEGS,
199
+
200
+ "BboxDetectorCombined_v2": BboxDetectorCombined,
201
+ "SegmDetectorCombined_v2": SegmDetectorCombined,
202
+ "SegsToCombinedMask": SegsToCombinedMask,
203
+
204
+ "KSamplerProvider": KSamplerProvider,
205
+ "TwoSamplersForMask": TwoSamplersForMask,
206
+ "TiledKSamplerProvider": TiledKSamplerProvider,
207
+
208
+ "KSamplerAdvancedProvider": KSamplerAdvancedProvider,
209
+ "TwoAdvancedSamplersForMask": TwoAdvancedSamplersForMask,
210
+
211
+ "ImpactNegativeConditioningPlaceholder": NegativeConditioningPlaceholder,
212
+
213
+ "PreviewBridge": PreviewBridge,
214
+ "PreviewBridgeLatent": PreviewBridgeLatent,
215
+ "ImageSender": ImageSender,
216
+ "ImageReceiver": ImageReceiver,
217
+ "LatentSender": LatentSender,
218
+ "LatentReceiver": LatentReceiver,
219
+ "ImageMaskSwitch": ImageMaskSwitch,
220
+ "LatentSwitch": GeneralSwitch,
221
+ "SEGSSwitch": GeneralSwitch,
222
+ "ImpactSwitch": GeneralSwitch,
223
+ "ImpactInversedSwitch": GeneralInversedSwitch,
224
+
225
+ "ImpactWildcardProcessor": ImpactWildcardProcessor,
226
+ "ImpactWildcardEncode": ImpactWildcardEncode,
227
+
228
+ "SEGSUpscaler": SEGSUpscaler,
229
+ "SEGSUpscalerPipe": SEGSUpscalerPipe,
230
+ "SEGSDetailer": SEGSDetailer,
231
+ "SEGSPaste": SEGSPaste,
232
+ "SEGSPreview": SEGSPreview,
233
+ "SEGSPreviewCNet": SEGSPreviewCNet,
234
+ "SEGSToImageList": SEGSToImageList,
235
+ "ImpactSEGSToMaskList": SEGSToMaskList,
236
+ "ImpactSEGSToMaskBatch": SEGSToMaskBatch,
237
+ "ImpactSEGSConcat": SEGSConcat,
238
+ "ImpactSEGSPicker": SEGSPicker,
239
+ "ImpactMakeTileSEGS": MakeTileSEGS,
240
+
241
+ "SEGSDetailerForAnimateDiff": SEGSDetailerForAnimateDiff,
242
+
243
+ "ImpactKSamplerBasicPipe": KSamplerBasicPipe,
244
+ "ImpactKSamplerAdvancedBasicPipe": KSamplerAdvancedBasicPipe,
245
+
246
+ "ReencodeLatent": ReencodeLatent,
247
+ "ReencodeLatentPipe": ReencodeLatentPipe,
248
+
249
+ "ImpactImageBatchToImageList": ImageBatchToImageList,
250
+ "ImpactMakeImageList": MakeImageList,
251
+ "ImpactMakeImageBatch": MakeImageBatch,
252
+
253
+ "RegionalSampler": RegionalSampler,
254
+ "RegionalSamplerAdvanced": RegionalSamplerAdvanced,
255
+ "CombineRegionalPrompts": CombineRegionalPrompts,
256
+ "RegionalPrompt": RegionalPrompt,
257
+
258
+ "ImpactCombineConditionings": CombineConditionings,
259
+ "ImpactConcatConditionings": ConcatConditionings,
260
+
261
+ "ImpactSEGSLabelAssign": SEGSLabelAssign,
262
+ "ImpactSEGSLabelFilter": SEGSLabelFilter,
263
+ "ImpactSEGSRangeFilter": SEGSRangeFilter,
264
+ "ImpactSEGSOrderedFilter": SEGSOrderedFilter,
265
+
266
+ "ImpactCompare": ImpactCompare,
267
+ "ImpactConditionalBranch": ImpactConditionalBranch,
268
+ "ImpactConditionalBranchSelMode": ImpactConditionalBranchSelMode,
269
+ "ImpactIfNone": ImpactIfNone,
270
+ "ImpactConvertDataType": ImpactConvertDataType,
271
+ "ImpactLogicalOperators": ImpactLogicalOperators,
272
+ "ImpactInt": ImpactInt,
273
+ "ImpactFloat": ImpactFloat,
274
+ "ImpactValueSender": ImpactValueSender,
275
+ "ImpactValueReceiver": ImpactValueReceiver,
276
+ "ImpactImageInfo": ImpactImageInfo,
277
+ "ImpactLatentInfo": ImpactLatentInfo,
278
+ "ImpactMinMax": ImpactMinMax,
279
+ "ImpactNeg": ImpactNeg,
280
+ "ImpactConditionalStopIteration": ImpactConditionalStopIteration,
281
+ "ImpactStringSelector": StringSelector,
282
+ "StringListToString": StringListToString,
283
+ "WildcardPromptFromString": WildcardPromptFromString,
284
+ "ImpactExecutionOrderController": ImpactExecutionOrderController,
285
+
286
+ "RemoveNoiseMask": RemoveNoiseMask,
287
+
288
+ "ImpactLogger": ImpactLogger,
289
+ "ImpactDummyInput": ImpactDummyInput,
290
+
291
+ "ImpactQueueTrigger": ImpactQueueTrigger,
292
+ "ImpactQueueTriggerCountdown": ImpactQueueTriggerCountdown,
293
+ "ImpactSetWidgetValue": ImpactSetWidgetValue,
294
+ "ImpactNodeSetMuteState": ImpactNodeSetMuteState,
295
+ "ImpactControlBridge": ImpactControlBridge,
296
+ "ImpactIsNotEmptySEGS": ImpactNotEmptySEGS,
297
+ "ImpactSleep": ImpactSleep,
298
+ "ImpactRemoteBoolean": ImpactRemoteBoolean,
299
+ "ImpactRemoteInt": ImpactRemoteInt,
300
+
301
+ "ImpactHFTransformersClassifierProvider": HF_TransformersClassifierProvider,
302
+ "ImpactSEGSClassify": SEGS_Classify,
303
+
304
+ "ImpactSchedulerAdapter": ImpactSchedulerAdapter,
305
+ "GITSSchedulerFuncProvider": GITSSchedulerFuncProvider
306
+ }
307
+
308
+
309
+ NODE_DISPLAY_NAME_MAPPINGS = {
310
+ "SAMLoader": "SAMLoader (Impact)",
311
+
312
+ "BboxDetectorSEGS": "BBOX Detector (SEGS)",
313
+ "SegmDetectorSEGS": "SEGM Detector (SEGS)",
314
+ "ONNXDetectorSEGS": "ONNX Detector (SEGS/legacy) - use BBOXDetector",
315
+ "ImpactSimpleDetectorSEGS_for_AD": "Simple Detector for AnimateDiff (SEGS)",
316
+ "ImpactSimpleDetectorSEGS": "Simple Detector (SEGS)",
317
+ "ImpactSimpleDetectorSEGSPipe": "Simple Detector (SEGS/pipe)",
318
+ "ImpactControlNetApplySEGS": "ControlNetApply (SEGS)",
319
+ "ImpactControlNetApplyAdvancedSEGS": "ControlNetApplyAdvanced (SEGS)",
320
+ "ImpactIPAdapterApplySEGS": "IPAdapterApply (SEGS)",
321
+
322
+ "BboxDetectorCombined_v2": "BBOX Detector (combined)",
323
+ "SegmDetectorCombined_v2": "SEGM Detector (combined)",
324
+ "SegsToCombinedMask": "SEGS to MASK (combined)",
325
+ "MediaPipeFaceMeshToSEGS": "MediaPipe FaceMesh to SEGS",
326
+ "MaskToSEGS": "MASK to SEGS",
327
+ "MaskToSEGS_for_AnimateDiff": "MASK to SEGS for AnimateDiff",
328
+ "BitwiseAndMaskForEach": "Pixelwise(SEGS & SEGS)",
329
+ "SubtractMaskForEach": "Pixelwise(SEGS - SEGS)",
330
+ "ImpactSegsAndMask": "Pixelwise(SEGS & MASK)",
331
+ "ImpactSegsAndMaskForEach": "Pixelwise(SEGS & MASKS ForEach)",
332
+ "BitwiseAndMask": "Pixelwise(MASK & MASK)",
333
+ "SubtractMask": "Pixelwise(MASK - MASK)",
334
+ "AddMask": "Pixelwise(MASK + MASK)",
335
+ "DetailerForEach": "Detailer (SEGS)",
336
+ "DetailerForEachPipe": "Detailer (SEGS/pipe)",
337
+ "DetailerForEachDebug": "DetailerDebug (SEGS)",
338
+ "DetailerForEachDebugPipe": "DetailerDebug (SEGS/pipe)",
339
+ "SEGSDetailerForAnimateDiff": "SEGSDetailer For AnimateDiff (SEGS/pipe)",
340
+ "DetailerForEachPipeForAnimateDiff": "Detailer For AnimateDiff (SEGS/pipe)",
341
+ "SEGSUpscaler": "Upscaler (SEGS)",
342
+ "SEGSUpscalerPipe": "Upscaler (SEGS/pipe)",
343
+
344
+ "SAMDetectorCombined": "SAMDetector (combined)",
345
+ "SAMDetectorSegmented": "SAMDetector (segmented)",
346
+ "FaceDetailerPipe": "FaceDetailer (pipe)",
347
+ "MaskDetailerPipe": "MaskDetailer (pipe)",
348
+
349
+ "FromDetailerPipeSDXL": "FromDetailer (SDXL/pipe)",
350
+ "BasicPipeToDetailerPipeSDXL": "BasicPipe -> DetailerPipe (SDXL)",
351
+ "EditDetailerPipeSDXL": "Edit DetailerPipe (SDXL)",
352
+
353
+ "BasicPipeToDetailerPipe": "BasicPipe -> DetailerPipe",
354
+ "DetailerPipeToBasicPipe": "DetailerPipe -> BasicPipe",
355
+ "EditBasicPipe": "Edit BasicPipe",
356
+ "EditDetailerPipe": "Edit DetailerPipe",
357
+
358
+ "LatentPixelScale": "Latent Scale (on Pixel Space)",
359
+ "IterativeLatentUpscale": "Iterative Upscale (Latent/on Pixel Space)",
360
+ "IterativeImageUpscale": "Iterative Upscale (Image)",
361
+
362
+ "TwoSamplersForMaskUpscalerProvider": "TwoSamplersForMask Upscaler Provider",
363
+ "TwoSamplersForMaskUpscalerProviderPipe": "TwoSamplersForMask Upscaler Provider (pipe)",
364
+
365
+ "ReencodeLatent": "Reencode Latent",
366
+ "ReencodeLatentPipe": "Reencode Latent (pipe)",
367
+
368
+ "ImpactKSamplerBasicPipe": "KSampler (pipe)",
369
+ "ImpactKSamplerAdvancedBasicPipe": "KSampler (Advanced/pipe)",
370
+ "ImpactSEGSLabelAssign": "SEGS Assign (label)",
371
+ "ImpactSEGSLabelFilter": "SEGS Filter (label)",
372
+ "ImpactSEGSRangeFilter": "SEGS Filter (range)",
373
+ "ImpactSEGSOrderedFilter": "SEGS Filter (ordered)",
374
+ "ImpactSEGSConcat": "SEGS Concat",
375
+ "ImpactSEGSToMaskList": "SEGS to Mask List",
376
+ "ImpactSEGSToMaskBatch": "SEGS to Mask Batch",
377
+ "ImpactSEGSPicker": "Picker (SEGS)",
378
+ "ImpactMakeTileSEGS": "Make Tile SEGS",
379
+
380
+ "ImpactDecomposeSEGS": "Decompose (SEGS)",
381
+ "ImpactAssembleSEGS": "Assemble (SEGS)",
382
+ "ImpactFrom_SEG_ELT": "From SEG_ELT",
383
+ "ImpactEdit_SEG_ELT": "Edit SEG_ELT",
384
+ "ImpactFrom_SEG_ELT_bbox": "From SEG_ELT bbox",
385
+ "ImpactFrom_SEG_ELT_crop_region": "From SEG_ELT crop_region",
386
+ "ImpactDilate_Mask_SEG_ELT": "Dilate Mask (SEG_ELT)",
387
+ "ImpactScaleBy_BBOX_SEG_ELT": "ScaleBy BBOX (SEG_ELT)",
388
+ "ImpactCount_Elts_in_SEGS": "Count Elts in SEGS",
389
+ "ImpactDilateMask": "Dilate Mask",
390
+ "ImpactGaussianBlurMask": "Gaussian Blur Mask",
391
+ "ImpactDilateMaskInSEGS": "Dilate Mask (SEGS)",
392
+ "ImpactGaussianBlurMaskInSEGS": "Gaussian Blur Mask (SEGS)",
393
+
394
+ "PreviewBridge": "Preview Bridge (Image)",
395
+ "PreviewBridgeLatent": "Preview Bridge (Latent)",
396
+ "ImageSender": "Image Sender",
397
+ "ImageReceiver": "Image Receiver",
398
+ "ImageMaskSwitch": "Switch (images, mask)",
399
+ "ImpactSwitch": "Switch (Any)",
400
+ "ImpactInversedSwitch": "Inversed Switch (Any)",
401
+ "ImpactExecutionOrderController": "Execution Order Controller",
402
+
403
+ "MasksToMaskList": "Masks to Mask List",
404
+ "MaskListToMaskBatch": "Mask List to Masks",
405
+ "ImpactImageBatchToImageList": "Image batch to Image List",
406
+ "ImageListToImageBatch": "Image List to Image Batch",
407
+ "ImpactMakeImageList": "Make Image List",
408
+ "ImpactMakeImageBatch": "Make Image Batch",
409
+ "ImpactStringSelector": "String Selector",
410
+ "StringListToString": "String List to String",
411
+ "WildcardPromptFromString": "Wildcard Prompt from String",
412
+ "ImpactIsNotEmptySEGS": "SEGS isn't Empty",
413
+ "SetDefaultImageForSEGS": "Set Default Image for SEGS",
414
+ "RemoveImageFromSEGS": "Remove Image from SEGS",
415
+
416
+ "RemoveNoiseMask": "Remove Noise Mask",
417
+
418
+ "ImpactCombineConditionings": "Combine Conditionings",
419
+ "ImpactConcatConditionings": "Concat Conditionings",
420
+
421
+ "ImpactQueueTrigger": "Queue Trigger",
422
+ "ImpactQueueTriggerCountdown": "Queue Trigger (Countdown)",
423
+ "ImpactSetWidgetValue": "Set Widget Value",
424
+ "ImpactNodeSetMuteState": "Set Mute State",
425
+ "ImpactControlBridge": "Control Bridge",
426
+ "ImpactSleep": "Sleep",
427
+ "ImpactRemoteBoolean": "Remote Boolean (on prompt)",
428
+ "ImpactRemoteInt": "Remote Int (on prompt)",
429
+
430
+ "ImpactHFTransformersClassifierProvider": "HF Transformers Classifier Provider",
431
+ "ImpactSEGSClassify": "SEGS Classify",
432
+
433
+ "LatentSwitch": "Switch (latent/legacy)",
434
+ "SEGSSwitch": "Switch (SEGS/legacy)",
435
+
436
+ "SEGSPreviewCNet": "SEGSPreview (CNET Image)",
437
+
438
+ "ImpactSchedulerAdapter": "Impact Scheduler Adapter",
439
+ "GITSSchedulerFuncProvider": "GITSScheduler Func Provider",
440
+ "ImpactNegativeConditioningPlaceholder": "Negative Cond Placeholder"
441
+ }
442
+
443
+ if not impact.config.get_config()['mmdet_skip']:
444
+ from impact.mmdet_nodes import *
445
+ import impact.legacy_nodes
446
+ NODE_CLASS_MAPPINGS.update({
447
+ "MMDetDetectorProvider": MMDetDetectorProvider,
448
+ "MMDetLoader": impact.legacy_nodes.MMDetLoader,
449
+ "MaskPainter": impact.legacy_nodes.MaskPainter,
450
+ "SegsMaskCombine": impact.legacy_nodes.SegsMaskCombine,
451
+ "BboxDetectorForEach": impact.legacy_nodes.BboxDetectorForEach,
452
+ "SegmDetectorForEach": impact.legacy_nodes.SegmDetectorForEach,
453
+ "BboxDetectorCombined": impact.legacy_nodes.BboxDetectorCombined,
454
+ "SegmDetectorCombined": impact.legacy_nodes.SegmDetectorCombined,
455
+ })
456
+
457
+ NODE_DISPLAY_NAME_MAPPINGS.update({
458
+ "MaskPainter": "MaskPainter (Deprecated)",
459
+ "MMDetLoader": "MMDetLoader (Legacy)",
460
+ "SegsMaskCombine": "SegsMaskCombine (Legacy)",
461
+ "BboxDetectorForEach": "BboxDetectorForEach (Legacy)",
462
+ "SegmDetectorForEach": "SegmDetectorForEach (Legacy)",
463
+ "BboxDetectorCombined": "BboxDetectorCombined (Legacy)",
464
+ "SegmDetectorCombined": "SegmDetectorCombined (Legacy)",
465
+ })
466
+
467
+ try:
468
+ import impact.subpack_nodes
469
+
470
+ NODE_CLASS_MAPPINGS.update(impact.subpack_nodes.NODE_CLASS_MAPPINGS)
471
+ NODE_DISPLAY_NAME_MAPPINGS.update(impact.subpack_nodes.NODE_DISPLAY_NAME_MAPPINGS)
472
+ except Exception as e:
473
+ print("### ComfyUI-Impact-Pack: (IMPORT FAILED) Subpack\n")
474
+ print(" The module at the `custom_nodes/ComfyUI-Impact-Pack/impact_subpack` path appears to be incomplete.")
475
+ print(" Recommended to delete the path and restart ComfyUI.")
476
+ print(" If the issue persists, please report it to https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues.")
477
+ print("\n---------------------------------")
478
+ traceback.print_exc()
479
+ print("---------------------------------\n")
480
+
481
+ # NOTE: Inject directly into EXTENSION_WEB_DIRS instead of WEB_DIRECTORY
482
+ # Provide the js path fixed as ComfyUI-Impact-Pack instead of the path name, making it available for external use
483
+
484
+ # WEB_DIRECTORY = "js" -- deprecated method
485
+ nodes.EXTENSION_WEB_DIRS["ComfyUI-Impact-Pack"] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'js')
486
+
487
+
488
+ __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
489
+
490
+
491
+ try:
492
+ import cm_global
493
+ cm_global.register_extension('ComfyUI-Impact-Pack',
494
+ {'version': config.version_code,
495
+ 'name': 'Impact Pack',
496
+ 'nodes': set(NODE_CLASS_MAPPINGS.keys()),
497
+ 'description': 'This extension provides inpainting functionality based on the detector and detailer, along with convenient workflow features like wildcards and logics.', })
498
+ except:
499
+ pass
custom_nodes/ComfyUI-Impact-Pack/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (16.3 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/custom_wildcards/put_wildcards_here ADDED
File without changes
custom_nodes/ComfyUI-Impact-Pack/disable.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import time
4
+ import platform
5
+ import shutil
6
+ import subprocess
7
+
8
+ comfy_path = '../..'
9
+
10
+ def rmtree(path):
11
+ retry_count = 3
12
+
13
+ while True:
14
+ try:
15
+ retry_count -= 1
16
+
17
+ if platform.system() == "Windows":
18
+ subprocess.check_call(['attrib', '-R', path + '\\*', '/S'])
19
+
20
+ shutil.rmtree(path)
21
+
22
+ return True
23
+
24
+ except Exception as ex:
25
+ print(f"ex: {ex}")
26
+ time.sleep(3)
27
+
28
+ if retry_count < 0:
29
+ raise ex
30
+
31
+ print(f"Uninstall retry({retry_count})")
32
+
33
+ js_dest_path = os.path.join(comfy_path, "web", "extensions", "impact-pack")
34
+
35
+ if os.path.exists(js_dest_path):
36
+ rmtree(js_dest_path)
37
+
38
+
custom_nodes/ComfyUI-Impact-Pack/impact-pack.ini ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ [default]
2
+ dependency_version = 22
3
+ mmdet_skip = True
4
+ sam_editor_cpu = False
5
+ sam_editor_model = sam_vit_b_01ec64.pth
6
+ custom_wildcards = C:\Projects\projects\fi\custom_nodes\ComfyUI-Impact-Pack\custom_wildcards
7
+ disable_gpu_opencv = True
8
+
custom_nodes/ComfyUI-Impact-Pack/impact_subpack/.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ __pycache__
2
+ *.ini
3
+ wildcards/**
4
+ .vscode/
5
+ .idea/
custom_nodes/ComfyUI-Impact-Pack/impact_subpack/LICENSE ADDED
@@ -0,0 +1,661 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU Affero General Public License is a free, copyleft license for
11
+ software and other kinds of works, specifically designed to ensure
12
+ cooperation with the community in the case of network server software.
13
+
14
+ The licenses for most software and other practical works are designed
15
+ to take away your freedom to share and change the works. By contrast,
16
+ our General Public Licenses are intended to guarantee your freedom to
17
+ share and change all versions of a program--to make sure it remains free
18
+ software for all its users.
19
+
20
+ When we speak of free software, we are referring to freedom, not
21
+ price. Our General Public Licenses are designed to make sure that you
22
+ have the freedom to distribute copies of free software (and charge for
23
+ them if you wish), that you receive source code or can get it if you
24
+ want it, that you can change the software or use pieces of it in new
25
+ free programs, and that you know you can do these things.
26
+
27
+ Developers that use our General Public Licenses protect your rights
28
+ with two steps: (1) assert copyright on the software, and (2) offer
29
+ you this License which gives you legal permission to copy, distribute
30
+ and/or modify the software.
31
+
32
+ A secondary benefit of defending all users' freedom is that
33
+ improvements made in alternate versions of the program, if they
34
+ receive widespread use, become available for other developers to
35
+ incorporate. Many developers of free software are heartened and
36
+ encouraged by the resulting cooperation. However, in the case of
37
+ software used on network servers, this result may fail to come about.
38
+ The GNU General Public License permits making a modified version and
39
+ letting the public access it on a server without ever releasing its
40
+ source code to the public.
41
+
42
+ The GNU Affero General Public License is designed specifically to
43
+ ensure that, in such cases, the modified source code becomes available
44
+ to the community. It requires the operator of a network server to
45
+ provide the source code of the modified version running there to the
46
+ users of that server. Therefore, public use of a modified version, on
47
+ a publicly accessible server, gives the public access to the source
48
+ code of the modified version.
49
+
50
+ An older license, called the Affero General Public License and
51
+ published by Affero, was designed to accomplish similar goals. This is
52
+ a different license, not a version of the Affero GPL, but Affero has
53
+ released a new version of the Affero GPL which permits relicensing under
54
+ this license.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ TERMS AND CONDITIONS
60
+
61
+ 0. Definitions.
62
+
63
+ "This License" refers to version 3 of the GNU Affero General Public License.
64
+
65
+ "Copyright" also means copyright-like laws that apply to other kinds of
66
+ works, such as semiconductor masks.
67
+
68
+ "The Program" refers to any copyrightable work licensed under this
69
+ License. Each licensee is addressed as "you". "Licensees" and
70
+ "recipients" may be individuals or organizations.
71
+
72
+ To "modify" a work means to copy from or adapt all or part of the work
73
+ in a fashion requiring copyright permission, other than the making of an
74
+ exact copy. The resulting work is called a "modified version" of the
75
+ earlier work or a work "based on" the earlier work.
76
+
77
+ A "covered work" means either the unmodified Program or a work based
78
+ on the Program.
79
+
80
+ To "propagate" a work means to do anything with it that, without
81
+ permission, would make you directly or secondarily liable for
82
+ infringement under applicable copyright law, except executing it on a
83
+ computer or modifying a private copy. Propagation includes copying,
84
+ distribution (with or without modification), making available to the
85
+ public, and in some countries other activities as well.
86
+
87
+ To "convey" a work means any kind of propagation that enables other
88
+ parties to make or receive copies. Mere interaction with a user through
89
+ a computer network, with no transfer of a copy, is not conveying.
90
+
91
+ An interactive user interface displays "Appropriate Legal Notices"
92
+ to the extent that it includes a convenient and prominently visible
93
+ feature that (1) displays an appropriate copyright notice, and (2)
94
+ tells the user that there is no warranty for the work (except to the
95
+ extent that warranties are provided), that licensees may convey the
96
+ work under this License, and how to view a copy of this License. If
97
+ the interface presents a list of user commands or options, such as a
98
+ menu, a prominent item in the list meets this criterion.
99
+
100
+ 1. Source Code.
101
+
102
+ The "source code" for a work means the preferred form of the work
103
+ for making modifications to it. "Object code" means any non-source
104
+ form of a work.
105
+
106
+ A "Standard Interface" means an interface that either is an official
107
+ standard defined by a recognized standards body, or, in the case of
108
+ interfaces specified for a particular programming language, one that
109
+ is widely used among developers working in that language.
110
+
111
+ The "System Libraries" of an executable work include anything, other
112
+ than the work as a whole, that (a) is included in the normal form of
113
+ packaging a Major Component, but which is not part of that Major
114
+ Component, and (b) serves only to enable use of the work with that
115
+ Major Component, or to implement a Standard Interface for which an
116
+ implementation is available to the public in source code form. A
117
+ "Major Component", in this context, means a major essential component
118
+ (kernel, window system, and so on) of the specific operating system
119
+ (if any) on which the executable work runs, or a compiler used to
120
+ produce the work, or an object code interpreter used to run it.
121
+
122
+ The "Corresponding Source" for a work in object code form means all
123
+ the source code needed to generate, install, and (for an executable
124
+ work) run the object code and to modify the work, including scripts to
125
+ control those activities. However, it does not include the work's
126
+ System Libraries, or general-purpose tools or generally available free
127
+ programs which are used unmodified in performing those activities but
128
+ which are not part of the work. For example, Corresponding Source
129
+ includes interface definition files associated with source files for
130
+ the work, and the source code for shared libraries and dynamically
131
+ linked subprograms that the work is specifically designed to require,
132
+ such as by intimate data communication or control flow between those
133
+ subprograms and other parts of the work.
134
+
135
+ The Corresponding Source need not include anything that users
136
+ can regenerate automatically from other parts of the Corresponding
137
+ Source.
138
+
139
+ The Corresponding Source for a work in source code form is that
140
+ same work.
141
+
142
+ 2. Basic Permissions.
143
+
144
+ All rights granted under this License are granted for the term of
145
+ copyright on the Program, and are irrevocable provided the stated
146
+ conditions are met. This License explicitly affirms your unlimited
147
+ permission to run the unmodified Program. The output from running a
148
+ covered work is covered by this License only if the output, given its
149
+ content, constitutes a covered work. This License acknowledges your
150
+ rights of fair use or other equivalent, as provided by copyright law.
151
+
152
+ You may make, run and propagate covered works that you do not
153
+ convey, without conditions so long as your license otherwise remains
154
+ in force. You may convey covered works to others for the sole purpose
155
+ of having them make modifications exclusively for you, or provide you
156
+ with facilities for running those works, provided that you comply with
157
+ the terms of this License in conveying all material for which you do
158
+ not control copyright. Those thus making or running the covered works
159
+ for you must do so exclusively on your behalf, under your direction
160
+ and control, on terms that prohibit them from making any copies of
161
+ your copyrighted material outside their relationship with you.
162
+
163
+ Conveying under any other circumstances is permitted solely under
164
+ the conditions stated below. Sublicensing is not allowed; section 10
165
+ makes it unnecessary.
166
+
167
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
+
169
+ No covered work shall be deemed part of an effective technological
170
+ measure under any applicable law fulfilling obligations under article
171
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172
+ similar laws prohibiting or restricting circumvention of such
173
+ measures.
174
+
175
+ When you convey a covered work, you waive any legal power to forbid
176
+ circumvention of technological measures to the extent such circumvention
177
+ is effected by exercising rights under this License with respect to
178
+ the covered work, and you disclaim any intention to limit operation or
179
+ modification of the work as a means of enforcing, against the work's
180
+ users, your or third parties' legal rights to forbid circumvention of
181
+ technological measures.
182
+
183
+ 4. Conveying Verbatim Copies.
184
+
185
+ You may convey verbatim copies of the Program's source code as you
186
+ receive it, in any medium, provided that you conspicuously and
187
+ appropriately publish on each copy an appropriate copyright notice;
188
+ keep intact all notices stating that this License and any
189
+ non-permissive terms added in accord with section 7 apply to the code;
190
+ keep intact all notices of the absence of any warranty; and give all
191
+ recipients a copy of this License along with the Program.
192
+
193
+ You may charge any price or no price for each copy that you convey,
194
+ and you may offer support or warranty protection for a fee.
195
+
196
+ 5. Conveying Modified Source Versions.
197
+
198
+ You may convey a work based on the Program, or the modifications to
199
+ produce it from the Program, in the form of source code under the
200
+ terms of section 4, provided that you also meet all of these conditions:
201
+
202
+ a) The work must carry prominent notices stating that you modified
203
+ it, and giving a relevant date.
204
+
205
+ b) The work must carry prominent notices stating that it is
206
+ released under this License and any conditions added under section
207
+ 7. This requirement modifies the requirement in section 4 to
208
+ "keep intact all notices".
209
+
210
+ c) You must license the entire work, as a whole, under this
211
+ License to anyone who comes into possession of a copy. This
212
+ License will therefore apply, along with any applicable section 7
213
+ additional terms, to the whole of the work, and all its parts,
214
+ regardless of how they are packaged. This License gives no
215
+ permission to license the work in any other way, but it does not
216
+ invalidate such permission if you have separately received it.
217
+
218
+ d) If the work has interactive user interfaces, each must display
219
+ Appropriate Legal Notices; however, if the Program has interactive
220
+ interfaces that do not display Appropriate Legal Notices, your
221
+ work need not make them do so.
222
+
223
+ A compilation of a covered work with other separate and independent
224
+ works, which are not by their nature extensions of the covered work,
225
+ and which are not combined with it such as to form a larger program,
226
+ in or on a volume of a storage or distribution medium, is called an
227
+ "aggregate" if the compilation and its resulting copyright are not
228
+ used to limit the access or legal rights of the compilation's users
229
+ beyond what the individual works permit. Inclusion of a covered work
230
+ in an aggregate does not cause this License to apply to the other
231
+ parts of the aggregate.
232
+
233
+ 6. Conveying Non-Source Forms.
234
+
235
+ You may convey a covered work in object code form under the terms
236
+ of sections 4 and 5, provided that you also convey the
237
+ machine-readable Corresponding Source under the terms of this License,
238
+ in one of these ways:
239
+
240
+ a) Convey the object code in, or embodied in, a physical product
241
+ (including a physical distribution medium), accompanied by the
242
+ Corresponding Source fixed on a durable physical medium
243
+ customarily used for software interchange.
244
+
245
+ b) Convey the object code in, or embodied in, a physical product
246
+ (including a physical distribution medium), accompanied by a
247
+ written offer, valid for at least three years and valid for as
248
+ long as you offer spare parts or customer support for that product
249
+ model, to give anyone who possesses the object code either (1) a
250
+ copy of the Corresponding Source for all the software in the
251
+ product that is covered by this License, on a durable physical
252
+ medium customarily used for software interchange, for a price no
253
+ more than your reasonable cost of physically performing this
254
+ conveying of source, or (2) access to copy the
255
+ Corresponding Source from a network server at no charge.
256
+
257
+ c) Convey individual copies of the object code with a copy of the
258
+ written offer to provide the Corresponding Source. This
259
+ alternative is allowed only occasionally and noncommercially, and
260
+ only if you received the object code with such an offer, in accord
261
+ with subsection 6b.
262
+
263
+ d) Convey the object code by offering access from a designated
264
+ place (gratis or for a charge), and offer equivalent access to the
265
+ Corresponding Source in the same way through the same place at no
266
+ further charge. You need not require recipients to copy the
267
+ Corresponding Source along with the object code. If the place to
268
+ copy the object code is a network server, the Corresponding Source
269
+ may be on a different server (operated by you or a third party)
270
+ that supports equivalent copying facilities, provided you maintain
271
+ clear directions next to the object code saying where to find the
272
+ Corresponding Source. Regardless of what server hosts the
273
+ Corresponding Source, you remain obligated to ensure that it is
274
+ available for as long as needed to satisfy these requirements.
275
+
276
+ e) Convey the object code using peer-to-peer transmission, provided
277
+ you inform other peers where the object code and Corresponding
278
+ Source of the work are being offered to the general public at no
279
+ charge under subsection 6d.
280
+
281
+ A separable portion of the object code, whose source code is excluded
282
+ from the Corresponding Source as a System Library, need not be
283
+ included in conveying the object code work.
284
+
285
+ A "User Product" is either (1) a "consumer product", which means any
286
+ tangible personal property which is normally used for personal, family,
287
+ or household purposes, or (2) anything designed or sold for incorporation
288
+ into a dwelling. In determining whether a product is a consumer product,
289
+ doubtful cases shall be resolved in favor of coverage. For a particular
290
+ product received by a particular user, "normally used" refers to a
291
+ typical or common use of that class of product, regardless of the status
292
+ of the particular user or of the way in which the particular user
293
+ actually uses, or expects or is expected to use, the product. A product
294
+ is a consumer product regardless of whether the product has substantial
295
+ commercial, industrial or non-consumer uses, unless such uses represent
296
+ the only significant mode of use of the product.
297
+
298
+ "Installation Information" for a User Product means any methods,
299
+ procedures, authorization keys, or other information required to install
300
+ and execute modified versions of a covered work in that User Product from
301
+ a modified version of its Corresponding Source. The information must
302
+ suffice to ensure that the continued functioning of the modified object
303
+ code is in no case prevented or interfered with solely because
304
+ modification has been made.
305
+
306
+ If you convey an object code work under this section in, or with, or
307
+ specifically for use in, a User Product, and the conveying occurs as
308
+ part of a transaction in which the right of possession and use of the
309
+ User Product is transferred to the recipient in perpetuity or for a
310
+ fixed term (regardless of how the transaction is characterized), the
311
+ Corresponding Source conveyed under this section must be accompanied
312
+ by the Installation Information. But this requirement does not apply
313
+ if neither you nor any third party retains the ability to install
314
+ modified object code on the User Product (for example, the work has
315
+ been installed in ROM).
316
+
317
+ The requirement to provide Installation Information does not include a
318
+ requirement to continue to provide support service, warranty, or updates
319
+ for a work that has been modified or installed by the recipient, or for
320
+ the User Product in which it has been modified or installed. Access to a
321
+ network may be denied when the modification itself materially and
322
+ adversely affects the operation of the network or violates the rules and
323
+ protocols for communication across the network.
324
+
325
+ Corresponding Source conveyed, and Installation Information provided,
326
+ in accord with this section must be in a format that is publicly
327
+ documented (and with an implementation available to the public in
328
+ source code form), and must require no special password or key for
329
+ unpacking, reading or copying.
330
+
331
+ 7. Additional Terms.
332
+
333
+ "Additional permissions" are terms that supplement the terms of this
334
+ License by making exceptions from one or more of its conditions.
335
+ Additional permissions that are applicable to the entire Program shall
336
+ be treated as though they were included in this License, to the extent
337
+ that they are valid under applicable law. If additional permissions
338
+ apply only to part of the Program, that part may be used separately
339
+ under those permissions, but the entire Program remains governed by
340
+ this License without regard to the additional permissions.
341
+
342
+ When you convey a copy of a covered work, you may at your option
343
+ remove any additional permissions from that copy, or from any part of
344
+ it. (Additional permissions may be written to require their own
345
+ removal in certain cases when you modify the work.) You may place
346
+ additional permissions on material, added by you to a covered work,
347
+ for which you have or can give appropriate copyright permission.
348
+
349
+ Notwithstanding any other provision of this License, for material you
350
+ add to a covered work, you may (if authorized by the copyright holders of
351
+ that material) supplement the terms of this License with terms:
352
+
353
+ a) Disclaiming warranty or limiting liability differently from the
354
+ terms of sections 15 and 16 of this License; or
355
+
356
+ b) Requiring preservation of specified reasonable legal notices or
357
+ author attributions in that material or in the Appropriate Legal
358
+ Notices displayed by works containing it; or
359
+
360
+ c) Prohibiting misrepresentation of the origin of that material, or
361
+ requiring that modified versions of such material be marked in
362
+ reasonable ways as different from the original version; or
363
+
364
+ d) Limiting the use for publicity purposes of names of licensors or
365
+ authors of the material; or
366
+
367
+ e) Declining to grant rights under trademark law for use of some
368
+ trade names, trademarks, or service marks; or
369
+
370
+ f) Requiring indemnification of licensors and authors of that
371
+ material by anyone who conveys the material (or modified versions of
372
+ it) with contractual assumptions of liability to the recipient, for
373
+ any liability that these contractual assumptions directly impose on
374
+ those licensors and authors.
375
+
376
+ All other non-permissive additional terms are considered "further
377
+ restrictions" within the meaning of section 10. If the Program as you
378
+ received it, or any part of it, contains a notice stating that it is
379
+ governed by this License along with a term that is a further
380
+ restriction, you may remove that term. If a license document contains
381
+ a further restriction but permits relicensing or conveying under this
382
+ License, you may add to a covered work material governed by the terms
383
+ of that license document, provided that the further restriction does
384
+ not survive such relicensing or conveying.
385
+
386
+ If you add terms to a covered work in accord with this section, you
387
+ must place, in the relevant source files, a statement of the
388
+ additional terms that apply to those files, or a notice indicating
389
+ where to find the applicable terms.
390
+
391
+ Additional terms, permissive or non-permissive, may be stated in the
392
+ form of a separately written license, or stated as exceptions;
393
+ the above requirements apply either way.
394
+
395
+ 8. Termination.
396
+
397
+ You may not propagate or modify a covered work except as expressly
398
+ provided under this License. Any attempt otherwise to propagate or
399
+ modify it is void, and will automatically terminate your rights under
400
+ this License (including any patent licenses granted under the third
401
+ paragraph of section 11).
402
+
403
+ However, if you cease all violation of this License, then your
404
+ license from a particular copyright holder is reinstated (a)
405
+ provisionally, unless and until the copyright holder explicitly and
406
+ finally terminates your license, and (b) permanently, if the copyright
407
+ holder fails to notify you of the violation by some reasonable means
408
+ prior to 60 days after the cessation.
409
+
410
+ Moreover, your license from a particular copyright holder is
411
+ reinstated permanently if the copyright holder notifies you of the
412
+ violation by some reasonable means, this is the first time you have
413
+ received notice of violation of this License (for any work) from that
414
+ copyright holder, and you cure the violation prior to 30 days after
415
+ your receipt of the notice.
416
+
417
+ Termination of your rights under this section does not terminate the
418
+ licenses of parties who have received copies or rights from you under
419
+ this License. If your rights have been terminated and not permanently
420
+ reinstated, you do not qualify to receive new licenses for the same
421
+ material under section 10.
422
+
423
+ 9. Acceptance Not Required for Having Copies.
424
+
425
+ You are not required to accept this License in order to receive or
426
+ run a copy of the Program. Ancillary propagation of a covered work
427
+ occurring solely as a consequence of using peer-to-peer transmission
428
+ to receive a copy likewise does not require acceptance. However,
429
+ nothing other than this License grants you permission to propagate or
430
+ modify any covered work. These actions infringe copyright if you do
431
+ not accept this License. Therefore, by modifying or propagating a
432
+ covered work, you indicate your acceptance of this License to do so.
433
+
434
+ 10. Automatic Licensing of Downstream Recipients.
435
+
436
+ Each time you convey a covered work, the recipient automatically
437
+ receives a license from the original licensors, to run, modify and
438
+ propagate that work, subject to this License. You are not responsible
439
+ for enforcing compliance by third parties with this License.
440
+
441
+ An "entity transaction" is a transaction transferring control of an
442
+ organization, or substantially all assets of one, or subdividing an
443
+ organization, or merging organizations. If propagation of a covered
444
+ work results from an entity transaction, each party to that
445
+ transaction who receives a copy of the work also receives whatever
446
+ licenses to the work the party's predecessor in interest had or could
447
+ give under the previous paragraph, plus a right to possession of the
448
+ Corresponding Source of the work from the predecessor in interest, if
449
+ the predecessor has it or can get it with reasonable efforts.
450
+
451
+ You may not impose any further restrictions on the exercise of the
452
+ rights granted or affirmed under this License. For example, you may
453
+ not impose a license fee, royalty, or other charge for exercise of
454
+ rights granted under this License, and you may not initiate litigation
455
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
456
+ any patent claim is infringed by making, using, selling, offering for
457
+ sale, or importing the Program or any portion of it.
458
+
459
+ 11. Patents.
460
+
461
+ A "contributor" is a copyright holder who authorizes use under this
462
+ License of the Program or a work on which the Program is based. The
463
+ work thus licensed is called the contributor's "contributor version".
464
+
465
+ A contributor's "essential patent claims" are all patent claims
466
+ owned or controlled by the contributor, whether already acquired or
467
+ hereafter acquired, that would be infringed by some manner, permitted
468
+ by this License, of making, using, or selling its contributor version,
469
+ but do not include claims that would be infringed only as a
470
+ consequence of further modification of the contributor version. For
471
+ purposes of this definition, "control" includes the right to grant
472
+ patent sublicenses in a manner consistent with the requirements of
473
+ this License.
474
+
475
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
476
+ patent license under the contributor's essential patent claims, to
477
+ make, use, sell, offer for sale, import and otherwise run, modify and
478
+ propagate the contents of its contributor version.
479
+
480
+ In the following three paragraphs, a "patent license" is any express
481
+ agreement or commitment, however denominated, not to enforce a patent
482
+ (such as an express permission to practice a patent or covenant not to
483
+ sue for patent infringement). To "grant" such a patent license to a
484
+ party means to make such an agreement or commitment not to enforce a
485
+ patent against the party.
486
+
487
+ If you convey a covered work, knowingly relying on a patent license,
488
+ and the Corresponding Source of the work is not available for anyone
489
+ to copy, free of charge and under the terms of this License, through a
490
+ publicly available network server or other readily accessible means,
491
+ then you must either (1) cause the Corresponding Source to be so
492
+ available, or (2) arrange to deprive yourself of the benefit of the
493
+ patent license for this particular work, or (3) arrange, in a manner
494
+ consistent with the requirements of this License, to extend the patent
495
+ license to downstream recipients. "Knowingly relying" means you have
496
+ actual knowledge that, but for the patent license, your conveying the
497
+ covered work in a country, or your recipient's use of the covered work
498
+ in a country, would infringe one or more identifiable patents in that
499
+ country that you have reason to believe are valid.
500
+
501
+ If, pursuant to or in connection with a single transaction or
502
+ arrangement, you convey, or propagate by procuring conveyance of, a
503
+ covered work, and grant a patent license to some of the parties
504
+ receiving the covered work authorizing them to use, propagate, modify
505
+ or convey a specific copy of the covered work, then the patent license
506
+ you grant is automatically extended to all recipients of the covered
507
+ work and works based on it.
508
+
509
+ A patent license is "discriminatory" if it does not include within
510
+ the scope of its coverage, prohibits the exercise of, or is
511
+ conditioned on the non-exercise of one or more of the rights that are
512
+ specifically granted under this License. You may not convey a covered
513
+ work if you are a party to an arrangement with a third party that is
514
+ in the business of distributing software, under which you make payment
515
+ to the third party based on the extent of your activity of conveying
516
+ the work, and under which the third party grants, to any of the
517
+ parties who would receive the covered work from you, a discriminatory
518
+ patent license (a) in connection with copies of the covered work
519
+ conveyed by you (or copies made from those copies), or (b) primarily
520
+ for and in connection with specific products or compilations that
521
+ contain the covered work, unless you entered into that arrangement,
522
+ or that patent license was granted, prior to 28 March 2007.
523
+
524
+ Nothing in this License shall be construed as excluding or limiting
525
+ any implied license or other defenses to infringement that may
526
+ otherwise be available to you under applicable patent law.
527
+
528
+ 12. No Surrender of Others' Freedom.
529
+
530
+ If conditions are imposed on you (whether by court order, agreement or
531
+ otherwise) that contradict the conditions of this License, they do not
532
+ excuse you from the conditions of this License. If you cannot convey a
533
+ covered work so as to satisfy simultaneously your obligations under this
534
+ License and any other pertinent obligations, then as a consequence you may
535
+ not convey it at all. For example, if you agree to terms that obligate you
536
+ to collect a royalty for further conveying from those to whom you convey
537
+ the Program, the only way you could satisfy both those terms and this
538
+ License would be to refrain entirely from conveying the Program.
539
+
540
+ 13. Remote Network Interaction; Use with the GNU General Public License.
541
+
542
+ Notwithstanding any other provision of this License, if you modify the
543
+ Program, your modified version must prominently offer all users
544
+ interacting with it remotely through a computer network (if your version
545
+ supports such interaction) an opportunity to receive the Corresponding
546
+ Source of your version by providing access to the Corresponding Source
547
+ from a network server at no charge, through some standard or customary
548
+ means of facilitating copying of software. This Corresponding Source
549
+ shall include the Corresponding Source for any work covered by version 3
550
+ of the GNU General Public License that is incorporated pursuant to the
551
+ following paragraph.
552
+
553
+ Notwithstanding any other provision of this License, you have
554
+ permission to link or combine any covered work with a work licensed
555
+ under version 3 of the GNU General Public License into a single
556
+ combined work, and to convey the resulting work. The terms of this
557
+ License will continue to apply to the part which is the covered work,
558
+ but the work with which it is combined will remain governed by version
559
+ 3 of the GNU General Public License.
560
+
561
+ 14. Revised Versions of this License.
562
+
563
+ The Free Software Foundation may publish revised and/or new versions of
564
+ the GNU Affero General Public License from time to time. Such new versions
565
+ will be similar in spirit to the present version, but may differ in detail to
566
+ address new problems or concerns.
567
+
568
+ Each version is given a distinguishing version number. If the
569
+ Program specifies that a certain numbered version of the GNU Affero General
570
+ Public License "or any later version" applies to it, you have the
571
+ option of following the terms and conditions either of that numbered
572
+ version or of any later version published by the Free Software
573
+ Foundation. If the Program does not specify a version number of the
574
+ GNU Affero General Public License, you may choose any version ever published
575
+ by the Free Software Foundation.
576
+
577
+ If the Program specifies that a proxy can decide which future
578
+ versions of the GNU Affero General Public License can be used, that proxy's
579
+ public statement of acceptance of a version permanently authorizes you
580
+ to choose that version for the Program.
581
+
582
+ Later license versions may give you additional or different
583
+ permissions. However, no additional obligations are imposed on any
584
+ author or copyright holder as a result of your choosing to follow a
585
+ later version.
586
+
587
+ 15. Disclaimer of Warranty.
588
+
589
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
+
598
+ 16. Limitation of Liability.
599
+
600
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608
+ SUCH DAMAGES.
609
+
610
+ 17. Interpretation of Sections 15 and 16.
611
+
612
+ If the disclaimer of warranty and limitation of liability provided
613
+ above cannot be given local legal effect according to their terms,
614
+ reviewing courts shall apply local law that most closely approximates
615
+ an absolute waiver of all civil liability in connection with the
616
+ Program, unless a warranty or assumption of liability accompanies a
617
+ copy of the Program in return for a fee.
618
+
619
+ END OF TERMS AND CONDITIONS
620
+
621
+ How to Apply These Terms to Your New Programs
622
+
623
+ If you develop a new program, and you want it to be of the greatest
624
+ possible use to the public, the best way to achieve this is to make it
625
+ free software which everyone can redistribute and change under these terms.
626
+
627
+ To do so, attach the following notices to the program. It is safest
628
+ to attach them to the start of each source file to most effectively
629
+ state the exclusion of warranty; and each file should have at least
630
+ the "copyright" line and a pointer to where the full notice is found.
631
+
632
+ <one line to give the program's name and a brief idea of what it does.>
633
+ Copyright (C) <year> <name of author>
634
+
635
+ This program is free software: you can redistribute it and/or modify
636
+ it under the terms of the GNU Affero General Public License as published
637
+ by the Free Software Foundation, either version 3 of the License, or
638
+ (at your option) any later version.
639
+
640
+ This program is distributed in the hope that it will be useful,
641
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
642
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643
+ GNU Affero General Public License for more details.
644
+
645
+ You should have received a copy of the GNU Affero General Public License
646
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
647
+
648
+ Also add information on how to contact you by electronic and paper mail.
649
+
650
+ If your software can interact with users remotely through a computer
651
+ network, you should also make sure that it provides a way for users to
652
+ get its source. For example, if your program is a web application, its
653
+ interface could display a "Source" link that leads users to an archive
654
+ of the code. There are many ways you could offer source, and different
655
+ solutions will be better for different programs; see section 13 for the
656
+ specific requirements.
657
+
658
+ You should also get your employer (if you work as a programmer) or school,
659
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
660
+ For more information on this, and how to apply and follow the GNU AGPL, see
661
+ <https://www.gnu.org/licenses/>.
custom_nodes/ComfyUI-Impact-Pack/impact_subpack/README.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ComfyUI-Impact-Subpack
2
+ This extension serves as a complement to the Impact Pack, offering features that are not deemed suitable for inclusion by default in the ComfyUI Impact Pack.
3
+
4
+ The nodes in this repository cannot be used standalone and depend on [ComfyUI-Impact-Pack](https://github.com/ltdrdata/ComfyUI-Impact-Pack).
5
+
6
+ ## Nodes
7
+ * UltralyticsDetectorProvider - This node provides an object detection detector based on Ultralystics.
8
+ * By using this Detector Provider, you can replace the existing mmdet-based detector.
9
+
10
+
11
+ ## Credits
12
+
13
+ ComfyUI/[ComfyUI](https://github.com/comfyanonymous/ComfyUI) - A powerful and modular stable diffusion GUI.
14
+
15
+ Bing-su/[adetailer](https://github.com/Bing-su/adetailer/) - This repository provides an object detection model and features based on Ultralystics.
16
+
17
+ huggingface/Bingsu/[adetailer](https://huggingface.co/Bingsu/adetailer/tree/main) - This repository offers various models based on Ultralystics.
18
+ * You can download other models supported by the UltralyticsDetectorProvider from here.
custom_nodes/ComfyUI-Impact-Pack/impact_subpack/impact/__pycache__/subcore.cpython-310.pyc ADDED
Binary file (5.28 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/impact_subpack/impact/__pycache__/subpack_nodes.cpython-310.pyc ADDED
Binary file (1.89 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/impact_subpack/impact/subcore.py ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ from PIL import Image
3
+
4
+ import impact.core as core
5
+ import cv2
6
+ import numpy as np
7
+ from torchvision.transforms.functional import to_pil_image
8
+ import torch
9
+
10
+ try:
11
+ from ultralytics import YOLO
12
+ except Exception as e:
13
+ print(e)
14
+ print(f"\n!!!!!\n\n[ComfyUI-Impact-Subpack] If this error occurs, please check the following link:\n\thttps://github.com/ltdrdata/ComfyUI-Impact-Pack/blob/Main/troubleshooting/TROUBLESHOOTING.md\n\n!!!!!\n")
15
+ raise e
16
+
17
+
18
+ def load_yolo(model_path: str):
19
+ try:
20
+ return YOLO(model_path)
21
+ except ModuleNotFoundError:
22
+ # https://github.com/ultralytics/ultralytics/issues/3856
23
+ YOLO("yolov8n.pt")
24
+ return YOLO(model_path)
25
+
26
+
27
+ def inference_bbox(
28
+ model,
29
+ image: Image.Image,
30
+ confidence: float = 0.3,
31
+ device: str = "",
32
+ ):
33
+ pred = model(image, conf=confidence, device=device)
34
+
35
+ bboxes = pred[0].boxes.xyxy.cpu().numpy()
36
+ cv2_image = np.array(image)
37
+ if len(cv2_image.shape) == 3:
38
+ cv2_image = cv2_image[:, :, ::-1].copy() # Convert RGB to BGR for cv2 processing
39
+ else:
40
+ # Handle the grayscale image here
41
+ # For example, you might want to convert it to a 3-channel grayscale image for consistency:
42
+ cv2_image = cv2.cvtColor(cv2_image, cv2.COLOR_GRAY2BGR)
43
+ cv2_gray = cv2.cvtColor(cv2_image, cv2.COLOR_BGR2GRAY)
44
+
45
+ segms = []
46
+ for x0, y0, x1, y1 in bboxes:
47
+ cv2_mask = np.zeros(cv2_gray.shape, np.uint8)
48
+ cv2.rectangle(cv2_mask, (int(x0), int(y0)), (int(x1), int(y1)), 255, -1)
49
+ cv2_mask_bool = cv2_mask.astype(bool)
50
+ segms.append(cv2_mask_bool)
51
+
52
+ n, m = bboxes.shape
53
+ if n == 0:
54
+ return [[], [], [], []]
55
+
56
+ results = [[], [], [], []]
57
+ for i in range(len(bboxes)):
58
+ results[0].append(pred[0].names[int(pred[0].boxes[i].cls.item())])
59
+ results[1].append(bboxes[i])
60
+ results[2].append(segms[i])
61
+ results[3].append(pred[0].boxes[i].conf.cpu().numpy())
62
+
63
+ return results
64
+
65
+
66
+ def inference_segm(
67
+ model,
68
+ image: Image.Image,
69
+ confidence: float = 0.3,
70
+ device: str = "",
71
+ ):
72
+ pred = model(image, conf=confidence, device=device)
73
+
74
+ bboxes = pred[0].boxes.xyxy.cpu().numpy()
75
+ n, m = bboxes.shape
76
+ if n == 0:
77
+ return [[], [], [], []]
78
+
79
+ # NOTE: masks.data will be None when n == 0
80
+ segms = pred[0].masks.data.cpu().numpy()
81
+
82
+ h_segms = segms.shape[1]
83
+ w_segms = segms.shape[2]
84
+ h_orig = image.size[1]
85
+ w_orig = image.size[0]
86
+ ratio_segms = h_segms / w_segms
87
+ ratio_orig = h_orig / w_orig
88
+
89
+ if ratio_segms == ratio_orig:
90
+ h_gap = 0
91
+ w_gap = 0
92
+ elif ratio_segms > ratio_orig:
93
+ h_gap = int((ratio_segms - ratio_orig) * h_segms)
94
+ w_gap = 0
95
+ else:
96
+ h_gap = 0
97
+ ratio_segms = w_segms / h_segms
98
+ ratio_orig = w_orig / h_orig
99
+ w_gap = int((ratio_segms - ratio_orig) * w_segms)
100
+
101
+ results = [[], [], [], []]
102
+ for i in range(len(bboxes)):
103
+ results[0].append(pred[0].names[int(pred[0].boxes[i].cls.item())])
104
+ results[1].append(bboxes[i])
105
+
106
+ mask = torch.from_numpy(segms[i])
107
+ mask = mask[h_gap:mask.shape[0] - h_gap, w_gap:mask.shape[1] - w_gap]
108
+
109
+ scaled_mask = torch.nn.functional.interpolate(mask.unsqueeze(0).unsqueeze(0), size=(image.size[1], image.size[0]),
110
+ mode='bilinear', align_corners=False)
111
+ scaled_mask = scaled_mask.squeeze().squeeze()
112
+
113
+ results[2].append(scaled_mask.numpy())
114
+ results[3].append(pred[0].boxes[i].conf.cpu().numpy())
115
+
116
+ return results
117
+
118
+
119
+ class UltraBBoxDetector:
120
+ bbox_model = None
121
+
122
+ def __init__(self, bbox_model):
123
+ self.bbox_model = bbox_model
124
+
125
+ def detect(self, image, threshold, dilation, crop_factor, drop_size=1, detailer_hook=None):
126
+ drop_size = max(drop_size, 1)
127
+ detected_results = inference_bbox(self.bbox_model, core.tensor2pil(image), threshold)
128
+ segmasks = core.create_segmasks(detected_results)
129
+
130
+ if dilation > 0:
131
+ segmasks = core.dilate_masks(segmasks, dilation)
132
+
133
+ items = []
134
+ h = image.shape[1]
135
+ w = image.shape[2]
136
+
137
+ for x, label in zip(segmasks, detected_results[0]):
138
+ item_bbox = x[0]
139
+ item_mask = x[1]
140
+
141
+ y1, x1, y2, x2 = item_bbox
142
+
143
+ if x2 - x1 > drop_size and y2 - y1 > drop_size: # minimum dimension must be (2,2) to avoid squeeze issue
144
+ crop_region = core.make_crop_region(w, h, item_bbox, crop_factor)
145
+
146
+ if detailer_hook is not None:
147
+ crop_region = detailer_hook.post_crop_region(w, h, item_bbox, crop_region)
148
+
149
+ cropped_image = core.crop_image(image, crop_region)
150
+ cropped_mask = core.crop_ndarray2(item_mask, crop_region)
151
+ confidence = x[2]
152
+ # bbox_size = (item_bbox[2]-item_bbox[0],item_bbox[3]-item_bbox[1]) # (w,h)
153
+
154
+ item = core.SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox, label, None)
155
+
156
+ items.append(item)
157
+
158
+ shape = image.shape[1], image.shape[2]
159
+ segs = shape, items
160
+
161
+ if detailer_hook is not None and hasattr(detailer_hook, "post_detection"):
162
+ segs = detailer_hook.post_detection(segs)
163
+
164
+ return segs
165
+
166
+ def detect_combined(self, image, threshold, dilation):
167
+ detected_results = inference_bbox(self.bbox_model, core.tensor2pil(image), threshold)
168
+ segmasks = core.create_segmasks(detected_results)
169
+ if dilation > 0:
170
+ segmasks = core.dilate_masks(segmasks, dilation)
171
+
172
+ return core.combine_masks(segmasks)
173
+
174
+ def setAux(self, x):
175
+ pass
176
+
177
+
178
+ class UltraSegmDetector:
179
+ bbox_model = None
180
+
181
+ def __init__(self, bbox_model):
182
+ self.bbox_model = bbox_model
183
+
184
+ def detect(self, image, threshold, dilation, crop_factor, drop_size=1, detailer_hook=None):
185
+ drop_size = max(drop_size, 1)
186
+ detected_results = inference_segm(self.bbox_model, core.tensor2pil(image), threshold)
187
+ segmasks = core.create_segmasks(detected_results)
188
+
189
+ if dilation > 0:
190
+ segmasks = core.dilate_masks(segmasks, dilation)
191
+
192
+ items = []
193
+ h = image.shape[1]
194
+ w = image.shape[2]
195
+
196
+ for x, label in zip(segmasks, detected_results[0]):
197
+ item_bbox = x[0]
198
+ item_mask = x[1]
199
+
200
+ y1, x1, y2, x2 = item_bbox
201
+
202
+ if x2 - x1 > drop_size and y2 - y1 > drop_size: # minimum dimension must be (2,2) to avoid squeeze issue
203
+ crop_region = core.make_crop_region(w, h, item_bbox, crop_factor)
204
+
205
+ if detailer_hook is not None:
206
+ crop_region = detailer_hook.post_crop_region(w, h, item_bbox, crop_region)
207
+
208
+ cropped_image = core.crop_image(image, crop_region)
209
+ cropped_mask = core.crop_ndarray2(item_mask, crop_region)
210
+ confidence = x[2]
211
+ # bbox_size = (item_bbox[2]-item_bbox[0],item_bbox[3]-item_bbox[1]) # (w,h)
212
+
213
+ item = core.SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox, label, None)
214
+
215
+ items.append(item)
216
+
217
+ shape = image.shape[1], image.shape[2]
218
+ segs = shape, items
219
+
220
+ if detailer_hook is not None and hasattr(detailer_hook, "post_detection"):
221
+ segs = detailer_hook.post_detection(segs)
222
+
223
+ return segs
224
+
225
+ def detect_combined(self, image, threshold, dilation):
226
+ detected_results = inference_segm(self.bbox_model, core.tensor2pil(image), threshold)
227
+ segmasks = core.create_segmasks(detected_results)
228
+ if dilation > 0:
229
+ segmasks = core.dilate_masks(segmasks, dilation)
230
+
231
+ return core.combine_masks(segmasks)
232
+
233
+ def setAux(self, x):
234
+ pass
custom_nodes/ComfyUI-Impact-Pack/impact_subpack/impact/subpack_nodes.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import folder_paths
3
+ import impact.core as core
4
+ import impact.subcore as subcore
5
+ from impact.utils import add_folder_path_and_extensions
6
+
7
+ version_code = 22
8
+
9
+ print(f"### Loading: ComfyUI-Impact-Pack (Subpack: V0.6)")
10
+
11
+ model_path = folder_paths.models_dir
12
+ add_folder_path_and_extensions("ultralytics_bbox", [os.path.join(model_path, "ultralytics", "bbox")], folder_paths.supported_pt_extensions)
13
+ add_folder_path_and_extensions("ultralytics_segm", [os.path.join(model_path, "ultralytics", "segm")], folder_paths.supported_pt_extensions)
14
+ add_folder_path_and_extensions("ultralytics", [os.path.join(model_path, "ultralytics")], folder_paths.supported_pt_extensions)
15
+
16
+
17
+ class UltralyticsDetectorProvider:
18
+ @classmethod
19
+ def INPUT_TYPES(s):
20
+ bboxs = ["bbox/"+x for x in folder_paths.get_filename_list("ultralytics_bbox")]
21
+ segms = ["segm/"+x for x in folder_paths.get_filename_list("ultralytics_segm")]
22
+ return {"required": {"model_name": (bboxs + segms, )}}
23
+ RETURN_TYPES = ("BBOX_DETECTOR", "SEGM_DETECTOR")
24
+ FUNCTION = "doit"
25
+
26
+ CATEGORY = "ImpactPack"
27
+
28
+ def doit(self, model_name):
29
+ model_path = folder_paths.get_full_path("ultralytics", model_name)
30
+ model = subcore.load_yolo(model_path)
31
+
32
+ if model_name.startswith("bbox"):
33
+ return subcore.UltraBBoxDetector(model), core.NO_SEGM_DETECTOR()
34
+ else:
35
+ return subcore.UltraBBoxDetector(model), subcore.UltraSegmDetector(model)
36
+
37
+
38
+ NODE_CLASS_MAPPINGS = {
39
+ "UltralyticsDetectorProvider": UltralyticsDetectorProvider
40
+ }
41
+
42
+
43
+ NODE_DISPLAY_NAME_MAPPINGS = {
44
+
45
+ }
custom_nodes/ComfyUI-Impact-Pack/impact_subpack/install.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ from torchvision.datasets.utils import download_url
4
+
5
+ subpack_path = os.path.join(os.path.dirname(__file__))
6
+
7
+ comfy_path = os.environ.get('COMFYUI_PATH')
8
+ if comfy_path is None:
9
+ print(f"\n[bold yellow]WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `{os.path.dirname(__file__)}/../../../` as the ComfyUI path.[/bold yellow]", file=sys.stderr)
10
+ comfy_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
11
+
12
+ sys.path.append(comfy_path)
13
+
14
+ model_path = os.environ.get('COMFYUI_MODEL_PATH')
15
+ if model_path is None:
16
+ print(f"\n[bold yellow]WARN: The `COMFYUI_MODEL_PATH` environment variable is not set. Assuming `{model_path}` as the ComfyUI path.[/bold yellow]", file=sys.stderr)
17
+ model_path = os.path.abspath(os.path.join(comfy_path, 'models'))
18
+
19
+ ultralytics_bbox_path = os.path.join(model_path, "ultralytics", "bbox")
20
+ ultralytics_segm_path = os.path.join(model_path, "ultralytics", "segm")
21
+
22
+ if not os.path.exists(os.path.join(subpack_path, '..', '..', 'skip_download_model')):
23
+ if not os.path.exists(ultralytics_bbox_path):
24
+ os.makedirs(ultralytics_bbox_path)
25
+
26
+ if not os.path.exists(ultralytics_segm_path):
27
+ os.makedirs(ultralytics_segm_path)
28
+
29
+ if not os.path.exists(os.path.join(ultralytics_bbox_path, "face_yolov8m.pt")):
30
+ download_url("https://huggingface.co/Bingsu/adetailer/resolve/main/face_yolov8m.pt",
31
+ ultralytics_bbox_path)
32
+
33
+ if not os.path.exists(os.path.join(ultralytics_bbox_path, "hand_yolov8s.pt")):
34
+ download_url("https://huggingface.co/Bingsu/adetailer/resolve/main/hand_yolov8s.pt",
35
+ ultralytics_bbox_path)
36
+
37
+ if not os.path.exists(os.path.join(ultralytics_segm_path, "person_yolov8m-seg.pt")):
38
+ download_url("https://huggingface.co/Bingsu/adetailer/resolve/main/person_yolov8m-seg.pt",
39
+ ultralytics_segm_path)
custom_nodes/ComfyUI-Impact-Pack/impact_subpack/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ matplotlib==3.8
2
+ ultralytics!=8.2.5
custom_nodes/ComfyUI-Impact-Pack/install.py ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+ import sys
4
+ import subprocess
5
+ import threading
6
+ import locale
7
+ import traceback
8
+ import re
9
+
10
+
11
+ if sys.argv[0] == 'install.py':
12
+ sys.path.append('.') # for portable version
13
+
14
+
15
+ impact_path = os.path.join(os.path.dirname(__file__), "modules")
16
+ old_subpack_path = os.path.join(os.path.dirname(__file__), "subpack")
17
+ subpack_path = os.path.join(os.path.dirname(__file__), "impact_subpack")
18
+ subpack_repo = "https://github.com/ltdrdata/ComfyUI-Impact-Subpack"
19
+
20
+
21
+ comfy_path = os.environ.get('COMFYUI_PATH')
22
+ if comfy_path is None:
23
+ print(f"\n[bold yellow]WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `{os.path.dirname(__file__)}/../../` as the ComfyUI path.[/bold yellow]", file=sys.stderr)
24
+ comfy_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
25
+
26
+ model_path = os.environ.get('COMFYUI_MODEL_PATH')
27
+ if model_path is None:
28
+ try:
29
+ import folder_paths
30
+ model_path = folder_paths.models_dir
31
+ except:
32
+ pass
33
+
34
+ if model_path is None:
35
+ model_path = os.path.abspath(os.path.join(comfy_path, 'models'))
36
+ print(f"\n[bold yellow]WARN: The `COMFYUI_MODEL_PATH` environment variable is not set. Assuming `{model_path}` as the ComfyUI path.[/bold yellow]", file=sys.stderr)
37
+
38
+
39
+ sys.path.append(impact_path)
40
+ sys.path.append(comfy_path)
41
+
42
+
43
+ # ---
44
+ def handle_stream(stream, is_stdout):
45
+ stream.reconfigure(encoding=locale.getpreferredencoding(), errors='replace')
46
+
47
+ for msg in stream:
48
+ if is_stdout:
49
+ print(msg, end="", file=sys.stdout)
50
+ else:
51
+ print(msg, end="", file=sys.stderr)
52
+
53
+
54
+ def process_wrap(cmd_str, cwd=None, handler=None, env=None):
55
+ print(f"[Impact Pack] EXECUTE: {cmd_str} in '{cwd}'")
56
+ process = subprocess.Popen(cmd_str, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, text=True, bufsize=1)
57
+
58
+ if handler is None:
59
+ handler = handle_stream
60
+
61
+ stdout_thread = threading.Thread(target=handler, args=(process.stdout, True))
62
+ stderr_thread = threading.Thread(target=handler, args=(process.stderr, False))
63
+
64
+ stdout_thread.start()
65
+ stderr_thread.start()
66
+
67
+ stdout_thread.join()
68
+ stderr_thread.join()
69
+
70
+ return process.wait()
71
+ # ---
72
+
73
+
74
+ pip_list = None
75
+
76
+
77
+ def get_installed_packages():
78
+ global pip_list
79
+
80
+ if pip_list is None:
81
+ try:
82
+ result = subprocess.check_output([sys.executable, '-m', 'pip', 'list'], universal_newlines=True)
83
+ pip_list = set([line.split()[0].lower() for line in result.split('\n') if line.strip()])
84
+ except subprocess.CalledProcessError as e:
85
+ print(f"[ComfyUI-Manager] Failed to retrieve the information of installed pip packages.")
86
+ return set()
87
+
88
+ return pip_list
89
+
90
+
91
+ def is_installed(name):
92
+ name = name.strip()
93
+ pattern = r'([^<>!=]+)([<>!=]=?)'
94
+ match = re.search(pattern, name)
95
+
96
+ if match:
97
+ name = match.group(1)
98
+
99
+ result = name.lower() in get_installed_packages()
100
+ return result
101
+
102
+
103
+ def is_requirements_installed(file_path):
104
+ print(f"req_path: {file_path}")
105
+ if os.path.exists(file_path):
106
+ with open(file_path, 'r') as file:
107
+ lines = file.readlines()
108
+ for line in lines:
109
+ if not is_installed(line):
110
+ return False
111
+
112
+ return True
113
+
114
+ try:
115
+ import platform
116
+ from torchvision.datasets.utils import download_url
117
+ import impact.config
118
+
119
+
120
+ print("### ComfyUI-Impact-Pack: Check dependencies")
121
+
122
+ if "python_embeded" in sys.executable or "python_embedded" in sys.executable:
123
+ pip_install = [sys.executable, '-s', '-m', 'pip', 'install']
124
+ pip_upgrade = [sys.executable, '-s', '-m', 'pip', 'install', '-U']
125
+ mim_install = [sys.executable, '-s', '-m', 'mim', 'install']
126
+ else:
127
+ pip_install = [sys.executable, '-m', 'pip', 'install']
128
+ pip_upgrade = [sys.executable, '-m', 'pip', 'install', '-U']
129
+ mim_install = [sys.executable, '-m', 'mim', 'install']
130
+
131
+
132
+ def ensure_subpack():
133
+ import git
134
+ if os.path.exists(subpack_path):
135
+ try:
136
+ repo = git.Repo(subpack_path)
137
+ repo.remotes.origin.pull()
138
+ except:
139
+ traceback.print_exc()
140
+ if platform.system() == 'Windows':
141
+ print(f"[ComfyUI-Impact-Pack] Please turn off ComfyUI and remove '{subpack_path}' and restart ComfyUI.")
142
+ else:
143
+ shutil.rmtree(subpack_path)
144
+ git.Repo.clone_from(subpack_repo, subpack_path)
145
+ else:
146
+ git.Repo.clone_from(subpack_repo, subpack_path)
147
+
148
+ if os.path.exists(old_subpack_path):
149
+ shutil.rmtree(old_subpack_path)
150
+
151
+
152
+ def ensure_pip_packages_first():
153
+ subpack_req = os.path.join(subpack_path, "requirements.txt")
154
+ if os.path.exists(subpack_req) and not is_requirements_installed(subpack_req):
155
+ process_wrap(pip_install + ['-r', 'requirements.txt'], cwd=subpack_path)
156
+
157
+ if not impact.config.get_config()['mmdet_skip']:
158
+ process_wrap(pip_install + ['openmim'])
159
+
160
+ try:
161
+ import pycocotools
162
+ except Exception:
163
+ if platform.system() not in ["Windows"] or platform.machine() not in ["AMD64", "x86_64"]:
164
+ print(f"Your system is {platform.system()}; !! You need to install 'libpython3-dev' for this step. !!")
165
+
166
+ process_wrap(pip_install + ['pycocotools'])
167
+ else:
168
+ pycocotools = {
169
+ (3, 8): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp38-cp38-win_amd64.whl",
170
+ (3, 9): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp39-cp39-win_amd64.whl",
171
+ (3, 10): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp310-cp310-win_amd64.whl",
172
+ (3, 11): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp311-cp311-win_amd64.whl",
173
+ }
174
+
175
+ version = sys.version_info[:2]
176
+ url = pycocotools[version]
177
+ process_wrap(pip_install + [url])
178
+
179
+
180
+ def ensure_pip_packages_last():
181
+ my_path = os.path.dirname(__file__)
182
+ requirements_path = os.path.join(my_path, "requirements.txt")
183
+
184
+ if not is_requirements_installed(requirements_path):
185
+ process_wrap(pip_install + ['-r', requirements_path])
186
+
187
+ # fallback
188
+ try:
189
+ import segment_anything
190
+ from skimage.measure import label, regionprops
191
+ import piexif
192
+ except Exception:
193
+ process_wrap(pip_install + ['-r', requirements_path])
194
+
195
+ # !! cv2 importing test must be very last !!
196
+ try:
197
+ from cv2 import setNumThreads
198
+ except Exception:
199
+ try:
200
+ is_open_cv_installed = False
201
+
202
+ # upgrade if opencv is installed already
203
+ if is_installed('opencv-python'):
204
+ process_wrap(pip_upgrade + ['opencv-python'])
205
+ is_open_cv_installed = True
206
+
207
+ if is_installed('opencv-python-headless'):
208
+ process_wrap(pip_upgrade + ['opencv-python-headless'])
209
+ is_open_cv_installed = True
210
+
211
+ if is_installed('opencv-contrib-python'):
212
+ process_wrap(pip_upgrade + ['opencv-contrib-python'])
213
+ is_open_cv_installed = True
214
+
215
+ if is_installed('opencv-contrib-python-headless'):
216
+ process_wrap(pip_upgrade + ['opencv-contrib-python-headless'])
217
+ is_open_cv_installed = True
218
+
219
+ # if opencv is not installed install `opencv-python-headless`
220
+ if not is_open_cv_installed:
221
+ process_wrap(pip_install + ['opencv-python-headless'])
222
+ except:
223
+ print(f"[ERROR] ComfyUI-Impact-Pack: failed to install 'opencv-python'. Please, install manually.")
224
+
225
+ def ensure_mmdet_package():
226
+ try:
227
+ import mmcv
228
+ import mmdet
229
+ from mmdet.evaluation import get_classes
230
+ except Exception:
231
+ process_wrap(pip_install + ['opendatalab==0.0.9'])
232
+ process_wrap(pip_install + ['-U', 'openmim'])
233
+ process_wrap(mim_install + ['mmcv>=2.0.0rc4, <2.1.0'])
234
+ process_wrap(mim_install + ['mmdet==3.0.0'])
235
+ process_wrap(mim_install + ['mmengine==0.7.4'])
236
+
237
+
238
+ def install():
239
+ subpack_install_script = os.path.join(subpack_path, "install.py")
240
+
241
+ print(f"### ComfyUI-Impact-Pack: Updating subpack")
242
+ try:
243
+ import git
244
+ except Exception:
245
+ if not is_installed('GitPython'):
246
+ process_wrap(pip_install + ['GitPython'])
247
+
248
+ ensure_subpack() # The installation of the subpack must take place before ensure_pip. cv2 triggers a permission error.
249
+
250
+ new_env = os.environ.copy()
251
+ new_env["COMFYUI_PATH"] = comfy_path
252
+ new_env["COMFYUI_MODEL_PATH"] = model_path
253
+
254
+ if os.path.exists(subpack_install_script):
255
+ process_wrap([sys.executable, 'install.py'], cwd=subpack_path, env=new_env)
256
+ if not is_requirements_installed(os.path.join(subpack_path, 'requirements.txt')):
257
+ process_wrap(pip_install + ['-r', 'requirements.txt'], cwd=subpack_path)
258
+ else:
259
+ print(f"### ComfyUI-Impact-Pack: (Install Failed) Subpack\nFile not found: `{subpack_install_script}`")
260
+
261
+ ensure_pip_packages_first()
262
+
263
+ if not impact.config.get_config()['mmdet_skip']:
264
+ ensure_mmdet_package()
265
+
266
+ ensure_pip_packages_last()
267
+
268
+ # Download model
269
+ print("### ComfyUI-Impact-Pack: Check basic models")
270
+ bbox_path = os.path.join(model_path, "mmdets", "bbox")
271
+ sam_path = os.path.join(model_path, "sams")
272
+ onnx_path = os.path.join(model_path, "onnx")
273
+
274
+ if not os.path.exists(os.path.join(os.path.dirname(__file__), '..', 'skip_download_model')):
275
+ if not os.path.exists(bbox_path):
276
+ os.makedirs(bbox_path)
277
+
278
+ if not impact.config.get_config()['mmdet_skip']:
279
+ if not os.path.exists(os.path.join(bbox_path, "mmdet_anime-face_yolov3.pth")):
280
+ download_url("https://huggingface.co/dustysys/ddetailer/resolve/main/mmdet/bbox/mmdet_anime-face_yolov3.pth", bbox_path)
281
+
282
+ if not os.path.exists(os.path.join(bbox_path, "mmdet_anime-face_yolov3.py")):
283
+ download_url("https://raw.githubusercontent.com/Bing-su/dddetailer/master/config/mmdet_anime-face_yolov3.py", bbox_path)
284
+
285
+ if not os.path.exists(os.path.join(sam_path, "sam_vit_b_01ec64.pth")):
286
+ download_url("https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth", sam_path)
287
+
288
+ if not os.path.exists(onnx_path):
289
+ print(f"### ComfyUI-Impact-Pack: onnx model directory created ({onnx_path})")
290
+ os.mkdir(onnx_path)
291
+
292
+ impact.config.write_config()
293
+
294
+
295
+ install()
296
+
297
+ except Exception as e:
298
+ print("[ERROR] ComfyUI-Impact-Pack: Dependency installation has failed. Please install manually.")
299
+ traceback.print_exc()
custom_nodes/ComfyUI-Impact-Pack/js/comboBoolMigration.js ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComfyApp, app } from "../../scripts/app.js";
2
+
3
+ let conflict_check = undefined;
4
+
5
+ app.registerExtension({
6
+ name: "Comfy.impact.comboBoolMigration",
7
+
8
+ nodeCreated(node, app) {
9
+ for(let i in node.widgets) {
10
+ let widget = node.widgets[i];
11
+
12
+ if(conflict_check == undefined) {
13
+ conflict_check = !!app.extensions.find((ext) => ext.name === "Comfy.comboBoolMigration");
14
+ }
15
+
16
+ if(conflict_check)
17
+ return;
18
+
19
+ if(widget.type == "toggle") {
20
+ let value = widget.value;
21
+
22
+ var v = Object.getOwnPropertyDescriptor(widget, 'value');
23
+ if(!v) {
24
+ Object.defineProperty(widget, "value", {
25
+ set: (value) => {
26
+ delete widget.value;
27
+ widget.value = value == true || value == widget.options.on;
28
+ },
29
+ get: () => { return value; }
30
+ });
31
+ }
32
+ }
33
+ }
34
+ }
35
+ });
custom_nodes/ComfyUI-Impact-Pack/js/common.js ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { api } from "../../scripts/api.js";
2
+ import { app } from "../../scripts/app.js";
3
+
4
+ let original_show = app.ui.dialog.show;
5
+
6
+ function dialog_show_wrapper(html) {
7
+ if (typeof html === "string") {
8
+ if(html.includes("IMPACT-PACK-SIGNAL: STOP CONTROL BRIDGE")) {
9
+ return;
10
+ }
11
+
12
+ this.textElement.innerHTML = html;
13
+ } else {
14
+ this.textElement.replaceChildren(html);
15
+ }
16
+ this.element.style.display = "flex";
17
+ }
18
+
19
+ app.ui.dialog.show = dialog_show_wrapper;
20
+
21
+
22
+ function nodeFeedbackHandler(event) {
23
+ let nodes = app.graph._nodes_by_id;
24
+ let node = nodes[event.detail.node_id];
25
+ if(node) {
26
+ const w = node.widgets.find((w) => event.detail.widget_name === w.name);
27
+ if(w) {
28
+ w.value = event.detail.value;
29
+ }
30
+ }
31
+ }
32
+
33
+ api.addEventListener("impact-node-feedback", nodeFeedbackHandler);
34
+
35
+
36
+ function setMuteState(event) {
37
+ let nodes = app.graph._nodes_by_id;
38
+ let node = nodes[event.detail.node_id];
39
+ if(node) {
40
+ if(event.detail.is_active)
41
+ node.mode = 0;
42
+ else
43
+ node.mode = 2;
44
+ }
45
+ }
46
+
47
+ api.addEventListener("impact-node-mute-state", setMuteState);
48
+
49
+
50
+ async function bridgeContinue(event) {
51
+ let nodes = app.graph._nodes_by_id;
52
+ let node = nodes[event.detail.node_id];
53
+ if(node) {
54
+ const mutes = new Set(event.detail.mutes);
55
+ const actives = new Set(event.detail.actives);
56
+ const bypasses = new Set(event.detail.bypasses);
57
+
58
+ for(let i in app.graph._nodes_by_id) {
59
+ let this_node = app.graph._nodes_by_id[i];
60
+ if(mutes.has(i)) {
61
+ this_node.mode = 2;
62
+ }
63
+ else if(actives.has(i)) {
64
+ this_node.mode = 0;
65
+ }
66
+ else if(bypasses.has(i)) {
67
+ this_node.mode = 4;
68
+ }
69
+ }
70
+
71
+ await app.queuePrompt(0, 1);
72
+ }
73
+ }
74
+
75
+ api.addEventListener("impact-bridge-continue", bridgeContinue);
76
+
77
+
78
+ function addQueue(event) {
79
+ app.queuePrompt(0, 1);
80
+ }
81
+
82
+ api.addEventListener("impact-add-queue", addQueue);
83
+
84
+
85
+ function refreshPreview(event) {
86
+ let node_id = event.detail.node_id;
87
+ let item = event.detail.item;
88
+ let img = new Image();
89
+ img.src = `/view?filename=${item.filename}&subfolder=${item.subfolder}&type=${item.type}&no-cache=${Date.now()}`;
90
+ let node = app.graph._nodes_by_id[node_id];
91
+ if(node)
92
+ node.imgs = [img];
93
+ }
94
+
95
+ api.addEventListener("impact-preview", refreshPreview);
custom_nodes/ComfyUI-Impact-Pack/js/impact-image-util.js ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComfyApp, app } from "../../scripts/app.js";
2
+ import { api } from "../../scripts/api.js";
3
+
4
+ function load_image(str) {
5
+ let base64String = canvas.toDataURL('image/png');
6
+ let img = new Image();
7
+ img.src = base64String;
8
+ }
9
+
10
+ function getFileItem(baseType, path) {
11
+ try {
12
+ let pathType = baseType;
13
+
14
+ if (path.endsWith("[output]")) {
15
+ pathType = "output";
16
+ path = path.slice(0, -9);
17
+ } else if (path.endsWith("[input]")) {
18
+ pathType = "input";
19
+ path = path.slice(0, -8);
20
+ } else if (path.endsWith("[temp]")) {
21
+ pathType = "temp";
22
+ path = path.slice(0, -7);
23
+ }
24
+
25
+ const subfolder = path.substring(0, path.lastIndexOf('/'));
26
+ const filename = path.substring(path.lastIndexOf('/') + 1);
27
+
28
+ return {
29
+ filename: filename,
30
+ subfolder: subfolder,
31
+ type: pathType
32
+ };
33
+ }
34
+ catch(exception) {
35
+ return null;
36
+ }
37
+ }
38
+
39
+ async function loadImageFromUrl(image, node_id, v, need_to_load) {
40
+ let item = getFileItem('temp', v);
41
+
42
+ if(item) {
43
+ let params = `?node_id=${node_id}&filename=${item.filename}&type=${item.type}&subfolder=${item.subfolder}`;
44
+
45
+ let res = await api.fetchApi('/impact/set/pb_id_image'+params, { cache: "no-store" });
46
+ if(res.status == 200) {
47
+ let pb_id = await res.text();
48
+ if(need_to_load) {;
49
+ image.src = api.apiURL(`/view?filename=${item.filename}&type=${item.type}&subfolder=${item.subfolder}`);
50
+ }
51
+ return pb_id;
52
+ }
53
+ else {
54
+ return `$${node_id}-0`;
55
+ }
56
+ }
57
+ else {
58
+ return `$${node_id}-0`;
59
+ }
60
+ }
61
+
62
+ async function loadImageFromId(image, v) {
63
+ let res = await api.fetchApi('/impact/get/pb_id_image?id='+v, { cache: "no-store" });
64
+ if(res.status == 200) {
65
+ let item = await res.json();
66
+ image.src = api.apiURL(`/view?filename=${item.filename}&type=${item.type}&subfolder=${item.subfolder}`);
67
+ return true;
68
+ }
69
+
70
+ return false;
71
+ }
72
+
73
+ app.registerExtension({
74
+ name: "Comfy.Impact.img",
75
+
76
+ nodeCreated(node, app) {
77
+ if(node.comfyClass == "PreviewBridge" || node.comfyClass == "PreviewBridgeLatent") {
78
+ let w = node.widgets.find(obj => obj.name === 'image');
79
+ node._imgs = [new Image()];
80
+ node.imageIndex = 0;
81
+
82
+ Object.defineProperty(w, 'value', {
83
+ async set(v) {
84
+ if(w._lock)
85
+ return;
86
+
87
+ const stackTrace = new Error().stack;
88
+ if(stackTrace.includes('presetText.js'))
89
+ return;
90
+
91
+ var image = new Image();
92
+ if(v && v.constructor == String && v.startsWith('$')) {
93
+ // from node feedback
94
+ let need_to_load = node._imgs[0].src == '';
95
+ if(await loadImageFromId(image, v, need_to_load)) {
96
+ w._value = v;
97
+ if(node._imgs[0].src == '') {
98
+ node._imgs = [image];
99
+ }
100
+ }
101
+ else {
102
+ w._value = `$${node.id}-0`;
103
+ }
104
+ }
105
+ else {
106
+ // from clipspace
107
+ w._lock = true;
108
+ w._value = await loadImageFromUrl(image, node.id, v, false);
109
+ w._lock = false;
110
+ }
111
+ },
112
+ get() {
113
+ if(w._value == undefined) {
114
+ w._value = `$${node.id}-0`;
115
+ }
116
+ return w._value;
117
+ }
118
+ });
119
+
120
+ Object.defineProperty(node, 'imgs', {
121
+ set(v) {
122
+ const stackTrace = new Error().stack;
123
+ if(v && v.length == 0)
124
+ return;
125
+ else if(stackTrace.includes('pasteFromClipspace')) {
126
+ let sp = new URLSearchParams(v[0].src.split("?")[1]);
127
+ let str = "";
128
+ if(sp.get('subfolder')) {
129
+ str += sp.get('subfolder') + '/';
130
+ }
131
+ str += `${sp.get("filename")} [${sp.get("type")}]`;
132
+
133
+ w.value = str;
134
+ }
135
+
136
+ node._imgs = v;
137
+ },
138
+ get() {
139
+ return node._imgs;
140
+ }
141
+ });
142
+ }
143
+
144
+ if(node.comfyClass == "ImageReceiver") {
145
+ let path_widget = node.widgets.find(obj => obj.name === 'image');
146
+ let w = node.widgets.find(obj => obj.name === 'image_data');
147
+ let stw_widget = node.widgets.find(obj => obj.name === 'save_to_workflow');
148
+ w._value = "";
149
+
150
+ Object.defineProperty(w, 'value', {
151
+ set(v) {
152
+ if(v != '[IMAGE DATA]')
153
+ w._value = v;
154
+ },
155
+ get() {
156
+ const stackTrace = new Error().stack;
157
+ if(!stackTrace.includes('draw') && !stackTrace.includes('graphToPrompt') && stackTrace.includes('app.js')) {
158
+ return "[IMAGE DATA]";
159
+ }
160
+ else {
161
+ if(stw_widget.value)
162
+ return w._value;
163
+ else
164
+ return "";
165
+ }
166
+ }
167
+ });
168
+
169
+ let set_img_act = (v) => {
170
+ node._img = v;
171
+ var canvas = document.createElement('canvas');
172
+ canvas.width = v[0].width;
173
+ canvas.height = v[0].height;
174
+
175
+ var context = canvas.getContext('2d');
176
+ context.drawImage(v[0], 0, 0, v[0].width, v[0].height);
177
+
178
+ var base64Image = canvas.toDataURL('image/png');
179
+ w.value = base64Image;
180
+ };
181
+
182
+ Object.defineProperty(node, 'imgs', {
183
+ set(v) {
184
+ if (v && !v[0].complete) {
185
+ let orig_onload = v[0].onload;
186
+ v[0].onload = function(v2) {
187
+ if(orig_onload)
188
+ orig_onload();
189
+ set_img_act(v);
190
+ };
191
+ }
192
+ else {
193
+ set_img_act(v);
194
+ }
195
+ },
196
+ get() {
197
+ if(this._img == undefined && w.value != '') {
198
+ this._img = [new Image()];
199
+ if(stw_widget.value && w.value != '[IMAGE DATA]')
200
+ this._img[0].src = w.value;
201
+ }
202
+ else if(this._img == undefined && path_widget.value) {
203
+ let image = new Image();
204
+ image.src = path_widget.value;
205
+
206
+ try {
207
+ let item = getFileItem('temp', path_widget.value);
208
+ let params = `?filename=${item.filename}&type=${item.type}&subfolder=${item.subfolder}`;
209
+
210
+ let res = api.fetchApi('/view/validate'+params, { cache: "no-store" }).then(response => response);
211
+ if(res.status == 200) {
212
+ image.src = api.apiURL('/view'+params);
213
+ }
214
+
215
+ this._img = [new Image()]; // placeholder
216
+ image.onload = function(v) {
217
+ set_img_act([image]);
218
+ };
219
+ }
220
+ catch {
221
+
222
+ }
223
+ }
224
+ return this._img;
225
+ }
226
+ });
227
+ }
228
+ }
229
+ })
custom_nodes/ComfyUI-Impact-Pack/js/impact-pack.js ADDED
@@ -0,0 +1,815 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComfyApp, app } from "../../scripts/app.js";
2
+ import { ComfyDialog, $el } from "../../scripts/ui.js";
3
+ import { api } from "../../scripts/api.js";
4
+
5
+ let wildcards_list = [];
6
+ async function load_wildcards() {
7
+ let res = await api.fetchApi('/impact/wildcards/list');
8
+ let data = await res.json();
9
+ wildcards_list = data.data;
10
+ }
11
+
12
+ load_wildcards();
13
+
14
+ export function get_wildcards_list() {
15
+ return wildcards_list;
16
+ }
17
+
18
+ // temporary implementation (copying from https://github.com/pythongosssss/ComfyUI-WD14-Tagger)
19
+ // I think this should be included into master!!
20
+ class ImpactProgressBadge {
21
+ constructor() {
22
+ if (!window.__progress_badge__) {
23
+ window.__progress_badge__ = Symbol("__impact_progress_badge__");
24
+ }
25
+ this.symbol = window.__progress_badge__;
26
+ }
27
+
28
+ getState(node) {
29
+ return node[this.symbol] || {};
30
+ }
31
+
32
+ setState(node, state) {
33
+ node[this.symbol] = state;
34
+ app.canvas.setDirty(true);
35
+ }
36
+
37
+ addStatusHandler(nodeType) {
38
+ if (nodeType[this.symbol]?.statusTagHandler) {
39
+ return;
40
+ }
41
+ if (!nodeType[this.symbol]) {
42
+ nodeType[this.symbol] = {};
43
+ }
44
+ nodeType[this.symbol] = {
45
+ statusTagHandler: true,
46
+ };
47
+
48
+ api.addEventListener("impact/update_status", ({ detail }) => {
49
+ let { node, progress, text } = detail;
50
+ const n = app.graph.getNodeById(+(node || app.runningNodeId));
51
+ if (!n) return;
52
+ const state = this.getState(n);
53
+ state.status = Object.assign(state.status || {}, { progress: text ? progress : null, text: text || null });
54
+ this.setState(n, state);
55
+ });
56
+
57
+ const self = this;
58
+ const onDrawForeground = nodeType.prototype.onDrawForeground;
59
+ nodeType.prototype.onDrawForeground = function (ctx) {
60
+ const r = onDrawForeground?.apply?.(this, arguments);
61
+ const state = self.getState(this);
62
+ if (!state?.status?.text) {
63
+ return r;
64
+ }
65
+
66
+ const { fgColor, bgColor, text, progress, progressColor } = { ...state.status };
67
+
68
+ ctx.save();
69
+ ctx.font = "12px sans-serif";
70
+ const sz = ctx.measureText(text);
71
+ ctx.fillStyle = bgColor || "dodgerblue";
72
+ ctx.beginPath();
73
+ ctx.roundRect(0, -LiteGraph.NODE_TITLE_HEIGHT - 20, sz.width + 12, 20, 5);
74
+ ctx.fill();
75
+
76
+ if (progress) {
77
+ ctx.fillStyle = progressColor || "green";
78
+ ctx.beginPath();
79
+ ctx.roundRect(0, -LiteGraph.NODE_TITLE_HEIGHT - 20, (sz.width + 12) * progress, 20, 5);
80
+ ctx.fill();
81
+ }
82
+
83
+ ctx.fillStyle = fgColor || "#fff";
84
+ ctx.fillText(text, 6, -LiteGraph.NODE_TITLE_HEIGHT - 6);
85
+ ctx.restore();
86
+ return r;
87
+ };
88
+ }
89
+ }
90
+
91
+ const input_tracking = {};
92
+ const input_dirty = {};
93
+ const output_tracking = {};
94
+
95
+ function progressExecuteHandler(event) {
96
+ if(event.detail.output.aux){
97
+ const id = event.detail.node;
98
+ if(input_tracking.hasOwnProperty(id)) {
99
+ if(input_tracking.hasOwnProperty(id) && input_tracking[id][0] != event.detail.output.aux[0]) {
100
+ input_dirty[id] = true;
101
+ }
102
+ else{
103
+
104
+ }
105
+ }
106
+
107
+ input_tracking[id] = event.detail.output.aux;
108
+ }
109
+ }
110
+
111
+ function imgSendHandler(event) {
112
+ if(event.detail.images.length > 0){
113
+ let data = event.detail.images[0];
114
+ let filename = `${data.filename} [${data.type}]`;
115
+
116
+ let nodes = app.graph._nodes;
117
+ for(let i in nodes) {
118
+ if(nodes[i].type == 'ImageReceiver') {
119
+ let is_linked = false;
120
+
121
+ if(nodes[i].widgets[1].type == 'converted-widget') {
122
+ for(let j in nodes[i].inputs) {
123
+ let input = nodes[i].inputs[j];
124
+ if(input.name === 'link_id') {
125
+ if(input.link) {
126
+ let src_node = app.graph._nodes_by_id[app.graph.links[input.link].origin_id];
127
+ if(src_node.type == 'ImpactInt' || src_node.type == 'PrimitiveNode') {
128
+ is_linked = true;
129
+ }
130
+ }
131
+ break;
132
+ }
133
+ }
134
+ }
135
+ else if(nodes[i].widgets[1].value == event.detail.link_id) {
136
+ is_linked = true;
137
+ }
138
+
139
+ if(is_linked) {
140
+ if(data.subfolder)
141
+ nodes[i].widgets[0].value = `${data.subfolder}/${data.filename} [${data.type}]`;
142
+ else
143
+ nodes[i].widgets[0].value = `${data.filename} [${data.type}]`;
144
+
145
+ let img = new Image();
146
+ img.onload = (event) => {
147
+ nodes[i].imgs = [img];
148
+ nodes[i].size[1] = Math.max(200, nodes[i].size[1]);
149
+ app.canvas.setDirty(true);
150
+ };
151
+ img.src = `/view?filename=${data.filename}&type=${data.type}&subfolder=${data.subfolder}`+app.getPreviewFormatParam();
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+
158
+
159
+ function latentSendHandler(event) {
160
+ if(event.detail.images.length > 0){
161
+ let data = event.detail.images[0];
162
+ let filename = `${data.filename} [${data.type}]`;
163
+
164
+ let nodes = app.graph._nodes;
165
+ for(let i in nodes) {
166
+ if(nodes[i].type == 'LatentReceiver') {
167
+ if(nodes[i].widgets[1].value == event.detail.link_id) {
168
+ if(data.subfolder)
169
+ nodes[i].widgets[0].value = `${data.subfolder}/${data.filename} [${data.type}]`;
170
+ else
171
+ nodes[i].widgets[0].value = `${data.filename} [${data.type}]`;
172
+
173
+ let img = new Image();
174
+ img.src = `/view?filename=${data.filename}&type=${data.type}&subfolder=${data.subfolder}`+app.getPreviewFormatParam();
175
+ nodes[i].imgs = [img];
176
+ nodes[i].size[1] = Math.max(200, nodes[i].size[1]);
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
182
+
183
+
184
+ function valueSendHandler(event) {
185
+ let nodes = app.graph._nodes;
186
+ for(let i in nodes) {
187
+ if(nodes[i].type == 'ImpactValueReceiver') {
188
+ if(nodes[i].widgets[2].value == event.detail.link_id) {
189
+ nodes[i].widgets[1].value = event.detail.value;
190
+
191
+ let typ = typeof event.detail.value;
192
+ if(typ == 'string') {
193
+ nodes[i].widgets[0].value = "STRING";
194
+ }
195
+ else if(typ == "boolean") {
196
+ nodes[i].widgets[0].value = "BOOLEAN";
197
+ }
198
+ else if(typ != "number") {
199
+ nodes[i].widgets[0].value = typeof event.detail.value;
200
+ }
201
+ else if(Number.isInteger(event.detail.value)) {
202
+ nodes[i].widgets[0].value = "INT";
203
+ }
204
+ else {
205
+ nodes[i].widgets[0].value = "FLOAT";
206
+ }
207
+ }
208
+ }
209
+ }
210
+ }
211
+
212
+
213
+ const impactProgressBadge = new ImpactProgressBadge();
214
+
215
+ api.addEventListener("stop-iteration", () => {
216
+ document.getElementById("autoQueueCheckbox").checked = false;
217
+ });
218
+ api.addEventListener("value-send", valueSendHandler);
219
+ api.addEventListener("img-send", imgSendHandler);
220
+ api.addEventListener("latent-send", latentSendHandler);
221
+ api.addEventListener("executed", progressExecuteHandler);
222
+
223
+ app.registerExtension({
224
+ name: "Comfy.Impack",
225
+ loadedGraphNode(node, app) {
226
+ if (node.comfyClass == "MaskPainter") {
227
+ input_dirty[node.id + ""] = true;
228
+ }
229
+ },
230
+
231
+ async beforeRegisterNodeDef(nodeType, nodeData, app) {
232
+ if (nodeData.name == "IterativeLatentUpscale" || nodeData.name == "IterativeImageUpscale"
233
+ || nodeData.name == "RegionalSampler"|| nodeData.name == "RegionalSamplerAdvanced") {
234
+ impactProgressBadge.addStatusHandler(nodeType);
235
+ }
236
+
237
+ if(nodeData.name == "ImpactControlBridge") {
238
+ const onConnectionsChange = nodeType.prototype.onConnectionsChange;
239
+ nodeType.prototype.onConnectionsChange = function (type, index, connected, link_info) {
240
+ if(!link_info || this.inputs[0].type != '*')
241
+ return;
242
+
243
+ // assign type
244
+ let slot_type = '*';
245
+
246
+ if(type == 2) {
247
+ slot_type = link_info.type;
248
+ }
249
+ else {
250
+ const node = app.graph.getNodeById(link_info.origin_id);
251
+ slot_type = node.outputs[link_info.origin_slot].type;
252
+ }
253
+
254
+ this.inputs[0].type = slot_type;
255
+ this.outputs[0].type = slot_type;
256
+ this.outputs[0].label = slot_type;
257
+ }
258
+ }
259
+
260
+ if(nodeData.name == "ImpactConditionalBranch" || nodeData.name == "ImpactConditionalBranchSelMode") {
261
+ const onConnectionsChange = nodeType.prototype.onConnectionsChange;
262
+ nodeType.prototype.onConnectionsChange = function (type, index, connected, link_info) {
263
+ if(!link_info || this.inputs[0].type != '*')
264
+ return;
265
+
266
+ if(index >= 2)
267
+ return;
268
+
269
+ // assign type
270
+ let slot_type = '*';
271
+
272
+ if(type == 2) {
273
+ slot_type = link_info.type;
274
+ }
275
+ else {
276
+ const node = app.graph.getNodeById(link_info.origin_id);
277
+ slot_type = node.outputs[link_info.origin_slot].type;
278
+ }
279
+
280
+ this.inputs[0].type = slot_type;
281
+ this.inputs[1].type = slot_type;
282
+ this.outputs[0].type = slot_type;
283
+ this.outputs[0].label = slot_type;
284
+ }
285
+ }
286
+
287
+ if(nodeData.name == "ImpactCompare") {
288
+ const onConnectionsChange = nodeType.prototype.onConnectionsChange;
289
+ nodeType.prototype.onConnectionsChange = function (type, index, connected, link_info) {
290
+ if(!link_info || this.inputs[0].type != '*' || type == 2)
291
+ return;
292
+
293
+ // assign type
294
+ const node = app.graph.getNodeById(link_info.origin_id);
295
+ let slot_type = node.outputs[link_info.origin_slot].type;
296
+
297
+ this.inputs[0].type = slot_type;
298
+ this.inputs[1].type = slot_type;
299
+ }
300
+ }
301
+
302
+ if(nodeData.name === 'ImpactInversedSwitch') {
303
+ nodeData.output = ['*'];
304
+ nodeData.output_is_list = [false];
305
+ nodeData.output_name = ['output1'];
306
+
307
+ const onConnectionsChange = nodeType.prototype.onConnectionsChange;
308
+ nodeType.prototype.onConnectionsChange = function (type, index, connected, link_info) {
309
+ if(!link_info)
310
+ return;
311
+
312
+ if(type == 2) {
313
+ // connect output
314
+ if(connected){
315
+ if(app.graph._nodes_by_id[link_info.target_id].type == 'Reroute') {
316
+ app.graph._nodes_by_id[link_info.target_id].disconnectInput(link_info.target_slot);
317
+ }
318
+
319
+ if(this.outputs[0].type == '*'){
320
+ if(link_info.type == '*') {
321
+ app.graph._nodes_by_id[link_info.target_id].disconnectInput(link_info.target_slot);
322
+ }
323
+ else {
324
+ // propagate type
325
+ this.outputs[0].type = link_info.type;
326
+ this.outputs[0].name = link_info.type;
327
+
328
+ for(let i in this.inputs) {
329
+ if(this.inputs[i].name != 'select')
330
+ this.inputs[i].type = link_info.type;
331
+ }
332
+ }
333
+ }
334
+ }
335
+ }
336
+ else {
337
+ if(app.graph._nodes_by_id[link_info.origin_id].type == 'Reroute')
338
+ this.disconnectInput(link_info.target_slot);
339
+
340
+ // connect input
341
+ if(this.inputs[0].type == '*'){
342
+ const node = app.graph.getNodeById(link_info.origin_id);
343
+ let origin_type = node.outputs[link_info.origin_slot].type;
344
+
345
+ if(origin_type == '*') {
346
+ this.disconnectInput(link_info.target_slot);
347
+ return;
348
+ }
349
+
350
+ for(let i in this.inputs) {
351
+ if(this.inputs[i].name != 'select')
352
+ this.inputs[i].type = origin_type;
353
+ }
354
+
355
+ this.outputs[0].type = origin_type;
356
+ this.outputs[0].name = origin_type;
357
+ }
358
+
359
+ return;
360
+ }
361
+
362
+ if (!connected && this.outputs.length > 1) {
363
+ const stackTrace = new Error().stack;
364
+
365
+ if(
366
+ !stackTrace.includes('LGraphNode.prototype.connect') && // for touch device
367
+ !stackTrace.includes('LGraphNode.connect') && // for mouse device
368
+ !stackTrace.includes('loadGraphData')) {
369
+ if(this.outputs[link_info.origin_slot].links.length == 0)
370
+ this.removeOutput(link_info.origin_slot);
371
+ }
372
+ }
373
+
374
+ let slot_i = 1;
375
+ for (let i = 0; i < this.outputs.length; i++) {
376
+ this.outputs[i].name = `output${slot_i}`
377
+ slot_i++;
378
+ }
379
+
380
+ let last_slot = this.outputs[this.outputs.length - 1];
381
+ if (last_slot.slot_index == link_info.origin_slot) {
382
+ this.addOutput(`output${slot_i}`, this.outputs[0].type);
383
+ }
384
+
385
+ let select_slot = this.inputs.find(x => x.name == "select");
386
+ if(this.widgets) {
387
+ this.widgets[0].options.max = select_slot?this.outputs.length-1:this.outputs.length;
388
+ this.widgets[0].value = Math.min(this.widgets[0].value, this.widgets[0].options.max);
389
+ if(this.widgets[0].options.max > 0 && this.widgets[0].value == 0)
390
+ this.widgets[0].value = 1;
391
+ }
392
+ }
393
+ }
394
+
395
+ if (nodeData.name === 'ImpactMakeImageList' || nodeData.name === 'ImpactMakeImageBatch' ||
396
+ nodeData.name === 'CombineRegionalPrompts' ||
397
+ nodeData.name === 'ImpactCombineConditionings' || nodeData.name === 'ImpactConcatConditionings' ||
398
+ nodeData.name === 'ImpactSEGSConcat' ||
399
+ nodeData.name === 'ImpactSwitch' || nodeData.name === 'LatentSwitch' || nodeData.name == 'SEGSSwitch') {
400
+ var input_name = "input";
401
+
402
+ switch(nodeData.name) {
403
+ case 'ImpactMakeImageList':
404
+ case 'ImpactMakeImageBatch':
405
+ input_name = "image";
406
+ break;
407
+
408
+ case 'ImpactSEGSConcat':
409
+ input_name = "segs";
410
+ break;
411
+
412
+ case 'CombineRegionalPrompts':
413
+ input_name = "regional_prompts";
414
+ break;
415
+
416
+ case 'ImpactCombineConditionings':
417
+ case 'ImpactConcatConditionings':
418
+ input_name = "conditioning";
419
+ break;
420
+
421
+ case 'LatentSwitch':
422
+ input_name = "input";
423
+ break;
424
+
425
+ case 'SEGSSwitch':
426
+ input_name = "input";
427
+ break;
428
+
429
+ case 'ImpactSwitch':
430
+ input_name = "input";
431
+ }
432
+
433
+ const onConnectionsChange = nodeType.prototype.onConnectionsChange;
434
+ nodeType.prototype.onConnectionsChange = function (type, index, connected, link_info) {
435
+ if(!link_info)
436
+ return;
437
+
438
+ if(type == 2) {
439
+ // connect output
440
+ if(connected && index == 0){
441
+ if(nodeData.name == 'ImpactSwitch' && app.graph._nodes_by_id[link_info.target_id]?.type == 'Reroute') {
442
+ app.graph._nodes_by_id[link_info.target_id].disconnectInput(link_info.target_slot);
443
+ }
444
+
445
+ if(this.outputs[0].type == '*'){
446
+ if(link_info.type == '*') {
447
+ app.graph._nodes_by_id[link_info.target_id].disconnectInput(link_info.target_slot);
448
+ }
449
+ else {
450
+ // propagate type
451
+ this.outputs[0].type = link_info.type;
452
+ this.outputs[0].label = link_info.type;
453
+ this.outputs[0].name = link_info.type;
454
+
455
+ for(let i in this.inputs) {
456
+ let input_i = this.inputs[i];
457
+ if(input_i.name != 'select' && input_i.name != 'sel_mode')
458
+ input_i.type = link_info.type;
459
+ }
460
+ }
461
+ }
462
+ }
463
+
464
+ return;
465
+ }
466
+ else {
467
+ if(nodeData.name == 'ImpactSwitch' && app.graph._nodes_by_id[link_info.origin_id].type == 'Reroute')
468
+ this.disconnectInput(link_info.target_slot);
469
+
470
+ // connect input
471
+ if(this.inputs[index].name == 'select' || this.inputs[index].name == 'sel_mode')
472
+ return;
473
+
474
+ if(this.inputs[0].type == '*'){
475
+ const node = app.graph.getNodeById(link_info.origin_id);
476
+ let origin_type = node.outputs[link_info.origin_slot].type;
477
+
478
+ if(origin_type == '*') {
479
+ this.disconnectInput(link_info.target_slot);
480
+ return;
481
+ }
482
+
483
+ for(let i in this.inputs) {
484
+ let input_i = this.inputs[i];
485
+ if(input_i.name != 'select' && input_i.name != 'sel_mode')
486
+ input_i.type = origin_type;
487
+ }
488
+
489
+ this.outputs[0].type = origin_type;
490
+ this.outputs[0].label = origin_type;
491
+ this.outputs[0].name = origin_type;
492
+ }
493
+ }
494
+
495
+ let select_slot = this.inputs.find(x => x.name == "select");
496
+ let mode_slot = this.inputs.find(x => x.name == "sel_mode");
497
+
498
+ let converted_count = 0;
499
+ converted_count += select_slot?1:0;
500
+ converted_count += mode_slot?1:0;
501
+
502
+ if (!connected && (this.inputs.length > 1+converted_count)) {
503
+ const stackTrace = new Error().stack;
504
+
505
+ if(
506
+ !stackTrace.includes('LGraphNode.prototype.connect') && // for touch device
507
+ !stackTrace.includes('LGraphNode.connect') && // for mouse device
508
+ !stackTrace.includes('loadGraphData') &&
509
+ this.inputs[index].name != 'select') {
510
+ this.removeInput(index);
511
+ }
512
+ }
513
+
514
+ let slot_i = 1;
515
+ for (let i = 0; i < this.inputs.length; i++) {
516
+ let input_i = this.inputs[i];
517
+ if(input_i.name != 'select'&& input_i.name != 'sel_mode') {
518
+ input_i.name = `${input_name}${slot_i}`
519
+ slot_i++;
520
+ }
521
+ }
522
+
523
+ let last_slot = this.inputs[this.inputs.length - 1];
524
+ if (
525
+ (last_slot.name == 'select' && last_slot.name != 'sel_mode' && this.inputs[this.inputs.length - 2].link != undefined)
526
+ || (last_slot.name != 'select' && last_slot.name != 'sel_mode' && last_slot.link != undefined)) {
527
+ this.addInput(`${input_name}${slot_i}`, this.outputs[0].type);
528
+ }
529
+
530
+ if(this.widgets) {
531
+ this.widgets[0].options.max = select_slot?this.inputs.length-1:this.inputs.length;
532
+ this.widgets[0].value = Math.min(this.widgets[0].value, this.widgets[0].options.max);
533
+ if(this.widgets[0].options.max > 0 && this.widgets[0].value == 0)
534
+ this.widgets[0].value = 1;
535
+ }
536
+ }
537
+ }
538
+ },
539
+
540
+ nodeCreated(node, app) {
541
+ if(node.comfyClass == "MaskPainter") {
542
+ node.addWidget("button", "Edit mask", null, () => {
543
+ ComfyApp.copyToClipspace(node);
544
+ ComfyApp.clipspace_return_node = node;
545
+ ComfyApp.open_maskeditor();
546
+ });
547
+ }
548
+
549
+ switch(node.comfyClass) {
550
+ case "ToDetailerPipe":
551
+ case "ToDetailerPipeSDXL":
552
+ case "BasicPipeToDetailerPipe":
553
+ case "BasicPipeToDetailerPipeSDXL":
554
+ case "EditDetailerPipe":
555
+ case "FaceDetailer":
556
+ case "DetailerForEach":
557
+ case "DetailerForEachDebug":
558
+ case "DetailerForEachPipe":
559
+ case "DetailerForEachDebugPipe":
560
+ {
561
+ for(let i in node.widgets) {
562
+ let widget = node.widgets[i];
563
+ if(widget.type === "customtext") {
564
+ widget.dynamicPrompts = false;
565
+ widget.inputEl.placeholder = "wildcard spec: if kept empty, this option will be ignored";
566
+ widget.serializeValue = () => {
567
+ return node.widgets[i].value;
568
+ };
569
+ }
570
+ }
571
+ }
572
+ break;
573
+ }
574
+
575
+ if(node.comfyClass == "ImpactSEGSLabelFilter" || node.comfyClass == "SEGSLabelFilterDetailerHookProvider") {
576
+ Object.defineProperty(node.widgets[0], "value", {
577
+ set: (value) => {
578
+ const stackTrace = new Error().stack;
579
+ if(stackTrace.includes('inner_value_change')) {
580
+ if(node.widgets[1].value.trim() != "" && !node.widgets[1].value.trim().endsWith(","))
581
+ node.widgets[1].value += ", "
582
+
583
+ node.widgets[1].value += value;
584
+ node.widgets_values[1] = node.widgets[1].value;
585
+ }
586
+
587
+ node._value = value;
588
+ },
589
+ get: () => {
590
+ return node._value;
591
+ }
592
+ });
593
+ }
594
+
595
+ if(node.comfyClass == "UltralyticsDetectorProvider") {
596
+ let model_name_widget = node.widgets.find((w) => w.name === "model_name");
597
+ let orig_draw = node.onDrawForeground;
598
+ node.onDrawForeground = function (ctx) {
599
+ const r = orig_draw?.apply?.(this, arguments);
600
+
601
+ let is_seg = model_name_widget.value?.startsWith('segm/') || model_name_widget.value?.includes('-seg');
602
+ if(!is_seg) {
603
+ var slot_pos = new Float32Array(2);
604
+ var pos = node.getConnectionPos(false, 1, slot_pos);
605
+
606
+ pos[0] -= node.pos[0] - 10;
607
+ pos[1] -= node.pos[1];
608
+
609
+ ctx.beginPath();
610
+ ctx.strokeStyle = "red";
611
+ ctx.lineWidth = 4;
612
+ ctx.moveTo(pos[0] - 5, pos[1] - 5);
613
+ ctx.lineTo(pos[0] + 5, pos[1] + 5);
614
+ ctx.moveTo(pos[0] + 5, pos[1] - 5);
615
+ ctx.lineTo(pos[0] - 5, pos[1] + 5);
616
+ ctx.stroke();
617
+ }
618
+ }
619
+ }
620
+
621
+ if(
622
+ node.comfyClass == "ImpactWildcardEncode" || node.comfyClass == "ImpactWildcardProcessor"
623
+ || node.comfyClass == "ToDetailerPipe" || node.comfyClass == "ToDetailerPipeSDXL"
624
+ || node.comfyClass == "EditDetailerPipe" || node.comfyClass == "EditDetailerPipeSDXL"
625
+ || node.comfyClass == "BasicPipeToDetailerPipe" || node.comfyClass == "BasicPipeToDetailerPipeSDXL") {
626
+ node._value = "Select the LoRA to add to the text";
627
+ node._wvalue = "Select the Wildcard to add to the text";
628
+
629
+ var tbox_id = 0;
630
+ var combo_id = 3;
631
+ var has_lora = true;
632
+
633
+ switch(node.comfyClass){
634
+ case "ImpactWildcardEncode":
635
+ tbox_id = 0;
636
+ combo_id = 3;
637
+ break;
638
+
639
+ case "ImpactWildcardProcessor":
640
+ tbox_id = 0;
641
+ combo_id = 4;
642
+ has_lora = false;
643
+ break;
644
+
645
+ case "ToDetailerPipe":
646
+ case "ToDetailerPipeSDXL":
647
+ case "EditDetailerPipe":
648
+ case "EditDetailerPipeSDXL":
649
+ case "BasicPipeToDetailerPipe":
650
+ case "BasicPipeToDetailerPipeSDXL":
651
+ tbox_id = 0;
652
+ combo_id = 1;
653
+ break;
654
+ }
655
+
656
+ Object.defineProperty(node.widgets[combo_id+1], "value", {
657
+ set: (value) => {
658
+ const stackTrace = new Error().stack;
659
+ if(stackTrace.includes('inner_value_change')) {
660
+ if(value != "Select the Wildcard to add to the text") {
661
+ if(node.widgets[tbox_id].value != '')
662
+ node.widgets[tbox_id].value += ', '
663
+
664
+ node.widgets[tbox_id].value += value;
665
+ }
666
+ }
667
+ },
668
+ get: () => { return "Select the Wildcard to add to the text"; }
669
+ });
670
+
671
+ Object.defineProperty(node.widgets[combo_id+1].options, "values", {
672
+ set: (x) => {},
673
+ get: () => {
674
+ return wildcards_list;
675
+ }
676
+ });
677
+
678
+ if(has_lora) {
679
+ Object.defineProperty(node.widgets[combo_id], "value", {
680
+ set: (value) => {
681
+ const stackTrace = new Error().stack;
682
+ if(stackTrace.includes('inner_value_change')) {
683
+ if(value != "Select the LoRA to add to the text") {
684
+ let lora_name = value;
685
+ if (lora_name.endsWith('.safetensors')) {
686
+ lora_name = lora_name.slice(0, -12);
687
+ }
688
+
689
+ node.widgets[tbox_id].value += `<lora:${lora_name}>`;
690
+ if(node.widgets_values) {
691
+ node.widgets_values[tbox_id] = node.widgets[tbox_id].value;
692
+ }
693
+ }
694
+ }
695
+
696
+ node._value = value;
697
+ },
698
+
699
+ get: () => { return "Select the LoRA to add to the text"; }
700
+ });
701
+ }
702
+
703
+ // Preventing validation errors from occurring in any situation.
704
+ if(has_lora) {
705
+ node.widgets[combo_id].serializeValue = () => { return "Select the LoRA to add to the text"; }
706
+ }
707
+ node.widgets[combo_id+1].serializeValue = () => { return "Select the Wildcard to add to the text"; }
708
+ }
709
+
710
+ if(node.comfyClass == "ImpactWildcardProcessor" || node.comfyClass == "ImpactWildcardEncode") {
711
+ node.widgets[0].inputEl.placeholder = "Wildcard Prompt (User input)";
712
+ node.widgets[1].inputEl.placeholder = "Populated Prompt (Will be generated automatically)";
713
+ node.widgets[1].inputEl.disabled = true;
714
+
715
+ const populated_text_widget = node.widgets.find((w) => w.name == 'populated_text');
716
+ const mode_widget = node.widgets.find((w) => w.name == 'mode');
717
+
718
+ // mode combo
719
+ Object.defineProperty(mode_widget, "value", {
720
+ set: (value) => {
721
+ node._mode_value = value == true || value == "Populate";
722
+ populated_text_widget.inputEl.disabled = value == true || value == "Populate";
723
+ },
724
+ get: () => {
725
+ if(node._mode_value != undefined)
726
+ return node._mode_value;
727
+ else
728
+ return true;
729
+ }
730
+ });
731
+ }
732
+
733
+ if (node.comfyClass == "MaskPainter") {
734
+ node.widgets[0].value = '#placeholder';
735
+
736
+ Object.defineProperty(node, "images", {
737
+ set: function(value) {
738
+ node._images = value;
739
+ },
740
+ get: function() {
741
+ const id = node.id+"";
742
+ if(node.widgets[0].value != '#placeholder') {
743
+ var need_invalidate = false;
744
+
745
+ if(input_dirty.hasOwnProperty(id) && input_dirty[id]) {
746
+ node.widgets[0].value = {...input_tracking[id][1]};
747
+ input_dirty[id] = false;
748
+ need_invalidate = true
749
+ this._images = app.nodeOutputs[id].images;
750
+ }
751
+
752
+ let filename = app.nodeOutputs[id]['aux'][1][0]['filename'];
753
+ let subfolder = app.nodeOutputs[id]['aux'][1][0]['subfolder'];
754
+ let type = app.nodeOutputs[id]['aux'][1][0]['type'];
755
+
756
+ let item =
757
+ {
758
+ image_hash: app.nodeOutputs[id]['aux'][0],
759
+ forward_filename: app.nodeOutputs[id]['aux'][1][0]['filename'],
760
+ forward_subfolder: app.nodeOutputs[id]['aux'][1][0]['subfolder'],
761
+ forward_type: app.nodeOutputs[id]['aux'][1][0]['type']
762
+ };
763
+
764
+ if(node._images) {
765
+ app.nodeOutputs[id].images = [{
766
+ ...node._images[0],
767
+ ...item
768
+ }];
769
+
770
+ node.widgets[0].value =
771
+ {
772
+ ...node._images[0],
773
+ ...item
774
+ };
775
+ }
776
+ else {
777
+ app.nodeOutputs[id].images = [{
778
+ ...item
779
+ }];
780
+
781
+ node.widgets[0].value =
782
+ {
783
+ ...item
784
+ };
785
+ }
786
+
787
+ if(need_invalidate) {
788
+ Promise.all(
789
+ app.nodeOutputs[id].images.map((src) => {
790
+ return new Promise((r) => {
791
+ const img = new Image();
792
+ img.onload = () => r(img);
793
+ img.onerror = () => r(null);
794
+ img.src = "/view?" + new URLSearchParams(src).toString();
795
+ });
796
+ })
797
+ ).then((imgs) => {
798
+ this.imgs = imgs.filter(Boolean);
799
+ this.setSizeForImage?.();
800
+ app.graph.setDirtyCanvas(true);
801
+ });
802
+
803
+ app.nodeOutputs[id].images[0] = { ...node.widgets[0].value };
804
+ }
805
+
806
+ return app.nodeOutputs[id].images;
807
+ }
808
+ else {
809
+ return node._images;
810
+ }
811
+ }
812
+ });
813
+ }
814
+ }
815
+ });
custom_nodes/ComfyUI-Impact-Pack/js/impact-sam-editor.js ADDED
@@ -0,0 +1,637 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { app } from "../../scripts/app.js";
2
+ import { api } from "../../scripts/api.js";
3
+ import { ComfyDialog, $el } from "../../scripts/ui.js";
4
+ import { ComfyApp } from "../../scripts/app.js";
5
+ import { ClipspaceDialog } from "../../extensions/core/clipspace.js";
6
+
7
+ function addMenuHandler(nodeType, cb) {
8
+ const getOpts = nodeType.prototype.getExtraMenuOptions;
9
+ nodeType.prototype.getExtraMenuOptions = function () {
10
+ const r = getOpts.apply(this, arguments);
11
+ cb.apply(this, arguments);
12
+ return r;
13
+ };
14
+ }
15
+
16
+ // Helper function to convert a data URL to a Blob object
17
+ function dataURLToBlob(dataURL) {
18
+ const parts = dataURL.split(';base64,');
19
+ const contentType = parts[0].split(':')[1];
20
+ const byteString = atob(parts[1]);
21
+ const arrayBuffer = new ArrayBuffer(byteString.length);
22
+ const uint8Array = new Uint8Array(arrayBuffer);
23
+ for (let i = 0; i < byteString.length; i++) {
24
+ uint8Array[i] = byteString.charCodeAt(i);
25
+ }
26
+ return new Blob([arrayBuffer], { type: contentType });
27
+ }
28
+
29
+ function loadedImageToBlob(image) {
30
+ const canvas = document.createElement('canvas');
31
+
32
+ canvas.width = image.width;
33
+ canvas.height = image.height;
34
+
35
+ const ctx = canvas.getContext('2d');
36
+
37
+ ctx.drawImage(image, 0, 0);
38
+
39
+ const dataURL = canvas.toDataURL('image/png', 1);
40
+ const blob = dataURLToBlob(dataURL);
41
+
42
+ return blob;
43
+ }
44
+
45
+ async function uploadMask(filepath, formData) {
46
+ await api.fetchApi('/upload/mask', {
47
+ method: 'POST',
48
+ body: formData
49
+ }).then(response => {}).catch(error => {
50
+ console.error('Error:', error);
51
+ });
52
+
53
+ ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']] = new Image();
54
+ ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src = `view?filename=${filepath.filename}&type=${filepath.type}`;
55
+
56
+ if(ComfyApp.clipspace.images)
57
+ ComfyApp.clipspace.images[ComfyApp.clipspace['selectedIndex']] = filepath;
58
+
59
+ ClipspaceDialog.invalidatePreview();
60
+ }
61
+
62
+ class ImpactSamEditorDialog extends ComfyDialog {
63
+ static instance = null;
64
+
65
+ static getInstance() {
66
+ if(!ImpactSamEditorDialog.instance) {
67
+ ImpactSamEditorDialog.instance = new ImpactSamEditorDialog();
68
+ }
69
+
70
+ return ImpactSamEditorDialog.instance;
71
+ }
72
+
73
+ constructor() {
74
+ super();
75
+ this.element = $el("div.comfy-modal", { parent: document.body },
76
+ [ $el("div.comfy-modal-content",
77
+ [...this.createButtons()]),
78
+ ]);
79
+ }
80
+
81
+ createButtons() {
82
+ return [];
83
+ }
84
+
85
+ createButton(name, callback) {
86
+ var button = document.createElement("button");
87
+ button.innerText = name;
88
+ button.addEventListener("click", callback);
89
+ return button;
90
+ }
91
+
92
+ createLeftButton(name, callback) {
93
+ var button = this.createButton(name, callback);
94
+ button.style.cssFloat = "left";
95
+ button.style.marginRight = "4px";
96
+ return button;
97
+ }
98
+
99
+ createRightButton(name, callback) {
100
+ var button = this.createButton(name, callback);
101
+ button.style.cssFloat = "right";
102
+ button.style.marginLeft = "4px";
103
+ return button;
104
+ }
105
+
106
+ createLeftSlider(self, name, callback) {
107
+ const divElement = document.createElement('div');
108
+ divElement.id = "sam-confidence-slider";
109
+ divElement.style.cssFloat = "left";
110
+ divElement.style.fontFamily = "sans-serif";
111
+ divElement.style.marginRight = "4px";
112
+ divElement.style.color = "var(--input-text)";
113
+ divElement.style.backgroundColor = "var(--comfy-input-bg)";
114
+ divElement.style.borderRadius = "8px";
115
+ divElement.style.borderColor = "var(--border-color)";
116
+ divElement.style.borderStyle = "solid";
117
+ divElement.style.fontSize = "15px";
118
+ divElement.style.height = "21px";
119
+ divElement.style.padding = "1px 6px";
120
+ divElement.style.display = "flex";
121
+ divElement.style.position = "relative";
122
+ divElement.style.top = "2px";
123
+ self.confidence_slider_input = document.createElement('input');
124
+ self.confidence_slider_input.setAttribute('type', 'range');
125
+ self.confidence_slider_input.setAttribute('min', '0');
126
+ self.confidence_slider_input.setAttribute('max', '100');
127
+ self.confidence_slider_input.setAttribute('value', '70');
128
+ const labelElement = document.createElement("label");
129
+ labelElement.textContent = name;
130
+
131
+ divElement.appendChild(labelElement);
132
+ divElement.appendChild(self.confidence_slider_input);
133
+
134
+ self.confidence_slider_input.addEventListener("change", callback);
135
+
136
+ return divElement;
137
+ }
138
+
139
+ async detect_and_invalidate_mask_canvas(self) {
140
+ const mask_img = await self.detect(self);
141
+
142
+ const canvas = self.maskCtx.canvas;
143
+ const ctx = self.maskCtx;
144
+
145
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
146
+
147
+ await new Promise((resolve, reject) => {
148
+ self.mask_image = new Image();
149
+ self.mask_image.onload = function() {
150
+ ctx.drawImage(self.mask_image, 0, 0, canvas.width, canvas.height);
151
+ resolve();
152
+ };
153
+ self.mask_image.onerror = reject;
154
+ self.mask_image.src = mask_img.src;
155
+ });
156
+ }
157
+
158
+ setlayout(imgCanvas, maskCanvas, pointsCanvas) {
159
+ const self = this;
160
+
161
+ // If it is specified as relative, using it only as a hidden placeholder for padding is recommended
162
+ // to prevent anomalies where it exceeds a certain size and goes outside of the window.
163
+ var placeholder = document.createElement("div");
164
+ placeholder.style.position = "relative";
165
+ placeholder.style.height = "50px";
166
+
167
+ var bottom_panel = document.createElement("div");
168
+ bottom_panel.style.position = "absolute";
169
+ bottom_panel.style.bottom = "0px";
170
+ bottom_panel.style.left = "20px";
171
+ bottom_panel.style.right = "20px";
172
+ bottom_panel.style.height = "50px";
173
+
174
+ var brush = document.createElement("div");
175
+ brush.id = "sam-brush";
176
+ brush.style.backgroundColor = "blue";
177
+ brush.style.outline = "2px solid pink";
178
+ brush.style.borderRadius = "50%";
179
+ brush.style.MozBorderRadius = "50%";
180
+ brush.style.WebkitBorderRadius = "50%";
181
+ brush.style.position = "absolute";
182
+ brush.style.zIndex = 100;
183
+ brush.style.pointerEvents = "none";
184
+ this.brush = brush;
185
+ this.element.appendChild(imgCanvas);
186
+ this.element.appendChild(maskCanvas);
187
+ this.element.appendChild(pointsCanvas);
188
+ this.element.appendChild(placeholder); // must below z-index than bottom_panel to avoid covering button
189
+ this.element.appendChild(bottom_panel);
190
+ document.body.appendChild(brush);
191
+ this.brush_size = 5;
192
+
193
+ var confidence_slider = this.createLeftSlider(self, "Confidence", (event) => {
194
+ self.confidence = event.target.value;
195
+ });
196
+
197
+ var clearButton = this.createLeftButton("Clear", () => {
198
+ self.maskCtx.clearRect(0, 0, self.maskCanvas.width, self.maskCanvas.height);
199
+ self.pointsCtx.clearRect(0, 0, self.pointsCanvas.width, self.pointsCanvas.height);
200
+
201
+ self.prompt_points = [];
202
+
203
+ self.invalidatePointsCanvas(self);
204
+ });
205
+
206
+ var detectButton = this.createLeftButton("Detect", () => self.detect_and_invalidate_mask_canvas(self));
207
+
208
+ var cancelButton = this.createRightButton("Cancel", () => {
209
+ document.removeEventListener("mouseup", ImpactSamEditorDialog.handleMouseUp);
210
+ document.removeEventListener("keydown", ImpactSamEditorDialog.handleKeyDown);
211
+ self.close();
212
+ });
213
+
214
+ self.saveButton = this.createRightButton("Save", () => {
215
+ document.removeEventListener("mouseup", ImpactSamEditorDialog.handleMouseUp);
216
+ document.removeEventListener("keydown", ImpactSamEditorDialog.handleKeyDown);
217
+ self.save(self);
218
+ });
219
+
220
+ var undoButton = this.createLeftButton("Undo", () => {
221
+ if(self.prompt_points.length > 0) {
222
+ self.prompt_points.pop();
223
+ self.pointsCtx.clearRect(0, 0, self.pointsCanvas.width, self.pointsCanvas.height);
224
+ self.invalidatePointsCanvas(self);
225
+ }
226
+ });
227
+
228
+ bottom_panel.appendChild(clearButton);
229
+ bottom_panel.appendChild(detectButton);
230
+ bottom_panel.appendChild(self.saveButton);
231
+ bottom_panel.appendChild(cancelButton);
232
+ bottom_panel.appendChild(confidence_slider);
233
+ bottom_panel.appendChild(undoButton);
234
+
235
+ imgCanvas.style.position = "relative";
236
+ imgCanvas.style.top = "200";
237
+ imgCanvas.style.left = "0";
238
+
239
+ maskCanvas.style.position = "absolute";
240
+ maskCanvas.style.opacity = 0.5;
241
+ pointsCanvas.style.position = "absolute";
242
+ }
243
+
244
+ show() {
245
+ this.mask_image = null;
246
+ self.prompt_points = [];
247
+
248
+ this.message_box = $el("p", ["Please wait a moment while the SAM model and the image are being loaded."]);
249
+ this.element.appendChild(this.message_box);
250
+
251
+ if(self.imgCtx) {
252
+ self.imgCtx.clearRect(0, 0, self.imageCanvas.width, self.imageCanvas.height);
253
+ }
254
+
255
+ const target_image_path = ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src;
256
+ this.load_sam(target_image_path);
257
+
258
+ if(!this.is_layout_created) {
259
+ // layout
260
+ const imgCanvas = document.createElement('canvas');
261
+ const maskCanvas = document.createElement('canvas');
262
+ const pointsCanvas = document.createElement('canvas');
263
+
264
+ imgCanvas.id = "imageCanvas";
265
+ maskCanvas.id = "maskCanvas";
266
+ pointsCanvas.id = "pointsCanvas";
267
+
268
+ this.setlayout(imgCanvas, maskCanvas, pointsCanvas);
269
+
270
+ // prepare content
271
+ this.imgCanvas = imgCanvas;
272
+ this.maskCanvas = maskCanvas;
273
+ this.pointsCanvas = pointsCanvas;
274
+ this.maskCtx = maskCanvas.getContext('2d');
275
+ this.pointsCtx = pointsCanvas.getContext('2d');
276
+
277
+ this.is_layout_created = true;
278
+
279
+ // replacement of onClose hook since close is not real close
280
+ const self = this;
281
+ const observer = new MutationObserver(function(mutations) {
282
+ mutations.forEach(function(mutation) {
283
+ if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
284
+ if(self.last_display_style && self.last_display_style != 'none' && self.element.style.display == 'none') {
285
+ ComfyApp.onClipspaceEditorClosed();
286
+ }
287
+
288
+ self.last_display_style = self.element.style.display;
289
+ }
290
+ });
291
+ });
292
+
293
+ const config = { attributes: true };
294
+ observer.observe(this.element, config);
295
+ }
296
+
297
+ this.setImages(target_image_path, this.imgCanvas, this.pointsCanvas);
298
+
299
+ if(ComfyApp.clipspace_return_node) {
300
+ this.saveButton.innerText = "Save to node";
301
+ }
302
+ else {
303
+ this.saveButton.innerText = "Save";
304
+ }
305
+ this.saveButton.disabled = true;
306
+
307
+ this.element.style.display = "block";
308
+ this.element.style.zIndex = 8888; // NOTE: alert dialog must be high priority.
309
+ }
310
+
311
+ updateBrushPreview(self, event) {
312
+ event.preventDefault();
313
+
314
+ const centerX = event.pageX;
315
+ const centerY = event.pageY;
316
+
317
+ const brush = self.brush;
318
+
319
+ brush.style.width = self.brush_size * 2 + "px";
320
+ brush.style.height = self.brush_size * 2 + "px";
321
+ brush.style.left = (centerX - self.brush_size) + "px";
322
+ brush.style.top = (centerY - self.brush_size) + "px";
323
+ }
324
+
325
+ setImages(target_image_path, imgCanvas, pointsCanvas) {
326
+ const imgCtx = imgCanvas.getContext('2d');
327
+ const maskCtx = this.maskCtx;
328
+ const maskCanvas = this.maskCanvas;
329
+
330
+ const self = this;
331
+
332
+ // image load
333
+ const orig_image = new Image();
334
+ window.addEventListener("resize", () => {
335
+ // repositioning
336
+ imgCanvas.width = window.innerWidth - 250;
337
+ imgCanvas.height = window.innerHeight - 200;
338
+
339
+ // redraw image
340
+ let drawWidth = orig_image.width;
341
+ let drawHeight = orig_image.height;
342
+
343
+ if (orig_image.width > imgCanvas.width) {
344
+ drawWidth = imgCanvas.width;
345
+ drawHeight = (drawWidth / orig_image.width) * orig_image.height;
346
+ }
347
+
348
+ if (drawHeight > imgCanvas.height) {
349
+ drawHeight = imgCanvas.height;
350
+ drawWidth = (drawHeight / orig_image.height) * orig_image.width;
351
+ }
352
+
353
+ imgCtx.drawImage(orig_image, 0, 0, drawWidth, drawHeight);
354
+
355
+ // update mask
356
+ pointsCanvas.width = drawWidth;
357
+ pointsCanvas.height = drawHeight;
358
+ pointsCanvas.style.top = imgCanvas.offsetTop + "px";
359
+ pointsCanvas.style.left = imgCanvas.offsetLeft + "px";
360
+
361
+ maskCanvas.width = drawWidth;
362
+ maskCanvas.height = drawHeight;
363
+ maskCanvas.style.top = imgCanvas.offsetTop + "px";
364
+ maskCanvas.style.left = imgCanvas.offsetLeft + "px";
365
+
366
+ self.invalidateMaskCanvas(self);
367
+ self.invalidatePointsCanvas(self);
368
+ });
369
+
370
+ // original image load
371
+ orig_image.onload = () => self.onLoaded(self);
372
+ const rgb_url = new URL(target_image_path);
373
+ rgb_url.searchParams.delete('channel');
374
+ rgb_url.searchParams.set('channel', 'rgb');
375
+ orig_image.src = rgb_url;
376
+ self.image = orig_image;
377
+ }
378
+
379
+ onLoaded(self) {
380
+ if(self.message_box) {
381
+ self.element.removeChild(self.message_box);
382
+ self.message_box = null;
383
+ }
384
+
385
+ window.dispatchEvent(new Event('resize'));
386
+
387
+ self.setEventHandler(pointsCanvas);
388
+ self.saveButton.disabled = false;
389
+ }
390
+
391
+ setEventHandler(targetCanvas) {
392
+ targetCanvas.addEventListener("contextmenu", (event) => {
393
+ event.preventDefault();
394
+ });
395
+
396
+ const self = this;
397
+ targetCanvas.addEventListener('pointermove', (event) => this.updateBrushPreview(self,event));
398
+ targetCanvas.addEventListener('pointerdown', (event) => this.handlePointerDown(self,event));
399
+ targetCanvas.addEventListener('pointerover', (event) => { this.brush.style.display = "block"; });
400
+ targetCanvas.addEventListener('pointerleave', (event) => { this.brush.style.display = "none"; });
401
+ document.addEventListener('keydown', ImpactSamEditorDialog.handleKeyDown);
402
+ }
403
+
404
+ static handleKeyDown(event) {
405
+ const self = ImpactSamEditorDialog.instance;
406
+ if (event.key === '=') { // positive
407
+ brush.style.backgroundColor = "blue";
408
+ brush.style.outline = "2px solid pink";
409
+ self.is_positive_mode = true;
410
+ } else if (event.key === '-') { // negative
411
+ brush.style.backgroundColor = "red";
412
+ brush.style.outline = "2px solid skyblue";
413
+ self.is_positive_mode = false;
414
+ }
415
+ }
416
+
417
+ is_positive_mode = true;
418
+ prompt_points = [];
419
+ confidence = 70;
420
+
421
+ invalidatePointsCanvas(self) {
422
+ const ctx = self.pointsCtx;
423
+
424
+ for (const i in self.prompt_points) {
425
+ const [is_positive, x, y] = self.prompt_points[i];
426
+
427
+ const scaledX = x * ctx.canvas.width / self.image.width;
428
+ const scaledY = y * ctx.canvas.height / self.image.height;
429
+
430
+ if(is_positive)
431
+ ctx.fillStyle = "blue";
432
+ else
433
+ ctx.fillStyle = "red";
434
+ ctx.beginPath();
435
+ ctx.arc(scaledX, scaledY, 3, 0, 3 * Math.PI);
436
+ ctx.fill();
437
+ }
438
+ }
439
+
440
+ invalidateMaskCanvas(self) {
441
+ if(self.mask_image) {
442
+ self.maskCtx.clearRect(0, 0, self.maskCanvas.width, self.maskCanvas.height);
443
+ self.maskCtx.drawImage(self.mask_image, 0, 0, self.maskCanvas.width, self.maskCanvas.height);
444
+ }
445
+ }
446
+
447
+ async load_sam(url) {
448
+ const parsedUrl = new URL(url);
449
+ const searchParams = new URLSearchParams(parsedUrl.search);
450
+
451
+ const filename = searchParams.get("filename") || "";
452
+ const fileType = searchParams.get("type") || "";
453
+ const subfolder = searchParams.get("subfolder") || "";
454
+
455
+ const data = {
456
+ sam_model_name: "auto",
457
+ filename: filename,
458
+ type: fileType,
459
+ subfolder: subfolder
460
+ };
461
+
462
+ api.fetchApi('/sam/prepare', {
463
+ method: 'POST',
464
+ headers: { 'Content-Type': 'application/json' },
465
+ body: JSON.stringify(data)
466
+ });
467
+ }
468
+
469
+ async detect(self) {
470
+ const positive_points = [];
471
+ const negative_points = [];
472
+
473
+ for(const i in self.prompt_points) {
474
+ const [is_positive, x, y] = self.prompt_points[i];
475
+ const point = [x,y];
476
+ if(is_positive)
477
+ positive_points.push(point);
478
+ else
479
+ negative_points.push(point);
480
+ }
481
+
482
+ const data = {
483
+ positive_points: positive_points,
484
+ negative_points: negative_points,
485
+ threshold: self.confidence/100
486
+ };
487
+
488
+ const response = await api.fetchApi('/sam/detect', {
489
+ method: 'POST',
490
+ headers: { 'Content-Type': 'image/png' },
491
+ body: JSON.stringify(data)
492
+ });
493
+
494
+ const blob = await response.blob();
495
+ const url = URL.createObjectURL(blob);
496
+
497
+ return new Promise((resolve, reject) => {
498
+ const image = new Image();
499
+ image.onload = () => resolve(image);
500
+ image.onerror = reject;
501
+ image.src = url;
502
+ });
503
+ }
504
+
505
+ handlePointerDown(self, event) {
506
+ if ([0, 2, 5].includes(event.button)) {
507
+ event.preventDefault();
508
+ const x = event.offsetX || event.targetTouches[0].clientX - maskRect.left;
509
+ const y = event.offsetY || event.targetTouches[0].clientY - maskRect.top;
510
+
511
+ const originalX = x * self.image.width / self.pointsCanvas.width;
512
+ const originalY = y * self.image.height / self.pointsCanvas.height;
513
+
514
+ var point = null;
515
+ if (event.button == 0) {
516
+ // positive
517
+ point = [true, originalX, originalY];
518
+ } else {
519
+ // negative
520
+ point = [false, originalX, originalY];
521
+ }
522
+
523
+ self.prompt_points.push(point);
524
+
525
+ self.invalidatePointsCanvas(self);
526
+ }
527
+ }
528
+
529
+ async save(self) {
530
+ if(!self.mask_image) {
531
+ this.close();
532
+ return;
533
+ }
534
+
535
+ const save_canvas = document.createElement('canvas');
536
+
537
+ const save_ctx = save_canvas.getContext('2d', {willReadFrequently:true});
538
+ save_canvas.width = self.mask_image.width;
539
+ save_canvas.height = self.mask_image.height;
540
+
541
+ save_ctx.drawImage(self.mask_image, 0, 0, save_canvas.width, save_canvas.height);
542
+
543
+ const save_data = save_ctx.getImageData(0, 0, save_canvas.width, save_canvas.height);
544
+
545
+ // refine mask image
546
+ for (let i = 0; i < save_data.data.length; i += 4) {
547
+ if(save_data.data[i]) {
548
+ save_data.data[i+3] = 0;
549
+ }
550
+ else {
551
+ save_data.data[i+3] = 255;
552
+ }
553
+
554
+ save_data.data[i] = 0;
555
+ save_data.data[i+1] = 0;
556
+ save_data.data[i+2] = 0;
557
+ }
558
+
559
+ save_ctx.globalCompositeOperation = 'source-over';
560
+ save_ctx.putImageData(save_data, 0, 0);
561
+
562
+ const formData = new FormData();
563
+ const filename = "clipspace-mask-" + performance.now() + ".png";
564
+
565
+ const item =
566
+ {
567
+ "filename": filename,
568
+ "subfolder": "",
569
+ "type": "temp",
570
+ };
571
+
572
+ if(ComfyApp.clipspace.images)
573
+ ComfyApp.clipspace.images[0] = item;
574
+
575
+ if(ComfyApp.clipspace.widgets) {
576
+ const index = ComfyApp.clipspace.widgets.findIndex(obj => obj.name === 'image');
577
+
578
+ if(index >= 0)
579
+ ComfyApp.clipspace.widgets[index].value = `${filename} [temp]`;
580
+ }
581
+
582
+ const dataURL = save_canvas.toDataURL();
583
+ const blob = dataURLToBlob(dataURL);
584
+
585
+ let original_url = new URL(this.image.src);
586
+
587
+ const original_ref = { filename: original_url.searchParams.get('filename') };
588
+
589
+ let original_subfolder = original_url.searchParams.get("subfolder");
590
+ if(original_subfolder)
591
+ original_ref.subfolder = original_subfolder;
592
+
593
+ let original_type = original_url.searchParams.get("type");
594
+ if(original_type)
595
+ original_ref.type = original_type;
596
+
597
+ formData.append('image', blob, filename);
598
+ formData.append('original_ref', JSON.stringify(original_ref));
599
+ formData.append('type', "temp");
600
+
601
+ await uploadMask(item, formData);
602
+ ComfyApp.onClipspaceEditorSave();
603
+ this.close();
604
+ }
605
+ }
606
+
607
+ app.registerExtension({
608
+ name: "Comfy.Impact.SAMEditor",
609
+ init(app) {
610
+ const callback =
611
+ function () {
612
+ let dlg = ImpactSamEditorDialog.getInstance();
613
+ dlg.show();
614
+ };
615
+
616
+ const context_predicate = () => ComfyApp.clipspace && ComfyApp.clipspace.imgs && ComfyApp.clipspace.imgs.length > 0
617
+ ClipspaceDialog.registerButton("Impact SAM Detector", context_predicate, callback);
618
+ },
619
+
620
+ async beforeRegisterNodeDef(nodeType, nodeData, app) {
621
+ if (Array.isArray(nodeData.output) && (nodeData.output.includes("MASK") || nodeData.output.includes("IMAGE"))) {
622
+ addMenuHandler(nodeType, function (_, options) {
623
+ options.unshift({
624
+ content: "Open in SAM Detector",
625
+ callback: () => {
626
+ ComfyApp.copyToClipspace(this);
627
+ ComfyApp.clipspace_return_node = this;
628
+
629
+ let dlg = ImpactSamEditorDialog.getInstance();
630
+ dlg.show();
631
+ },
632
+ });
633
+ });
634
+ }
635
+ }
636
+ });
637
+
custom_nodes/ComfyUI-Impact-Pack/js/impact-segs-picker.js ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComfyApp, app } from "../../scripts/app.js";
2
+ import { ComfyDialog, $el } from "../../scripts/ui.js";
3
+ import { api } from "../../scripts/api.js";
4
+
5
+ async function open_picker(node) {
6
+ const resp = await api.fetchApi(`/impact/segs/picker/count?id=${node.id}`);
7
+ const body = await resp.text();
8
+
9
+ let cnt = parseInt(body);
10
+
11
+ var existingPicker = document.getElementById('impact-picker');
12
+ if (existingPicker) {
13
+ existingPicker.parentNode.removeChild(existingPicker);
14
+ }
15
+
16
+ var gallery = document.createElement('div');
17
+ gallery.id = 'impact-picker';
18
+
19
+ gallery.style.position = "absolute";
20
+ gallery.style.height = "80%";
21
+ gallery.style.width = "80%";
22
+ gallery.style.top = "10%";
23
+ gallery.style.left = "10%";
24
+ gallery.style.display = 'flex';
25
+ gallery.style.flexWrap = 'wrap';
26
+ gallery.style.maxHeight = '600px';
27
+ gallery.style.overflow = 'auto';
28
+ gallery.style.backgroundColor = 'rgba(0,0,0,0.3)';
29
+ gallery.style.padding = '20px';
30
+ gallery.draggable = false;
31
+ gallery.style.zIndex = 5000;
32
+
33
+ var doneButton = document.createElement('button');
34
+ doneButton.textContent = 'Done';
35
+ doneButton.style.padding = '10px 10px';
36
+ doneButton.style.border = 'none';
37
+ doneButton.style.borderRadius = '5px';
38
+ doneButton.style.fontFamily = 'Arial, sans-serif';
39
+ doneButton.style.fontSize = '16px';
40
+ doneButton.style.fontWeight = 'bold';
41
+ doneButton.style.color = '#fff';
42
+ doneButton.style.background = 'linear-gradient(to bottom, #0070B8, #003D66)';
43
+ doneButton.style.boxShadow = '0 2px 4px rgba(0, 0, 0, 0.4)';
44
+ doneButton.style.margin = "20px";
45
+ doneButton.style.height = "40px";
46
+
47
+ var cancelButton = document.createElement('button');
48
+ cancelButton.textContent = 'Cancel';
49
+ cancelButton.style.padding = '10px 10px';
50
+ cancelButton.style.border = 'none';
51
+ cancelButton.style.borderRadius = '5px';
52
+ cancelButton.style.fontFamily = 'Arial, sans-serif';
53
+ cancelButton.style.fontSize = '16px';
54
+ cancelButton.style.fontWeight = 'bold';
55
+ cancelButton.style.color = '#fff';
56
+ cancelButton.style.background = 'linear-gradient(to bottom, #ff70B8, #ff3D66)';
57
+ cancelButton.style.boxShadow = '0 2px 4px rgba(0, 0, 0, 0.4)';
58
+ cancelButton.style.margin = "20px";
59
+ cancelButton.style.height = "40px";
60
+
61
+ const w = node.widgets.find((w) => w.name == 'picks');
62
+ let prev_selected = w.value.split(',').map(function(item) {
63
+ return parseInt(item, 10);
64
+ });
65
+
66
+ let images = [];
67
+ doneButton.onclick = () => {
68
+ var result = '';
69
+ for(let i in images) {
70
+ if(images[i].isSelected) {
71
+ if(result != '')
72
+ result += ', ';
73
+
74
+ result += (parseInt(i)+1);
75
+ }
76
+ }
77
+
78
+ w.value = result;
79
+
80
+ gallery.parentNode.removeChild(gallery);
81
+ }
82
+
83
+ cancelButton.onclick = () => {
84
+ gallery.parentNode.removeChild(gallery);
85
+ }
86
+
87
+ var panel = document.createElement('div');
88
+ panel.style.clear = 'both';
89
+ panel.style.width = '100%';
90
+ panel.style.height = '40px';
91
+ panel.style.justifyContent = 'center';
92
+ panel.style.alignItems = 'center';
93
+ panel.style.display = 'flex';
94
+ panel.appendChild(doneButton);
95
+ panel.appendChild(cancelButton);
96
+ gallery.appendChild(panel);
97
+
98
+ var hint = document.createElement('label');
99
+ hint.style.position = 'absolute';
100
+ hint.innerHTML = 'Click: Toggle Selection<BR>Ctrl-click: Single Selection';
101
+ gallery.appendChild(hint);
102
+
103
+ let max_size = 300;
104
+
105
+ for(let i=0; i<cnt; i++) {
106
+ let image = new Image();
107
+ image.src = `/impact/segs/picker/view?id=${node.id}&idx=${i}`;
108
+ image.style.margin = '10px';
109
+ image.draggable = false;
110
+ images.push(image);
111
+ image.isSelected = prev_selected.includes(i + 1);
112
+ if(image.isSelected) {
113
+ image.style.border = '2px solid #006699';
114
+ }
115
+
116
+ image.onload = function() {
117
+ var ratio = 1.0;
118
+ if(image.naturalWidth > image.naturalHeight) {
119
+ ratio = max_size/image.naturalWidth;
120
+ }
121
+ else {
122
+ ratio = max_size/image.naturalHeight;
123
+ }
124
+
125
+ let width = image.naturalWidth * ratio;
126
+ let height = image.naturalHeight * ratio;
127
+
128
+ if(width < height) {
129
+ this.style.marginLeft = (200-width)/2+"px";
130
+ }
131
+ else{
132
+ this.style.marginTop = (200-height)/2+"px";
133
+ }
134
+
135
+ this.style.width = width+"px";
136
+ this.style.height = height+"px";
137
+ this.style.objectFit = 'cover';
138
+ }
139
+
140
+ image.addEventListener('click', function(event) {
141
+ if(event.ctrlKey) {
142
+ for(let i in images) {
143
+ if(images[i].isSelected) {
144
+ images[i].style.border = 'none';
145
+ images[i].isSelected = false;
146
+ }
147
+ }
148
+
149
+ image.style.border = '2px solid #006699';
150
+ image.isSelected = true;
151
+
152
+ return;
153
+ }
154
+
155
+ if(image.isSelected) {
156
+ image.style.border = 'none';
157
+ image.isSelected = false;
158
+ }
159
+ else {
160
+ image.style.border = '2px solid #006699';
161
+ image.isSelected = true;
162
+ }
163
+ });
164
+
165
+ gallery.appendChild(image);
166
+ }
167
+
168
+ document.body.appendChild(gallery);
169
+ }
170
+
171
+
172
+ app.registerExtension({
173
+ name: "Comfy.Impack.Picker",
174
+
175
+ nodeCreated(node, app) {
176
+ if(node.comfyClass == "ImpactSEGSPicker") {
177
+ node.addWidget("button", "pick", "image", () => {
178
+ open_picker(node);
179
+ });
180
+ }
181
+ }
182
+ });
custom_nodes/ComfyUI-Impact-Pack/js/impact-wildcard.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComfyApp, app } from "../../scripts/app.js";
2
+ import { api } from "../../scripts/api.js";
3
+
4
+ let refresh_btn = document.getElementById('comfy-refresh-button');
5
+ let refresh_btn2 = document.querySelector('button[title="Refresh widgets in nodes to find new models or files"]');
6
+
7
+ let orig = refresh_btn.onclick;
8
+
9
+ refresh_btn.onclick = function() {
10
+ orig();
11
+ api.fetchApi('/impact/wildcards/refresh');
12
+ };
13
+
14
+ refresh_btn2.addEventListener('click', function() {
15
+ api.fetchApi('/impact/wildcards/refresh');
16
+ });
custom_nodes/ComfyUI-Impact-Pack/latent.png ADDED
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/animatediff_nodes.cpython-310.pyc ADDED
Binary file (5.49 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/bridge_nodes.cpython-310.pyc ADDED
Binary file (7.59 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/config.cpython-310.pyc ADDED
Binary file (1.9 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/core.cpython-310.pyc ADDED
Binary file (52.8 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/defs.cpython-310.pyc ADDED
Binary file (1.21 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/detectors.cpython-310.pyc ADDED
Binary file (16.1 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/hf_nodes.cpython-310.pyc ADDED
Binary file (3.94 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/hook_nodes.cpython-310.pyc ADDED
Binary file (3.12 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/hooks.cpython-310.pyc ADDED
Binary file (17.2 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/impact_pack.cpython-310.pyc ADDED
Binary file (58.6 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/impact_sampling.cpython-310.pyc ADDED
Binary file (9.19 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/impact_server.cpython-310.pyc ADDED
Binary file (14.7 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/logics.cpython-310.pyc ADDED
Binary file (18.7 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/pipe.cpython-310.pyc ADDED
Binary file (10 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/sample_error_enhancer.cpython-310.pyc ADDED
Binary file (858 Bytes). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/segs_nodes.cpython-310.pyc ADDED
Binary file (43.8 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/segs_upscaler.cpython-310.pyc ADDED
Binary file (3.62 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/special_samplers.cpython-310.pyc ADDED
Binary file (22.5 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/util_nodes.cpython-310.pyc ADDED
Binary file (16.6 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/utils.cpython-310.pyc ADDED
Binary file (15.9 kB). View file
 
custom_nodes/ComfyUI-Impact-Pack/modules/impact/__pycache__/wildcards.cpython-310.pyc ADDED
Binary file (13.9 kB). View file