crystantine commited on
Commit
9a602b5
1 Parent(s): 072a4ba

Upload 46 files

Browse files
Files changed (46) hide show
  1. ComfyUI-Impact-Pack/.gitignore +5 -0
  2. ComfyUI-Impact-Pack/.gitmodules +3 -0
  3. ComfyUI-Impact-Pack/LICENSE.txt +674 -0
  4. ComfyUI-Impact-Pack/README.md +304 -0
  5. ComfyUI-Impact-Pack/__init__.py +303 -0
  6. ComfyUI-Impact-Pack/custom_wildcards/put_wildcards_here +0 -0
  7. ComfyUI-Impact-Pack/disable.py +38 -0
  8. ComfyUI-Impact-Pack/install.py +178 -0
  9. ComfyUI-Impact-Pack/js/comboBoolMigration.js +31 -0
  10. ComfyUI-Impact-Pack/js/impact-pack.js +395 -0
  11. ComfyUI-Impact-Pack/js/impact-sam-editor.js +636 -0
  12. ComfyUI-Impact-Pack/latent.png +3 -0
  13. ComfyUI-Impact-Pack/modules/impact/additional_dependencies.py +12 -0
  14. ComfyUI-Impact-Pack/modules/impact/config.py +51 -0
  15. ComfyUI-Impact-Pack/modules/impact/core.py +1330 -0
  16. ComfyUI-Impact-Pack/modules/impact/detectors.py +144 -0
  17. ComfyUI-Impact-Pack/modules/impact/impact_pack.py +0 -0
  18. ComfyUI-Impact-Pack/modules/impact/impact_server.py +179 -0
  19. ComfyUI-Impact-Pack/modules/impact/legacy_nodes.py +273 -0
  20. ComfyUI-Impact-Pack/modules/impact/logics.py +253 -0
  21. ComfyUI-Impact-Pack/modules/impact/mmdet_nodes.py +213 -0
  22. ComfyUI-Impact-Pack/modules/impact/onnx.py +38 -0
  23. ComfyUI-Impact-Pack/modules/impact/pipe.py +260 -0
  24. ComfyUI-Impact-Pack/modules/impact/utils.py +240 -0
  25. ComfyUI-Impact-Pack/modules/impact/wildcards.py +140 -0
  26. ComfyUI-Impact-Pack/notebook/comfyui_colab_impact_pack.ipynb +172 -0
  27. ComfyUI-Impact-Pack/requirements.txt +3 -0
  28. ComfyUI-Impact-Pack/subpack/.gitignore +5 -0
  29. ComfyUI-Impact-Pack/subpack/LICENSE +661 -0
  30. ComfyUI-Impact-Pack/subpack/README.md +18 -0
  31. ComfyUI-Impact-Pack/subpack/impact/subcore.py +182 -0
  32. ComfyUI-Impact-Pack/subpack/impact/subpack_nodes.py +42 -0
  33. ComfyUI-Impact-Pack/subpack/install.py +31 -0
  34. ComfyUI-Impact-Pack/subpack/requirements.txt +1 -0
  35. ComfyUI-Impact-Pack/test/advanced-sampler.json +976 -0
  36. ComfyUI-Impact-Pack/test/detailer-pipe-test.json +3230 -0
  37. ComfyUI-Impact-Pack/test/loop-test.json +1114 -0
  38. ComfyUI-Impact-Pack/test/masks.json +622 -0
  39. ComfyUI-Impact-Pack/test/regional_prompt.json +975 -0
  40. ComfyUI-Impact-Pack/troubleshooting/TROUBLESHOOTING.md +25 -0
  41. ComfyUI-Impact-Pack/troubleshooting/black1.png +3 -0
  42. ComfyUI-Impact-Pack/troubleshooting/black2.png +3 -0
  43. ComfyUI-Impact-Pack/uninstall.py +38 -0
  44. ComfyUI-Impact-Pack/wildcards/put_wildcards_here +0 -0
  45. ComfyUI-Impact-Pack/wildcards/samples/flower.txt +9 -0
  46. ComfyUI-Impact-Pack/wildcards/samples/jewel.txt +9 -0
ComfyUI-Impact-Pack/.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ __pycache__
2
+ *.ini
3
+ wildcards/**
4
+ .vscode/
5
+ .idea/
ComfyUI-Impact-Pack/.gitmodules ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [submodule "subpack"]
2
+ path = subpack
3
+ url = https://github.com/ltdrdata/ComfyUI-Impact-Subpack
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>.
ComfyUI-Impact-Pack/README.md ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Starting from V3.6, requires latest version(Aug 8, 9ccc965) of ComfyUI.
11
+ * **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.**
12
+ * Starting from V3.0, nodes related to `mmdet` are optional nodes that are activated only based on the configuration settings.
13
+ - Through ComfyUI-Impact-Subpack, you can utilize UltralyticsDetectorProvider to access various detection models.
14
+ * 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.
15
+ * 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.
16
+ * The "PreviewBridge" feature may not function correctly on ComfyUI versions released before July 1, 2023.
17
+ * Attempting to load the "ComfyUI-Impact-Pack" on ComfyUI versions released before June 27, 2023, will result in a failure.
18
+ * 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.
19
+
20
+
21
+ ## Custom Nodes
22
+ * SAMLoader - Loads the SAM model.
23
+ * UltralyticsDetectorProvider - Loads the Ultralystics model to provide SEGM_DETECTOR, BBOX_DETECTOR.
24
+ - Unlike `MMDetDetectorProvider`, for segm models, `BBOX_DETECTOR` is also provided.
25
+ - The various models available in UltralyticsDetectorProvider can be downloaded through **ComfyUI-Manager**.
26
+ * ONNXDetectorProvider - Loads the ONNX model to provide SEGM_DETECTOR.
27
+ * CLIPSegDetectorProvider - Wrapper for CLIPSeg to provide BBOX_DETECTOR.
28
+ * You need to install the ComfyUI-CLIPSeg node extension.
29
+ * SEGM Detector (combined) - Detects segmentation and returns a mask from the input image.
30
+ * BBOX Detector (combined) - Detects bounding boxes and returns a mask from the input image.
31
+ * 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.
32
+ * 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.
33
+ * 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.
34
+ * While `batch_masks` may not be completely separated, it provides functionality to perform some level of segmentation.
35
+ * Bitwise(SEGS & SEGS) - Performs a 'bitwise and' operation between two SEGS.
36
+ * Bitwise(SEGS - SEGS) - Subtracts one SEGS from another.
37
+ * Bitwise(SEGS & MASK) - Performs a bitwise AND operation between SEGS and MASK.
38
+ * Bitwise(SEGS & MASKS ForEach) - Performs a bitwise AND operation between SEGS and MASKS.
39
+ * Please note that this operation is performed with batches of MASKS, not just a single MASK.
40
+ * Bitwise(MASK & MASK) - Performs a 'bitwise and' operation between two masks.
41
+ * Bitwise(MASK - MASK) - Subtracts one mask from another.
42
+ * Bitwise(MASK + MASK) - Combine two masks.
43
+ * SEGM Detector (SEGS) - Detects segmentation and returns SEGS from the input image.
44
+ * BBOX Detector (SEGS) - Detects bounding boxes and returns SEGS from the input image.
45
+ * ONNX Detector (SEGS) - Utilizes the ONNX model to identify the bbox and retrieve the SEGS from the input image.
46
+ * Detailer (SEGS) - Refines the image based on SEGS.
47
+ * 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.
48
+ * 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.
49
+ * MASK to SEGS - Generates SEGS based on the mask.
50
+ * 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.
51
+ * Masks to Mask List - MASKS
52
+ * This node converts the MASKS in batch form to a list of individual masks.
53
+ * EmptySEGS - Provides an empty SEGS.
54
+ * MaskPainter - Provides a feature to draw masks.
55
+ * FaceDetailer - Easily detects faces and improves them.
56
+ * FaceDetailer (pipe) - Easily detects faces and improves them (for multipass).
57
+
58
+ * SEGSDetailer - Performs detailed work on SEGS without pasting it back onto the original image.
59
+ * SEGSPaste - Pastes the results of SEGS onto the original image.
60
+ * 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.
61
+ * SEGSPreview - Provides a preview of SEGS.
62
+ * 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.
63
+ * SEGSToImageList - Convert SEGS To Image List
64
+ * SEGSToMaskList - Convert SEGS To Mask List
65
+ * SEGS Filter (label) - This node filters SEGS based on the label of the detected areas.
66
+ * SEGS Filter (ordered) - This node sorts SEGS based on size and position and retrieves SEGs within a certain range.
67
+ * SEGS Filter (range) - This node retrieves only SEGs from SEGS that have a size and position within a certain range.
68
+ * SEGSConcat - Concatenate segs1 and segs2. If source shape of segs1 and segs2 are different then segs2 will be ignored.
69
+
70
+ * Pipe nodes
71
+ * 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.
72
+ * 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.
73
+ * EditBasicPipe, EditDetailerPipe - These nodes are used to replace some elements in BASIC_PIPE or DETAILER_PIPE.
74
+ * 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.
75
+ * Latent Scale (on Pixel Space) - This node converts latent to pixel space, upscales it, and then converts it back to latent.
76
+ * 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.
77
+ * 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.
78
+ * Similar to 'Latent Scale (on Pixel Space)', if upscale_model_opt is provided, it performs pixel upscaling using the model.
79
+ * PixelTiledKSampleUpscalerProvider - It is similar to PixelKSampleUpscalerProvider, but it uses ComfyUI_TiledKSampler and Tiled VAE Decoder/Encoder to avoid GPU VRAM issues at high resolutions.
80
+ * You need to install the [ComfyUI_TiledKSampler](https://github.com/BlenderNeko/ComfyUI_TiledKSampler) node extension.
81
+
82
+ * DenoiseScheduleHookProvider - IterativeUpscale provides a hook that gradually changes the denoise to target_denoise as the step progresses.
83
+ * CfgScheduleHookProvider - IterativeUpscale provides a hook that gradually changes the cfg to target_cfg as the step progresses.
84
+ * PixelKSampleHookCombine - This is used to connect two PK_HOOKs. hook1 is executed first and then hook2 is executed.
85
+ * If you want to simultaneously change cfg and denoise, you can combine the PK_HOOKs of CfgScheduleHookProvider and PixelKSampleHookCombine.
86
+
87
+ * Iterative Upscale (Latent) - The upscaler takes the input upscaler and splits the scale_factor into steps, then iteratively performs upscaling.
88
+ This takes latent as input and outputs latent as the result.
89
+ * 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.
90
+ * Internally, this node uses 'Iterative Upscale (Latent)'.
91
+
92
+ * 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.
93
+ * Note: The latent encoded through VAEEncodeForInpaint cannot be used.
94
+ * KSamplerProvider - This is a wrapper that enables KSampler to be used in TwoSamplersForMask TwoSamplersForMaskUpscalerProvider.
95
+ * TiledKSamplerProvider - ComfyUI_TiledKSampler is a wrapper that provides KSAMPLER.
96
+ * You need to install the [ComfyUI_TiledKSampler](https://github.com/BlenderNeko/ComfyUI_TiledKSampler) node extension.
97
+
98
+ * 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.
99
+ * KSamplerAdvancedProvider - This is a wrapper that enables KSampler to be used in TwoAdvancedSamplersForMask.
100
+
101
+ * TwoSamplersForMaskUpscalerProvider - This is an Upscaler that extends TwoSamplersForMask to be used in Iterative Upscale.
102
+ * TwoSamplersForMaskUpscalerProviderPipe - pipe version of TwoSamplersForMaskUpscalerProvider.
103
+
104
+ * PreviewBridge - This custom node can be used with a bridge when using the MaskEditor feature of Clipspace.
105
+ * ImageSender, ImageReceiver - The images generated in ImageSender are automatically sent to the ImageReceiver with the same link_id.
106
+ * LatentSender, LatentReceiver - The latent generated in LatentSender are automatically sent to the LatentReceiver with the same link_id.
107
+ * Furthermore, LatentSender is implemented with PreviewLatent, which stores the latent in payload form within the image thumbnail.
108
+ * 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.
109
+
110
+ * 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.
111
+ * 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.
112
+ * When an image is generated with the "fixed" mode, the prompt used for that particular generation is stored in the metadata.
113
+ * Known Issue: The old version of `presetText.js` script from **pythongosssss's [ComfyUI-Custom-Scripts](https://github.com/pythongosssss/ComfyUI-Custom-Scripts)** is causing a conflict, preventing it from being used together.
114
+ If you'd installed that extension before (Jul 23, 2023). Please update to latest version.
115
+
116
+ * RegionalSampler, CombineRegionalPrompts, RegionalPrompt - experimental feature
117
+ - multiple region version of TwoAdvancedSamplersForMask
118
+ *
119
+ * KSampler (pipe), KSampler (advanced/pipe)
120
+
121
+ * ImpactCompare, ImpactConditionalBranch, ImpactInt, ImpactValueSender, ImpactValueReceiver, ImpactImageInfo, ImpactMinMax, ImpactNeg, ImpactConditionalStopIteration
122
+ - Experimental set of nodes for implementing loop functionality (tutorial to be prepared later / [example workflow](test/loop-test.json)).
123
+
124
+ * Image batch To Image List - Convert Image batch to Image List
125
+ - You can use images generated in a multi batch to handle them.
126
+
127
+
128
+ ## MMDet nodes
129
+ * MMDetDetectorProvider - Loads the MMDet model to provide BBOX_DETECTOR and SEGM_DETECTOR.
130
+ * To use the existing MMDetDetectorProvider, you need to enable the MMDet usage configuration.
131
+
132
+
133
+ ## Feature
134
+ * 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)'.
135
+
136
+
137
+ ## Deprecated
138
+ * The following nodes have been kept only for compatibility with existing workflows, and are no longer supported. Please replace them with new nodes.
139
+ * MMDetLoader -> MMDetDetectorProvider
140
+ * SegsMaskCombine -> SEGS to MASK (combined)
141
+ * BboxDetectorForEach -> BBOX Detector (SEGS)
142
+ * SegmDetectorForEach -> SEGM Detector (SEGS)
143
+ * BboxDetectorCombined -> BBOX Detector (combined)
144
+ * SegmDetectorCombined -> SEGM Detector (combined)
145
+ * MaskPainter -> PreviewBridge
146
+ * To use the existing deprecated legacy nodes, you need to enable the MMDet usage configuration.
147
+
148
+
149
+ ## How to activate 'MMDet usage'
150
+ * Upon the initial execution, an `impact-pack.ini` file will be generated in the custom_nodes/ComfyUI-Impact-Pack directory.
151
+ ```
152
+ [default]
153
+ dependency_version = 2
154
+ mmdet_skip = True
155
+ ```
156
+ * Change `mmdet_skip = True` to `mmdet_skip = False`
157
+ ```
158
+ [default]
159
+ dependency_version = 2
160
+ mmdet_skip = False
161
+ ```
162
+ * Restart ComfyUI
163
+
164
+
165
+ ## Installation
166
+
167
+ 1. `cd custom_nodes`
168
+ 1. `git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack.git`
169
+ 3. `cd ComfyUI-Impact-Pack`
170
+ 4. (optional) `git submodule update --init --recursive`
171
+ * Impact Pack will automatically download subpack during its initial launch.
172
+ 5. (optional) `python install.py`
173
+ * Impact Pack will automatically install its dependencies during its initial launch.
174
+ * For the portable version, you should execute the command `..\..\..\python_embedded\python.exe install.py` to run the installation script.
175
+
176
+
177
+ 6. Restart ComfyUI
178
+
179
+ * NOTE: If an error occurs during the installation process, please refer to [Troubleshooting Page](troubleshooting/TROUBLESHOOTING.md) for assistance.
180
+ * 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.
181
+
182
+ ## Package Dependencies (If you need to manual setup.)
183
+
184
+ * pip install
185
+ * openmim
186
+ * segment-anything
187
+ * ultralytics
188
+ * scikit-image
189
+ * piexif
190
+ * (optional) pycocotools
191
+ * (optional) onnxruntime
192
+
193
+ * mim install (optional)
194
+ * mmcv==2.0.0, mmdet==3.0.0, mmengine==0.7.2
195
+
196
+ * linux packages (ubuntu)
197
+ * libgl1-mesa-glx
198
+ * libglib2.0-0
199
+
200
+ ## Other Materials (auto-download on initial startup)
201
+
202
+ * ComfyUI/models/mmdets/bbox <= https://huggingface.co/dustysys/ddetailer/resolve/main/mmdet/bbox/mmdet_anime-face_yolov3.pth
203
+ * ComfyUI/models/mmdets/bbox <= https://raw.githubusercontent.com/Bing-su/dddetailer/master/config/mmdet_anime-face_yolov3.py
204
+ * ComfyUI/models/sams <= https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth
205
+
206
+ ## Troubleshooting page
207
+ * [Troubleshooting Page](troubleshooting/TROUBLESHOOTING.md)
208
+
209
+
210
+ ## How to use (DDetailer feature)
211
+
212
+ #### 1. Basic auto face detection and refine exapmle.
213
+ ![simple](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/simple.png)
214
+ * 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.
215
+ * 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.
216
+ * 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.
217
+ * The MASK output of FaceDetailer provides a visualization of where the detected and enhanced areas are.
218
+
219
+ ![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)
220
+ * You can see that the face in the image on the left has increased detail as in the image on the right.
221
+
222
+ #### 2. 2Pass refine (restore a severely damaged face)
223
+ ![2pass-workflow-example](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/2pass-simple.png)
224
+ * 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.
225
+ * 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.
226
+
227
+ ![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)
228
+ * In the first stage, the severely damaged face is restored to some extent, and in the second stage, the details are restored
229
+
230
+ #### 3. Face Bbox(bounding box) + Person silhouette segmentation (prevent distortion of the background.)
231
+ ![combination-workflow-example](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/combination.jpg)
232
+ ![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)
233
+
234
+ * 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.
235
+
236
+ * 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.
237
+
238
+ #### 4. Iterative Upscale
239
+ ![upscale-workflow-example](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/upscale-workflow.png)
240
+
241
+ * 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.
242
+ * 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.
243
+ * 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.
244
+
245
+ * The following image is an image of 304x512 pixels and the same image scaled up to three times its original size using IterativeUpscale.
246
+
247
+ ![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)
248
+
249
+
250
+ #### 5. Interactive SAM Detector (Clipspace)
251
+
252
+ * 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.
253
+ ![samdetector-menu](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/SAMDetector-menu.png)
254
+
255
+ * 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.
256
+ * 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.
257
+
258
+ ![samdetector-dialog](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/SAMDetector-dialog.jpg)
259
+
260
+ * 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.
261
+
262
+ ![samdetector-result](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/images/SAMDetector-result.jpg)
263
+
264
+ * When you execute using the reflected mask in the node, you can observe that the image and mask are displayed separately.
265
+
266
+
267
+ ## Others Tutorials
268
+ * [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.
269
+ * [Advanced Tutorial](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/advanced.md)
270
+ * [SAM Application](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/sam.md)
271
+ * [PreviewBridge](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/previewbridge.md)
272
+ * [Mask Pointer](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/maskpointer.md)
273
+ * [ONNX Tutorial](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/ONNX.md)
274
+ * [CLIPSeg Tutorial](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/clipseg.md)
275
+ * [Extreme Highresolution Upscale](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/extreme-upscale.md)
276
+ * [TwoSamplersForMask](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/TwoSamplers.md)
277
+ * [TwoAdvancedSamplersForMask](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/TwoAdvancedSamplers.md)
278
+ * [Advanced Iterative Upscale: PK_HOOK](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/pk_hook.md)
279
+ * [Advanced Iterative Upscale: TwoSamplersForMask Upscale Provider](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/TwoSamplersUpscale.md)
280
+ * [Interactive SAM + PreviewBridge](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/sam_with_preview_bridge.md)
281
+ * [ImageSender/ImageReceiver/LatentSender/LatentReceiver](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/sender_receiver.md)
282
+ * [ImpactWildcardProcessor](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/ImpactWildcardProcessor.md)
283
+
284
+
285
+ ## Credits
286
+
287
+ ComfyUI/[ComfyUI](https://github.com/comfyanonymous/ComfyUI) - A powerful and modular stable diffusion GUI.
288
+
289
+ dustysys/[ddetailer](https://github.com/dustysys/ddetailer) - DDetailer for Stable-diffusion-webUI extension.
290
+
291
+ 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.
292
+
293
+ facebook/[segment-anything](https://github.com/facebookresearch/segment-anything) - Segmentation Anything!
294
+
295
+ 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.
296
+
297
+ 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.
298
+
299
+ 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.
300
+
301
+ BlenderNeok/[ComfyUI-TiledKSampler](https://github.com/BlenderNeko/ComfyUI_TiledKSampler) -
302
+ The tile sampler allows high-resolution sampling even in places with low GPU VRAM.
303
+
304
+ WASasquatch/[was-node-suite-comfyui](https://github.com/WASasquatch/was-node-suite-comfyui) - A powerful custom node extensions of ComfyUI.
ComfyUI-Impact-Pack/__init__.py ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import shutil
2
+ import folder_paths
3
+ import os
4
+ import sys
5
+
6
+ comfy_path = os.path.dirname(folder_paths.__file__)
7
+ impact_path = os.path.join(os.path.dirname(__file__))
8
+ subpack_path = os.path.join(os.path.dirname(__file__), "subpack")
9
+ modules_path = os.path.join(os.path.dirname(__file__), "modules")
10
+ wildcards_path = os.path.join(os.path.dirname(__file__), "wildcards")
11
+ custom_wildcards_path = os.path.join(os.path.dirname(__file__), "custom_wildcards")
12
+
13
+ sys.path.append(modules_path)
14
+ sys.path.append(subpack_path)
15
+
16
+
17
+ import impact.config
18
+ print(f"### Loading: ComfyUI-Impact-Pack ({impact.config.version})")
19
+
20
+
21
+ def do_install():
22
+ import importlib
23
+ spec = importlib.util.spec_from_file_location('impact_install', os.path.join(os.path.dirname(__file__), 'install.py'))
24
+ impact_install = importlib.util.module_from_spec(spec)
25
+ spec.loader.exec_module(impact_install)
26
+
27
+
28
+ # ensure dependency
29
+ if impact.config.get_config()['dependency_version'] < impact.config.dependency_version:
30
+ print(f"## ComfyUI-Impact-Pack: Updating dependencies")
31
+ do_install()
32
+
33
+
34
+ # Core
35
+ # recheck dependencies for colab
36
+ try:
37
+ import folder_paths
38
+ import torch
39
+ import cv2
40
+ import numpy as np
41
+ import comfy.samplers
42
+ import comfy.sd
43
+ import warnings
44
+ from PIL import Image, ImageFilter
45
+ from skimage.measure import label, regionprops
46
+ from collections import namedtuple
47
+ import piexif
48
+
49
+ if not impact.config.get_config()['mmdet_skip']:
50
+ import mmcv
51
+ from mmdet.apis import (inference_detector, init_detector)
52
+ from mmdet.evaluation import get_classes
53
+ except:
54
+ import importlib
55
+ print("### ComfyUI-Impact-Pack: Reinstall dependencies (several dependencies are missing.)")
56
+ do_install()
57
+
58
+ import impact.impact_server # to load server api
59
+
60
+ def setup_js():
61
+ # remove garbage
62
+ old_js_path = os.path.join(comfy_path, "web", "extensions", "core", "impact-pack.js")
63
+ if os.path.exists(old_js_path):
64
+ os.remove(old_js_path)
65
+
66
+ # setup js
67
+ js_dest_path = os.path.join(comfy_path, "web", "extensions", "impact-pack")
68
+ if not os.path.exists(js_dest_path):
69
+ os.makedirs(js_dest_path)
70
+
71
+ js_src_path = os.path.join(impact_path, "js", "impact-pack.js")
72
+ shutil.copy(js_src_path, js_dest_path)
73
+
74
+ js_src_path = os.path.join(impact_path, "js", "impact-sam-editor.js")
75
+ shutil.copy(js_src_path, js_dest_path)
76
+
77
+ js_src_path = os.path.join(impact_path, "js", "comboBoolMigration.js")
78
+ shutil.copy(js_src_path, js_dest_path)
79
+
80
+ setup_js()
81
+
82
+ from impact.impact_pack import *
83
+ from impact.detectors import *
84
+ from impact.pipe import *
85
+ from impact.logics import *
86
+
87
+ impact.wildcards.read_wildcard_dict(wildcards_path)
88
+ impact.wildcards.read_wildcard_dict(custom_wildcards_path)
89
+
90
+ NODE_CLASS_MAPPINGS = {
91
+ "SAMLoader": SAMLoader,
92
+ "CLIPSegDetectorProvider": CLIPSegDetectorProvider,
93
+ "ONNXDetectorProvider": ONNXDetectorProvider,
94
+
95
+ "BitwiseAndMaskForEach": BitwiseAndMaskForEach,
96
+ "SubtractMaskForEach": SubtractMaskForEach,
97
+
98
+ "DetailerForEach": DetailerForEach,
99
+ "DetailerForEachDebug": DetailerForEachTest,
100
+ "DetailerForEachPipe": DetailerForEachPipe,
101
+ "DetailerForEachDebugPipe": DetailerForEachTestPipe,
102
+
103
+ "SAMDetectorCombined": SAMDetectorCombined,
104
+ "SAMDetectorSegmented": SAMDetectorSegmented,
105
+
106
+ "FaceDetailer": FaceDetailer,
107
+ "FaceDetailerPipe": FaceDetailerPipe,
108
+
109
+ "ToDetailerPipe": ToDetailerPipe,
110
+ "FromDetailerPipe": FromDetailerPipe,
111
+ "FromDetailerPipe_v2": FromDetailerPipe_v2,
112
+ "ToBasicPipe": ToBasicPipe,
113
+ "FromBasicPipe": FromBasicPipe,
114
+ "FromBasicPipe_v2": FromBasicPipe_v2,
115
+ "BasicPipeToDetailerPipe": BasicPipeToDetailerPipe,
116
+ "DetailerPipeToBasicPipe": DetailerPipeToBasicPipe,
117
+ "EditBasicPipe": EditBasicPipe,
118
+ "EditDetailerPipe": EditDetailerPipe,
119
+
120
+ "LatentPixelScale": LatentPixelScale,
121
+ "PixelKSampleUpscalerProvider": PixelKSampleUpscalerProvider,
122
+ "PixelKSampleUpscalerProviderPipe": PixelKSampleUpscalerProviderPipe,
123
+ "IterativeLatentUpscale": IterativeLatentUpscale,
124
+ "IterativeImageUpscale": IterativeImageUpscale,
125
+ "PixelTiledKSampleUpscalerProvider": PixelTiledKSampleUpscalerProvider,
126
+ "PixelTiledKSampleUpscalerProviderPipe": PixelTiledKSampleUpscalerProviderPipe,
127
+ "TwoSamplersForMaskUpscalerProvider": TwoSamplersForMaskUpscalerProvider,
128
+ "TwoSamplersForMaskUpscalerProviderPipe": TwoSamplersForMaskUpscalerProviderPipe,
129
+
130
+ "PixelKSampleHookCombine": PixelKSampleHookCombine,
131
+ "DenoiseScheduleHookProvider": DenoiseScheduleHookProvider,
132
+ "CfgScheduleHookProvider": CfgScheduleHookProvider,
133
+
134
+ "BitwiseAndMask": BitwiseAndMask,
135
+ "SubtractMask": SubtractMask,
136
+ "AddMask": AddMask,
137
+ "Segs & Mask": SegsBitwiseAndMask,
138
+ "Segs & Mask ForEach": SegsBitwiseAndMaskForEach,
139
+ "EmptySegs": EmptySEGS,
140
+
141
+ "MaskToSEGS": MaskToSEGS,
142
+ "ToBinaryMask": ToBinaryMask,
143
+ "MasksToMaskList": MasksToMaskList,
144
+
145
+ "BboxDetectorSEGS": BboxDetectorForEach,
146
+ "SegmDetectorSEGS": SegmDetectorForEach,
147
+ "ONNXDetectorSEGS": ONNXDetectorForEach,
148
+
149
+ "BboxDetectorCombined_v2": BboxDetectorCombined,
150
+ "SegmDetectorCombined_v2": SegmDetectorCombined,
151
+ "SegsToCombinedMask": SegsToCombinedMask,
152
+
153
+ "KSamplerProvider": KSamplerProvider,
154
+ "TwoSamplersForMask": TwoSamplersForMask,
155
+ "TiledKSamplerProvider": TiledKSamplerProvider,
156
+
157
+ "KSamplerAdvancedProvider": KSamplerAdvancedProvider,
158
+ "TwoAdvancedSamplersForMask": TwoAdvancedSamplersForMask,
159
+
160
+ "PreviewBridge": PreviewBridge,
161
+ "ImageSender": ImageSender,
162
+ "ImageReceiver": ImageReceiver,
163
+ "LatentSender": LatentSender,
164
+ "LatentReceiver": LatentReceiver,
165
+ "ImageMaskSwitch": ImageMaskSwitch,
166
+ "LatentSwitch": LatentSwitch,
167
+ "SEGSSwitch": SEGSSwitch,
168
+
169
+ # "SaveConditioning": SaveConditioning,
170
+ # "LoadConditioning": LoadConditioning,
171
+
172
+ "ImpactWildcardProcessor": ImpactWildcardProcessor,
173
+ "ImpactLogger": ImpactLogger,
174
+
175
+ "SEGSDetailer": SEGSDetailer,
176
+ "SEGSPaste": SEGSPaste,
177
+ "SEGSPreview": SEGSPreview,
178
+ "SEGSToImageList": SEGSToImageList,
179
+ "ImpactSEGSToMaskList": SEGSToMaskList,
180
+ "ImpactSEGSConcat": SEGSConcat,
181
+
182
+ # "SEGPick": SEGPick,
183
+ # "SEGEdit": SEGEdit,
184
+
185
+ "ImpactKSamplerBasicPipe": KSamplerBasicPipe,
186
+ "ImpactKSamplerAdvancedBasicPipe": KSamplerAdvancedBasicPipe,
187
+
188
+ "ReencodeLatent": ReencodeLatent,
189
+ "ReencodeLatentPipe": ReencodeLatentPipe,
190
+
191
+ "ImpactImageBatchToImageList": ImageBatchToImageList,
192
+
193
+ "RegionalSampler": RegionalSampler,
194
+ "CombineRegionalPrompts": CombineRegionalPrompts,
195
+ "RegionalPrompt": RegionalPrompt,
196
+
197
+ "ImpactSEGSLabelFilter": SEGSLabelFilter,
198
+ "ImpactSEGSRangeFilter": SEGSRangeFilter,
199
+ "ImpactSEGSOrderedFilter": SEGSOrderedFilter,
200
+
201
+ "ImpactCompare": ImpactCompare,
202
+ "ImpactConditionalBranch": ImpactConditionalBranch,
203
+ "ImpactInt": ImpactInt,
204
+ # "ImpactFloat": ImpactFloat,
205
+ "ImpactValueSender": ImpactValueSender,
206
+ "ImpactValueReceiver": ImpactValueReceiver,
207
+ "ImpactImageInfo": ImpactImageInfo,
208
+ "ImpactMinMax": ImpactMinMax,
209
+ "ImpactNeg": ImpactNeg,
210
+ "ImpactConditionalStopIteration": ImpactConditionalStopIteration,
211
+ }
212
+
213
+
214
+ NODE_DISPLAY_NAME_MAPPINGS = {
215
+ "BboxDetectorSEGS": "BBOX Detector (SEGS)",
216
+ "SegmDetectorSEGS": "SEGM Detector (SEGS)",
217
+ "ONNXDetectorSEGS": "ONNX Detector (SEGS)",
218
+ "BboxDetectorCombined_v2": "BBOX Detector (combined)",
219
+ "SegmDetectorCombined_v2": "SEGM Detector (combined)",
220
+ "SegsToCombinedMask": "SEGS to MASK (combined)",
221
+ "MaskToSEGS": "MASK to SEGS",
222
+ "BitwiseAndMaskForEach": "Bitwise(SEGS & SEGS)",
223
+ "SubtractMaskForEach": "Bitwise(SEGS - SEGS)",
224
+ "Segs & Mask": "Bitwise(SEGS & MASK)",
225
+ "Segs & Mask ForEach": "Bitwise(SEGS & MASKS ForEach)",
226
+ "BitwiseAndMask": "Bitwise(MASK & MASK)",
227
+ "SubtractMask": "Bitwise(MASK - MASK)",
228
+ "AddMask": "Bitwise(MASK + MASK)",
229
+ "DetailerForEach": "Detailer (SEGS)",
230
+ "DetailerForEachPipe": "Detailer (SEGS/pipe)",
231
+ "DetailerForEachDebug": "DetailerDebug (SEGS)",
232
+ "DetailerForEachDebugPipe": "DetailerDebug (SEGS/pipe)",
233
+ "SAMDetectorCombined": "SAMDetector (combined)",
234
+ "SAMDetectorSegmented": "SAMDetector (segmented)",
235
+ "FaceDetailerPipe": "FaceDetailer (pipe)",
236
+
237
+ "BasicPipeToDetailerPipe": "BasicPipe -> DetailerPipe",
238
+ "DetailerPipeToBasicPipe": "DetailerPipe -> BasicPipe",
239
+ "EditBasicPipe": "Edit BasicPipe",
240
+ "EditDetailerPipe": "Edit DetailerPipe",
241
+
242
+ "LatentPixelScale": "Latent Scale (on Pixel Space)",
243
+ "IterativeLatentUpscale": "Iterative Upscale (Latent)",
244
+ "IterativeImageUpscale": "Iterative Upscale (Image)",
245
+
246
+ "TwoSamplersForMaskUpscalerProvider": "TwoSamplersForMask Upscaler Provider",
247
+ "TwoSamplersForMaskUpscalerProviderPipe": "TwoSamplersForMask Upscaler Provider (pipe)",
248
+
249
+ "ReencodeLatent": "Reencode Latent",
250
+ "ReencodeLatentPipe": "Reencode Latent (pipe)",
251
+
252
+ "ImpactKSamplerBasicPipe": "KSampler (pipe)",
253
+ "ImpactKSamplerAdvancedBasicPipe": "KSampler (Advanced/pipe)",
254
+ "ImpactSEGSLabelFilter": "SEGS Filter (label)",
255
+ "ImpactSEGSRangeFilter": "SEGS Filter (range)",
256
+ "ImpactSEGSOrderedFilter": "SEGS Filter (ordered)",
257
+ "ImpactSEGSConcat": "SEGS Concat",
258
+
259
+ "PreviewBridge": "Preview Bridge",
260
+ "ImageSender": "Image Sender",
261
+ "ImageReceiver": "Image Receiver",
262
+ "ImageMaskSwitch": "Switch (images, mask)",
263
+ "LatentSwitch": "Switch (latent)",
264
+ "SEGSSwitch": "Switch (SEGS)",
265
+
266
+ "MasksToMaskList": "Masks to Mask List",
267
+ "ImpactImageBatchToImageList": "Image batch to Image List"
268
+ }
269
+
270
+ if not impact.config.get_config()['mmdet_skip']:
271
+ from impact.mmdet_nodes import *
272
+ import impact.legacy_nodes
273
+ NODE_CLASS_MAPPINGS.update({
274
+ "MMDetDetectorProvider": MMDetDetectorProvider,
275
+ "MMDetLoader": impact.legacy_nodes.MMDetLoader,
276
+ "MaskPainter": impact.legacy_nodes.MaskPainter,
277
+ "SegsMaskCombine": impact.legacy_nodes.SegsMaskCombine,
278
+ "BboxDetectorForEach": impact.legacy_nodes.BboxDetectorForEach,
279
+ "SegmDetectorForEach": impact.legacy_nodes.SegmDetectorForEach,
280
+ "BboxDetectorCombined": impact.legacy_nodes.BboxDetectorCombined,
281
+ "SegmDetectorCombined": impact.legacy_nodes.SegmDetectorCombined,
282
+ })
283
+
284
+ NODE_DISPLAY_NAME_MAPPINGS.update({
285
+ "MaskPainter": "MaskPainter (Deprecated)",
286
+ "MMDetLoader": "MMDetLoader (Legacy)",
287
+ "SegsMaskCombine": "SegsMaskCombine (Legacy)",
288
+ "BboxDetectorForEach": "BboxDetectorForEach (Legacy)",
289
+ "SegmDetectorForEach": "SegmDetectorForEach (Legacy)",
290
+ "BboxDetectorCombined": "BboxDetectorCombined (Legacy)",
291
+ "SegmDetectorCombined": "SegmDetectorCombined (Legacy)",
292
+ })
293
+
294
+ try:
295
+ import impact.subpack_nodes
296
+
297
+ NODE_CLASS_MAPPINGS.update(impact.subpack_nodes.NODE_CLASS_MAPPINGS)
298
+ NODE_DISPLAY_NAME_MAPPINGS.update(impact.subpack_nodes.NODE_DISPLAY_NAME_MAPPINGS)
299
+
300
+ except:
301
+ pass
302
+
303
+ __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
ComfyUI-Impact-Pack/custom_wildcards/put_wildcards_here ADDED
File without changes
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
+
ComfyUI-Impact-Pack/install.py ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import subprocess
4
+
5
+
6
+ if sys.argv[0] == 'install.py':
7
+ sys.path.append('.') # for portable version
8
+
9
+
10
+ impact_path = os.path.join(os.path.dirname(__file__), "modules")
11
+ subpack_path = os.path.join(os.path.dirname(__file__), "subpack")
12
+ subpack_repo = ""
13
+ comfy_path = os.path.join(os.path.dirname(__file__), '..', '..')
14
+
15
+
16
+ sys.path.append(impact_path)
17
+ sys.path.append(comfy_path)
18
+
19
+ import platform
20
+ import folder_paths
21
+ from torchvision.datasets.utils import download_url
22
+ import impact.config
23
+
24
+
25
+ print("### ComfyUI-Impact-Pack: Check dependencies")
26
+
27
+ if "python_embeded" in sys.executable or "python_embedded" in sys.executable:
28
+ pip_install = [sys.executable, '-s', '-m', 'pip', 'install']
29
+ mim_install = [sys.executable, '-s', '-m', 'mim', 'install']
30
+ else:
31
+ pip_install = [sys.executable, '-m', 'pip', 'install']
32
+ mim_install = [sys.executable, '-m', 'mim', 'install']
33
+
34
+
35
+ def ensure_subpack():
36
+ import git
37
+ repo = git.Repo(os.path.dirname(__file__))
38
+ origin = repo.remote(name='origin')
39
+ origin.pull()
40
+ repo.git.submodule('update', '--init', '--recursive')
41
+
42
+
43
+ def remove_olds():
44
+ global comfy_path
45
+
46
+ comfy_path = os.path.dirname(folder_paths.__file__)
47
+ custom_nodes_path = os.path.join(comfy_path, "custom_nodes")
48
+ old_ini_path = os.path.join(custom_nodes_path, "impact-pack.ini")
49
+ old_py_path = os.path.join(custom_nodes_path, "comfyui-impact-pack.py")
50
+
51
+ if os.path.exists(impact.config.old_config_path):
52
+ impact.config.get_config()['mmdet_skip'] = False
53
+ os.remove(impact.config.old_config_path)
54
+
55
+ if os.path.exists(old_ini_path):
56
+ print(f"Delete legacy file: {old_ini_path}")
57
+ os.remove(old_ini_path)
58
+
59
+ if os.path.exists(old_py_path):
60
+ print(f"Delete legacy file: {old_py_path}")
61
+ os.remove(old_py_path)
62
+
63
+
64
+ def ensure_pip_packages_first():
65
+ subpack_req = os.path.join(subpack_path, "requirements.txt")
66
+ if os.path.exists(subpack_req):
67
+ subprocess.run(pip_install + ['-r', 'requirements.txt'], cwd=subpack_path)
68
+
69
+ if not impact.config.get_config()['mmdet_skip']:
70
+ subprocess.run(pip_install + ['openmim'], cwd=subpack_path)
71
+
72
+ try:
73
+ import pycocotools
74
+ except Exception:
75
+ if platform.system() not in ["Windows"] or platform.machine() not in ["AMD64", "x86_64"]:
76
+ print(f"Your system is {platform.system()}; !! You need to install 'libpython3-dev' for this step. !!")
77
+
78
+ subprocess.check_call(pip_install + ['pycocotools'])
79
+ else:
80
+ pycocotools = {
81
+ (3, 8): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp38-cp38-win_amd64.whl",
82
+ (3, 9): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp39-cp39-win_amd64.whl",
83
+ (3, 10): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp310-cp310-win_amd64.whl",
84
+ (3, 11): "https://github.com/Bing-su/dddetailer/releases/download/pycocotools/pycocotools-2.0.6-cp311-cp311-win_amd64.whl",
85
+ }
86
+
87
+ version = sys.version_info[:2]
88
+ url = pycocotools[version]
89
+ subprocess.check_call(pip_install + [url])
90
+
91
+
92
+ def ensure_pip_packages_last():
93
+ try:
94
+ import segment_anything
95
+ from skimage.measure import label, regionprops
96
+ import piexif
97
+ except Exception:
98
+ my_path = os.path.dirname(__file__)
99
+ requirements_path = os.path.join(my_path, "requirements.txt")
100
+ subprocess.check_call(pip_install + ['-r', requirements_path])
101
+
102
+ # !! cv2 importing test must be very last !!
103
+ try:
104
+ import cv2
105
+ except Exception:
106
+ try:
107
+ subprocess.check_call(pip_install + ['opencv-python'])
108
+ except:
109
+ print(f"ComfyUI-Impact-Pack: failed to install 'opencv-python'. Please, install manually.")
110
+
111
+ try:
112
+ import git
113
+ except Exception:
114
+ subprocess.check_call(pip_install + ['gitpython'])
115
+
116
+
117
+ def ensure_mmdet_package():
118
+ try:
119
+ import mmcv
120
+ import mmdet
121
+ from mmdet.evaluation import get_classes
122
+ except Exception:
123
+ subprocess.check_call(pip_install + ['opendatalab==0.0.9'])
124
+ subprocess.check_call(pip_install + ['-U', 'openmim'])
125
+ subprocess.check_call(mim_install + ['mmcv==2.0.0'])
126
+ subprocess.check_call(mim_install + ['mmdet==3.0.0'])
127
+ subprocess.check_call(mim_install + ['mmengine==0.7.4'])
128
+
129
+
130
+ def install():
131
+ remove_olds()
132
+ ensure_pip_packages_first()
133
+
134
+ if not impact.config.get_config()['mmdet_skip']:
135
+ ensure_mmdet_package()
136
+
137
+ ensure_pip_packages_last()
138
+
139
+ # Download model
140
+ print("### ComfyUI-Impact-Pack: Check basic models")
141
+
142
+ model_path = folder_paths.models_dir
143
+
144
+ bbox_path = os.path.join(model_path, "mmdets", "bbox")
145
+ sam_path = os.path.join(model_path, "sams")
146
+ onnx_path = os.path.join(model_path, "onnx")
147
+
148
+ if not os.path.exists(bbox_path):
149
+ os.makedirs(bbox_path)
150
+
151
+ if not impact.config.get_config()['mmdet_skip']:
152
+ if not os.path.exists(os.path.join(bbox_path, "mmdet_anime-face_yolov3.pth")):
153
+ download_url("https://huggingface.co/dustysys/ddetailer/resolve/main/mmdet/bbox/mmdet_anime-face_yolov3.pth", bbox_path)
154
+
155
+ if not os.path.exists(os.path.join(bbox_path, "mmdet_anime-face_yolov3.py")):
156
+ download_url("https://raw.githubusercontent.com/Bing-su/dddetailer/master/config/mmdet_anime-face_yolov3.py", bbox_path)
157
+
158
+ if not os.path.exists(os.path.join(sam_path, "sam_vit_b_01ec64.pth")):
159
+ download_url("https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth", sam_path)
160
+
161
+ subpack_install_script = os.path.join(subpack_path, "install.py")
162
+
163
+ print(f"### ComfyUI-Impact-Pack: Updating subpack")
164
+ ensure_subpack()
165
+
166
+ if os.path.exists(subpack_install_script):
167
+ subprocess.run([sys.executable, 'install.py'], cwd=subpack_path)
168
+ subprocess.run(pip_install + ['-r', 'requirements.txt'], cwd=subpack_path)
169
+
170
+ if not os.path.exists(onnx_path):
171
+ print(f"### ComfyUI-Impact-Pack: onnx model directory created ({onnx_path})")
172
+ os.mkdir(onnx_path)
173
+
174
+ impact.config.write_config()
175
+
176
+
177
+ install()
178
+
ComfyUI-Impact-Pack/js/comboBoolMigration.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ Object.defineProperty(widget, "value", {
22
+ set: (value) => {
23
+ delete widget.value;
24
+ widget.value = value == true || value == widget.options.on;
25
+ },
26
+ get: () => { return value; }
27
+ });
28
+ }
29
+ }
30
+ }
31
+ });
ComfyUI-Impact-Pack/js/impact-pack.js ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ // temporary implementation (copying from https://github.com/pythongosssss/ComfyUI-WD14-Tagger)
6
+ // I think this should be included into master!!
7
+ class ImpactProgressBadge {
8
+ constructor() {
9
+ if (!window.__progress_badge__) {
10
+ window.__progress_badge__ = Symbol("__impact_progress_badge__");
11
+ }
12
+ this.symbol = window.__progress_badge__;
13
+ }
14
+
15
+ getState(node) {
16
+ return node[this.symbol] || {};
17
+ }
18
+
19
+ setState(node, state) {
20
+ node[this.symbol] = state;
21
+ app.canvas.setDirty(true);
22
+ }
23
+
24
+ addStatusHandler(nodeType) {
25
+ if (nodeType[this.symbol]?.statusTagHandler) {
26
+ return;
27
+ }
28
+ if (!nodeType[this.symbol]) {
29
+ nodeType[this.symbol] = {};
30
+ }
31
+ nodeType[this.symbol] = {
32
+ statusTagHandler: true,
33
+ };
34
+
35
+ api.addEventListener("impact/update_status", ({ detail }) => {
36
+ let { node, progress, text } = detail;
37
+ const n = app.graph.getNodeById(+(node || app.runningNodeId));
38
+ if (!n) return;
39
+ const state = this.getState(n);
40
+ state.status = Object.assign(state.status || {}, { progress: text ? progress : null, text: text || null });
41
+ this.setState(n, state);
42
+ });
43
+
44
+ const self = this;
45
+ const onDrawForeground = nodeType.prototype.onDrawForeground;
46
+ nodeType.prototype.onDrawForeground = function (ctx) {
47
+ const r = onDrawForeground?.apply?.(this, arguments);
48
+ const state = self.getState(this);
49
+ if (!state?.status?.text) {
50
+ return r;
51
+ }
52
+
53
+ const { fgColor, bgColor, text, progress, progressColor } = { ...state.status };
54
+
55
+ ctx.save();
56
+ ctx.font = "12px sans-serif";
57
+ const sz = ctx.measureText(text);
58
+ ctx.fillStyle = bgColor || "dodgerblue";
59
+ ctx.beginPath();
60
+ ctx.roundRect(0, -LiteGraph.NODE_TITLE_HEIGHT - 20, sz.width + 12, 20, 5);
61
+ ctx.fill();
62
+
63
+ if (progress) {
64
+ ctx.fillStyle = progressColor || "green";
65
+ ctx.beginPath();
66
+ ctx.roundRect(0, -LiteGraph.NODE_TITLE_HEIGHT - 20, (sz.width + 12) * progress, 20, 5);
67
+ ctx.fill();
68
+ }
69
+
70
+ ctx.fillStyle = fgColor || "#fff";
71
+ ctx.fillText(text, 6, -LiteGraph.NODE_TITLE_HEIGHT - 6);
72
+ ctx.restore();
73
+ return r;
74
+ };
75
+ }
76
+ }
77
+
78
+ const input_tracking = {};
79
+ const input_dirty = {};
80
+ const output_tracking = {};
81
+
82
+ function progressExecuteHandler(event) {
83
+ if(event.detail.output.aux){
84
+ const id = event.detail.node;
85
+ if(input_tracking.hasOwnProperty(id)) {
86
+ if(input_tracking.hasOwnProperty(id) && input_tracking[id][0] != event.detail.output.aux[0]) {
87
+ input_dirty[id] = true;
88
+ }
89
+ else{
90
+
91
+ }
92
+ }
93
+
94
+ input_tracking[id] = event.detail.output.aux;
95
+ }
96
+ }
97
+
98
+ function imgSendHandler(event) {
99
+ if(event.detail.images.length > 0){
100
+ let data = event.detail.images[0];
101
+ let filename = `${data.filename} [${data.type}]`;
102
+
103
+ let nodes = app.graph._nodes;
104
+ for(let i in nodes) {
105
+ if(nodes[i].type == 'ImageReceiver') {
106
+ if(nodes[i].widgets[1].value == event.detail.link_id) {
107
+ if(data.subfolder)
108
+ nodes[i].widgets[0].value = `${data.subfolder}/${data.filename} [${data.type}]`;
109
+ else
110
+ nodes[i].widgets[0].value = `${data.filename} [${data.type}]`;
111
+
112
+ let img = new Image();
113
+ img.src = `/view?filename=${data.filename}&type=${data.type}&subfolder=${data.subfolder}`+app.getPreviewFormatParam();
114
+ nodes[i].imgs = [img];
115
+ nodes[i].size[1] = Math.max(200, nodes[i].size[1]);
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+
122
+
123
+ function latentSendHandler(event) {
124
+ if(event.detail.images.length > 0){
125
+ let data = event.detail.images[0];
126
+ let filename = `${data.filename} [${data.type}]`;
127
+
128
+ let nodes = app.graph._nodes;
129
+ for(let i in nodes) {
130
+ if(nodes[i].type == 'LatentReceiver') {
131
+ if(nodes[i].widgets[1].value == event.detail.link_id) {
132
+ if(data.subfolder)
133
+ nodes[i].widgets[0].value = `${data.subfolder}/${data.filename} [${data.type}]`;
134
+ else
135
+ nodes[i].widgets[0].value = `${data.filename} [${data.type}]`;
136
+
137
+ let img = new Image();
138
+ img.src = `/view?filename=${data.filename}&type=${data.type}&subfolder=${data.subfolder}`+app.getPreviewFormatParam();
139
+ nodes[i].imgs = [img];
140
+ nodes[i].size[1] = Math.max(200, nodes[i].size[1]);
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+
147
+
148
+ function valueSendHandler(event) {
149
+ let nodes = app.graph._nodes;
150
+ for(let i in nodes) {
151
+ if(nodes[i].type == 'ImpactValueReceiver') {
152
+ if(nodes[i].widgets[2].value == event.detail.link_id) {
153
+ nodes[i].widgets[1].value = event.detail.value;
154
+
155
+ let typ = typeof event.detail.value;
156
+ if(typ != "number") {
157
+ nodes[i].widgets[0].value = typeof event.detail.value;
158
+ }
159
+ else if(Number.isInteger(event.detail.value)) {
160
+ nodes[i].widgets[0].value = "INT";
161
+ }
162
+ else {
163
+ nodes[i].widgets[0].value = "FLOAT";
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }
169
+
170
+
171
+ const impactProgressBadge = new ImpactProgressBadge();
172
+
173
+ api.addEventListener("stop-iteration", () => {
174
+ document.getElementById("autoQueueCheckbox").checked = false;
175
+ });
176
+ api.addEventListener("value-send", valueSendHandler);
177
+ api.addEventListener("img-send", imgSendHandler);
178
+ api.addEventListener("latent-send", latentSendHandler);
179
+ api.addEventListener("executed", progressExecuteHandler);
180
+
181
+ app.registerExtension({
182
+ name: "Comfy.Impack",
183
+ loadedGraphNode(node, app) {
184
+ if (node.comfyClass == "PreviewBridge" || node.comfyClass == "MaskPainter") {
185
+ input_dirty[node.id + ""] = true;
186
+ }
187
+ },
188
+
189
+ async beforeRegisterNodeDef(nodeType, nodeData, app) {
190
+ if (nodeData.name == "IterativeLatentUpscale" || nodeData.name == "IterativeImageUpscale") {
191
+ impactProgressBadge.addStatusHandler(nodeType);
192
+ }
193
+ },
194
+
195
+ nodeCreated(node, app) {
196
+ if(node.comfyClass == "MaskPainter") {
197
+ node.addWidget("button", "Edit mask", null, () => {
198
+ ComfyApp.copyToClipspace(node);
199
+ ComfyApp.clipspace_return_node = node;
200
+ ComfyApp.open_maskeditor();
201
+ });
202
+ }
203
+
204
+ switch(node.comfyClass) {
205
+ case "ToDetailerPipe":
206
+ case "BasicPipeToDetailerPipe":
207
+ case "EditDetailerPipe":
208
+ case "FaceDetailer":
209
+ {
210
+ for(let i in node.widgets) {
211
+ let widget = node.widgets[i];
212
+ if(widget.type === "customtext") {
213
+ widget.dynamicPrompts = false;
214
+ widget.inputEl.placeholder = "wildcard spec: if kept empty, this option will be ignored";
215
+ widget.serializeValue = () => {
216
+ return node.widgets[i].value;
217
+ };
218
+ }
219
+ }
220
+ }
221
+ break;
222
+ }
223
+
224
+ if(node.comfyClass == "ImpactSEGSLabelFilter") {
225
+ Object.defineProperty(node.widgets[0], "value", {
226
+ set: (value) => {
227
+ const stackTrace = new Error().stack;
228
+ if(stackTrace.includes('inner_value_change')) {
229
+ if(node.widgets[1].value.trim() != "" && !node.widgets[1].value.trim().endsWith(","))
230
+ node.widgets[1].value += ", "
231
+
232
+ node.widgets[1].value += value;
233
+ node.widgets_values[1] = node.widgets[1].value;
234
+ }
235
+
236
+ this._value = value;
237
+ },
238
+ get: () => {
239
+ return this._value;
240
+ }
241
+ });
242
+ }
243
+
244
+ if(node.comfyClass == "ImpactWildcardProcessor") {
245
+ node.widgets[0].inputEl.placeholder = "Wildcard Prompt (User input)";
246
+ node.widgets[1].inputEl.placeholder = "Populated Prompt (Will be generated automatically)";
247
+ node.widgets[1].inputEl.disabled = true;
248
+ node.widgets[0].dynamicPrompts = false;
249
+ node.widgets[1].dynamicPrompts = false;
250
+
251
+ let populate_getter = node.widgets[1].__lookupGetter__('value');
252
+ let populate_setter = node.widgets[1].__lookupSetter__('value');
253
+
254
+ let force_serializeValue = async (n,i) =>
255
+ {
256
+ if(!node.widgets[2].value) {
257
+ return node.widgets[1].value;
258
+ }
259
+ else {
260
+ let wildcard_text = await node.widgets[0].serializeValue();
261
+
262
+ let response = await api.fetchApi(`/impact/wildcards`, {
263
+ method: 'POST',
264
+ headers: { 'Content-Type': 'application/json' },
265
+ body: JSON.stringify({text: wildcard_text})
266
+ });
267
+
268
+ let populated = await response.json();
269
+
270
+ n.widgets_values[2] = false;
271
+ n.widgets_values[1] = populated.text;
272
+ populate_setter.call(node.widgets[1], populated.text);
273
+
274
+ return populated.text;
275
+ }
276
+ };
277
+
278
+ // mode combo
279
+ Object.defineProperty(node.widgets[2], "value", {
280
+ set: (value) => {
281
+ node._mode_value = value == true || value == "Populate";
282
+ node.widgets[1].inputEl.disabled = value == true || value == "Populate";
283
+ },
284
+ get: () => {
285
+ if(node._mode_value != undefined)
286
+ return node._mode_value;
287
+ else
288
+ return true;
289
+ }
290
+ });
291
+
292
+ // to avoid conflict with presetText.js of pythongosssss
293
+ Object.defineProperty(node.widgets[1], "value", {
294
+ set: (value) => {
295
+ const stackTrace = new Error().stack;
296
+ if(!stackTrace.includes('serializeValue'))
297
+ populate_setter.call(node.widgets[1], value);
298
+ },
299
+ get: () => {
300
+ return populate_getter.call(node.widgets[1]);
301
+ }
302
+ });
303
+
304
+ node.widgets[0].serializeValue = (n,i) => {
305
+ if(node.inputs) {
306
+ let link_id = node.inputs.find(x => x.name=="wildcard_text")?.link;
307
+ if(link_id != undefined) {
308
+ let link = app.graph.links[link_id];
309
+ let input_widget = app.graph._nodes_by_id[link.origin_id].widgets[link.origin_slot];
310
+ if(input_widget.type == "customtext") {
311
+ return input_widget.value;
312
+ }
313
+ }
314
+ else {
315
+ return node.widgets[0].value;
316
+ }
317
+ }
318
+ else {
319
+ return node.widgets[0].value;
320
+ }
321
+ };
322
+ node.widgets[1].serializeValue = force_serializeValue;
323
+ }
324
+
325
+ if (node.comfyClass == "PreviewBridge" || node.comfyClass == "MaskPainter") {
326
+ node.widgets[0].value = '#placeholder';
327
+
328
+ Object.defineProperty(node, "images", {
329
+ set: function(value) {
330
+ node._images = value;
331
+ },
332
+ get: function() {
333
+ const id = node.id+"";
334
+ if(node.widgets[0].value != '#placeholder') {
335
+ var need_invalidate = false;
336
+
337
+ if(input_dirty.hasOwnProperty(id) && input_dirty[id]) {
338
+ node.widgets[0].value = {...input_tracking[id][1]};
339
+ input_dirty[id] = false;
340
+ need_invalidate = true
341
+ this._images = app.nodeOutputs[id].images;
342
+ }
343
+
344
+ let filename = app.nodeOutputs[id]['aux'][1][0]['filename'];
345
+ let subfolder = app.nodeOutputs[id]['aux'][1][0]['subfolder'];
346
+ let type = app.nodeOutputs[id]['aux'][1][0]['type'];
347
+
348
+ let item =
349
+ {
350
+ image_hash: app.nodeOutputs[id]['aux'][0],
351
+ forward_filename: app.nodeOutputs[id]['aux'][1][0]['filename'],
352
+ forward_subfolder: app.nodeOutputs[id]['aux'][1][0]['subfolder'],
353
+ forward_type: app.nodeOutputs[id]['aux'][1][0]['type']
354
+ };
355
+
356
+ app.nodeOutputs[id].images = [{
357
+ ...node._images[0],
358
+ ...item
359
+ }];
360
+
361
+ node.widgets[0].value =
362
+ {
363
+ ...node._images[0],
364
+ ...item
365
+ };
366
+
367
+ if(need_invalidate) {
368
+ Promise.all(
369
+ app.nodeOutputs[id].images.map((src) => {
370
+ return new Promise((r) => {
371
+ const img = new Image();
372
+ img.onload = () => r(img);
373
+ img.onerror = () => r(null);
374
+ img.src = "/view?" + new URLSearchParams(src).toString();
375
+ });
376
+ })
377
+ ).then((imgs) => {
378
+ this.imgs = imgs.filter(Boolean);
379
+ this.setSizeForImage?.();
380
+ app.graph.setDirtyCanvas(true);
381
+ });
382
+
383
+ app.nodeOutputs[id].images[0] = { ...node.widgets[0].value };
384
+ }
385
+
386
+ return app.nodeOutputs[id].images;
387
+ }
388
+ else {
389
+ return node._images;
390
+ }
391
+ }
392
+ });
393
+ }
394
+ }
395
+ });
ComfyUI-Impact-Pack/js/impact-sam-editor.js ADDED
@@ -0,0 +1,636 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { app } from "../../scripts/app.js";
2
+ import { ComfyDialog, $el } from "../../scripts/ui.js";
3
+ import { ComfyApp } from "../../scripts/app.js";
4
+ import { ClipspaceDialog } from "../../extensions/core/clipspace.js";
5
+
6
+ function addMenuHandler(nodeType, cb) {
7
+ const getOpts = nodeType.prototype.getExtraMenuOptions;
8
+ nodeType.prototype.getExtraMenuOptions = function () {
9
+ const r = getOpts.apply(this, arguments);
10
+ cb.apply(this, arguments);
11
+ return r;
12
+ };
13
+ }
14
+
15
+ // Helper function to convert a data URL to a Blob object
16
+ function dataURLToBlob(dataURL) {
17
+ const parts = dataURL.split(';base64,');
18
+ const contentType = parts[0].split(':')[1];
19
+ const byteString = atob(parts[1]);
20
+ const arrayBuffer = new ArrayBuffer(byteString.length);
21
+ const uint8Array = new Uint8Array(arrayBuffer);
22
+ for (let i = 0; i < byteString.length; i++) {
23
+ uint8Array[i] = byteString.charCodeAt(i);
24
+ }
25
+ return new Blob([arrayBuffer], { type: contentType });
26
+ }
27
+
28
+ function loadedImageToBlob(image) {
29
+ const canvas = document.createElement('canvas');
30
+
31
+ canvas.width = image.width;
32
+ canvas.height = image.height;
33
+
34
+ const ctx = canvas.getContext('2d');
35
+
36
+ ctx.drawImage(image, 0, 0);
37
+
38
+ const dataURL = canvas.toDataURL('image/png', 1);
39
+ const blob = dataURLToBlob(dataURL);
40
+
41
+ return blob;
42
+ }
43
+
44
+ async function uploadMask(filepath, formData) {
45
+ await fetch('/upload/mask', {
46
+ method: 'POST',
47
+ body: formData
48
+ }).then(response => {}).catch(error => {
49
+ console.error('Error:', error);
50
+ });
51
+
52
+ ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']] = new Image();
53
+ ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src = `view?filename=${filepath.filename}&type=${filepath.type}`;
54
+
55
+ if(ComfyApp.clipspace.images)
56
+ ComfyApp.clipspace.images[ComfyApp.clipspace['selectedIndex']] = filepath;
57
+
58
+ ClipspaceDialog.invalidatePreview();
59
+ }
60
+
61
+ class ImpactSamEditorDialog extends ComfyDialog {
62
+ static instance = null;
63
+
64
+ static getInstance() {
65
+ if(!ImpactSamEditorDialog.instance) {
66
+ ImpactSamEditorDialog.instance = new ImpactSamEditorDialog();
67
+ }
68
+
69
+ return ImpactSamEditorDialog.instance;
70
+ }
71
+
72
+ constructor() {
73
+ super();
74
+ this.element = $el("div.comfy-modal", { parent: document.body },
75
+ [ $el("div.comfy-modal-content",
76
+ [...this.createButtons()]),
77
+ ]);
78
+ }
79
+
80
+ createButtons() {
81
+ return [];
82
+ }
83
+
84
+ createButton(name, callback) {
85
+ var button = document.createElement("button");
86
+ button.innerText = name;
87
+ button.addEventListener("click", callback);
88
+ return button;
89
+ }
90
+
91
+ createLeftButton(name, callback) {
92
+ var button = this.createButton(name, callback);
93
+ button.style.cssFloat = "left";
94
+ button.style.marginRight = "4px";
95
+ return button;
96
+ }
97
+
98
+ createRightButton(name, callback) {
99
+ var button = this.createButton(name, callback);
100
+ button.style.cssFloat = "right";
101
+ button.style.marginLeft = "4px";
102
+ return button;
103
+ }
104
+
105
+ createLeftSlider(self, name, callback) {
106
+ const divElement = document.createElement('div');
107
+ divElement.id = "sam-confidence-slider";
108
+ divElement.style.cssFloat = "left";
109
+ divElement.style.fontFamily = "sans-serif";
110
+ divElement.style.marginRight = "4px";
111
+ divElement.style.color = "var(--input-text)";
112
+ divElement.style.backgroundColor = "var(--comfy-input-bg)";
113
+ divElement.style.borderRadius = "8px";
114
+ divElement.style.borderColor = "var(--border-color)";
115
+ divElement.style.borderStyle = "solid";
116
+ divElement.style.fontSize = "15px";
117
+ divElement.style.height = "21px";
118
+ divElement.style.padding = "1px 6px";
119
+ divElement.style.display = "flex";
120
+ divElement.style.position = "relative";
121
+ divElement.style.top = "2px";
122
+ self.confidence_slider_input = document.createElement('input');
123
+ self.confidence_slider_input.setAttribute('type', 'range');
124
+ self.confidence_slider_input.setAttribute('min', '0');
125
+ self.confidence_slider_input.setAttribute('max', '100');
126
+ self.confidence_slider_input.setAttribute('value', '70');
127
+ const labelElement = document.createElement("label");
128
+ labelElement.textContent = name;
129
+
130
+ divElement.appendChild(labelElement);
131
+ divElement.appendChild(self.confidence_slider_input);
132
+
133
+ self.confidence_slider_input.addEventListener("change", callback);
134
+
135
+ return divElement;
136
+ }
137
+
138
+ async detect_and_invalidate_mask_canvas(self) {
139
+ const mask_img = await self.detect(self);
140
+
141
+ const canvas = self.maskCtx.canvas;
142
+ const ctx = self.maskCtx;
143
+
144
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
145
+
146
+ await new Promise((resolve, reject) => {
147
+ self.mask_image = new Image();
148
+ self.mask_image.onload = function() {
149
+ ctx.drawImage(self.mask_image, 0, 0, canvas.width, canvas.height);
150
+ resolve();
151
+ };
152
+ self.mask_image.onerror = reject;
153
+ self.mask_image.src = mask_img.src;
154
+ });
155
+ }
156
+
157
+ setlayout(imgCanvas, maskCanvas, pointsCanvas) {
158
+ const self = this;
159
+
160
+ // If it is specified as relative, using it only as a hidden placeholder for padding is recommended
161
+ // to prevent anomalies where it exceeds a certain size and goes outside of the window.
162
+ var placeholder = document.createElement("div");
163
+ placeholder.style.position = "relative";
164
+ placeholder.style.height = "50px";
165
+
166
+ var bottom_panel = document.createElement("div");
167
+ bottom_panel.style.position = "absolute";
168
+ bottom_panel.style.bottom = "0px";
169
+ bottom_panel.style.left = "20px";
170
+ bottom_panel.style.right = "20px";
171
+ bottom_panel.style.height = "50px";
172
+
173
+ var brush = document.createElement("div");
174
+ brush.id = "sam-brush";
175
+ brush.style.backgroundColor = "blue";
176
+ brush.style.outline = "2px solid pink";
177
+ brush.style.borderRadius = "50%";
178
+ brush.style.MozBorderRadius = "50%";
179
+ brush.style.WebkitBorderRadius = "50%";
180
+ brush.style.position = "absolute";
181
+ brush.style.zIndex = 100;
182
+ brush.style.pointerEvents = "none";
183
+ this.brush = brush;
184
+ this.element.appendChild(imgCanvas);
185
+ this.element.appendChild(maskCanvas);
186
+ this.element.appendChild(pointsCanvas);
187
+ this.element.appendChild(placeholder); // must below z-index than bottom_panel to avoid covering button
188
+ this.element.appendChild(bottom_panel);
189
+ document.body.appendChild(brush);
190
+ this.brush_size = 5;
191
+
192
+ var confidence_slider = this.createLeftSlider(self, "Confidence", (event) => {
193
+ self.confidence = event.target.value;
194
+ });
195
+
196
+ var clearButton = this.createLeftButton("Clear", () => {
197
+ self.maskCtx.clearRect(0, 0, self.maskCanvas.width, self.maskCanvas.height);
198
+ self.pointsCtx.clearRect(0, 0, self.pointsCanvas.width, self.pointsCanvas.height);
199
+
200
+ self.prompt_points = [];
201
+
202
+ self.invalidatePointsCanvas(self);
203
+ });
204
+
205
+ var detectButton = this.createLeftButton("Detect", () => self.detect_and_invalidate_mask_canvas(self));
206
+
207
+ var cancelButton = this.createRightButton("Cancel", () => {
208
+ document.removeEventListener("mouseup", ImpactSamEditorDialog.handleMouseUp);
209
+ document.removeEventListener("keydown", ImpactSamEditorDialog.handleKeyDown);
210
+ self.close();
211
+ });
212
+
213
+ self.saveButton = this.createRightButton("Save", () => {
214
+ document.removeEventListener("mouseup", ImpactSamEditorDialog.handleMouseUp);
215
+ document.removeEventListener("keydown", ImpactSamEditorDialog.handleKeyDown);
216
+ self.save(self);
217
+ });
218
+
219
+ var undoButton = this.createLeftButton("Undo", () => {
220
+ if(self.prompt_points.length > 0) {
221
+ self.prompt_points.pop();
222
+ self.pointsCtx.clearRect(0, 0, self.pointsCanvas.width, self.pointsCanvas.height);
223
+ self.invalidatePointsCanvas(self);
224
+ }
225
+ });
226
+
227
+ bottom_panel.appendChild(clearButton);
228
+ bottom_panel.appendChild(detectButton);
229
+ bottom_panel.appendChild(self.saveButton);
230
+ bottom_panel.appendChild(cancelButton);
231
+ bottom_panel.appendChild(confidence_slider);
232
+ bottom_panel.appendChild(undoButton);
233
+
234
+ imgCanvas.style.position = "relative";
235
+ imgCanvas.style.top = "200";
236
+ imgCanvas.style.left = "0";
237
+
238
+ maskCanvas.style.position = "absolute";
239
+ maskCanvas.style.opacity = 0.5;
240
+ pointsCanvas.style.position = "absolute";
241
+ }
242
+
243
+ show() {
244
+ this.mask_image = null;
245
+ self.prompt_points = [];
246
+
247
+ this.message_box = $el("p", ["Please wait a moment while the SAM model and the image are being loaded."]);
248
+ this.element.appendChild(this.message_box);
249
+
250
+ if(self.imgCtx) {
251
+ self.imgCtx.clearRect(0, 0, self.imageCanvas.width, self.imageCanvas.height);
252
+ }
253
+
254
+ const target_image_path = ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src;
255
+ this.load_sam(target_image_path);
256
+
257
+ if(!this.is_layout_created) {
258
+ // layout
259
+ const imgCanvas = document.createElement('canvas');
260
+ const maskCanvas = document.createElement('canvas');
261
+ const pointsCanvas = document.createElement('canvas');
262
+
263
+ imgCanvas.id = "imageCanvas";
264
+ maskCanvas.id = "maskCanvas";
265
+ pointsCanvas.id = "pointsCanvas";
266
+
267
+ this.setlayout(imgCanvas, maskCanvas, pointsCanvas);
268
+
269
+ // prepare content
270
+ this.imgCanvas = imgCanvas;
271
+ this.maskCanvas = maskCanvas;
272
+ this.pointsCanvas = pointsCanvas;
273
+ this.maskCtx = maskCanvas.getContext('2d');
274
+ this.pointsCtx = pointsCanvas.getContext('2d');
275
+
276
+ this.is_layout_created = true;
277
+
278
+ // replacement of onClose hook since close is not real close
279
+ const self = this;
280
+ const observer = new MutationObserver(function(mutations) {
281
+ mutations.forEach(function(mutation) {
282
+ if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
283
+ if(self.last_display_style && self.last_display_style != 'none' && self.element.style.display == 'none') {
284
+ ComfyApp.onClipspaceEditorClosed();
285
+ }
286
+
287
+ self.last_display_style = self.element.style.display;
288
+ }
289
+ });
290
+ });
291
+
292
+ const config = { attributes: true };
293
+ observer.observe(this.element, config);
294
+ }
295
+
296
+ this.setImages(target_image_path, this.imgCanvas, this.pointsCanvas);
297
+
298
+ if(ComfyApp.clipspace_return_node) {
299
+ this.saveButton.innerText = "Save to node";
300
+ }
301
+ else {
302
+ this.saveButton.innerText = "Save";
303
+ }
304
+ this.saveButton.disabled = true;
305
+
306
+ this.element.style.display = "block";
307
+ this.element.style.zIndex = 8888; // NOTE: alert dialog must be high priority.
308
+ }
309
+
310
+ updateBrushPreview(self, event) {
311
+ event.preventDefault();
312
+
313
+ const centerX = event.pageX;
314
+ const centerY = event.pageY;
315
+
316
+ const brush = self.brush;
317
+
318
+ brush.style.width = self.brush_size * 2 + "px";
319
+ brush.style.height = self.brush_size * 2 + "px";
320
+ brush.style.left = (centerX - self.brush_size) + "px";
321
+ brush.style.top = (centerY - self.brush_size) + "px";
322
+ }
323
+
324
+ setImages(target_image_path, imgCanvas, pointsCanvas) {
325
+ const imgCtx = imgCanvas.getContext('2d');
326
+ const maskCtx = this.maskCtx;
327
+ const maskCanvas = this.maskCanvas;
328
+
329
+ const self = this;
330
+
331
+ // image load
332
+ const orig_image = new Image();
333
+ window.addEventListener("resize", () => {
334
+ // repositioning
335
+ imgCanvas.width = window.innerWidth - 250;
336
+ imgCanvas.height = window.innerHeight - 200;
337
+
338
+ // redraw image
339
+ let drawWidth = orig_image.width;
340
+ let drawHeight = orig_image.height;
341
+
342
+ if (orig_image.width > imgCanvas.width) {
343
+ drawWidth = imgCanvas.width;
344
+ drawHeight = (drawWidth / orig_image.width) * orig_image.height;
345
+ }
346
+
347
+ if (drawHeight > imgCanvas.height) {
348
+ drawHeight = imgCanvas.height;
349
+ drawWidth = (drawHeight / orig_image.height) * orig_image.width;
350
+ }
351
+
352
+ imgCtx.drawImage(orig_image, 0, 0, drawWidth, drawHeight);
353
+
354
+ // update mask
355
+ pointsCanvas.width = drawWidth;
356
+ pointsCanvas.height = drawHeight;
357
+ pointsCanvas.style.top = imgCanvas.offsetTop + "px";
358
+ pointsCanvas.style.left = imgCanvas.offsetLeft + "px";
359
+
360
+ maskCanvas.width = drawWidth;
361
+ maskCanvas.height = drawHeight;
362
+ maskCanvas.style.top = imgCanvas.offsetTop + "px";
363
+ maskCanvas.style.left = imgCanvas.offsetLeft + "px";
364
+
365
+ self.invalidateMaskCanvas(self);
366
+ self.invalidatePointsCanvas(self);
367
+ });
368
+
369
+ // original image load
370
+ orig_image.onload = () => self.onLoaded(self);
371
+ const rgb_url = new URL(target_image_path);
372
+ rgb_url.searchParams.delete('channel');
373
+ rgb_url.searchParams.set('channel', 'rgb');
374
+ orig_image.src = rgb_url;
375
+ self.image = orig_image;
376
+ }
377
+
378
+ onLoaded(self) {
379
+ if(self.message_box) {
380
+ self.element.removeChild(self.message_box);
381
+ self.message_box = null;
382
+ }
383
+
384
+ window.dispatchEvent(new Event('resize'));
385
+
386
+ self.setEventHandler(pointsCanvas);
387
+ self.saveButton.disabled = false;
388
+ }
389
+
390
+ setEventHandler(targetCanvas) {
391
+ targetCanvas.addEventListener("contextmenu", (event) => {
392
+ event.preventDefault();
393
+ });
394
+
395
+ const self = this;
396
+ targetCanvas.addEventListener('pointermove', (event) => this.updateBrushPreview(self,event));
397
+ targetCanvas.addEventListener('pointerdown', (event) => this.handlePointerDown(self,event));
398
+ targetCanvas.addEventListener('pointerover', (event) => { this.brush.style.display = "block"; });
399
+ targetCanvas.addEventListener('pointerleave', (event) => { this.brush.style.display = "none"; });
400
+ document.addEventListener('keydown', ImpactSamEditorDialog.handleKeyDown);
401
+ }
402
+
403
+ static handleKeyDown(event) {
404
+ const self = ImpactSamEditorDialog.instance;
405
+ if (event.key === '=') { // positive
406
+ brush.style.backgroundColor = "blue";
407
+ brush.style.outline = "2px solid pink";
408
+ self.is_positive_mode = true;
409
+ } else if (event.key === '-') { // negative
410
+ brush.style.backgroundColor = "red";
411
+ brush.style.outline = "2px solid skyblue";
412
+ self.is_positive_mode = false;
413
+ }
414
+ }
415
+
416
+ is_positive_mode = true;
417
+ prompt_points = [];
418
+ confidence = 70;
419
+
420
+ invalidatePointsCanvas(self) {
421
+ const ctx = self.pointsCtx;
422
+
423
+ for (const i in self.prompt_points) {
424
+ const [is_positive, x, y] = self.prompt_points[i];
425
+
426
+ const scaledX = x * ctx.canvas.width / self.image.width;
427
+ const scaledY = y * ctx.canvas.height / self.image.height;
428
+
429
+ if(is_positive)
430
+ ctx.fillStyle = "blue";
431
+ else
432
+ ctx.fillStyle = "red";
433
+ ctx.beginPath();
434
+ ctx.arc(scaledX, scaledY, 3, 0, 3 * Math.PI);
435
+ ctx.fill();
436
+ }
437
+ }줘
438
+
439
+ invalidateMaskCanvas(self) {
440
+ if(self.mask_image) {
441
+ self.maskCtx.clearRect(0, 0, self.maskCanvas.width, self.maskCanvas.height);
442
+ self.maskCtx.drawImage(self.mask_image, 0, 0, self.maskCanvas.width, self.maskCanvas.height);
443
+ }
444
+ }
445
+
446
+ async load_sam(url) {
447
+ const parsedUrl = new URL(url);
448
+ const searchParams = new URLSearchParams(parsedUrl.search);
449
+
450
+ const filename = searchParams.get("filename") || "";
451
+ const fileType = searchParams.get("type") || "";
452
+ const subfolder = searchParams.get("subfolder") || "";
453
+
454
+ const data = {
455
+ sam_model_name: "sam_vit_b_01ec64.pth",
456
+ filename: filename,
457
+ type: fileType,
458
+ subfolder: subfolder
459
+ };
460
+
461
+ fetch('/sam/prepare', {
462
+ method: 'POST',
463
+ headers: { 'Content-Type': 'application/json' },
464
+ body: JSON.stringify(data)
465
+ });
466
+ }
467
+
468
+ async detect(self) {
469
+ const positive_points = [];
470
+ const negative_points = [];
471
+
472
+ for(const i in self.prompt_points) {
473
+ const [is_positive, x, y] = self.prompt_points[i];
474
+ const point = [x,y];
475
+ if(is_positive)
476
+ positive_points.push(point);
477
+ else
478
+ negative_points.push(point);
479
+ }
480
+
481
+ const data = {
482
+ positive_points: positive_points,
483
+ negative_points: negative_points,
484
+ threshold: self.confidence/100
485
+ };
486
+
487
+ const response = await fetch('/sam/detect', {
488
+ method: 'POST',
489
+ headers: { 'Content-Type': 'image/png' },
490
+ body: JSON.stringify(data)
491
+ });
492
+
493
+ const blob = await response.blob();
494
+ const url = URL.createObjectURL(blob);
495
+
496
+ return new Promise((resolve, reject) => {
497
+ const image = new Image();
498
+ image.onload = () => resolve(image);
499
+ image.onerror = reject;
500
+ image.src = url;
501
+ });
502
+ }
503
+
504
+ handlePointerDown(self, event) {
505
+ if ([0, 2, 5].includes(event.button)) {
506
+ event.preventDefault();
507
+ const x = event.offsetX || event.targetTouches[0].clientX - maskRect.left;
508
+ const y = event.offsetY || event.targetTouches[0].clientY - maskRect.top;
509
+
510
+ const originalX = x * self.image.width / self.pointsCanvas.width;
511
+ const originalY = y * self.image.height / self.pointsCanvas.height;
512
+
513
+ var point = null;
514
+ if (event.button == 0) {
515
+ // positive
516
+ point = [true, originalX, originalY];
517
+ } else {
518
+ // negative
519
+ point = [false, originalX, originalY];
520
+ }
521
+
522
+ self.prompt_points.push(point);
523
+
524
+ self.invalidatePointsCanvas(self);
525
+ }
526
+ }
527
+
528
+ async save(self) {
529
+ if(!self.mask_image) {
530
+ this.close();
531
+ return;
532
+ }
533
+
534
+ const save_canvas = document.createElement('canvas');
535
+
536
+ const save_ctx = save_canvas.getContext('2d', {willReadFrequently:true});
537
+ save_canvas.width = self.mask_image.width;
538
+ save_canvas.height = self.mask_image.height;
539
+
540
+ save_ctx.drawImage(self.mask_image, 0, 0, save_canvas.width, save_canvas.height);
541
+
542
+ const save_data = save_ctx.getImageData(0, 0, save_canvas.width, save_canvas.height);
543
+
544
+ // refine mask image
545
+ for (let i = 0; i < save_data.data.length; i += 4) {
546
+ if(save_data.data[i]) {
547
+ save_data.data[i+3] = 0;
548
+ }
549
+ else {
550
+ save_data.data[i+3] = 255;
551
+ }
552
+
553
+ save_data.data[i] = 0;
554
+ save_data.data[i+1] = 0;
555
+ save_data.data[i+2] = 0;
556
+ }
557
+
558
+ save_ctx.globalCompositeOperation = 'source-over';
559
+ save_ctx.putImageData(save_data, 0, 0);
560
+
561
+ const formData = new FormData();
562
+ const filename = "clipspace-mask-" + performance.now() + ".png";
563
+
564
+ const item =
565
+ {
566
+ "filename": filename,
567
+ "subfolder": "",
568
+ "type": "temp",
569
+ };
570
+
571
+ if(ComfyApp.clipspace.images)
572
+ ComfyApp.clipspace.images[0] = item;
573
+
574
+ if(ComfyApp.clipspace.widgets) {
575
+ const index = ComfyApp.clipspace.widgets.findIndex(obj => obj.name === 'image');
576
+
577
+ if(index >= 0)
578
+ ComfyApp.clipspace.widgets[index].value = `${filename} [temp]`;
579
+ }
580
+
581
+ const dataURL = save_canvas.toDataURL();
582
+ const blob = dataURLToBlob(dataURL);
583
+
584
+ let original_url = new URL(this.image.src);
585
+
586
+ const original_ref = { filename: original_url.searchParams.get('filename') };
587
+
588
+ let original_subfolder = original_url.searchParams.get("subfolder");
589
+ if(original_subfolder)
590
+ original_ref.subfolder = original_subfolder;
591
+
592
+ let original_type = original_url.searchParams.get("type");
593
+ if(original_type)
594
+ original_ref.type = original_type;
595
+
596
+ formData.append('image', blob, filename);
597
+ formData.append('original_ref', JSON.stringify(original_ref));
598
+ formData.append('type', "temp");
599
+
600
+ await uploadMask(item, formData);
601
+ ComfyApp.onClipspaceEditorSave();
602
+ this.close();
603
+ }
604
+ }
605
+
606
+ app.registerExtension({
607
+ name: "Comfy.Impact.SAMEditor",
608
+ init(app) {
609
+ const callback =
610
+ function () {
611
+ let dlg = ImpactSamEditorDialog.getInstance();
612
+ dlg.show();
613
+ };
614
+
615
+ const context_predicate = () => ComfyApp.clipspace && ComfyApp.clipspace.imgs && ComfyApp.clipspace.imgs.length > 0
616
+ ClipspaceDialog.registerButton("Impact SAM Detector", context_predicate, callback);
617
+ },
618
+
619
+ async beforeRegisterNodeDef(nodeType, nodeData, app) {
620
+ if (nodeData.output.includes("MASK") && nodeData.output.includes("IMAGE")) {
621
+ addMenuHandler(nodeType, function (_, options) {
622
+ options.unshift({
623
+ content: "Open in SAM Detector",
624
+ callback: () => {
625
+ ComfyApp.copyToClipspace(this);
626
+ ComfyApp.clipspace_return_node = this;
627
+
628
+ let dlg = ImpactSamEditorDialog.getInstance();
629
+ dlg.show();
630
+ },
631
+ });
632
+ });
633
+ }
634
+ }
635
+ });
636
+
ComfyUI-Impact-Pack/latent.png ADDED

Git LFS Details

  • SHA256: 1faf0cc926b0d65c8ab93e7485aea816283eb22fdeefe9682c206948c1de2043
  • Pointer size: 129 Bytes
  • Size of remote file: 2.81 kB
ComfyUI-Impact-Pack/modules/impact/additional_dependencies.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import subprocess
3
+
4
+
5
+ def ensure_onnx_package():
6
+ try:
7
+ import onnxruntime
8
+ except Exception:
9
+ if "python_embeded" in sys.executable or "python_embedded" in sys.executable:
10
+ subprocess.check_call([sys.executable, '-s', '-m', 'pip', 'install', 'onnxruntime'])
11
+ else:
12
+ subprocess.check_call([sys.executable, '-s', '-m', 'pip', 'install', 'onnxruntime'])
ComfyUI-Impact-Pack/modules/impact/config.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import configparser
2
+ import os
3
+
4
+
5
+ version = "V3.12.1"
6
+
7
+ dependency_version = 9
8
+
9
+ my_path = os.path.dirname(__file__)
10
+ old_config_path = os.path.join(my_path, "impact-pack.ini")
11
+ config_path = os.path.join(my_path, "..", "..", "impact-pack.ini")
12
+ latent_letter_path = os.path.join(my_path, "..", "..", "latent.png")
13
+
14
+ MAX_RESOLUTION = 8192
15
+
16
+
17
+ def write_config():
18
+ config = configparser.ConfigParser()
19
+ config['default'] = {
20
+ 'dependency_version': dependency_version,
21
+ 'mmdet_skip': get_config()['mmdet_skip'],
22
+ }
23
+ with open(config_path, 'w') as configfile:
24
+ config.write(configfile)
25
+
26
+
27
+ def read_config():
28
+ try:
29
+ config = configparser.ConfigParser()
30
+ config.read(config_path)
31
+ default_conf = config['default']
32
+
33
+ return {
34
+ 'dependency_version': int(default_conf['dependency_version']),
35
+ 'mmdet_skip': default_conf['mmdet_skip'].lower() == 'true'
36
+ }
37
+
38
+ except Exception:
39
+ return {'dependency_version': 0, 'mmdet_skip': True}
40
+
41
+
42
+ cached_config = None
43
+
44
+
45
+ def get_config():
46
+ global cached_config
47
+
48
+ if cached_config is None:
49
+ cached_config = read_config()
50
+
51
+ return cached_config
ComfyUI-Impact-Pack/modules/impact/core.py ADDED
@@ -0,0 +1,1330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from segment_anything import SamPredictor
3
+ import torch.nn.functional as F
4
+
5
+ from impact.utils import *
6
+ from collections import namedtuple
7
+ import numpy as np
8
+ from skimage.measure import label, regionprops
9
+
10
+ import nodes
11
+ import comfy_extras.nodes_upscale_model as model_upscale
12
+ from server import PromptServer
13
+ import comfy
14
+ import impact.wildcards as wildcards
15
+ import math
16
+
17
+ SEG = namedtuple("SEG", ['cropped_image', 'cropped_mask', 'confidence', 'crop_region', 'bbox', 'label'],
18
+ defaults=[None])
19
+
20
+
21
+ def erosion_mask(mask, grow_mask_by):
22
+ w = mask.shape[1]
23
+ h = mask.shape[0]
24
+
25
+ mask = mask.clone()
26
+
27
+ mask2 = torch.nn.functional.interpolate(mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1])), size=(w, h),
28
+ mode="bilinear")
29
+ if grow_mask_by == 0:
30
+ mask_erosion = mask2
31
+ else:
32
+ kernel_tensor = torch.ones((1, 1, grow_mask_by, grow_mask_by))
33
+ padding = math.ceil((grow_mask_by - 1) / 2)
34
+
35
+ mask_erosion = torch.clamp(torch.nn.functional.conv2d(mask2.round(), kernel_tensor, padding=padding), 0, 1)
36
+
37
+ return mask_erosion[:, :, :w, :h].round()
38
+
39
+
40
+ class REGIONAL_PROMPT:
41
+ def __init__(self, mask, sampler):
42
+ self.mask = mask
43
+ self.sampler = sampler
44
+ self.mask_erosion = None
45
+ self.erosion_factor = None
46
+
47
+ def get_mask_erosion(self, factor):
48
+ if self.mask_erosion is None or self.erosion_factor != factor:
49
+ self.mask_erosion = erosion_mask(self.mask, factor)
50
+
51
+ return self.mask_erosion
52
+
53
+
54
+ class NO_BBOX_DETECTOR:
55
+ pass
56
+
57
+
58
+ class NO_SEGM_DETECTOR:
59
+ pass
60
+
61
+
62
+ def create_segmasks(results):
63
+ bboxs = results[1]
64
+ segms = results[2]
65
+ confidence = results[3]
66
+
67
+ results = []
68
+ for i in range(len(segms)):
69
+ item = (bboxs[i], segms[i].astype(np.float32), confidence[i])
70
+ results.append(item)
71
+ return results
72
+
73
+
74
+ def gen_detection_hints_from_mask_area(x, y, mask, threshold, use_negative):
75
+ points = []
76
+ plabs = []
77
+
78
+ # minimum sampling step >= 3
79
+ y_step = max(3, int(mask.shape[0]/20))
80
+ x_step = max(3, int(mask.shape[1]/20))
81
+
82
+ for i in range(0, len(mask), y_step):
83
+ for j in range(0, len(mask[i]), x_step):
84
+ if mask[i][j] > threshold:
85
+ points.append((x+j, y+i))
86
+ plabs.append(1)
87
+ elif use_negative and mask[i][j] == 0:
88
+ points.append((x+j, y+i))
89
+ plabs.append(0)
90
+
91
+ return points, plabs
92
+
93
+
94
+ def gen_negative_hints(w, h, x1, y1, x2, y2):
95
+ npoints = []
96
+ nplabs = []
97
+
98
+ # minimum sampling step >= 3
99
+ y_step = max(3, int(w/20))
100
+ x_step = max(3, int(h/20))
101
+
102
+ for i in range(10, h-10, y_step):
103
+ for j in range(10, w-10, x_step):
104
+ if not (x1-10 <= j and j <= x2+10 and y1-10 <= i and i <= y2+10):
105
+ npoints.append((j, i))
106
+ nplabs.append(0)
107
+
108
+ return npoints, nplabs
109
+
110
+
111
+ def enhance_detail(image, model, clip, vae, guide_size, guide_size_for_bbox, max_size, bbox, seed, steps, cfg, sampler_name,
112
+ scheduler, positive, negative, denoise, noise_mask, force_inpaint, wildcard_opt=None):
113
+ if wildcard_opt is not None and wildcard_opt != "":
114
+ model, positive = wildcards.process_with_loras(wildcard_opt, model, clip)
115
+
116
+ h = image.shape[1]
117
+ w = image.shape[2]
118
+
119
+ bbox_h = bbox[3] - bbox[1]
120
+ bbox_w = bbox[2] - bbox[0]
121
+
122
+ # Skip processing if the detected bbox is already larger than the guide_size
123
+ if not force_inpaint and bbox_h >= guide_size and bbox_w >= guide_size:
124
+ print(f"Detailer: segment skip (enough big)")
125
+ return None
126
+
127
+ if guide_size_for_bbox: # == "bbox"
128
+ # Scale up based on the smaller dimension between width and height.
129
+ upscale = guide_size / min(bbox_w, bbox_h)
130
+ else:
131
+ # for cropped_size
132
+ upscale = guide_size / min(w, h)
133
+
134
+ new_w = int(w * upscale)
135
+ new_h = int(h * upscale)
136
+
137
+ # safeguard
138
+ if new_w > max_size or new_h > max_size:
139
+ upscale *= max_size / max(new_w, new_h)
140
+ new_w = int(w * upscale)
141
+ new_h = int(h * upscale)
142
+
143
+ if not force_inpaint:
144
+ if upscale <= 1.0:
145
+ print(f"Detailer: segment skip [determined upscale factor={upscale}]")
146
+ return None
147
+
148
+ if new_w == 0 or new_h == 0:
149
+ print(f"Detailer: segment skip [zero size={new_w, new_h}]")
150
+ return None
151
+ else:
152
+ if upscale <= 1.0 or new_w == 0 or new_h == 0:
153
+ print(f"Detailer: force inpaint")
154
+ upscale = 1.0
155
+ new_w = w
156
+ new_h = h
157
+
158
+ print(f"Detailer: segment upscale for ({bbox_w, bbox_h}) | crop region {w, h} x {upscale} -> {new_w, new_h}")
159
+
160
+ # upscale
161
+ upscaled_image = scale_tensor(new_w, new_h, torch.from_numpy(image))
162
+
163
+ # ksampler
164
+ latent_image = to_latent_image(upscaled_image, vae)
165
+
166
+ if noise_mask is not None:
167
+ # upscale the mask tensor by a factor of 2 using bilinear interpolation
168
+ noise_mask = torch.from_numpy(noise_mask)
169
+ upscaled_mask = torch.nn.functional.interpolate(noise_mask.unsqueeze(0).unsqueeze(0), size=(new_h, new_w),
170
+ mode='bilinear', align_corners=False)
171
+
172
+ # remove the extra dimensions added by unsqueeze
173
+ upscaled_mask = upscaled_mask.squeeze().squeeze()
174
+ latent_image['noise_mask'] = upscaled_mask
175
+
176
+ refined_latent = nodes.KSampler().sample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise)[0]
177
+
178
+ # non-latent downscale - latent downscale cause bad quality
179
+ refined_image = vae.decode(refined_latent['samples'])
180
+
181
+ # downscale
182
+ refined_image = scale_tensor_and_to_pil(w, h, refined_image)
183
+
184
+ # don't convert to latent - latent break image
185
+ # preserving pil is much better
186
+ return refined_image
187
+
188
+
189
+ def composite_to(dest_latent, crop_region, src_latent):
190
+ x1 = crop_region[0]
191
+ y1 = crop_region[1]
192
+
193
+ # composite to original latent
194
+ lc = nodes.LatentComposite()
195
+
196
+ # 현재 mask 를 고려한 composite 가 없음... 이거 처리 필요.
197
+
198
+ orig_image = lc.composite(dest_latent, src_latent, x1, y1)
199
+
200
+ return orig_image[0]
201
+
202
+
203
+ def sam_predict(predictor, points, plabs, bbox, threshold):
204
+ point_coords = None if not points else np.array(points)
205
+ point_labels = None if not plabs else np.array(plabs)
206
+
207
+ box = np.array([bbox]) if bbox is not None else None
208
+
209
+ cur_masks, scores, _ = predictor.predict(point_coords=point_coords, point_labels=point_labels, box=box)
210
+
211
+ total_masks = []
212
+
213
+ selected = False
214
+ max_score = 0
215
+ for idx in range(len(scores)):
216
+ if scores[idx] > max_score:
217
+ max_score = scores[idx]
218
+ max_mask = cur_masks[idx]
219
+
220
+ if scores[idx] >= threshold:
221
+ selected = True
222
+ total_masks.append(cur_masks[idx])
223
+ else:
224
+ pass
225
+
226
+ if not selected:
227
+ total_masks.append(max_mask)
228
+
229
+ return total_masks
230
+
231
+
232
+ def make_sam_mask(sam_model, segs, image, detection_hint, dilation,
233
+ threshold, bbox_expansion, mask_hint_threshold, mask_hint_use_negative):
234
+
235
+ if sam_model.is_auto_mode:
236
+ device = comfy.model_management.get_torch_device()
237
+ sam_model.to(device=device)
238
+
239
+ try:
240
+ predictor = SamPredictor(sam_model)
241
+ image = np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8)
242
+ predictor.set_image(image, "RGB")
243
+
244
+ total_masks = []
245
+
246
+ use_small_negative = mask_hint_use_negative == "Small"
247
+
248
+ # seg_shape = segs[0]
249
+ segs = segs[1]
250
+ if detection_hint == "mask-points":
251
+ points = []
252
+ plabs = []
253
+
254
+ for i in range(len(segs)):
255
+ bbox = segs[i].bbox
256
+ center = center_of_bbox(segs[i].bbox)
257
+ points.append(center)
258
+
259
+ # small point is background, big point is foreground
260
+ if use_small_negative and bbox[2] - bbox[0] < 10:
261
+ plabs.append(0)
262
+ else:
263
+ plabs.append(1)
264
+
265
+ detected_masks = sam_predict(predictor, points, plabs, None, threshold)
266
+ total_masks += detected_masks
267
+
268
+ else:
269
+ for i in range(len(segs)):
270
+ bbox = segs[i].bbox
271
+ center = center_of_bbox(bbox)
272
+
273
+ x1 = max(bbox[0] - bbox_expansion, 0)
274
+ y1 = max(bbox[1] - bbox_expansion, 0)
275
+ x2 = min(bbox[2] + bbox_expansion, image.shape[1])
276
+ y2 = min(bbox[3] + bbox_expansion, image.shape[0])
277
+
278
+ dilated_bbox = [x1, y1, x2, y2]
279
+
280
+ points = []
281
+ plabs = []
282
+ if detection_hint == "center-1":
283
+ points.append(center)
284
+ plabs = [1] # 1 = foreground point, 0 = background point
285
+
286
+ elif detection_hint == "horizontal-2":
287
+ gap = (x2 - x1) / 3
288
+ points.append((x1 + gap, center[1]))
289
+ points.append((x1 + gap * 2, center[1]))
290
+ plabs = [1, 1]
291
+
292
+ elif detection_hint == "vertical-2":
293
+ gap = (y2 - y1) / 3
294
+ points.append((center[0], y1 + gap))
295
+ points.append((center[0], y1 + gap * 2))
296
+ plabs = [1, 1]
297
+
298
+ elif detection_hint == "rect-4":
299
+ x_gap = (x2 - x1) / 3
300
+ y_gap = (y2 - y1) / 3
301
+ points.append((x1 + x_gap, center[1]))
302
+ points.append((x1 + x_gap * 2, center[1]))
303
+ points.append((center[0], y1 + y_gap))
304
+ points.append((center[0], y1 + y_gap * 2))
305
+ plabs = [1, 1, 1, 1]
306
+
307
+ elif detection_hint == "diamond-4":
308
+ x_gap = (x2 - x1) / 3
309
+ y_gap = (y2 - y1) / 3
310
+ points.append((x1 + x_gap, y1 + y_gap))
311
+ points.append((x1 + x_gap * 2, y1 + y_gap))
312
+ points.append((x1 + x_gap, y1 + y_gap * 2))
313
+ points.append((x1 + x_gap * 2, y1 + y_gap * 2))
314
+ plabs = [1, 1, 1, 1]
315
+
316
+ elif detection_hint == "mask-point-bbox":
317
+ center = center_of_bbox(segs[i].bbox)
318
+ points.append(center)
319
+ plabs = [1]
320
+
321
+ elif detection_hint == "mask-area":
322
+ points, plabs = gen_detection_hints_from_mask_area(segs[i].crop_region[0], segs[i].crop_region[1],
323
+ segs[i].cropped_mask,
324
+ mask_hint_threshold, use_small_negative)
325
+
326
+ if mask_hint_use_negative == "Outter":
327
+ npoints, nplabs = gen_negative_hints(image.shape[0], image.shape[1],
328
+ segs[i].crop_region[0], segs[i].crop_region[1],
329
+ segs[i].crop_region[2], segs[i].crop_region[3])
330
+
331
+ points += npoints
332
+ plabs += nplabs
333
+
334
+ detected_masks = sam_predict(predictor, points, plabs, dilated_bbox, threshold)
335
+ total_masks += detected_masks
336
+
337
+ # merge every collected masks
338
+ mask = combine_masks2(total_masks)
339
+
340
+ finally:
341
+ if sam_model.is_auto_mode:
342
+ print(f"semd to {device}")
343
+ sam_model.to(device="cpu")
344
+
345
+ if mask is not None:
346
+ mask = mask.float()
347
+ mask = dilate_mask(mask.cpu().numpy(), dilation)
348
+ mask = torch.from_numpy(mask)
349
+ else:
350
+ mask = torch.zeros((8, 8), dtype=torch.float32, device="cpu") # empty mask
351
+
352
+ return mask
353
+
354
+ def generate_detection_hints(image,seg,center,detection_hint,dilated_bbox,mask_hint_threshold, use_small_negative, mask_hint_use_negative):
355
+
356
+ [x1, y1, x2, y2] = dilated_bbox
357
+
358
+ points = []
359
+ plabs = []
360
+ if detection_hint == "center-1":
361
+ points.append(center)
362
+ plabs = [1] # 1 = foreground point, 0 = background point
363
+
364
+ elif detection_hint == "horizontal-2":
365
+ gap = (x2 - x1) / 3
366
+ points.append((x1 + gap, center[1]))
367
+ points.append((x1 + gap * 2, center[1]))
368
+ plabs = [1, 1]
369
+
370
+ elif detection_hint == "vertical-2":
371
+ gap = (y2 - y1) / 3
372
+ points.append((center[0], y1 + gap))
373
+ points.append((center[0], y1 + gap * 2))
374
+ plabs = [1, 1]
375
+
376
+ elif detection_hint == "rect-4":
377
+ x_gap = (x2 - x1) / 3
378
+ y_gap = (y2 - y1) / 3
379
+ points.append((x1 + x_gap, center[1]))
380
+ points.append((x1 + x_gap * 2, center[1]))
381
+ points.append((center[0], y1 + y_gap))
382
+ points.append((center[0], y1 + y_gap * 2))
383
+ plabs = [1, 1, 1, 1]
384
+
385
+ elif detection_hint == "diamond-4":
386
+ x_gap = (x2 - x1) / 3
387
+ y_gap = (y2 - y1) / 3
388
+ points.append((x1 + x_gap, y1 + y_gap))
389
+ points.append((x1 + x_gap * 2, y1 + y_gap))
390
+ points.append((x1 + x_gap, y1 + y_gap * 2))
391
+ points.append((x1 + x_gap * 2, y1 + y_gap * 2))
392
+ plabs = [1, 1, 1, 1]
393
+
394
+ elif detection_hint == "mask-point-bbox":
395
+ center = center_of_bbox(seg.bbox)
396
+ points.append(center)
397
+ plabs = [1]
398
+
399
+ elif detection_hint == "mask-area":
400
+ points, plabs = gen_detection_hints_from_mask_area(seg.crop_region[0], seg.crop_region[1],
401
+ seg.cropped_mask,
402
+ mask_hint_threshold, use_small_negative)
403
+
404
+ if mask_hint_use_negative == "Outter":
405
+ npoints, nplabs = gen_negative_hints(image.shape[0], image.shape[1],
406
+ seg.crop_region[0], seg.crop_region[1],
407
+ seg.crop_region[2], seg.crop_region[3])
408
+
409
+ points += npoints
410
+ plabs += nplabs
411
+
412
+ return points, plabs
413
+
414
+
415
+ def convert_and_stack_masks(masks):
416
+ if len(masks) == 0:
417
+ return None
418
+
419
+ mask_tensors = []
420
+ for mask in masks:
421
+ mask_array = np.array(mask, dtype=np.uint8)
422
+ mask_tensor = torch.from_numpy(mask_array).bool()
423
+ mask_tensors.append(mask_tensor)
424
+
425
+ stacked_masks = torch.stack(mask_tensors, dim=0)
426
+ stacked_masks = stacked_masks.unsqueeze(1)
427
+
428
+ return stacked_masks
429
+
430
+
431
+ def merge_and_stack_masks(stacked_masks, group_size):
432
+ if stacked_masks is None:
433
+ return None
434
+
435
+ num_masks = stacked_masks.size(0)
436
+ merged_masks = []
437
+
438
+ for i in range(0, num_masks, group_size):
439
+ subset_masks = stacked_masks[i:i+group_size]
440
+ merged_mask = torch.any(subset_masks, dim=0)
441
+ merged_masks.append(merged_mask)
442
+
443
+ if len(merged_masks) > 0:
444
+ merged_masks = torch.stack(merged_masks, dim=0)
445
+
446
+ return merged_masks
447
+
448
+
449
+ # Used Python's slicing feature. stacked_masks[2::3] means starting from index 2, selecting every third tensor with a step size of 3.
450
+ # This allows for quickly obtaining the last tensor of every three tensors in stacked_masks.
451
+ def every_three_pick_last(stacked_masks):
452
+ selected_masks = stacked_masks[2::3]
453
+ return selected_masks
454
+
455
+
456
+ def make_sam_mask_segmented(sam_model, segs, image, detection_hint, dilation,
457
+ threshold, bbox_expansion, mask_hint_threshold, mask_hint_use_negative):
458
+
459
+ if sam_model.is_auto_mode:
460
+ device = comfy.model_management.get_torch_device()
461
+ sam_model.to(device=device)
462
+
463
+ try:
464
+ predictor = SamPredictor(sam_model)
465
+ image = np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8)
466
+ predictor.set_image(image, "RGB")
467
+
468
+ total_masks = []
469
+
470
+ use_small_negative = mask_hint_use_negative == "Small"
471
+
472
+ # seg_shape = segs[0]
473
+ segs = segs[1]
474
+ if detection_hint == "mask-points":
475
+ points = []
476
+ plabs = []
477
+
478
+ for i in range(len(segs)):
479
+ bbox = segs[i].bbox
480
+ center = center_of_bbox(bbox)
481
+ points.append(center)
482
+
483
+ # small point is background, big point is foreground
484
+ if use_small_negative and bbox[2] - bbox[0] < 10:
485
+ plabs.append(0)
486
+ else:
487
+ plabs.append(1)
488
+
489
+ detected_masks = sam_predict(predictor, points, plabs, None, threshold)
490
+ total_masks += detected_masks
491
+
492
+ else:
493
+ for i in range(len(segs)):
494
+ bbox = segs[i].bbox
495
+ center = center_of_bbox(bbox)
496
+ x1 = max(bbox[0] - bbox_expansion, 0)
497
+ y1 = max(bbox[1] - bbox_expansion, 0)
498
+ x2 = min(bbox[2] + bbox_expansion, image.shape[1])
499
+ y2 = min(bbox[3] + bbox_expansion, image.shape[0])
500
+
501
+ dilated_bbox = [x1, y1, x2, y2]
502
+
503
+ points, plabs = generate_detection_hints(image, segs[i],center, detection_hint, dilated_bbox, mask_hint_threshold, use_small_negative, mask_hint_use_negative)
504
+
505
+ detected_masks = sam_predict(predictor, points, plabs, dilated_bbox, threshold)
506
+
507
+ total_masks += detected_masks
508
+
509
+ # merge every collected masks
510
+ mask = combine_masks2(total_masks)
511
+
512
+ finally:
513
+ if sam_model.is_auto_mode:
514
+ print(f"semd to {device}")
515
+ sam_model.to(device="cpu")
516
+
517
+ if mask is not None:
518
+ mask = mask.float()
519
+ mask = dilate_mask(mask.cpu().numpy(), dilation)
520
+ mask = torch.from_numpy(mask)
521
+ else:
522
+ mask = torch.zeros((8, 8), dtype=torch.float32, device="cpu") # empty mask
523
+
524
+ stacked_masks = convert_and_stack_masks(total_masks)
525
+
526
+ return (mask, merge_and_stack_masks(stacked_masks, group_size=3))
527
+ # return every_three_pick_last(stacked_masks)
528
+
529
+
530
+ def segs_bitwise_and_mask(segs, mask):
531
+ if mask is None:
532
+ print("[SegsBitwiseAndMask] Cannot operate: MASK is empty.")
533
+ return ([], )
534
+
535
+ items = []
536
+
537
+ mask = (mask.cpu().numpy() * 255).astype(np.uint8)
538
+
539
+ for seg in segs[1]:
540
+ cropped_mask = (seg.cropped_mask * 255).astype(np.uint8)
541
+ crop_region = seg.crop_region
542
+
543
+ cropped_mask2 = mask[crop_region[1]:crop_region[3], crop_region[0]:crop_region[2]]
544
+
545
+ new_mask = np.bitwise_and(cropped_mask.astype(np.uint8), cropped_mask2)
546
+ new_mask = new_mask.astype(np.float32) / 255.0
547
+
548
+ item = SEG(seg.cropped_image, new_mask, seg.confidence, seg.crop_region, seg.bbox, seg.label)
549
+ items.append(item)
550
+
551
+ return segs[0], items
552
+
553
+
554
+ def apply_mask_to_each_seg(segs, masks):
555
+ if masks is None:
556
+ print("[SegsBitwiseAndMask] Cannot operate: MASK is empty.")
557
+ return (segs[0], [], )
558
+
559
+ items = []
560
+
561
+ masks = masks.squeeze(1)
562
+
563
+ for seg, mask in zip(segs[1], masks):
564
+ cropped_mask = (seg.cropped_mask * 255).astype(np.uint8)
565
+ crop_region = seg.crop_region
566
+
567
+ cropped_mask2 = (mask.cpu().numpy() * 255).astype(np.uint8)
568
+ cropped_mask2 = cropped_mask2[crop_region[1]:crop_region[3], crop_region[0]:crop_region[2]]
569
+
570
+ new_mask = np.bitwise_and(cropped_mask.astype(np.uint8), cropped_mask2)
571
+ new_mask = new_mask.astype(np.float32) / 255.0
572
+
573
+ item = SEG(seg.cropped_image, new_mask, seg.confidence, seg.crop_region, seg.bbox, seg.label)
574
+ items.append(item)
575
+
576
+ return segs[0], items
577
+
578
+
579
+ class ONNXDetector:
580
+ onnx_model = None
581
+
582
+ def __init__(self, onnx_model):
583
+ self.onnx_model = onnx_model
584
+
585
+ def detect(self, image, threshold, dilation, crop_factor, drop_size=1):
586
+ drop_size = max(drop_size, 1)
587
+ try:
588
+ import impact.onnx as onnx
589
+
590
+ h = image.shape[1]
591
+ w = image.shape[2]
592
+
593
+ labels, scores, boxes = onnx.onnx_inference(image, self.onnx_model)
594
+
595
+ # collect feasible item
596
+ result = []
597
+
598
+ for i in range(len(labels)):
599
+ if scores[i] > threshold:
600
+ item_bbox = boxes[i]
601
+ x1, y1, x2, y2 = item_bbox
602
+
603
+ if x2 - x1 > drop_size and y2 - y1 > drop_size: # minimum dimension must be (2,2) to avoid squeeze issue
604
+ crop_region = make_crop_region(w, h, item_bbox, crop_factor)
605
+ crop_x1, crop_y1, crop_x2, crop_y2, = crop_region
606
+
607
+ # prepare cropped mask
608
+ cropped_mask = np.zeros((crop_y2-crop_y1,crop_x2-crop_x1))
609
+ inner_mask = np.ones((y2-y1, x2-x1))
610
+ cropped_mask[y1-crop_y1:y2-crop_y1, x1-crop_x1:x2-crop_x1] = inner_mask
611
+
612
+ # make items
613
+ item = SEG(None, cropped_mask, scores[i], crop_region, item_bbox)
614
+ result.append(item)
615
+
616
+ shape = h, w
617
+ return shape, result
618
+ except Exception as e:
619
+ print(f"ONNXDetector: unable to execute.\n{e}")
620
+ pass
621
+
622
+ def detect_combined(self, image, threshold, dilation):
623
+ return segs_to_combined_mask(self.detect(image, threshold, dilation, 1))
624
+
625
+ def setAux(self, x):
626
+ pass
627
+
628
+
629
+ def mask_to_segs(mask, combined, crop_factor, bbox_fill, drop_size=1):
630
+ drop_size = max(drop_size, 1)
631
+ if mask is None:
632
+ print("[mask_to_segs] Cannot operate: MASK is empty.")
633
+ return ([],)
634
+
635
+ if isinstance(mask, np.ndarray):
636
+ pass # `mask` is already a NumPy array
637
+ else:
638
+ try:
639
+ mask = mask.numpy()
640
+ except AttributeError:
641
+ print("[mask_to_segs] Cannot operate: MASK is not a NumPy array or Tensor.")
642
+ return ([],)
643
+
644
+ if mask is None:
645
+ print("[mask_to_segs] Cannot operate: MASK is empty.")
646
+ return ([],)
647
+
648
+ result = []
649
+
650
+ if len(mask.shape) == 2:
651
+ mask = np.expand_dims(mask, axis=0)
652
+ else:
653
+ mask = np.squeeze(mask, axis=1)
654
+
655
+ for i in range(mask.shape[0]):
656
+ mask_i = mask[i]
657
+
658
+ if combined:
659
+ indices = np.nonzero(mask_i)
660
+ if len(indices[0]) > 0 and len(indices[1]) > 0:
661
+ bbox = (
662
+ np.min(indices[1]),
663
+ np.min(indices[0]),
664
+ np.max(indices[1]),
665
+ np.max(indices[0]),
666
+ )
667
+ crop_region = make_crop_region(
668
+ mask_i.shape[1], mask_i.shape[0], bbox, crop_factor
669
+ )
670
+ x1, y1, x2, y2 = crop_region
671
+ if x2 - x1 > 0 and y2 - y1 > 0:
672
+ cropped_mask = mask_i[y1:y2, x1:x2]
673
+
674
+ if cropped_mask is not None:
675
+ item = SEG(None, cropped_mask, 1.0, crop_region, bbox, "A")
676
+ result.append(item)
677
+
678
+ else:
679
+ mask_i_uint8 = (mask_i * 255.0).astype(np.uint8)
680
+ contours, _ = cv2.findContours(mask_i_uint8, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
681
+ for contour in contours:
682
+ separated_mask = np.zeros_like(mask_i_uint8)
683
+ cv2.drawContours(separated_mask, [contour], 0, 255, -1)
684
+ separated_mask = np.array(separated_mask/255.0).astype(np.float32)
685
+
686
+ x, y, w, h = cv2.boundingRect(contour)
687
+ bbox = x, y, x+w, y+h
688
+ crop_region = make_crop_region(
689
+ mask_i.shape[1], mask_i.shape[0], bbox, crop_factor
690
+ )
691
+
692
+ if w > drop_size and h > drop_size:
693
+ cropped_mask = np.array(
694
+ separated_mask[
695
+ crop_region[1]: crop_region[3],
696
+ crop_region[0]: crop_region[2],
697
+ ]
698
+ )
699
+
700
+ if bbox_fill:
701
+ cropped_mask.fill(1.0)
702
+
703
+ if cropped_mask is not None:
704
+ item = SEG(None, cropped_mask, 1.0, crop_region, bbox, "A")
705
+ result.append(item)
706
+
707
+ if not result:
708
+ print(f"[mask_to_segs] Empty mask.")
709
+
710
+ print(f"# of Detected SEGS: {len(result)}")
711
+ # for r in result:
712
+ # print(f"\tbbox={r.bbox}, crop={r.crop_region}, label={r.label}")
713
+
714
+ # shape: (b,h,w) -> (h,w)
715
+ return (mask.shape[1], mask.shape[2]), result
716
+
717
+
718
+ def segs_to_combined_mask(segs):
719
+ shape = segs[0]
720
+ h = shape[0]
721
+ w = shape[1]
722
+
723
+ mask = np.zeros((h, w), dtype=np.uint8)
724
+
725
+ for seg in segs[1]:
726
+ cropped_mask = seg.cropped_mask
727
+ crop_region = seg.crop_region
728
+ mask[crop_region[1]:crop_region[3], crop_region[0]:crop_region[2]] |= (cropped_mask * 255).astype(np.uint8)
729
+
730
+ return torch.from_numpy(mask.astype(np.float32) / 255.0)
731
+
732
+
733
+ def segs_to_masklist(segs):
734
+ shape = segs[0]
735
+ h = shape[0]
736
+ w = shape[1]
737
+
738
+ masks = []
739
+ for seg in segs[1]:
740
+ mask = np.zeros((h, w), dtype=np.uint8)
741
+ cropped_mask = seg.cropped_mask
742
+ crop_region = seg.crop_region
743
+ mask[crop_region[1]:crop_region[3], crop_region[0]:crop_region[2]] |= (cropped_mask * 255).astype(np.uint8)
744
+ mask = torch.from_numpy(mask.astype(np.float32) / 255.0)
745
+ masks.append(mask)
746
+
747
+ return masks
748
+
749
+
750
+ def vae_decode(vae, samples, use_tile, hook):
751
+ if use_tile:
752
+ pixels = nodes.VAEDecodeTiled().decode(vae, samples)[0]
753
+ else:
754
+ pixels = nodes.VAEDecode().decode(vae, samples)[0]
755
+
756
+ if hook is not None:
757
+ hook.post_decode(pixels)
758
+
759
+ return pixels
760
+
761
+
762
+ def vae_encode(vae, pixels, use_tile, hook):
763
+ if use_tile:
764
+ samples = nodes.VAEEncodeTiled().encode(vae, pixels)[0]
765
+ else:
766
+ samples = nodes.VAEEncode().encode(vae, pixels)[0]
767
+
768
+ if hook is not None:
769
+ hook.post_encode(samples)
770
+
771
+ return samples
772
+
773
+
774
+ class KSamplerWrapper:
775
+ params = None
776
+
777
+ def __init__(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise):
778
+ self.params = model, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise
779
+
780
+ def sample(self, latent_image, hook=None):
781
+ model, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise = self.params
782
+
783
+ if hook is not None:
784
+ model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise = \
785
+ hook.pre_ksample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise)
786
+
787
+ return nodes.common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)[0]
788
+
789
+
790
+ class KSamplerAdvancedWrapper:
791
+ params = None
792
+
793
+ def __init__(self, model, cfg, sampler_name, scheduler, positive, negative):
794
+ self.params = model, cfg, sampler_name, scheduler, positive, negative
795
+
796
+ def sample_advanced(self, add_noise, seed, steps, latent_image, start_at_step, end_at_step, return_with_leftover_noise, hook=None):
797
+ model, cfg, sampler_name, scheduler, positive, negative = self.params
798
+
799
+ if hook is not None:
800
+ model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent = \
801
+ hook.pre_ksample_advanced(model, add_noise, seed, steps, cfg, sampler_name, scheduler,
802
+ positive, negative, latent_image, start_at_step, end_at_step,
803
+ return_with_leftover_noise)
804
+
805
+ return nodes.KSamplerAdvanced().sample(model, add_noise, seed, steps, cfg, sampler_name, scheduler,
806
+ positive, negative, latent_image, start_at_step, end_at_step,
807
+ return_with_leftover_noise)[0]
808
+
809
+
810
+ class PixelKSampleHook:
811
+ cur_step = 0
812
+ total_step = 0
813
+
814
+ def __init__(self):
815
+ pass
816
+
817
+ def set_steps(self, info):
818
+ self.cur_step, self.total_step = info
819
+
820
+ def post_decode(self, pixels):
821
+ return pixels
822
+
823
+ def post_upscale(self, pixels):
824
+ return pixels
825
+
826
+ def post_encode(self, samples):
827
+ return samples
828
+
829
+ def pre_ksample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise):
830
+ return model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise
831
+
832
+
833
+ class PixelKSampleHookCombine(PixelKSampleHook):
834
+ hook1 = None
835
+ hook2 = None
836
+
837
+ def __init__(self, hook1, hook2):
838
+ super().__init__()
839
+ self.hook1 = hook1
840
+ self.hook2 = hook2
841
+
842
+ def set_steps(self, info):
843
+ self.hook1.set_steps(info)
844
+ self.hook2.set_steps(info)
845
+
846
+ def post_decode(self, pixels):
847
+ return self.hook2.post_decode(self.hook1.post_decode(pixels))
848
+
849
+ def post_upscale(self, pixels):
850
+ return self.hook2.post_upscale(self.hook1.post_upscale(pixels))
851
+
852
+ def post_encode(self, samples):
853
+ return self.hook2.post_encode(self.hook1.post_encode(samples))
854
+
855
+ def pre_ksample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent,
856
+ denoise):
857
+ model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise = \
858
+ self.hook1.pre_ksample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise)
859
+
860
+ return self.hook2.pre_ksample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise)
861
+
862
+
863
+ class SimpleCfgScheduleHook(PixelKSampleHook):
864
+ target_cfg = 0
865
+
866
+ def __init__(self, target_cfg):
867
+ super().__init__()
868
+ self.target_cfg = target_cfg
869
+
870
+ def pre_ksample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise):
871
+ progress = self.cur_step/self.total_step
872
+ gap = self.target_cfg - cfg
873
+ current_cfg = cfg + gap*progress
874
+ return model, seed, steps, current_cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise
875
+
876
+
877
+ class SimpleDenoiseScheduleHook(PixelKSampleHook):
878
+ target_denoise = 0
879
+
880
+ def __init__(self, target_denoise):
881
+ super().__init__()
882
+ self.target_denoise = target_denoise
883
+
884
+ def pre_ksample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise):
885
+ progress = self.cur_step / self.total_step
886
+ gap = self.target_denoise - denoise
887
+ current_denoise = denoise + gap * progress
888
+ return model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, current_denoise
889
+
890
+
891
+ def latent_upscale_on_pixel_space_shape(samples, scale_method, w, h, vae, use_tile=False, save_temp_prefix=None, hook=None):
892
+ pixels = vae_decode(vae, samples, use_tile, hook)
893
+
894
+ if save_temp_prefix is not None:
895
+ nodes.PreviewImage().save_images(pixels, filename_prefix=save_temp_prefix)
896
+
897
+ pixels = nodes.ImageScale().upscale(pixels, scale_method, int(w), int(h), False)[0]
898
+
899
+ if hook is not None:
900
+ pixels = hook.post_upscale(pixels)
901
+
902
+ return vae_encode(vae, pixels, use_tile, hook)
903
+
904
+
905
+ def latent_upscale_on_pixel_space(samples, scale_method, scale_factor, vae, use_tile=False, save_temp_prefix=None, hook=None):
906
+ pixels = vae_decode(vae, samples, use_tile, hook)
907
+
908
+ if save_temp_prefix is not None:
909
+ nodes.PreviewImage().save_images(pixels, filename_prefix=save_temp_prefix)
910
+
911
+ w = pixels.shape[2] * scale_factor
912
+ h = pixels.shape[1] * scale_factor
913
+ pixels = nodes.ImageScale().upscale(pixels, scale_method, int(w), int(h), False)[0]
914
+
915
+ if hook is not None:
916
+ pixels = hook.post_upscale(pixels)
917
+
918
+ return vae_encode(vae, pixels, use_tile, hook)
919
+
920
+
921
+ def latent_upscale_on_pixel_space_with_model_shape(samples, scale_method, upscale_model, new_w, new_h, vae, use_tile=False, save_temp_prefix=None, hook=None):
922
+ pixels = vae_decode(vae, samples, use_tile, hook)
923
+
924
+ if save_temp_prefix is not None:
925
+ nodes.PreviewImage().save_images(pixels, filename_prefix=save_temp_prefix)
926
+
927
+ w = pixels.shape[2]
928
+
929
+ # upscale by model upscaler
930
+ current_w = w
931
+ while current_w < new_w:
932
+ pixels = model_upscale.ImageUpscaleWithModel().upscale(upscale_model, pixels)[0]
933
+ current_w = pixels.shape[2]
934
+
935
+ # downscale to target scale
936
+ pixels = nodes.ImageScale().upscale(pixels, scale_method, int(new_w), int(new_h), False)[0]
937
+
938
+ if hook is not None:
939
+ pixels = hook.post_upscale(pixels)
940
+
941
+ return vae_encode(vae, pixels, use_tile, hook)
942
+
943
+
944
+ def latent_upscale_on_pixel_space_with_model(samples, scale_method, upscale_model, scale_factor, vae, use_tile=False, save_temp_prefix=None, hook=None):
945
+ pixels = vae_decode(vae, samples, use_tile, hook)
946
+
947
+ if save_temp_prefix is not None:
948
+ nodes.PreviewImage().save_images(pixels, filename_prefix=save_temp_prefix)
949
+
950
+ w = pixels.shape[2]
951
+ h = pixels.shape[1]
952
+
953
+ new_w = w * scale_factor
954
+ new_h = h * scale_factor
955
+
956
+ # upscale by model upscaler
957
+ current_w = w
958
+ while current_w < new_w:
959
+ pixels = model_upscale.ImageUpscaleWithModel().upscale(upscale_model, pixels)[0]
960
+ current_w = pixels.shape[2]
961
+
962
+ # downscale to target scale
963
+ pixels = nodes.ImageScale().upscale(pixels, scale_method, int(new_w), int(new_h), False)[0]
964
+
965
+ if hook is not None:
966
+ pixels = hook.post_upscale(pixels)
967
+
968
+ return vae_encode(vae, pixels, use_tile, hook)
969
+
970
+
971
+ class TwoSamplersForMaskUpscaler:
972
+ params = None
973
+ upscale_model = None
974
+ hook_base = None
975
+ hook_mask = None
976
+ hook_full = None
977
+ use_tiled_vae = False
978
+ is_tiled = False
979
+
980
+ def __init__(self, scale_method, sample_schedule, use_tiled_vae, base_sampler, mask_sampler, mask, vae,
981
+ full_sampler_opt=None, upscale_model_opt=None, hook_base_opt=None, hook_mask_opt=None, hook_full_opt=None):
982
+ mask = mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1]))
983
+
984
+ self.params = scale_method, sample_schedule, use_tiled_vae, base_sampler, mask_sampler, mask, vae
985
+ self.upscale_model = upscale_model_opt
986
+ self.full_sampler = full_sampler_opt
987
+ self.hook_base = hook_base_opt
988
+ self.hook_mask = hook_mask_opt
989
+ self.hook_full = hook_full_opt
990
+ self.use_tiled_vae = use_tiled_vae
991
+
992
+ def upscale(self, step_info, samples, upscale_factor, save_temp_prefix=None):
993
+ scale_method, sample_schedule, use_tiled_vae, base_sampler, mask_sampler, mask, vae = self.params
994
+
995
+ self.prepare_hook(step_info)
996
+
997
+ # upscale latent
998
+ if self.upscale_model is None:
999
+ upscaled_latent = latent_upscale_on_pixel_space(samples, scale_method, upscale_factor, vae,
1000
+ use_tile=self.use_tiled_vae,
1001
+ save_temp_prefix=save_temp_prefix, hook=self.hook_base)
1002
+ else:
1003
+ upscaled_latent = latent_upscale_on_pixel_space_with_model(samples, scale_method, self.upscale_model, upscale_factor, vae,
1004
+ use_tile=self.use_tiled_vae,
1005
+ save_temp_prefix=save_temp_prefix, hook=self.hook_mask)
1006
+
1007
+ return self.do_samples(step_info, base_sampler, mask_sampler, sample_schedule, mask, upscaled_latent)
1008
+
1009
+ def prepare_hook(self, step_info):
1010
+ if self.hook_base is not None:
1011
+ self.hook_base.set_steps(step_info)
1012
+ if self.hook_mask is not None:
1013
+ self.hook_mask.set_steps(step_info)
1014
+ if self.hook_full is not None:
1015
+ self.hook_full.set_steps(step_info)
1016
+
1017
+ def upscale_shape(self, step_info, samples, w, h, save_temp_prefix=None):
1018
+ scale_method, sample_schedule, use_tiled_vae, base_sampler, mask_sampler, mask, vae = self.params
1019
+
1020
+ self.prepare_hook(step_info)
1021
+
1022
+ # upscale latent
1023
+ if self.upscale_model is None:
1024
+ upscaled_latent = latent_upscale_on_pixel_space_shape(samples, scale_method, w, h, vae,
1025
+ use_tile=self.use_tiled_vae,
1026
+ save_temp_prefix=save_temp_prefix, hook=self.hook_base)
1027
+ else:
1028
+ upscaled_latent = latent_upscale_on_pixel_space_with_model_shape(samples, scale_method, self.upscale_model, w, h, vae,
1029
+ use_tile=self.use_tiled_vae,
1030
+ save_temp_prefix=save_temp_prefix, hook=self.hook_mask)
1031
+
1032
+ return self.do_samples(step_info, base_sampler, mask_sampler, sample_schedule, mask, upscaled_latent)
1033
+
1034
+ def is_full_sample_time(self, step_info, sample_schedule):
1035
+ cur_step, total_step = step_info
1036
+
1037
+ # make start from 1 instead of zero
1038
+ cur_step += 1
1039
+ total_step += 1
1040
+
1041
+ if sample_schedule == "none":
1042
+ return False
1043
+
1044
+ elif sample_schedule == "interleave1":
1045
+ return cur_step % 2 == 0
1046
+
1047
+ elif sample_schedule == "interleave2":
1048
+ return cur_step % 3 == 0
1049
+
1050
+ elif sample_schedule == "interleave3":
1051
+ return cur_step % 4 == 0
1052
+
1053
+ elif sample_schedule == "last1":
1054
+ return cur_step == total_step
1055
+
1056
+ elif sample_schedule == "last2":
1057
+ return cur_step >= total_step-1
1058
+
1059
+ elif sample_schedule == "interleave1+last1":
1060
+ return cur_step % 2 == 0 or cur_step >= total_step-1
1061
+
1062
+ elif sample_schedule == "interleave2+last1":
1063
+ return cur_step % 2 == 0 or cur_step >= total_step-1
1064
+
1065
+ elif sample_schedule == "interleave3+last1":
1066
+ return cur_step % 2 == 0 or cur_step >= total_step-1
1067
+
1068
+ def do_samples(self, step_info, base_sampler, mask_sampler, sample_schedule, mask, upscaled_latent):
1069
+ if self.is_full_sample_time(step_info, sample_schedule):
1070
+ print(f"step_info={step_info} / full time")
1071
+
1072
+ upscaled_latent = base_sampler.sample(upscaled_latent, self.hook_base)
1073
+ sampler = self.full_sampler if self.full_sampler is not None else base_sampler
1074
+ return sampler.sample(upscaled_latent, self.hook_full)
1075
+
1076
+ else:
1077
+ print(f"step_info={step_info} / non-full time")
1078
+ # upscale mask
1079
+ upscaled_mask = F.interpolate(mask, size=(upscaled_latent['samples'].shape[2], upscaled_latent['samples'].shape[3]),
1080
+ mode='bilinear', align_corners=True)
1081
+ upscaled_mask = upscaled_mask[:, :, :upscaled_latent['samples'].shape[2], :upscaled_latent['samples'].shape[3]]
1082
+
1083
+ # base sampler
1084
+ upscaled_inv_mask = torch.where(upscaled_mask != 1.0, torch.tensor(1.0), torch.tensor(0.0))
1085
+ upscaled_latent['noise_mask'] = upscaled_inv_mask
1086
+ upscaled_latent = base_sampler.sample(upscaled_latent, self.hook_base)
1087
+
1088
+ # mask sampler
1089
+ upscaled_latent['noise_mask'] = upscaled_mask
1090
+ upscaled_latent = mask_sampler.sample(upscaled_latent, self.hook_mask)
1091
+
1092
+ # remove mask
1093
+ del upscaled_latent['noise_mask']
1094
+ return upscaled_latent
1095
+
1096
+
1097
+ class PixelKSampleUpscaler:
1098
+ params = None
1099
+ upscale_model = None
1100
+ hook = None
1101
+ use_tiled_vae = False
1102
+ is_tiled = False
1103
+
1104
+ def __init__(self, scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise,
1105
+ use_tiled_vae, upscale_model_opt=None, hook_opt=None):
1106
+ self.params = scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise
1107
+ self.upscale_model = upscale_model_opt
1108
+ self.hook = hook_opt
1109
+ self.use_tiled_vae = use_tiled_vae
1110
+
1111
+ def upscale(self, step_info, samples, upscale_factor, save_temp_prefix=None):
1112
+ scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise = self.params
1113
+
1114
+ if self.hook is not None:
1115
+ self.hook.set_steps(step_info)
1116
+
1117
+ if self.upscale_model is None:
1118
+ upscaled_latent = latent_upscale_on_pixel_space(samples, scale_method, upscale_factor, vae,
1119
+ use_tile=self.use_tiled_vae,
1120
+ save_temp_prefix=save_temp_prefix, hook=self.hook)
1121
+ else:
1122
+ upscaled_latent = latent_upscale_on_pixel_space_with_model(samples, scale_method, self.upscale_model, upscale_factor, vae,
1123
+ use_tile=self.use_tiled_vae,
1124
+ save_temp_prefix=save_temp_prefix, hook=self.hook)
1125
+
1126
+ if self.hook is not None:
1127
+ model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise = \
1128
+ self.hook.pre_ksample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise)
1129
+
1130
+ refined_latent = nodes.KSampler().sample(model, seed, steps, cfg, sampler_name, scheduler,
1131
+ positive, negative, upscaled_latent, denoise)[0]
1132
+ return refined_latent
1133
+
1134
+ def upscale_shape(self, step_info, samples, w, h, save_temp_prefix=None):
1135
+ scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise = self.params
1136
+
1137
+ if self.hook is not None:
1138
+ self.hook.set_steps(step_info)
1139
+
1140
+ if self.upscale_model is None:
1141
+ upscaled_latent = latent_upscale_on_pixel_space_shape(samples, scale_method, w, h, vae,
1142
+ use_tile=self.use_tiled_vae,
1143
+ save_temp_prefix=save_temp_prefix, hook=self.hook)
1144
+ else:
1145
+ upscaled_latent = latent_upscale_on_pixel_space_with_model_shape(samples, scale_method, self.upscale_model, w, h, vae,
1146
+ use_tile=self.use_tiled_vae,
1147
+ save_temp_prefix=save_temp_prefix, hook=self.hook)
1148
+
1149
+ if self.hook is not None:
1150
+ model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise = \
1151
+ self.hook.pre_ksample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise)
1152
+
1153
+ refined_latent = nodes.KSampler().sample(model, seed, steps, cfg, sampler_name, scheduler,
1154
+ positive, negative, upscaled_latent, denoise)[0]
1155
+ return refined_latent
1156
+
1157
+
1158
+ # REQUIREMENTS: BlenderNeko/ComfyUI_TiledKSampler
1159
+ try:
1160
+ class TiledKSamplerWrapper:
1161
+ params = None
1162
+
1163
+ def __init__(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise,
1164
+ tile_width, tile_height, tiling_strategy):
1165
+ self.params = model, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise, tile_width, tile_height, tiling_strategy
1166
+
1167
+ def sample(self, latent_image, hook=None):
1168
+ from custom_nodes.ComfyUI_TiledKSampler.nodes import TiledKSampler
1169
+
1170
+ model, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise, tile_width, tile_height, tiling_strategy = self.params
1171
+
1172
+ if hook is not None:
1173
+ model, seed, steps, cfg, sampler_name, scheduler, positive, negative, upscaled_latent, denoise = \
1174
+ hook.pre_ksample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise)
1175
+
1176
+ return TiledKSampler().sample(model, seed, tile_width, tile_height, tiling_strategy, steps, cfg, sampler_name, scheduler,
1177
+ positive, negative, latent_image, denoise)[0]
1178
+
1179
+ class PixelTiledKSampleUpscaler:
1180
+ params = None
1181
+ upscale_model = None
1182
+ tile_params = None
1183
+ hook = None
1184
+ is_tiled = True
1185
+
1186
+ def __init__(self, scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise,
1187
+ tile_width, tile_height, tiling_strategy,
1188
+ upscale_model_opt=None, hook_opt=None):
1189
+ self.params = scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise
1190
+ self.tile_params = tile_width, tile_height, tiling_strategy
1191
+ self.upscale_model = upscale_model_opt
1192
+ self.hook = hook_opt
1193
+
1194
+ def tiled_ksample(self, latent):
1195
+ from custom_nodes.ComfyUI_TiledKSampler.nodes import TiledKSampler
1196
+
1197
+ scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise = self.params
1198
+ tile_width, tile_height, tiling_strategy = self.tile_params
1199
+
1200
+ return TiledKSampler().sample(model, seed, tile_width, tile_height, tiling_strategy, steps, cfg, sampler_name, scheduler,
1201
+ positive, negative, latent, denoise)[0]
1202
+
1203
+ def upscale(self, step_info, samples, upscale_factor, save_temp_prefix=None):
1204
+ scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise = self.params
1205
+
1206
+ if self.hook is not None:
1207
+ self.hook.set_steps(step_info)
1208
+
1209
+ if self.upscale_model is None:
1210
+ upscaled_latent = latent_upscale_on_pixel_space(samples, scale_method, upscale_factor, vae,
1211
+ use_tile=True, save_temp_prefix=save_temp_prefix, hook=self.hook)
1212
+ else:
1213
+ upscaled_latent = latent_upscale_on_pixel_space_with_model(samples, scale_method, self.upscale_model, upscale_factor, vae,
1214
+ use_tile=True, save_temp_prefix=save_temp_prefix, hook=self.hook)
1215
+
1216
+ refined_latent = self.tiled_ksample(upscaled_latent)
1217
+
1218
+ return refined_latent
1219
+
1220
+ def upscale_shape(self, step_info, samples, w, h, save_temp_prefix=None):
1221
+ scale_method, model, vae, seed, steps, cfg, sampler_name, scheduler, positive, negative, denoise = self.params
1222
+
1223
+ if self.hook is not None:
1224
+ self.hook.set_steps(step_info)
1225
+
1226
+ if self.upscale_model is None:
1227
+ upscaled_latent = latent_upscale_on_pixel_space_shape(samples, scale_method, w, h, vae,
1228
+ use_tile=True, save_temp_prefix=save_temp_prefix, hook=self.hook)
1229
+ else:
1230
+ upscaled_latent = latent_upscale_on_pixel_space_with_model_shape(samples, scale_method, self.upscale_model, w, h, vae,
1231
+ use_tile=True, save_temp_prefix=save_temp_prefix, hook=self.hook)
1232
+
1233
+ refined_latent = self.tiled_ksample(upscaled_latent)
1234
+
1235
+ return refined_latent
1236
+ except:
1237
+ pass
1238
+
1239
+
1240
+ # REQUIREMENTS: biegert/ComfyUI-CLIPSeg
1241
+ try:
1242
+ class BBoxDetectorBasedOnCLIPSeg:
1243
+ prompt = None
1244
+ blur = None
1245
+ threshold = None
1246
+ dilation_factor = None
1247
+ aux = None
1248
+
1249
+ def __init__(self, prompt, blur, threshold, dilation_factor):
1250
+ self.prompt = prompt
1251
+ self.blur = blur
1252
+ self.threshold = threshold
1253
+ self.dilation_factor = dilation_factor
1254
+
1255
+ def detect(self, image, bbox_threshold, bbox_dilation, bbox_crop_factor, drop_size=1):
1256
+ mask = self.detect_combined(image, bbox_threshold, bbox_dilation)
1257
+ segs = mask_to_segs(mask, False, bbox_crop_factor, True, drop_size)
1258
+ return segs
1259
+
1260
+ def detect_combined(self, image, bbox_threshold, bbox_dilation):
1261
+ from custom_nodes.clipseg import CLIPSeg
1262
+
1263
+ if self.threshold is None:
1264
+ threshold = bbox_threshold
1265
+ else:
1266
+ threshold = self.threshold
1267
+
1268
+ if self.dilation_factor is None:
1269
+ dilation_factor = bbox_dilation
1270
+ else:
1271
+ dilation_factor = self.dilation_factor
1272
+
1273
+ prompt = self.aux if self.prompt == '' and self.aux is not None else self.prompt
1274
+
1275
+ mask, _, _ = CLIPSeg().segment_image(image, prompt, self.blur, threshold, dilation_factor)
1276
+ mask = to_binary_mask(mask)
1277
+ return mask
1278
+
1279
+ def setAux(self, x):
1280
+ self.aux = x
1281
+ except:
1282
+ pass
1283
+
1284
+
1285
+ def update_node_status(node, text, progress=None):
1286
+ if PromptServer.instance.client_id is None:
1287
+ return
1288
+
1289
+ PromptServer.instance.send_sync("impact/update_status", {
1290
+ "node": node,
1291
+ "progress": progress,
1292
+ "text": text
1293
+ }, PromptServer.instance.client_id)
1294
+
1295
+
1296
+ from comfy.cli_args import args, LatentPreviewMethod
1297
+ import folder_paths
1298
+ from latent_preview import TAESD, TAESDPreviewerImpl, Latent2RGBPreviewer
1299
+
1300
+ try:
1301
+ import comfy.latent_formats as latent_formats
1302
+
1303
+ def get_previewer(device, latent_format=latent_formats.SD15(), force=False):
1304
+ previewer = None
1305
+ method = args.preview_method
1306
+ if method != LatentPreviewMethod.NoPreviews or force:
1307
+ # TODO previewer methods
1308
+ taesd_decoder_path = folder_paths.get_full_path("vae_approx", latent_format.taesd_decoder_name)
1309
+
1310
+ if method == LatentPreviewMethod.Auto:
1311
+ method = LatentPreviewMethod.Latent2RGB
1312
+ if taesd_decoder_path:
1313
+ method = LatentPreviewMethod.TAESD
1314
+
1315
+ if method == LatentPreviewMethod.TAESD:
1316
+ if taesd_decoder_path:
1317
+ taesd = TAESD(None, taesd_decoder_path).to(device)
1318
+ previewer = TAESDPreviewerImpl(taesd)
1319
+ else:
1320
+ print("Warning: TAESD previews enabled, but could not find models/vae_approx/{}".format(latent_format.taesd_decoder_name))
1321
+
1322
+ if previewer is None:
1323
+ previewer = Latent2RGBPreviewer(latent_format.latent_rgb_factors)
1324
+ return previewer
1325
+
1326
+ except:
1327
+ print(f"#########################################################################")
1328
+ print(f"[ERROR] ComfyUI-Impact-Pack: Please update ComfyUI to the latest version.")
1329
+ print(f"#########################################################################")
1330
+
ComfyUI-Impact-Pack/modules/impact/detectors.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import impact.core as core
2
+ from impact.config import MAX_RESOLUTION
3
+
4
+
5
+ class SAMDetectorCombined:
6
+ @classmethod
7
+ def INPUT_TYPES(s):
8
+ return {"required": {
9
+ "sam_model": ("SAM_MODEL", ),
10
+ "segs": ("SEGS", ),
11
+ "image": ("IMAGE", ),
12
+ "detection_hint": (["center-1", "horizontal-2", "vertical-2", "rect-4", "diamond-4", "mask-area",
13
+ "mask-points", "mask-point-bbox", "none"],),
14
+ "dilation": ("INT", {"default": 0, "min": 0, "max": 255, "step": 1}),
15
+ "threshold": ("FLOAT", {"default": 0.93, "min": 0.0, "max": 1.0, "step": 0.01}),
16
+ "bbox_expansion": ("INT", {"default": 0, "min": 0, "max": 1000, "step": 1}),
17
+ "mask_hint_threshold": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 1.0, "step": 0.01}),
18
+ "mask_hint_use_negative": (["False", "Small", "Outter"], )
19
+ }
20
+ }
21
+
22
+ RETURN_TYPES = ("MASK",)
23
+ FUNCTION = "doit"
24
+
25
+ CATEGORY = "ImpactPack/Detector"
26
+
27
+ def doit(self, sam_model, segs, image, detection_hint, dilation,
28
+ threshold, bbox_expansion, mask_hint_threshold, mask_hint_use_negative):
29
+ return (core.make_sam_mask(sam_model, segs, image, detection_hint, dilation,
30
+ threshold, bbox_expansion, mask_hint_threshold, mask_hint_use_negative), )
31
+
32
+
33
+ class SAMDetectorSegmented:
34
+ @classmethod
35
+ def INPUT_TYPES(s):
36
+ return {"required": {
37
+ "sam_model": ("SAM_MODEL", ),
38
+ "segs": ("SEGS", ),
39
+ "image": ("IMAGE", ),
40
+ "detection_hint": (["center-1", "horizontal-2", "vertical-2", "rect-4", "diamond-4", "mask-area",
41
+ "mask-points", "mask-point-bbox", "none"],),
42
+ "dilation": ("INT", {"default": 0, "min": 0, "max": 255, "step": 1}),
43
+ "threshold": ("FLOAT", {"default": 0.93, "min": 0.0, "max": 1.0, "step": 0.01}),
44
+ "bbox_expansion": ("INT", {"default": 0, "min": 0, "max": 1000, "step": 1}),
45
+ "mask_hint_threshold": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 1.0, "step": 0.01}),
46
+ "mask_hint_use_negative": (["False", "Small", "Outter"], )
47
+ }
48
+ }
49
+
50
+ RETURN_TYPES = ("MASK", "MASKS")
51
+ RETURN_NAMES = ("combined_mask", "batch_masks")
52
+ FUNCTION = "doit"
53
+
54
+ CATEGORY = "ImpactPack/Detector"
55
+
56
+ def doit(self, sam_model, segs, image, detection_hint, dilation,
57
+ threshold, bbox_expansion, mask_hint_threshold, mask_hint_use_negative):
58
+ combined_mask, batch_masks = core.make_sam_mask_segmented(sam_model, segs, image, detection_hint, dilation,
59
+ threshold, bbox_expansion, mask_hint_threshold,
60
+ mask_hint_use_negative)
61
+ return (combined_mask, batch_masks, )
62
+
63
+
64
+ class BboxDetectorForEach:
65
+ @classmethod
66
+ def INPUT_TYPES(s):
67
+ return {"required": {
68
+ "bbox_detector": ("BBOX_DETECTOR", ),
69
+ "image": ("IMAGE", ),
70
+ "threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
71
+ "dilation": ("INT", {"default": 10, "min": 0, "max": 255, "step": 1}),
72
+ "crop_factor": ("FLOAT", {"default": 3.0, "min": 1.0, "max": 10, "step": 0.1}),
73
+ "drop_size": ("INT", {"min": 1, "max": MAX_RESOLUTION, "step": 1, "default": 10}),
74
+ }
75
+ }
76
+
77
+ RETURN_TYPES = ("SEGS", )
78
+ FUNCTION = "doit"
79
+
80
+ CATEGORY = "ImpactPack/Detector"
81
+
82
+ def doit(self, bbox_detector, image, threshold, dilation, crop_factor, drop_size):
83
+ segs = bbox_detector.detect(image, threshold, dilation, crop_factor, drop_size)
84
+ return (segs, )
85
+
86
+
87
+ class SegmDetectorForEach:
88
+ @classmethod
89
+ def INPUT_TYPES(s):
90
+ return {"required": {
91
+ "segm_detector": ("SEGM_DETECTOR", ),
92
+ "image": ("IMAGE", ),
93
+ "threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
94
+ "dilation": ("INT", {"default": 10, "min": 0, "max": 255, "step": 1}),
95
+ "crop_factor": ("FLOAT", {"default": 3.0, "min": 1.0, "max": 10, "step": 0.1}),
96
+ "drop_size": ("INT", {"min": 1, "max": MAX_RESOLUTION, "step": 1, "default": 10}),
97
+ }
98
+ }
99
+
100
+ RETURN_TYPES = ("SEGS", )
101
+ FUNCTION = "doit"
102
+
103
+ CATEGORY = "ImpactPack/Detector"
104
+
105
+ def doit(self, segm_detector, image, threshold, dilation, crop_factor, drop_size):
106
+ segs = segm_detector.detect(image, threshold, dilation, crop_factor, drop_size)
107
+ return (segs, )
108
+
109
+
110
+ class SegmDetectorCombined:
111
+ @classmethod
112
+ def INPUT_TYPES(s):
113
+ return {"required": {
114
+ "segm_detector": ("SEGM_DETECTOR", ),
115
+ "image": ("IMAGE", ),
116
+ "threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
117
+ "dilation": ("INT", {"default": 0, "min": 0, "max": 255, "step": 1}),
118
+ }
119
+ }
120
+
121
+ RETURN_TYPES = ("MASK",)
122
+ FUNCTION = "doit"
123
+
124
+ CATEGORY = "ImpactPack/Detector"
125
+
126
+ def doit(self, segm_detector, image, threshold, dilation):
127
+ mask = segm_detector.detect_combined(image, threshold, dilation)
128
+ return (mask,)
129
+
130
+
131
+ class BboxDetectorCombined(SegmDetectorCombined):
132
+ @classmethod
133
+ def INPUT_TYPES(s):
134
+ return {"required": {
135
+ "bbox_detector": ("BBOX_DETECTOR", ),
136
+ "image": ("IMAGE", ),
137
+ "threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
138
+ "dilation": ("INT", {"default": 4, "min": 0, "max": 255, "step": 1}),
139
+ }
140
+ }
141
+
142
+ def doit(self, bbox_detector, image, threshold, dilation):
143
+ mask = bbox_detector.detect_combined(image, threshold, dilation)
144
+ return (mask,)
ComfyUI-Impact-Pack/modules/impact/impact_pack.py ADDED
The diff for this file is too large to render. See raw diff
 
ComfyUI-Impact-Pack/modules/impact/impact_server.py ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import threading
3
+
4
+ from aiohttp import web
5
+ import server
6
+ import folder_paths
7
+
8
+ import impact.core as core
9
+ import impact.impact_pack as impact_pack
10
+ from segment_anything import SamPredictor, sam_model_registry
11
+ import numpy as np
12
+ import nodes
13
+ from PIL import Image
14
+ import io
15
+ import impact.wildcards as wildcards
16
+ import comfy
17
+
18
+ @server.PromptServer.instance.routes.post("/upload/temp")
19
+ async def upload_image(request):
20
+ upload_dir = folder_paths.get_temp_directory()
21
+
22
+ if not os.path.exists(upload_dir):
23
+ os.makedirs(upload_dir)
24
+
25
+ post = await request.post()
26
+ image = post.get("image")
27
+
28
+ if image and image.file:
29
+ filename = image.filename
30
+ if not filename:
31
+ return web.Response(status=400)
32
+
33
+ split = os.path.splitext(filename)
34
+ i = 1
35
+ while os.path.exists(os.path.join(upload_dir, filename)):
36
+ filename = f"{split[0]} ({i}){split[1]}"
37
+ i += 1
38
+
39
+ filepath = os.path.join(upload_dir, filename)
40
+
41
+ with open(filepath, "wb") as f:
42
+ f.write(image.file.read())
43
+
44
+ return web.json_response({"name": filename})
45
+ else:
46
+ return web.Response(status=400)
47
+
48
+
49
+ sam_predictor = None
50
+ default_sam_model_name = os.path.join(impact_pack.model_path, "sams", "sam_vit_b_01ec64.pth")
51
+
52
+ sam_lock = threading.Condition()
53
+
54
+ last_prepare_data = None
55
+
56
+
57
+ def async_prepare_sam(image_dir, model_name, filename):
58
+ with sam_lock:
59
+ global sam_predictor
60
+
61
+ if 'vit_h' in model_name:
62
+ model_kind = 'vit_h'
63
+ elif 'vit_l' in model_name:
64
+ model_kind = 'vit_l'
65
+ else:
66
+ model_kind = 'vit_b'
67
+
68
+ sam_model = sam_model_registry[model_kind](checkpoint=model_name)
69
+ sam_predictor = SamPredictor(sam_model)
70
+
71
+ image_path = os.path.join(image_dir, filename)
72
+ image = nodes.LoadImage().load_image(image_path)[0]
73
+ image = np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8)
74
+
75
+ device = comfy.model_management.get_torch_device()
76
+ sam_predictor.model.to(device=device)
77
+ sam_predictor.set_image(image, "RGB")
78
+ sam_predictor.model.cpu()
79
+
80
+
81
+ @server.PromptServer.instance.routes.post("/sam/prepare")
82
+ async def sam_prepare(request):
83
+ global sam_predictor
84
+ global last_prepare_data
85
+ data = await request.json()
86
+
87
+ with sam_lock:
88
+ if last_prepare_data is not None and last_prepare_data == data:
89
+ # already loaded: skip -- prevent redundant loading
90
+ return web.Response(status=200)
91
+
92
+ last_prepare_data = data
93
+
94
+ model_name = os.path.join(impact_pack.model_path, "sams", data['sam_model_name'])
95
+
96
+ print(f"ComfyUI-Impact-Pack: Loading SAM model '{impact_pack.model_path}'")
97
+
98
+ filename, image_dir = folder_paths.annotated_filepath(data["filename"])
99
+
100
+ if image_dir is None:
101
+ typ = data['type'] if data['type'] != '' else 'output'
102
+ image_dir = folder_paths.get_directory_by_type(typ)
103
+ if data['subfolder'] is not None and data['subfolder'] != '':
104
+ image_dir += f"/{data['subfolder']}"
105
+
106
+ if image_dir is None:
107
+ return web.Response(status=400)
108
+
109
+ thread = threading.Thread(target=async_prepare_sam, args=(image_dir, model_name, filename,))
110
+ thread.start()
111
+
112
+ print(f"ComfyUI-Impact-Pack: SAM model loaded. ")
113
+
114
+
115
+ @server.PromptServer.instance.routes.post("/sam/release")
116
+ async def release_sam(request):
117
+ global sam_predictor
118
+
119
+ with sam_lock:
120
+ del sam_predictor
121
+ sam_predictor = None
122
+
123
+ print(f"ComfyUI-Impact-Pack: unloading SAM model")
124
+
125
+
126
+ @server.PromptServer.instance.routes.post("/sam/detect")
127
+ async def sam_detect(request):
128
+ global sam_predictor
129
+ with sam_lock:
130
+ if sam_predictor is not None:
131
+ device = comfy.model_management.get_torch_device()
132
+ sam_predictor.model.to(device=device)
133
+ try:
134
+ data = await request.json()
135
+
136
+ positive_points = data['positive_points']
137
+ negative_points = data['negative_points']
138
+ threshold = data['threshold']
139
+
140
+ points = []
141
+ plabs = []
142
+
143
+ for p in positive_points:
144
+ points.append(p)
145
+ plabs.append(1)
146
+
147
+ for p in negative_points:
148
+ points.append(p)
149
+ plabs.append(0)
150
+
151
+ detected_masks = core.sam_predict(sam_predictor, points, plabs, None, threshold)
152
+ mask = core.combine_masks2(detected_masks)
153
+
154
+ if mask is None:
155
+ return web.Response(status=400)
156
+
157
+ image = mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1])).movedim(1, -1).expand(-1, -1, -1, 3)
158
+ i = 255. * image.cpu().numpy()
159
+
160
+ img = Image.fromarray(np.clip(i[0], 0, 255).astype(np.uint8))
161
+
162
+ img_buffer = io.BytesIO()
163
+ img.save(img_buffer, format='png')
164
+
165
+ headers = {'Content-Type': 'image/png'}
166
+ finally:
167
+ sam_predictor.model.to(device="cpu")
168
+
169
+ return web.Response(body=img_buffer.getvalue(), headers=headers)
170
+
171
+ else:
172
+ return web.Response(status=400)
173
+
174
+
175
+ @server.PromptServer.instance.routes.post("/impact/wildcards")
176
+ async def populate_wildcards(request):
177
+ data = await request.json()
178
+ populated = wildcards.process(data['text'])
179
+ return web.json_response({"text": populated})
ComfyUI-Impact-Pack/modules/impact/legacy_nodes.py ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import folder_paths
2
+
3
+ import impact.mmdet_nodes as mmdet_nodes
4
+ from impact.utils import *
5
+ from impact.core import SEG
6
+ import impact.core as core
7
+ import nodes
8
+
9
+ class NO_BBOX_MODEL:
10
+ pass
11
+
12
+
13
+ class NO_SEGM_MODEL:
14
+ pass
15
+
16
+
17
+ class MMDetLoader:
18
+ @classmethod
19
+ def INPUT_TYPES(s):
20
+ bboxs = ["bbox/"+x for x in folder_paths.get_filename_list("mmdets_bbox")]
21
+ segms = ["segm/"+x for x in folder_paths.get_filename_list("mmdets_segm")]
22
+ return {"required": {"model_name": (bboxs + segms, )}}
23
+ RETURN_TYPES = ("BBOX_MODEL", "SEGM_MODEL")
24
+ FUNCTION = "load_mmdet"
25
+
26
+ CATEGORY = "ImpactPack/Legacy"
27
+
28
+ def load_mmdet(self, model_name):
29
+ mmdet_path = folder_paths.get_full_path("mmdets", model_name)
30
+ model = mmdet_nodes.load_mmdet(mmdet_path)
31
+
32
+ if model_name.startswith("bbox"):
33
+ return model, NO_SEGM_MODEL()
34
+ else:
35
+ return NO_BBOX_MODEL(), model
36
+
37
+
38
+ class BboxDetectorForEach:
39
+ @classmethod
40
+ def INPUT_TYPES(s):
41
+ return {"required": {
42
+ "bbox_model": ("BBOX_MODEL", ),
43
+ "image": ("IMAGE", ),
44
+ "threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
45
+ "dilation": ("INT", {"default": 10, "min": 0, "max": 255, "step": 1}),
46
+ "crop_factor": ("FLOAT", {"default": 3.0, "min": 1.0, "max": 10, "step": 0.1}),
47
+ }
48
+ }
49
+
50
+ RETURN_TYPES = ("SEGS", )
51
+ FUNCTION = "doit"
52
+
53
+ CATEGORY = "ImpactPack/Legacy"
54
+
55
+ @staticmethod
56
+ def detect(bbox_model, image, threshold, dilation, crop_factor, drop_size=1):
57
+ mmdet_results = mmdet_nodes.inference_bbox(bbox_model, image, threshold)
58
+ segmasks = core.create_segmasks(mmdet_results)
59
+
60
+ if dilation > 0:
61
+ segmasks = dilate_masks(segmasks, dilation)
62
+
63
+ items = []
64
+ h = image.shape[1]
65
+ w = image.shape[2]
66
+ for x in segmasks:
67
+ item_bbox = x[0]
68
+ item_mask = x[1]
69
+
70
+ y1, x1, y2, x2 = item_bbox
71
+
72
+ if x2 - x1 > drop_size and y2 - y1 > drop_size:
73
+ crop_region = make_crop_region(w, h, item_bbox, crop_factor)
74
+ cropped_image = crop_image(image, crop_region)
75
+ cropped_mask = crop_ndarray2(item_mask, crop_region)
76
+ confidence = x[2]
77
+ # bbox_size = (item_bbox[2]-item_bbox[0],item_bbox[3]-item_bbox[1]) # (w,h)
78
+
79
+ item = SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox)
80
+ items.append(item)
81
+
82
+ shape = h, w
83
+ return shape, items
84
+
85
+ def doit(self, bbox_model, image, threshold, dilation, crop_factor):
86
+ return (BboxDetectorForEach.detect(bbox_model, image, threshold, dilation, crop_factor), )
87
+
88
+
89
+ class SegmDetectorCombined:
90
+ @classmethod
91
+ def INPUT_TYPES(s):
92
+ return {"required": {
93
+ "segm_model": ("SEGM_MODEL", ),
94
+ "image": ("IMAGE", ),
95
+ "threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
96
+ "dilation": ("INT", {"default": 0, "min": 0, "max": 255, "step": 1}),
97
+ }
98
+ }
99
+
100
+ RETURN_TYPES = ("MASK",)
101
+ FUNCTION = "doit"
102
+
103
+ CATEGORY = "ImpactPack/Legacy"
104
+
105
+ def doit(self, segm_model, image, threshold, dilation):
106
+ mmdet_results = mmdet_nodes.inference_segm(image, segm_model, threshold)
107
+ segmasks = core.create_segmasks(mmdet_results)
108
+ if dilation > 0:
109
+ segmasks = dilate_masks(segmasks, dilation)
110
+
111
+ mask = combine_masks(segmasks)
112
+ return (mask,)
113
+
114
+
115
+ class BboxDetectorCombined(SegmDetectorCombined):
116
+ @classmethod
117
+ def INPUT_TYPES(s):
118
+ return {"required": {
119
+ "bbox_model": ("BBOX_MODEL", ),
120
+ "image": ("IMAGE", ),
121
+ "threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
122
+ "dilation": ("INT", {"default": 4, "min": 0, "max": 255, "step": 1}),
123
+ }
124
+ }
125
+
126
+ def doit(self, bbox_model, image, threshold, dilation):
127
+ mmdet_results = mmdet_nodes.inference_bbox(bbox_model, image, threshold)
128
+ segmasks = core.create_segmasks(mmdet_results)
129
+ if dilation > 0:
130
+ segmasks = dilate_masks(segmasks, dilation)
131
+
132
+ mask = combine_masks(segmasks)
133
+ return (mask,)
134
+
135
+
136
+ class SegmDetectorForEach:
137
+ @classmethod
138
+ def INPUT_TYPES(s):
139
+ return {"required": {
140
+ "segm_model": ("SEGM_MODEL", ),
141
+ "image": ("IMAGE", ),
142
+ "threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
143
+ "dilation": ("INT", {"default": 10, "min": 0, "max": 255, "step": 1}),
144
+ "crop_factor": ("FLOAT", {"default": 3.0, "min": 1.0, "max": 10, "step": 0.1}),
145
+ }
146
+ }
147
+
148
+ RETURN_TYPES = ("SEGS", )
149
+ FUNCTION = "doit"
150
+
151
+ CATEGORY = "ImpactPack/Legacy"
152
+
153
+ def doit(self, segm_model, image, threshold, dilation, crop_factor):
154
+ mmdet_results = mmdet_nodes.inference_segm(image, segm_model, threshold)
155
+ segmasks = core.create_segmasks(mmdet_results)
156
+
157
+ if dilation > 0:
158
+ segmasks = dilate_masks(segmasks, dilation)
159
+
160
+ items = []
161
+ h = image.shape[1]
162
+ w = image.shape[2]
163
+ for x in segmasks:
164
+ item_bbox = x[0]
165
+ item_mask = x[1]
166
+
167
+ crop_region = make_crop_region(w, h, item_bbox, crop_factor)
168
+ cropped_image = crop_image(image, crop_region)
169
+ cropped_mask = crop_ndarray2(item_mask, crop_region)
170
+ confidence = x[2]
171
+
172
+ item = SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox)
173
+ items.append(item)
174
+
175
+ shape = h,w
176
+ return ((shape, items), )
177
+
178
+
179
+ class SegsMaskCombine:
180
+ @classmethod
181
+ def INPUT_TYPES(s):
182
+ return {"required": {
183
+ "segs": ("SEGS", ),
184
+ "image": ("IMAGE", ),
185
+ }
186
+ }
187
+
188
+ RETURN_TYPES = ("MASK",)
189
+ FUNCTION = "doit"
190
+
191
+ CATEGORY = "ImpactPack/Legacy"
192
+
193
+ @staticmethod
194
+ def combine(segs, image):
195
+ h = image.shape[1]
196
+ w = image.shape[2]
197
+
198
+ mask = np.zeros((h, w), dtype=np.uint8)
199
+
200
+ for seg in segs[1]:
201
+ cropped_mask = seg.cropped_mask
202
+ crop_region = seg.crop_region
203
+ mask[crop_region[1]:crop_region[3], crop_region[0]:crop_region[2]] |= (cropped_mask * 255).astype(np.uint8)
204
+
205
+ return torch.from_numpy(mask.astype(np.float32) / 255.0)
206
+
207
+ def doit(self, segs, image):
208
+ return (SegsMaskCombine.combine(segs, image), )
209
+
210
+
211
+ class MaskPainter(nodes.PreviewImage):
212
+ @classmethod
213
+ def INPUT_TYPES(s):
214
+ return {"required": {"images": ("IMAGE",), },
215
+ "hidden": {
216
+ "prompt": "PROMPT",
217
+ "extra_pnginfo": "EXTRA_PNGINFO",
218
+ },
219
+ "optional": {"mask_image": ("IMAGE_PATH",), },
220
+ "optional": {"image": (["#placeholder"], )},
221
+ }
222
+
223
+ RETURN_TYPES = ("MASK",)
224
+
225
+ FUNCTION = "save_painted_images"
226
+
227
+ CATEGORY = "ImpactPack/Legacy"
228
+
229
+ def save_painted_images(self, images, filename_prefix="impact-mask",
230
+ prompt=None, extra_pnginfo=None, mask_image=None, image=None):
231
+ if image == "#placeholder" or image['image_hash'] != id(images):
232
+ # new input image
233
+ res = self.save_images(images, filename_prefix, prompt, extra_pnginfo)
234
+
235
+ item = res['ui']['images'][0]
236
+
237
+ if not item['filename'].endswith(']'):
238
+ filepath = f"{item['filename']} [{item['type']}]"
239
+ else:
240
+ filepath = item['filename']
241
+
242
+ _, mask = nodes.LoadImage().load_image(filepath)
243
+
244
+ res['ui']['aux'] = [id(images), res['ui']['images']]
245
+ res['result'] = (mask, )
246
+
247
+ return res
248
+
249
+ else:
250
+ # new mask
251
+ if '0' in image: # fallback
252
+ image = image['0']
253
+
254
+ forward = {'filename': image['forward_filename'],
255
+ 'subfolder': image['forward_subfolder'],
256
+ 'type': image['forward_type'], }
257
+
258
+ res = {'ui': {'images': [forward]}}
259
+
260
+ imgpath = ""
261
+ if 'subfolder' in image and image['subfolder'] != "":
262
+ imgpath = image['subfolder'] + "/"
263
+
264
+ imgpath += f"{image['filename']}"
265
+
266
+ if 'type' in image and image['type'] != "":
267
+ imgpath += f" [{image['type']}]"
268
+
269
+ res['ui']['aux'] = [id(images), [forward]]
270
+ _, mask = nodes.LoadImage().load_image(imgpath)
271
+ res['result'] = (mask, )
272
+
273
+ return res
ComfyUI-Impact-Pack/modules/impact/logics.py ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from server import PromptServer
3
+
4
+ # wildcard trick is taken from pythongossss's
5
+ class AnyType(str):
6
+ def __ne__(self, __value: object) -> bool:
7
+ return False
8
+
9
+ any = AnyType("*")
10
+
11
+
12
+ class ImpactCompare:
13
+ @classmethod
14
+ def INPUT_TYPES(cls):
15
+ return {
16
+ "required": {
17
+ "cmp": (['a = b', 'a <> b', 'a > b', 'a < b', 'a >= b', 'a <= b', 'tt', 'ff'],),
18
+ "a": (any, ),
19
+ "b": (any, ),
20
+ },
21
+ }
22
+
23
+ FUNCTION = "doit"
24
+ CATEGORY = "ImpactPack/Logic"
25
+
26
+ RETURN_TYPES = ("BOOLEAN", )
27
+
28
+ def doit(self, cmp, a, b):
29
+ if cmp == "a = b":
30
+ return (a == b, )
31
+ elif cmp == "a <> b":
32
+ return (a != b, )
33
+ elif cmp == "a > b":
34
+ return (a > b, )
35
+ elif cmp == "a < b":
36
+ return (a < b, )
37
+ elif cmp == "a >= b":
38
+ return (a >= b, )
39
+ elif cmp == "a <= b":
40
+ return (a <= b, )
41
+ elif cmp == 'tt':
42
+ return (True, )
43
+ else:
44
+ return (False, )
45
+
46
+
47
+ class ImpactConditionalBranch:
48
+ @classmethod
49
+ def INPUT_TYPES(cls):
50
+ return {
51
+ "required": {
52
+ "cond": ("BOOLEAN", {"forceInput": True}),
53
+ "tt_value": (any,),
54
+ "ff_value": (any,),
55
+ },
56
+ }
57
+
58
+ FUNCTION = "doit"
59
+ CATEGORY = "ImpactPack/Logic"
60
+
61
+ RETURN_TYPES = (any, )
62
+
63
+ def doit(self, cond, tt_value, ff_value):
64
+ if cond:
65
+ return (tt_value,)
66
+ else:
67
+ return (ff_value,)
68
+
69
+
70
+ class ImpactConditionalStopIteration:
71
+ @classmethod
72
+ def INPUT_TYPES(cls):
73
+ return {
74
+ "required": { "cond": ("BOOLEAN", {"forceInput": True}), },
75
+ }
76
+
77
+ FUNCTION = "doit"
78
+ CATEGORY = "ImpactPack/Logic"
79
+
80
+ RETURN_TYPES = ()
81
+
82
+ OUTPUT_NODE = True
83
+
84
+ def doit(self, cond):
85
+ if cond:
86
+ PromptServer.instance.send_sync("stop-iteration", {})
87
+ return {}
88
+
89
+
90
+ class ImpactNeg:
91
+ @classmethod
92
+ def INPUT_TYPES(cls):
93
+ return {
94
+ "required": { "value": ("BOOLEAN", {"forceInput": True}), },
95
+ }
96
+
97
+ FUNCTION = "doit"
98
+ CATEGORY = "ImpactPack/Logic"
99
+
100
+ RETURN_TYPES = ("BOOLEAN", )
101
+
102
+ def doit(self, value):
103
+ return (not value, )
104
+
105
+
106
+ class ImpactInt:
107
+ @classmethod
108
+ def INPUT_TYPES(cls):
109
+ return {
110
+ "required": {
111
+ "value": ("INT", {"default": 0, "min": 0, "max": sys.maxsize, "step": 1}),
112
+ },
113
+ }
114
+
115
+ FUNCTION = "doit"
116
+ CATEGORY = "ImpactPack/Logic"
117
+
118
+ RETURN_TYPES = ("INT", )
119
+
120
+ def doit(self, value):
121
+ return (value, )
122
+
123
+
124
+ class ImpactFloat:
125
+ @classmethod
126
+ def INPUT_TYPES(cls):
127
+ return {
128
+ "required": {
129
+ "value": ("FLOAT", {"default": 1.0, "min": -3.402823466e+38, "max": 3.402823466e+38}),
130
+ },
131
+ }
132
+
133
+ FUNCTION = "doit"
134
+ CATEGORY = "ImpactPack/Logic"
135
+
136
+ RETURN_TYPES = ("FLOAT", )
137
+
138
+ def doit(self, value):
139
+ return (value, )
140
+
141
+
142
+ class ImpactValueSender:
143
+ @classmethod
144
+ def INPUT_TYPES(cls):
145
+ return {"required": {
146
+ "value": (any, ),
147
+ "link_id": ("INT", {"default": 0, "min": 0, "max": sys.maxsize, "step": 1}),
148
+ },
149
+ }
150
+
151
+ OUTPUT_NODE = True
152
+
153
+ FUNCTION = "doit"
154
+
155
+ CATEGORY = "ImpactPack/Logic"
156
+
157
+ RETURN_TYPES = ()
158
+
159
+ def doit(self, value, link_id=0):
160
+ PromptServer.instance.send_sync("value-send", {"link_id": link_id, "value": value})
161
+ return {}
162
+
163
+
164
+ class ImpactIntConstSender:
165
+ @classmethod
166
+ def INPUT_TYPES(cls):
167
+ return {"required": {
168
+ "signal": (any, ),
169
+ "value": ("INT", {"default": 0, "min": 0, "max": sys.maxsize, "step": 1}),
170
+ "link_id": ("INT", {"default": 0, "min": 0, "max": sys.maxsize, "step": 1}),
171
+ },
172
+ }
173
+
174
+ OUTPUT_NODE = True
175
+
176
+ FUNCTION = "doit"
177
+
178
+ CATEGORY = "ImpactPack/Logic"
179
+
180
+ RETURN_TYPES = ()
181
+
182
+ def doit(self, signal, value, link_id=0):
183
+ PromptServer.instance.send_sync("value-send", {"link_id": link_id, "value": value})
184
+ return {}
185
+
186
+
187
+ class ImpactValueReceiver:
188
+ @classmethod
189
+ def INPUT_TYPES(cls):
190
+ return {"required": {
191
+ "typ": (["STRING", "INT", "FLOAT", "BOOLEAN"], ),
192
+ "value": ("STRING", {"default": ""}),
193
+ "link_id": ("INT", {"default": 0, "min": 0, "max": sys.maxsize, "step": 1}),
194
+ },
195
+ }
196
+
197
+ FUNCTION = "doit"
198
+
199
+ CATEGORY = "ImpactPack/Logic"
200
+
201
+ RETURN_TYPES = (any, )
202
+
203
+ def doit(self, typ, value, link_id=0):
204
+ if typ == "INT":
205
+ return (int(value), )
206
+ elif typ == "FLOAT":
207
+ return (float(value), )
208
+ elif typ == "BOOLEAN":
209
+ return (bool(value), )
210
+ else:
211
+ return (value, )
212
+
213
+
214
+ class ImpactImageInfo:
215
+ @classmethod
216
+ def INPUT_TYPES(cls):
217
+ return {"required": {
218
+ "value": ("IMAGE", ),
219
+ },
220
+ }
221
+
222
+ FUNCTION = "doit"
223
+
224
+ CATEGORY = "ImpactPack/Logic/_for_test"
225
+
226
+ RETURN_TYPES = ("INT", "INT", "INT", "INT")
227
+ RETURN_NAMES = ("batch", "height", "width", "channel")
228
+
229
+ def doit(self, value):
230
+ return (value.shape[0], value.shape[1], value.shape[2], value.shape[3])
231
+
232
+
233
+ class ImpactMinMax:
234
+ @classmethod
235
+ def INPUT_TYPES(cls):
236
+ return {"required": {
237
+ "mode": ("BOOLEAN", {"default": True, "label_on": "max", "label_off": "min"}),
238
+ "a": (any,),
239
+ "b": (any,),
240
+ },
241
+ }
242
+
243
+ FUNCTION = "doit"
244
+
245
+ CATEGORY = "ImpactPack/Logic/_for_test"
246
+
247
+ RETURN_TYPES = ("INT", )
248
+
249
+ def doit(self, mode, a, b):
250
+ if mode:
251
+ return (max(a, b), )
252
+ else:
253
+ return (min(a, b),)
ComfyUI-Impact-Pack/modules/impact/mmdet_nodes.py ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import folder_paths
2
+ from impact.core import *
3
+
4
+ import mmcv
5
+ from mmdet.apis import (inference_detector, init_detector)
6
+ from mmdet.evaluation import get_classes
7
+
8
+
9
+ def load_mmdet(model_path):
10
+ model_config = os.path.splitext(model_path)[0] + ".py"
11
+ model = init_detector(model_config, model_path, device="cpu")
12
+ return model
13
+
14
+
15
+ def inference_segm_old(model, image, conf_threshold):
16
+ image = image.numpy()[0] * 255
17
+ mmdet_results = inference_detector(model, image)
18
+
19
+ bbox_results, segm_results = mmdet_results
20
+ label = "A"
21
+
22
+ classes = get_classes("coco")
23
+ labels = [
24
+ np.full(bbox.shape[0], i, dtype=np.int32)
25
+ for i, bbox in enumerate(bbox_results)
26
+ ]
27
+ n, m = bbox_results[0].shape
28
+ if n == 0:
29
+ return [[], [], []]
30
+ labels = np.concatenate(labels)
31
+ bboxes = np.vstack(bbox_results)
32
+ segms = mmcv.concat_list(segm_results)
33
+ filter_idxs = np.where(bboxes[:, -1] > conf_threshold)[0]
34
+ results = [[], [], []]
35
+ for i in filter_idxs:
36
+ results[0].append(label + "-" + classes[labels[i]])
37
+ results[1].append(bboxes[i])
38
+ results[2].append(segms[i])
39
+
40
+ return results
41
+
42
+
43
+ def inference_segm(image, modelname, conf_thres, lab="A"):
44
+ image = image.numpy()[0] * 255
45
+ mmdet_results = inference_detector(modelname, image).pred_instances
46
+ bboxes = mmdet_results.bboxes.numpy()
47
+ segms = mmdet_results.masks.numpy()
48
+ scores = mmdet_results.scores.numpy()
49
+
50
+ classes = get_classes("coco")
51
+
52
+ n, m = bboxes.shape
53
+ if n == 0:
54
+ return [[], [], [], []]
55
+ labels = mmdet_results.labels
56
+ filter_inds = np.where(mmdet_results.scores > conf_thres)[0]
57
+ results = [[], [], [], []]
58
+ for i in filter_inds:
59
+ results[0].append(lab + "-" + classes[labels[i]])
60
+ results[1].append(bboxes[i])
61
+ results[2].append(segms[i])
62
+ results[3].append(scores[i])
63
+
64
+ return results
65
+
66
+
67
+ def inference_bbox(modelname, image, conf_threshold):
68
+ image = image.numpy()[0] * 255
69
+ label = "A"
70
+ output = inference_detector(modelname, image).pred_instances
71
+ cv2_image = np.array(image)
72
+ cv2_image = cv2_image[:, :, ::-1].copy()
73
+ cv2_gray = cv2.cvtColor(cv2_image, cv2.COLOR_BGR2GRAY)
74
+
75
+ segms = []
76
+ for x0, y0, x1, y1 in output.bboxes:
77
+ cv2_mask = np.zeros(cv2_gray.shape, np.uint8)
78
+ cv2.rectangle(cv2_mask, (int(x0), int(y0)), (int(x1), int(y1)), 255, -1)
79
+ cv2_mask_bool = cv2_mask.astype(bool)
80
+ segms.append(cv2_mask_bool)
81
+
82
+ n, m = output.bboxes.shape
83
+ if n == 0:
84
+ return [[], [], [], []]
85
+
86
+ bboxes = output.bboxes.numpy()
87
+ scores = output.scores.numpy()
88
+ filter_idxs = np.where(scores > conf_threshold)[0]
89
+ results = [[], [], [], []]
90
+ for i in filter_idxs:
91
+ results[0].append(label)
92
+ results[1].append(bboxes[i])
93
+ results[2].append(segms[i])
94
+ results[3].append(scores[i])
95
+
96
+ return results
97
+
98
+
99
+ class BBoxDetector:
100
+ bbox_model = None
101
+
102
+ def __init__(self, bbox_model):
103
+ self.bbox_model = bbox_model
104
+
105
+ def detect(self, image, threshold, dilation, crop_factor, drop_size=1):
106
+ drop_size = max(drop_size, 1)
107
+ mmdet_results = inference_bbox(self.bbox_model, image, threshold)
108
+ segmasks = create_segmasks(mmdet_results)
109
+
110
+ if dilation > 0:
111
+ segmasks = dilate_masks(segmasks, dilation)
112
+
113
+ items = []
114
+ h = image.shape[1]
115
+ w = image.shape[2]
116
+
117
+ for x in segmasks:
118
+ item_bbox = x[0]
119
+ item_mask = x[1]
120
+
121
+ y1, x1, y2, x2 = item_bbox
122
+
123
+ if x2 - x1 > drop_size and y2 - y1 > drop_size: # minimum dimension must be (2,2) to avoid squeeze issue
124
+ crop_region = make_crop_region(w, h, item_bbox, crop_factor)
125
+ cropped_image = crop_image(image, crop_region)
126
+ cropped_mask = crop_ndarray2(item_mask, crop_region)
127
+ confidence = x[2]
128
+ # bbox_size = (item_bbox[2]-item_bbox[0],item_bbox[3]-item_bbox[1]) # (w,h)
129
+
130
+ item = SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox)
131
+
132
+ items.append(item)
133
+
134
+ shape = image.shape[1], image.shape[2]
135
+ return shape, items
136
+
137
+ def detect_combined(self, image, threshold, dilation):
138
+ mmdet_results = inference_bbox(self.bbox_model, image, threshold)
139
+ segmasks = create_segmasks(mmdet_results)
140
+ if dilation > 0:
141
+ segmasks = dilate_masks(segmasks, dilation)
142
+
143
+ return combine_masks(segmasks)
144
+
145
+ def setAux(self, x):
146
+ pass
147
+
148
+
149
+ class SegmDetector(BBoxDetector):
150
+ segm_model = None
151
+
152
+ def __init__(self, segm_model):
153
+ self.segm_model = segm_model
154
+
155
+ def detect(self, image, threshold, dilation, crop_factor, drop_size=1):
156
+ drop_size = max(drop_size, 1)
157
+ mmdet_results = inference_segm(image, self.segm_model, threshold)
158
+ segmasks = create_segmasks(mmdet_results)
159
+
160
+ if dilation > 0:
161
+ segmasks = dilate_masks(segmasks, dilation)
162
+
163
+ items = []
164
+ h = image.shape[1]
165
+ w = image.shape[2]
166
+ for x in segmasks:
167
+ item_bbox = x[0]
168
+ item_mask = x[1]
169
+
170
+ y1, x1, y2, x2 = item_bbox
171
+
172
+ if x2 - x1 > drop_size and y2 - y1 > drop_size: # minimum dimension must be (2,2) to avoid squeeze issue
173
+ crop_region = make_crop_region(w, h, item_bbox, crop_factor)
174
+ cropped_image = crop_image(image, crop_region)
175
+ cropped_mask = crop_ndarray2(item_mask, crop_region)
176
+ confidence = x[2]
177
+
178
+ item = SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox)
179
+ items.append(item)
180
+
181
+ return image.shape, items
182
+
183
+ def detect_combined(self, image, threshold, dilation):
184
+ mmdet_results = inference_bbox(self.bbox_model, image, threshold)
185
+ segmasks = create_segmasks(mmdet_results)
186
+ if dilation > 0:
187
+ segmasks = dilate_masks(segmasks, dilation)
188
+
189
+ return combine_masks(segmasks)
190
+
191
+ def setAux(self, x):
192
+ pass
193
+
194
+
195
+ class MMDetDetectorProvider:
196
+ @classmethod
197
+ def INPUT_TYPES(s):
198
+ bboxs = ["bbox/"+x for x in folder_paths.get_filename_list("mmdets_bbox")]
199
+ segms = ["segm/"+x for x in folder_paths.get_filename_list("mmdets_segm")]
200
+ return {"required": {"model_name": (bboxs + segms, )}}
201
+ RETURN_TYPES = ("BBOX_DETECTOR", "SEGM_DETECTOR")
202
+ FUNCTION = "load_mmdet"
203
+
204
+ CATEGORY = "ImpactPack"
205
+
206
+ def load_mmdet(self, model_name):
207
+ mmdet_path = folder_paths.get_full_path("mmdets", model_name)
208
+ model = load_mmdet(mmdet_path)
209
+
210
+ if model_name.startswith("bbox"):
211
+ return BBoxDetector(model), NO_SEGM_DETECTOR()
212
+ else:
213
+ return NO_BBOX_DETECTOR(), model
ComfyUI-Impact-Pack/modules/impact/onnx.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import impact.additional_dependencies
2
+ from impact.utils import *
3
+
4
+ impact.additional_dependencies.ensure_onnx_package()
5
+
6
+ try:
7
+ import onnxruntime
8
+
9
+ def onnx_inference(image, onnx_model):
10
+ # prepare image
11
+ pil = tensor2pil(image)
12
+ image = np.ascontiguousarray(pil)
13
+ image = image[:, :, ::-1] # to BGR image
14
+ image = image.astype(np.float32)
15
+ image -= [103.939, 116.779, 123.68] # 'caffe' mode image preprocessing
16
+
17
+ # do detection
18
+ onnx_model = onnxruntime.InferenceSession(onnx_model, providers=["CPUExecutionProvider"])
19
+ outputs = onnx_model.run(
20
+ [s_i.name for s_i in onnx_model.get_outputs()],
21
+ {onnx_model.get_inputs()[0].name: np.expand_dims(image, axis=0)},
22
+ )
23
+
24
+ labels = [op for op in outputs if op.dtype == "int32"][0]
25
+ scores = [op for op in outputs if isinstance(op[0][0], np.float32)][0]
26
+ boxes = [op for op in outputs if isinstance(op[0][0], np.ndarray)][0]
27
+
28
+ # filter-out useless item
29
+ idx = np.where(labels[0] == -1)[0][0]
30
+
31
+ labels = labels[0][:idx]
32
+ scores = scores[0][:idx]
33
+ boxes = boxes[0][:idx].astype(np.uint32)
34
+
35
+ return labels, scores, boxes
36
+ except Exception as e:
37
+ print("[ERROR] ComfyUI-Impact-Pack: 'onnxruntime' package doesn't support 'python 3.11', yet.")
38
+ print(f"\t{e}")
ComfyUI-Impact-Pack/modules/impact/pipe.py ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class ToDetailerPipe:
2
+ @classmethod
3
+ def INPUT_TYPES(s):
4
+ return {"required": {
5
+ "model": ("MODEL",),
6
+ "clip": ("CLIP",),
7
+ "vae": ("VAE",),
8
+ "positive": ("CONDITIONING",),
9
+ "negative": ("CONDITIONING",),
10
+ "bbox_detector": ("BBOX_DETECTOR", ),
11
+ "wildcard": ("STRING", {"multiline": True}),
12
+ },
13
+ "optional": {
14
+ "sam_model_opt": ("SAM_MODEL", ),
15
+ "segm_detector_opt": ("SEGM_DETECTOR", ),
16
+ }}
17
+
18
+ RETURN_TYPES = ("DETAILER_PIPE", )
19
+ RETURN_NAMES = ("detailer_pipe", )
20
+ FUNCTION = "doit"
21
+
22
+ CATEGORY = "ImpactPack/Pipe"
23
+
24
+ def doit(self, model, clip, vae, positive, negative, bbox_detector, wildcard, sam_model_opt=None, segm_detector_opt=None):
25
+ pipe = (model, clip, vae, positive, negative, wildcard, bbox_detector, segm_detector_opt, sam_model_opt)
26
+ return (pipe, )
27
+
28
+
29
+ class FromDetailerPipe:
30
+ @classmethod
31
+ def INPUT_TYPES(s):
32
+ return {"required": {"detailer_pipe": ("DETAILER_PIPE",), }, }
33
+
34
+ RETURN_TYPES = ("MODEL", "CLIP", "VAE", "CONDITIONING", "CONDITIONING", "BBOX_DETECTOR", "SAM_MODEL", "SEGM_DETECTOR")
35
+ RETURN_NAMES = ("model", "clip", "vae", "positive", "negative", "bbox_detector", "sam_model_opt", "segm_detector_opt")
36
+ FUNCTION = "doit"
37
+
38
+ CATEGORY = "ImpactPack/Pipe"
39
+
40
+ def doit(self, detailer_pipe):
41
+ model, clip, vae, positive, negative, wildcard, bbox_detector, segm_detector_opt, sam_model_opt = detailer_pipe
42
+ return model, clip, vae, positive, negative, bbox_detector, sam_model_opt, segm_detector_opt
43
+
44
+
45
+ class FromDetailerPipe_v2:
46
+ @classmethod
47
+ def INPUT_TYPES(s):
48
+ return {"required": {"detailer_pipe": ("DETAILER_PIPE",), }, }
49
+
50
+ RETURN_TYPES = ("DETAILER_PIPE", "MODEL", "CLIP", "VAE", "CONDITIONING", "CONDITIONING", "BBOX_DETECTOR", "SAM_MODEL", "SEGM_DETECTOR")
51
+ RETURN_NAMES = ("detailer_pipe", "model", "clip", "vae", "positive", "negative", "bbox_detector", "sam_model_opt", "segm_detector_opt")
52
+ FUNCTION = "doit"
53
+
54
+ CATEGORY = "ImpactPack/Pipe"
55
+
56
+ def doit(self, detailer_pipe):
57
+ model, clip, vae, positive, negative, wildcard, bbox_detector, segm_detector_opt, sam_model_opt = detailer_pipe
58
+ return detailer_pipe, model, clip, vae, positive, negative, bbox_detector, sam_model_opt, segm_detector_opt
59
+
60
+
61
+ class ToBasicPipe:
62
+ @classmethod
63
+ def INPUT_TYPES(s):
64
+ return {"required": {
65
+ "model": ("MODEL",),
66
+ "clip": ("CLIP",),
67
+ "vae": ("VAE",),
68
+ "positive": ("CONDITIONING",),
69
+ "negative": ("CONDITIONING",),
70
+ },
71
+ }
72
+
73
+ RETURN_TYPES = ("BASIC_PIPE", )
74
+ RETURN_NAMES = ("basic_pipe", )
75
+ FUNCTION = "doit"
76
+
77
+ CATEGORY = "ImpactPack/Pipe"
78
+
79
+ def doit(self, model, clip, vae, positive, negative):
80
+ pipe = (model, clip, vae, positive, negative)
81
+ return (pipe, )
82
+
83
+
84
+ class FromBasicPipe:
85
+ @classmethod
86
+ def INPUT_TYPES(s):
87
+ return {"required": {"basic_pipe": ("BASIC_PIPE",), }, }
88
+
89
+ RETURN_TYPES = ("MODEL", "CLIP", "VAE", "CONDITIONING", "CONDITIONING")
90
+ RETURN_NAMES = ("model", "clip", "vae", "positive", "negative")
91
+ FUNCTION = "doit"
92
+
93
+ CATEGORY = "ImpactPack/Pipe"
94
+
95
+ def doit(self, basic_pipe):
96
+ model, clip, vae, positive, negative = basic_pipe
97
+ return model, clip, vae, positive, negative
98
+
99
+
100
+ class FromBasicPipe_v2:
101
+ @classmethod
102
+ def INPUT_TYPES(s):
103
+ return {"required": {"basic_pipe": ("BASIC_PIPE",), }, }
104
+
105
+ RETURN_TYPES = ("BASIC_PIPE", "MODEL", "CLIP", "VAE", "CONDITIONING", "CONDITIONING")
106
+ RETURN_NAMES = ("basic_pipe", "model", "clip", "vae", "positive", "negative")
107
+ FUNCTION = "doit"
108
+
109
+ CATEGORY = "ImpactPack/Pipe"
110
+
111
+ def doit(self, basic_pipe):
112
+ model, clip, vae, positive, negative = basic_pipe
113
+ return basic_pipe, model, clip, vae, positive, negative
114
+
115
+
116
+ class BasicPipeToDetailerPipe:
117
+ @classmethod
118
+ def INPUT_TYPES(s):
119
+ return {"required": {"basic_pipe": ("BASIC_PIPE",),
120
+ "bbox_detector": ("BBOX_DETECTOR", ),
121
+ "wildcard": ("STRING", {"multiline": True}),
122
+ },
123
+ "optional": {
124
+ "sam_model_opt": ("SAM_MODEL", ),
125
+ "segm_detector_opt": ("SEGM_DETECTOR",),
126
+ },
127
+ }
128
+
129
+ RETURN_TYPES = ("DETAILER_PIPE", )
130
+ RETURN_NAMES = ("detailer_pipe", )
131
+ FUNCTION = "doit"
132
+
133
+ CATEGORY = "ImpactPack/Pipe"
134
+
135
+ def doit(self, basic_pipe, bbox_detector, wildcard, sam_model_opt=None, segm_detector_opt=None):
136
+ model, clip, vae, positive, negative = basic_pipe
137
+ pipe = model, clip, vae, positive, negative, wildcard, bbox_detector, segm_detector_opt, sam_model_opt
138
+ return (pipe, )
139
+
140
+
141
+ class DetailerPipeToBasicPipe:
142
+ @classmethod
143
+ def INPUT_TYPES(s):
144
+ return {"required": {"detailer_pipe": ("DETAILER_PIPE",), }}
145
+
146
+ RETURN_TYPES = ("BASIC_PIPE", )
147
+ RETURN_NAMES = ("basic_pipe", )
148
+ FUNCTION = "doit"
149
+
150
+ CATEGORY = "ImpactPack/Pipe"
151
+
152
+ def doit(self, detailer_pipe):
153
+ model, clip, vae, positive, negative, _, _, _, _ = detailer_pipe
154
+ pipe = model, clip, vae, positive, negative
155
+ return (pipe, )
156
+
157
+
158
+ class EditBasicPipe:
159
+ @classmethod
160
+ def INPUT_TYPES(s):
161
+ return {
162
+ "required": {"basic_pipe": ("BASIC_PIPE",), },
163
+ "optional": {
164
+ "model": ("MODEL",),
165
+ "clip": ("CLIP",),
166
+ "vae": ("VAE",),
167
+ "positive": ("CONDITIONING",),
168
+ "negative": ("CONDITIONING",),
169
+ },
170
+ }
171
+
172
+ RETURN_TYPES = ("BASIC_PIPE", )
173
+ RETURN_NAMES = ("basic_pipe", )
174
+ FUNCTION = "doit"
175
+
176
+ CATEGORY = "ImpactPack/Pipe"
177
+
178
+ def doit(self, basic_pipe, model=None, clip=None, vae=None, positive=None, negative=None):
179
+ res_model, res_clip, res_vae, res_positive, res_negative = basic_pipe
180
+
181
+ if model is not None:
182
+ res_model = model
183
+
184
+ if clip is not None:
185
+ res_clip = clip
186
+
187
+ if vae is not None:
188
+ res_vae = vae
189
+
190
+ if positive is not None:
191
+ res_positive = positive
192
+
193
+ if negative is not None:
194
+ res_negative = negative
195
+
196
+ pipe = res_model, res_clip, res_vae, res_positive, res_negative
197
+
198
+ return (pipe, )
199
+
200
+
201
+ class EditDetailerPipe:
202
+ @classmethod
203
+ def INPUT_TYPES(s):
204
+ return {
205
+ "required": {
206
+ "detailer_pipe": ("DETAILER_PIPE",),
207
+ "wildcard": ("STRING", {"multiline": True}),
208
+ },
209
+ "optional": {
210
+ "model": ("MODEL",),
211
+ "clip": ("CLIP",),
212
+ "vae": ("VAE",),
213
+ "positive": ("CONDITIONING",),
214
+ "negative": ("CONDITIONING",),
215
+ "bbox_detector": ("BBOX_DETECTOR",),
216
+ "sam_model": ("SAM_MODEL",),
217
+ "segm_detector_opt": ("SEGM_DETECTOR",),
218
+ },
219
+ }
220
+
221
+ RETURN_TYPES = ("DETAILER_PIPE",)
222
+ RETURN_NAMES = ("detailer_pipe",)
223
+ FUNCTION = "doit"
224
+
225
+ CATEGORY = "ImpactPack/Pipe"
226
+
227
+ def doit(self, detailer_pipe, wildcard, model=None, clip=None, vae=None, positive=None, negative=None,
228
+ bbox_detector=None, sam_model=None, segm_detector=None):
229
+ res_model, res_clip, res_vae, res_positive, res_negative, res_wildcard, res_bbox_detector, res_segm_detector, res_sam_model = detailer_pipe
230
+
231
+ if model is not None:
232
+ res_model = model
233
+
234
+ if clip is not None:
235
+ res_clip = clip
236
+
237
+ if vae is not None:
238
+ res_vae = vae
239
+
240
+ if positive is not None:
241
+ res_positive = positive
242
+
243
+ if negative is not None:
244
+ res_negative = negative
245
+
246
+ if bbox_detector is not None:
247
+ res_bbox_detector = bbox_detector
248
+
249
+ if segm_detector is not None:
250
+ res_segm_detector = segm_detector
251
+
252
+ if wildcard != "":
253
+ res_wildcard = wildcard
254
+
255
+ if sam_model is not None:
256
+ res_sam_model = sam_model
257
+
258
+ pipe = res_model, res_clip, res_vae, res_positive, res_negative, res_wildcard, res_bbox_detector, res_segm_detector, res_sam_model
259
+
260
+ return (pipe, )
ComfyUI-Impact-Pack/modules/impact/utils.py ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import cv2
3
+ import numpy as np
4
+ from PIL import Image, ImageDraw, ImageFilter
5
+
6
+ LANCZOS = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.LANCZOS)
7
+
8
+
9
+ def pil2tensor(image):
10
+ return torch.from_numpy(np.array(image).astype(np.float32) / 255.0).unsqueeze(0)
11
+
12
+
13
+ def tensor2pil(image):
14
+ return Image.fromarray(np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))
15
+
16
+
17
+ def center_of_bbox(bbox):
18
+ w, h = bbox[2] - bbox[0], bbox[3] - bbox[1]
19
+ return bbox[0] + w/2, bbox[1] + h/2
20
+
21
+
22
+ def combine_masks(masks):
23
+ if len(masks) == 0:
24
+ return None
25
+ else:
26
+ initial_cv2_mask = np.array(masks[0][1])
27
+ combined_cv2_mask = initial_cv2_mask
28
+
29
+ for i in range(1, len(masks)):
30
+ cv2_mask = np.array(masks[i][1])
31
+
32
+ if combined_cv2_mask.shape == cv2_mask.shape:
33
+ combined_cv2_mask = cv2.bitwise_or(combined_cv2_mask, cv2_mask)
34
+ else:
35
+ # do nothing - incompatible mask
36
+ pass
37
+
38
+ mask = torch.from_numpy(combined_cv2_mask)
39
+ return mask
40
+
41
+
42
+ def combine_masks2(masks):
43
+ if len(masks) == 0:
44
+ return None
45
+ else:
46
+ initial_cv2_mask = np.array(masks[0]).astype(np.uint8)
47
+ combined_cv2_mask = initial_cv2_mask
48
+
49
+ for i in range(1, len(masks)):
50
+ cv2_mask = np.array(masks[i]).astype(np.uint8)
51
+
52
+ if combined_cv2_mask.shape == cv2_mask.shape:
53
+ combined_cv2_mask = cv2.bitwise_or(combined_cv2_mask, cv2_mask)
54
+ else:
55
+ # do nothing - incompatible mask
56
+ pass
57
+
58
+ mask = torch.from_numpy(combined_cv2_mask)
59
+ return mask
60
+
61
+
62
+ def bitwise_and_masks(mask1, mask2):
63
+ mask1 = mask1.cpu()
64
+ mask2 = mask2.cpu()
65
+ cv2_mask1 = np.array(mask1)
66
+ cv2_mask2 = np.array(mask2)
67
+
68
+ if cv2_mask1.shape == cv2_mask2.shape:
69
+ cv2_mask = cv2.bitwise_and(cv2_mask1, cv2_mask2)
70
+ return torch.from_numpy(cv2_mask)
71
+ else:
72
+ # do nothing - incompatible mask shape: mostly empty mask
73
+ return mask1
74
+
75
+
76
+ def to_binary_mask(mask, threshold=0):
77
+ mask = mask.clone().cpu()
78
+ mask[mask > threshold] = 1.
79
+ mask[mask <= threshold] = 0.
80
+ return mask
81
+
82
+
83
+ def dilate_mask(mask, dilation_factor, iter=1):
84
+ if dilation_factor == 0:
85
+ return mask
86
+
87
+ kernel = np.ones((dilation_factor,dilation_factor), np.uint8)
88
+ return cv2.dilate(mask, kernel, iter)
89
+
90
+
91
+ def dilate_masks(segmasks, dilation_factor, iter=1):
92
+ if dilation_factor == 0:
93
+ return segmasks
94
+
95
+ dilated_masks = []
96
+ kernel = np.ones((dilation_factor,dilation_factor), np.uint8)
97
+ for i in range(len(segmasks)):
98
+ cv2_mask = segmasks[i][1]
99
+ dilated_mask = cv2.dilate(cv2_mask, kernel, iter)
100
+ item = (segmasks[i][0], dilated_mask, segmasks[i][2])
101
+ dilated_masks.append(item)
102
+ return dilated_masks
103
+
104
+
105
+ def feather_mask(mask, thickness):
106
+ pil_mask = Image.fromarray(np.uint8(mask * 255))
107
+
108
+ # Create a feathered mask by applying a Gaussian blur to the mask
109
+ blurred_mask = pil_mask.filter(ImageFilter.GaussianBlur(thickness))
110
+ feathered_mask = Image.new("L", pil_mask.size, 0)
111
+ feathered_mask.paste(blurred_mask, (0, 0), blurred_mask)
112
+ return feathered_mask
113
+
114
+
115
+ def subtract_masks(mask1, mask2):
116
+ mask1 = mask1.cpu()
117
+ mask2 = mask2.cpu()
118
+ cv2_mask1 = np.array(mask1) * 255
119
+ cv2_mask2 = np.array(mask2) * 255
120
+
121
+ if cv2_mask1.shape == cv2_mask2.shape:
122
+ cv2_mask = cv2.subtract(cv2_mask1, cv2_mask2)
123
+ return torch.from_numpy(cv2_mask) / 255.0
124
+ else:
125
+ # do nothing - incompatible mask shape: mostly empty mask
126
+ return mask1
127
+
128
+
129
+ def add_masks(mask1, mask2):
130
+ mask1 = mask1.cpu()
131
+ mask2 = mask2.cpu()
132
+ cv2_mask1 = np.array(mask1) * 255
133
+ cv2_mask2 = np.array(mask2) * 255
134
+
135
+ if cv2_mask1.shape == cv2_mask2.shape:
136
+ cv2_mask = cv2.add(cv2_mask1, cv2_mask2)
137
+ return torch.from_numpy(cv2_mask) / 255.0
138
+ else:
139
+ # do nothing - incompatible mask shape: mostly empty mask
140
+ return mask1
141
+
142
+
143
+ def normalize_region(limit, startp, size):
144
+ if startp < 0:
145
+ new_endp = min(limit, size)
146
+ new_startp = 0
147
+ elif startp + size > limit:
148
+ new_startp = max(0, limit - size)
149
+ new_endp = limit
150
+ else:
151
+ new_startp = startp
152
+ new_endp = min(limit, startp+size)
153
+
154
+ return int(new_startp), int(new_endp)
155
+
156
+
157
+ def make_crop_region(w, h, bbox, crop_factor):
158
+ x1 = bbox[0]
159
+ y1 = bbox[1]
160
+ x2 = bbox[2]
161
+ y2 = bbox[3]
162
+
163
+ bbox_w = x2 - x1
164
+ bbox_h = y2 - y1
165
+
166
+ crop_w = bbox_w * crop_factor
167
+ crop_h = bbox_h * crop_factor
168
+
169
+ kernel_x = x1 + bbox_w / 2
170
+ kernel_y = y1 + bbox_h / 2
171
+
172
+ new_x1 = int(kernel_x - crop_w / 2)
173
+ new_y1 = int(kernel_y - crop_h / 2)
174
+
175
+ # make sure position in (w,h)
176
+ new_x1, new_x2 = normalize_region(w, new_x1, crop_w)
177
+ new_y1, new_y2 = normalize_region(h, new_y1, crop_h)
178
+
179
+ return [new_x1, new_y1, new_x2, new_y2]
180
+
181
+
182
+ def crop_ndarray4(npimg, crop_region):
183
+ x1 = crop_region[0]
184
+ y1 = crop_region[1]
185
+ x2 = crop_region[2]
186
+ y2 = crop_region[3]
187
+
188
+ cropped = npimg[:, y1:y2, x1:x2, :]
189
+
190
+ return cropped
191
+
192
+
193
+ def crop_ndarray2(npimg, crop_region):
194
+ x1 = crop_region[0]
195
+ y1 = crop_region[1]
196
+ x2 = crop_region[2]
197
+ y2 = crop_region[3]
198
+
199
+ cropped = npimg[y1:y2, x1:x2]
200
+
201
+ return cropped
202
+
203
+
204
+ def crop_image(image, crop_region):
205
+ return crop_ndarray4(np.array(image), crop_region)
206
+
207
+
208
+ def to_latent_image(pixels, vae):
209
+ x = pixels.shape[1]
210
+ y = pixels.shape[2]
211
+ if pixels.shape[1] != x or pixels.shape[2] != y:
212
+ pixels = pixels[:, :x, :y, :]
213
+ t = vae.encode(pixels[:, :, :, :3])
214
+ return {"samples": t}
215
+
216
+
217
+ def scale_tensor(w, h, image):
218
+ image = tensor2pil(image)
219
+ scaled_image = image.resize((w, h), resample=LANCZOS)
220
+ return pil2tensor(scaled_image)
221
+
222
+
223
+ def scale_tensor_and_to_pil(w, h, image):
224
+ image = tensor2pil(image)
225
+ return image.resize((w, h), resample=LANCZOS)
226
+
227
+
228
+ def empty_pil_tensor(w=64, h=64):
229
+ image = Image.new("RGB", (w, h))
230
+ draw = ImageDraw.Draw(image)
231
+ draw.rectangle((0, 0, w-1, h-1), fill=(0, 0, 0))
232
+ return pil2tensor(image)
233
+
234
+
235
+ class NonListIterable:
236
+ def __init__(self, data):
237
+ self.data = data
238
+
239
+ def __getitem__(self, index):
240
+ return self.data[index]
ComfyUI-Impact-Pack/modules/impact/wildcards.py ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ import random
3
+ import os
4
+ import nodes
5
+ import folder_paths
6
+
7
+ wildcard_dict = {}
8
+
9
+
10
+ def read_wildcard_dict(wildcard_path):
11
+ global wildcard_dict
12
+ for root, directories, files in os.walk(wildcard_path):
13
+ for file in files:
14
+ if file.endswith('.txt'):
15
+ file_path = os.path.join(root, file)
16
+ rel_path = os.path.relpath(file_path, wildcard_path)
17
+ key = os.path.splitext(rel_path)[0].replace('\\', '/')
18
+
19
+ with open(file_path, 'r', encoding="UTF-8") as f:
20
+ lines = f.read().splitlines()
21
+ wildcard_dict[key] = lines
22
+
23
+ return wildcard_dict
24
+
25
+
26
+ def process(text):
27
+ def replace_options(string):
28
+ replacements_found = False
29
+
30
+ def replace_option(match):
31
+ nonlocal replacements_found
32
+ options = match.group(1).split('|')
33
+ replacement = random.choice(options)
34
+ replacements_found = True
35
+ return replacement
36
+
37
+ pattern = r'{([^{}]*?)}'
38
+ replaced_string = re.sub(pattern, replace_option, string)
39
+
40
+ pattern = r'\[([^[\]]*?)\]'
41
+ replaced_string = re.sub(pattern, replace_option, replaced_string)
42
+
43
+ return replaced_string, replacements_found
44
+
45
+ def replace_wildcard(string):
46
+ global wildcard_dict
47
+ pattern = r"__([\w.-/]+)__"
48
+ matches = re.findall(pattern, string)
49
+
50
+ replacements_found = False
51
+
52
+ for match in matches:
53
+ if match in wildcard_dict:
54
+ replacement = random.choice(wildcard_dict[match])
55
+ replacements_found = True
56
+ string = string.replace(f"__{match}__", replacement, 1)
57
+
58
+ return string, replacements_found
59
+
60
+ replace_depth = 100
61
+ stop_unwrap = False
62
+ while not stop_unwrap and replace_depth > 1:
63
+ replace_depth -= 1 # prevent infinite loop
64
+
65
+ # pass1: replace options
66
+ pass1, is_replaced1 = replace_options(text)
67
+
68
+ while is_replaced1:
69
+ pass1, is_replaced1 = replace_options(pass1)
70
+
71
+ # pass2: replace wildcards
72
+ text, is_replaced2 = replace_wildcard(pass1)
73
+ stop_unwrap = not is_replaced1 and not is_replaced2
74
+
75
+ return text
76
+
77
+
78
+ def safe_float(x):
79
+ try:
80
+ return float(x)
81
+ except:
82
+ return 1.0
83
+
84
+
85
+ def extract_lora_values(string):
86
+ pattern = r'<lora:([^>]+)>'
87
+ matches = re.findall(pattern, string)
88
+ items = [match.strip(':') for match in matches]
89
+
90
+ result = {}
91
+ for item in items:
92
+ item = item.split(':')
93
+
94
+ lora = None
95
+ a = 1.0
96
+ b = 1.0
97
+ if len(item) == 1:
98
+ lora = item[0]
99
+ elif len(item) == 2:
100
+ lora = item[0]
101
+ a = safe_float(item[1])
102
+ elif len(item) >= 3:
103
+ lora = item[0]
104
+ if item[1] != '':
105
+ a = safe_float(item[1])
106
+ b = safe_float(item[2])
107
+
108
+ if lora is not None:
109
+ result[lora] = a, b
110
+
111
+ return result
112
+
113
+
114
+ def remove_lora_tags(string):
115
+ pattern = r'<lora:[^>]+>'
116
+ result = re.sub(pattern, '', string)
117
+
118
+ return result
119
+
120
+
121
+ def process_with_loras(wildcard_opt, model, clip):
122
+ pass1 = process(wildcard_opt)
123
+ loras = extract_lora_values(pass1)
124
+ pass2 = remove_lora_tags(pass1)
125
+
126
+ for lora_name, (model_weight, clip_weight) in loras.items():
127
+ if (lora_name.split('.')[-1]) not in folder_paths.supported_pt_extensions:
128
+ lora_name = lora_name+".safetensors"
129
+
130
+ path = folder_paths.get_full_path("loras", lora_name)
131
+
132
+ if path is not None:
133
+ print(f"LOAD LORA: {lora_name}: {model_weight}, {clip_weight}")
134
+ model, clip = nodes.LoraLoader().load_lora(model, clip, lora_name, model_weight, clip_weight)
135
+ else:
136
+ print(f"LORA NOT FOUND: {lora_name}")
137
+
138
+ print(f"CLIP: {pass2}")
139
+ return model, nodes.CLIPTextEncode().encode(clip, pass2)[0]
140
+
ComfyUI-Impact-Pack/notebook/comfyui_colab_impact_pack.ipynb ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "attachments": {},
5
+ "cell_type": "markdown",
6
+ "metadata": {
7
+ "id": "aaaaaaaaaa"
8
+ },
9
+ "source": [
10
+ "Git clone the repo and install the requirements. (ignore the pip errors about protobuf)"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": null,
16
+ "metadata": {
17
+ "id": "bbbbbbbbbb"
18
+ },
19
+ "outputs": [],
20
+ "source": [
21
+ "#@title Environment Setup\n",
22
+ "\n",
23
+ "from pathlib import Path\n",
24
+ "\n",
25
+ "OPTIONS = {}\n",
26
+ "\n",
27
+ "WORKSPACE = 'ComfyUI'\n",
28
+ "USE_GOOGLE_DRIVE = True #@param {type:\"boolean\"}\n",
29
+ "UPDATE_COMFY_UI = True #@param {type:\"boolean\"}\n",
30
+ "\n",
31
+ "OPTIONS['USE_GOOGLE_DRIVE'] = USE_GOOGLE_DRIVE\n",
32
+ "OPTIONS['UPDATE_COMFY_UI'] = UPDATE_COMFY_UI\n",
33
+ "\n",
34
+ "if OPTIONS['USE_GOOGLE_DRIVE']:\n",
35
+ " !echo \"Mounting Google Drive...\"\n",
36
+ " %cd /\n",
37
+ " \n",
38
+ " from google.colab import drive\n",
39
+ " drive.mount('/content/drive')\n",
40
+ "\n",
41
+ " WORKSPACE = \"/content/drive/MyDrive/ComfyUI\"\n",
42
+ " \n",
43
+ " %cd /content/drive/MyDrive\n",
44
+ "\n",
45
+ "![ ! -d $WORKSPACE ] && echo \"-= Initial setup ComfyUI (Original)=-\" && git clone https://github.com/comfyanonymous/ComfyUI\n",
46
+ "%cd $WORKSPACE\n",
47
+ "\n",
48
+ "if OPTIONS['UPDATE_COMFY_UI']:\n",
49
+ " !echo \"-= Updating ComfyUI =-\"\n",
50
+ " !git pull\n",
51
+ " !rm \"/content/drive/MyDrive/ComfyUI/custom_nodes/comfyui-impact-pack.py\"\n",
52
+ "\n",
53
+ "%cd custom_nodes\n",
54
+ "!git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack\n",
55
+ "%cd $WORKSPACE\n",
56
+ "\n",
57
+ "!echo -= Install dependencies =-\n",
58
+ "!pip -q install xformers -r requirements.txt\n"
59
+ ]
60
+ },
61
+ {
62
+ "attachments": {},
63
+ "cell_type": "markdown",
64
+ "metadata": {
65
+ "id": "kkkkkkkkkkkkkk"
66
+ },
67
+ "source": [
68
+ "### Run ComfyUI with localtunnel (Recommended Way)\n",
69
+ "\n",
70
+ "\n"
71
+ ]
72
+ },
73
+ {
74
+ "cell_type": "code",
75
+ "execution_count": null,
76
+ "metadata": {
77
+ "colab": {
78
+ "base_uri": "https://localhost:8080/"
79
+ },
80
+ "id": "jjjjjjjjjjjjj",
81
+ "outputId": "83be9411-d939-4813-e6c1-80e75bf8e80d"
82
+ },
83
+ "outputs": [],
84
+ "source": [
85
+ "!npm install -g localtunnel\n",
86
+ "\n",
87
+ "import subprocess\n",
88
+ "import threading\n",
89
+ "import time\n",
90
+ "import socket\n",
91
+ "def iframe_thread(port):\n",
92
+ " while True:\n",
93
+ " time.sleep(0.5)\n",
94
+ " sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
95
+ " result = sock.connect_ex(('127.0.0.1', port))\n",
96
+ " if result == 0:\n",
97
+ " break\n",
98
+ " sock.close()\n",
99
+ " print(\"\\nComfyUI finished loading, trying to launch localtunnel (if it gets stuck here localtunnel is having issues)\")\n",
100
+ " p = subprocess.Popen([\"lt\", \"--port\", \"{}\".format(port)], stdout=subprocess.PIPE)\n",
101
+ " for line in p.stdout:\n",
102
+ " print(line.decode(), end='')\n",
103
+ "\n",
104
+ "\n",
105
+ "threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
106
+ "\n",
107
+ "!python main.py --dont-print-server"
108
+ ]
109
+ },
110
+ {
111
+ "attachments": {},
112
+ "cell_type": "markdown",
113
+ "metadata": {
114
+ "id": "gggggggggg"
115
+ },
116
+ "source": [
117
+ "### Run ComfyUI with colab iframe (use only in case the previous way with localtunnel doesn't work)\n",
118
+ "\n",
119
+ "You should see the ui appear in an iframe. If you get a 403 error, it's your firefox settings or an extension that's messing things up.\n",
120
+ "\n",
121
+ "If you want to open it in another window use the link.\n",
122
+ "\n",
123
+ "Note that some UI features like live image previews won't work because the colab iframe blocks websockets."
124
+ ]
125
+ },
126
+ {
127
+ "cell_type": "code",
128
+ "execution_count": null,
129
+ "metadata": {
130
+ "id": "hhhhhhhhhh"
131
+ },
132
+ "outputs": [],
133
+ "source": [
134
+ "import threading\n",
135
+ "import time\n",
136
+ "import socket\n",
137
+ "def iframe_thread(port):\n",
138
+ " while True:\n",
139
+ " time.sleep(0.5)\n",
140
+ " sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
141
+ " result = sock.connect_ex(('127.0.0.1', port))\n",
142
+ " if result == 0:\n",
143
+ " break\n",
144
+ " sock.close()\n",
145
+ " from google.colab import output\n",
146
+ " output.serve_kernel_port_as_iframe(port, height=1024)\n",
147
+ " print(\"to open it in a window you can open this link here:\")\n",
148
+ " output.serve_kernel_port_as_window(port)\n",
149
+ "\n",
150
+ "threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
151
+ "\n",
152
+ "!python main.py --dont-print-server"
153
+ ]
154
+ }
155
+ ],
156
+ "metadata": {
157
+ "accelerator": "GPU",
158
+ "colab": {
159
+ "provenance": []
160
+ },
161
+ "gpuClass": "standard",
162
+ "kernelspec": {
163
+ "display_name": "Python 3",
164
+ "name": "python3"
165
+ },
166
+ "language_info": {
167
+ "name": "python"
168
+ }
169
+ },
170
+ "nbformat": 4,
171
+ "nbformat_minor": 0
172
+ }
ComfyUI-Impact-Pack/requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ segment-anything
2
+ scikit-image
3
+ piexif
ComfyUI-Impact-Pack/subpack/.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ __pycache__
2
+ *.ini
3
+ wildcards/**
4
+ .vscode/
5
+ .idea/
ComfyUI-Impact-Pack/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/>.
ComfyUI-Impact-Pack/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 repo sitoryprovides 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.
ComfyUI-Impact-Pack/subpack/impact/subcore.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from ultralytics import YOLO
11
+
12
+ def load_yolo(model_path: str):
13
+ try:
14
+ return YOLO(model_path)
15
+ except ModuleNotFoundError:
16
+ # https://github.com/ultralytics/ultralytics/issues/3856
17
+ YOLO("yolov8n.pt")
18
+ return YOLO(model_path)
19
+
20
+
21
+ def inference_bbox(
22
+ model,
23
+ image: Image.Image,
24
+ confidence: float = 0.3,
25
+ device: str = "",
26
+ ):
27
+ pred = model(image, conf=confidence, device=device)
28
+
29
+ bboxes = pred[0].boxes.xyxy.cpu().numpy()
30
+ cv2_image = np.array(image)
31
+ cv2_image = cv2_image[:, :, ::-1].copy()
32
+ cv2_gray = cv2.cvtColor(cv2_image, cv2.COLOR_BGR2GRAY)
33
+
34
+ segms = []
35
+ for x0, y0, x1, y1 in bboxes:
36
+ cv2_mask = np.zeros(cv2_gray.shape, np.uint8)
37
+ cv2.rectangle(cv2_mask, (int(x0), int(y0)), (int(x1), int(y1)), 255, -1)
38
+ cv2_mask_bool = cv2_mask.astype(bool)
39
+ segms.append(cv2_mask_bool)
40
+
41
+ n, m = bboxes.shape
42
+ if n == 0:
43
+ return [[], [], [], []]
44
+
45
+ results = [[], [], [], []]
46
+ for i in range(len(bboxes)):
47
+ results[0].append(pred[0].names[int(pred[0].boxes[i].cls.item())])
48
+ results[1].append(bboxes[i])
49
+ results[2].append(segms[i])
50
+ results[3].append(pred[0].boxes[i].conf.cpu().numpy())
51
+
52
+ return results
53
+
54
+
55
+ def inference_segm(
56
+ model,
57
+ image: Image.Image,
58
+ confidence: float = 0.3,
59
+ device: str = "",
60
+ ):
61
+ pred = model(image, conf=confidence, device=device)
62
+ bboxes = pred[0].boxes.xyxy.cpu().numpy()
63
+ segms = pred[0].masks.data.cpu().numpy()
64
+
65
+ n, m = bboxes.shape
66
+ if n == 0:
67
+ return [[], [], [], []]
68
+
69
+ results = [[], [], [], []]
70
+ for i in range(len(bboxes)):
71
+ results[0].append(pred[0].names[int(pred[0].boxes[i].cls.item())])
72
+ results[1].append(bboxes[i])
73
+
74
+ mask = torch.from_numpy(segms[i])
75
+ scaled_mask = torch.nn.functional.interpolate(mask.unsqueeze(0).unsqueeze(0), size=(image.size[1], image.size[0]),
76
+ mode='bilinear', align_corners=False)
77
+ scaled_mask = scaled_mask.squeeze().squeeze()
78
+
79
+ results[2].append(scaled_mask.numpy())
80
+ results[3].append(pred[0].boxes[i].conf.cpu().numpy())
81
+
82
+ return results
83
+
84
+
85
+ class UltraBBoxDetector:
86
+ bbox_model = None
87
+
88
+ def __init__(self, bbox_model):
89
+ self.bbox_model = bbox_model
90
+
91
+ def detect(self, image, threshold, dilation, crop_factor, drop_size=1):
92
+ drop_size = max(drop_size, 1)
93
+ detected_results = inference_bbox(self.bbox_model, core.tensor2pil(image), threshold)
94
+ segmasks = core.create_segmasks(detected_results)
95
+
96
+ if dilation > 0:
97
+ segmasks = core.dilate_masks(segmasks, dilation)
98
+
99
+ items = []
100
+ h = image.shape[1]
101
+ w = image.shape[2]
102
+
103
+ for x, label in zip(segmasks, detected_results[0]):
104
+ item_bbox = x[0]
105
+ item_mask = x[1]
106
+
107
+ y1, x1, y2, x2 = item_bbox
108
+
109
+ if x2 - x1 > drop_size and y2 - y1 > drop_size: # minimum dimension must be (2,2) to avoid squeeze issue
110
+ crop_region = core.make_crop_region(w, h, item_bbox, crop_factor)
111
+ cropped_image = core.crop_image(image, crop_region)
112
+ cropped_mask = core.crop_ndarray2(item_mask, crop_region)
113
+ confidence = x[2]
114
+ # bbox_size = (item_bbox[2]-item_bbox[0],item_bbox[3]-item_bbox[1]) # (w,h)
115
+
116
+ item = core.SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox, label)
117
+
118
+ items.append(item)
119
+
120
+ shape = image.shape[1], image.shape[2]
121
+ return shape, items
122
+
123
+ def detect_combined(self, image, threshold, dilation):
124
+ detected_results = inference_bbox(self.bbox_model, image, threshold)
125
+ segmasks = core.create_segmasks(detected_results)
126
+ if dilation > 0:
127
+ segmasks = core.dilate_masks(segmasks, dilation)
128
+
129
+ return core.combine_masks(segmasks)
130
+
131
+ def setAux(self, x):
132
+ pass
133
+
134
+
135
+ class UltraSegmDetector:
136
+ bbox_model = None
137
+
138
+ def __init__(self, bbox_model):
139
+ self.bbox_model = bbox_model
140
+
141
+ def detect(self, image, threshold, dilation, crop_factor, drop_size=1):
142
+ drop_size = max(drop_size, 1)
143
+ detected_results = inference_segm(self.bbox_model, core.tensor2pil(image), threshold)
144
+ segmasks = core.create_segmasks(detected_results)
145
+
146
+ if dilation > 0:
147
+ segmasks = core.dilate_masks(segmasks, dilation)
148
+
149
+ items = []
150
+ h = image.shape[1]
151
+ w = image.shape[2]
152
+
153
+ for x, label in zip(segmasks, detected_results[0]):
154
+ item_bbox = x[0]
155
+ item_mask = x[1]
156
+
157
+ y1, x1, y2, x2 = item_bbox
158
+
159
+ if x2 - x1 > drop_size and y2 - y1 > drop_size: # minimum dimension must be (2,2) to avoid squeeze issue
160
+ crop_region = core.make_crop_region(w, h, item_bbox, crop_factor)
161
+ cropped_image = core.crop_image(image, crop_region)
162
+ cropped_mask = core.crop_ndarray2(item_mask, crop_region)
163
+ confidence = x[2]
164
+ # bbox_size = (item_bbox[2]-item_bbox[0],item_bbox[3]-item_bbox[1]) # (w,h)
165
+
166
+ item = core.SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox, label)
167
+
168
+ items.append(item)
169
+
170
+ shape = image.shape[1], image.shape[2]
171
+ return shape, items
172
+
173
+ def detect_combined(self, image, threshold, dilation):
174
+ detected_results = inference_bbox(self.bbox_model, image, threshold)
175
+ segmasks = core.create_segmasks(detected_results)
176
+ if dilation > 0:
177
+ segmasks = core.dilate_masks(segmasks, dilation)
178
+
179
+ return core.combine_masks(segmasks)
180
+
181
+ def setAux(self, x):
182
+ pass
ComfyUI-Impact-Pack/subpack/impact/subpack_nodes.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import folder_paths
3
+ import impact.core as core
4
+ import impact.subcore as subcore
5
+
6
+ print(f"### Loading: ComfyUI-Impact-Pack (Subpack: V0.2)")
7
+
8
+ model_path = folder_paths.models_dir
9
+ folder_paths.folder_names_and_paths["ultralytics_bbox"] = ([os.path.join(model_path, "ultralytics", "bbox")], folder_paths.supported_pt_extensions)
10
+ folder_paths.folder_names_and_paths["ultralytics_segm"] = ([os.path.join(model_path, "ultralytics", "segm")], folder_paths.supported_pt_extensions)
11
+ folder_paths.folder_names_and_paths["ultralytics"] = ([os.path.join(model_path, "ultralytics")], folder_paths.supported_pt_extensions)
12
+
13
+
14
+ class UltralyticsDetectorProvider:
15
+ @classmethod
16
+ def INPUT_TYPES(s):
17
+ bboxs = ["bbox/"+x for x in folder_paths.get_filename_list("ultralytics_bbox")]
18
+ segms = ["segm/"+x for x in folder_paths.get_filename_list("ultralytics_segm")]
19
+ return {"required": {"model_name": (bboxs + segms, )}}
20
+ RETURN_TYPES = ("BBOX_DETECTOR", "SEGM_DETECTOR")
21
+ FUNCTION = "doit"
22
+
23
+ CATEGORY = "ImpactPack"
24
+
25
+ def doit(self, model_name):
26
+ model_path = folder_paths.get_full_path("ultralytics", model_name)
27
+ model = subcore.load_yolo(model_path)
28
+
29
+ if model_name.startswith("bbox"):
30
+ return subcore.UltraBBoxDetector(model), core.NO_SEGM_DETECTOR()
31
+ else:
32
+ return subcore.UltraBBoxDetector(model), subcore.UltraSegmDetector(model)
33
+
34
+
35
+ NODE_CLASS_MAPPINGS = {
36
+ "UltralyticsDetectorProvider": UltralyticsDetectorProvider
37
+ }
38
+
39
+
40
+ NODE_DISPLAY_NAME_MAPPINGS = {
41
+
42
+ }
ComfyUI-Impact-Pack/subpack/install.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ comfy_path = os.path.join(subpack_path, '..', '..', '..')
7
+
8
+ sys.path.append(comfy_path)
9
+
10
+ import folder_paths
11
+ model_path = folder_paths.models_dir
12
+ ultralytics_bbox_path = os.path.join(model_path, "ultralytics", "bbox")
13
+ ultralytics_segm_path = os.path.join(model_path, "ultralytics", "segm")
14
+
15
+ if not os.path.exists(ultralytics_bbox_path):
16
+ os.makedirs(ultralytics_bbox_path)
17
+
18
+ if not os.path.exists(ultralytics_segm_path):
19
+ os.makedirs(ultralytics_segm_path)
20
+
21
+ if not os.path.exists(os.path.join(ultralytics_bbox_path, "face_yolov8m.pt")):
22
+ download_url("https://huggingface.co/Bingsu/adetailer/resolve/main/face_yolov8m.pt",
23
+ ultralytics_bbox_path)
24
+
25
+ if not os.path.exists(os.path.join(ultralytics_bbox_path, "hand_yolov8s.pt")):
26
+ download_url("https://huggingface.co/Bingsu/adetailer/resolve/main/hand_yolov8s.pt",
27
+ ultralytics_bbox_path)
28
+
29
+ if not os.path.exists(os.path.join(ultralytics_segm_path, "person_yolov8m-seg.pt")):
30
+ download_url("https://huggingface.co/Bingsu/adetailer/resolve/main/person_yolov8m-seg.pt",
31
+ ultralytics_segm_path)
ComfyUI-Impact-Pack/subpack/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ultralytics
ComfyUI-Impact-Pack/test/advanced-sampler.json ADDED
@@ -0,0 +1,976 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "last_node_id": 27,
3
+ "last_link_id": 46,
4
+ "nodes": [
5
+ {
6
+ "id": 11,
7
+ "type": "EditBasicPipe",
8
+ "pos": [
9
+ 1260,
10
+ 590
11
+ ],
12
+ "size": {
13
+ "0": 267,
14
+ "1": 126
15
+ },
16
+ "flags": {},
17
+ "order": 6,
18
+ "mode": 0,
19
+ "inputs": [
20
+ {
21
+ "name": "basic_pipe",
22
+ "type": "BASIC_PIPE",
23
+ "link": 15
24
+ },
25
+ {
26
+ "name": "model",
27
+ "type": "MODEL",
28
+ "link": null
29
+ },
30
+ {
31
+ "name": "clip",
32
+ "type": "CLIP",
33
+ "link": null
34
+ },
35
+ {
36
+ "name": "vae",
37
+ "type": "VAE",
38
+ "link": null
39
+ },
40
+ {
41
+ "name": "positive",
42
+ "type": "CONDITIONING",
43
+ "link": 17
44
+ },
45
+ {
46
+ "name": "negative",
47
+ "type": "CONDITIONING",
48
+ "link": null
49
+ }
50
+ ],
51
+ "outputs": [
52
+ {
53
+ "name": "basic_pipe",
54
+ "type": "BASIC_PIPE",
55
+ "links": [
56
+ 20
57
+ ],
58
+ "shape": 3,
59
+ "slot_index": 0
60
+ }
61
+ ],
62
+ "properties": {
63
+ "Node name for S&R": "EditBasicPipe"
64
+ }
65
+ },
66
+ {
67
+ "id": 12,
68
+ "type": "CLIPTextEncode",
69
+ "pos": [
70
+ 420,
71
+ 670
72
+ ],
73
+ "size": {
74
+ "0": 422.84503173828125,
75
+ "1": 164.31304931640625
76
+ },
77
+ "flags": {},
78
+ "order": 4,
79
+ "mode": 0,
80
+ "inputs": [
81
+ {
82
+ "name": "clip",
83
+ "type": "CLIP",
84
+ "link": 16
85
+ }
86
+ ],
87
+ "outputs": [
88
+ {
89
+ "name": "CONDITIONING",
90
+ "type": "CONDITIONING",
91
+ "links": [
92
+ 17
93
+ ],
94
+ "slot_index": 0
95
+ }
96
+ ],
97
+ "properties": {
98
+ "Node name for S&R": "CLIPTextEncode"
99
+ },
100
+ "widgets_values": [
101
+ "photorealistic:1.4, best quality:1.4, masterpiece, 1girl is sitting in the cafe terrace, (colorful hair:1.1)"
102
+ ]
103
+ },
104
+ {
105
+ "id": 6,
106
+ "type": "CLIPTextEncode",
107
+ "pos": [
108
+ 415,
109
+ 186
110
+ ],
111
+ "size": {
112
+ "0": 422.84503173828125,
113
+ "1": 164.31304931640625
114
+ },
115
+ "flags": {},
116
+ "order": 2,
117
+ "mode": 0,
118
+ "inputs": [
119
+ {
120
+ "name": "clip",
121
+ "type": "CLIP",
122
+ "link": 3
123
+ }
124
+ ],
125
+ "outputs": [
126
+ {
127
+ "name": "CONDITIONING",
128
+ "type": "CONDITIONING",
129
+ "links": [
130
+ 13
131
+ ],
132
+ "slot_index": 0
133
+ }
134
+ ],
135
+ "properties": {
136
+ "Node name for S&R": "CLIPTextEncode"
137
+ },
138
+ "widgets_values": [
139
+ "photorealistic:1.4, best quality:1.4, masterpiece, 1girl is sitting in the cafe terrace"
140
+ ]
141
+ },
142
+ {
143
+ "id": 7,
144
+ "type": "CLIPTextEncode",
145
+ "pos": [
146
+ 413,
147
+ 389
148
+ ],
149
+ "size": {
150
+ "0": 425.27801513671875,
151
+ "1": 180.6060791015625
152
+ },
153
+ "flags": {},
154
+ "order": 3,
155
+ "mode": 0,
156
+ "inputs": [
157
+ {
158
+ "name": "clip",
159
+ "type": "CLIP",
160
+ "link": 5
161
+ }
162
+ ],
163
+ "outputs": [
164
+ {
165
+ "name": "CONDITIONING",
166
+ "type": "CONDITIONING",
167
+ "links": [
168
+ 14
169
+ ],
170
+ "slot_index": 0
171
+ }
172
+ ],
173
+ "properties": {
174
+ "Node name for S&R": "CLIPTextEncode"
175
+ },
176
+ "widgets_values": [
177
+ "text, watermark, low quality:1.4, worst quality:1.4"
178
+ ]
179
+ },
180
+ {
181
+ "id": 10,
182
+ "type": "ToBasicPipe",
183
+ "pos": [
184
+ 952,
185
+ 189
186
+ ],
187
+ "size": {
188
+ "0": 241.79998779296875,
189
+ "1": 106
190
+ },
191
+ "flags": {},
192
+ "order": 5,
193
+ "mode": 0,
194
+ "inputs": [
195
+ {
196
+ "name": "model",
197
+ "type": "MODEL",
198
+ "link": 10
199
+ },
200
+ {
201
+ "name": "clip",
202
+ "type": "CLIP",
203
+ "link": 11
204
+ },
205
+ {
206
+ "name": "vae",
207
+ "type": "VAE",
208
+ "link": 12
209
+ },
210
+ {
211
+ "name": "positive",
212
+ "type": "CONDITIONING",
213
+ "link": 13
214
+ },
215
+ {
216
+ "name": "negative",
217
+ "type": "CONDITIONING",
218
+ "link": 14
219
+ }
220
+ ],
221
+ "outputs": [
222
+ {
223
+ "name": "basic_pipe",
224
+ "type": "BASIC_PIPE",
225
+ "links": [
226
+ 15,
227
+ 19,
228
+ 33
229
+ ],
230
+ "shape": 3,
231
+ "slot_index": 0
232
+ }
233
+ ],
234
+ "properties": {
235
+ "Node name for S&R": "ToBasicPipe"
236
+ }
237
+ },
238
+ {
239
+ "id": 22,
240
+ "type": "FromBasicPipe",
241
+ "pos": [
242
+ 880,
243
+ 1040
244
+ ],
245
+ "size": {
246
+ "0": 241.79998779296875,
247
+ "1": 106
248
+ },
249
+ "flags": {},
250
+ "order": 8,
251
+ "mode": 0,
252
+ "inputs": [
253
+ {
254
+ "name": "basic_pipe",
255
+ "type": "BASIC_PIPE",
256
+ "link": 33
257
+ }
258
+ ],
259
+ "outputs": [
260
+ {
261
+ "name": "model",
262
+ "type": "MODEL",
263
+ "links": [
264
+ 34
265
+ ],
266
+ "shape": 3,
267
+ "slot_index": 0
268
+ },
269
+ {
270
+ "name": "clip",
271
+ "type": "CLIP",
272
+ "links": null,
273
+ "shape": 3
274
+ },
275
+ {
276
+ "name": "vae",
277
+ "type": "VAE",
278
+ "links": [
279
+ 40
280
+ ],
281
+ "shape": 3,
282
+ "slot_index": 2
283
+ },
284
+ {
285
+ "name": "positive",
286
+ "type": "CONDITIONING",
287
+ "links": [
288
+ 35
289
+ ],
290
+ "shape": 3,
291
+ "slot_index": 3
292
+ },
293
+ {
294
+ "name": "negative",
295
+ "type": "CONDITIONING",
296
+ "links": [
297
+ 36
298
+ ],
299
+ "shape": 3,
300
+ "slot_index": 4
301
+ }
302
+ ],
303
+ "properties": {
304
+ "Node name for S&R": "FromBasicPipe"
305
+ }
306
+ },
307
+ {
308
+ "id": 24,
309
+ "type": "VAEDecode",
310
+ "pos": [
311
+ 1938,
312
+ 935
313
+ ],
314
+ "size": {
315
+ "0": 210,
316
+ "1": 46
317
+ },
318
+ "flags": {},
319
+ "order": 14,
320
+ "mode": 0,
321
+ "inputs": [
322
+ {
323
+ "name": "samples",
324
+ "type": "LATENT",
325
+ "link": 46
326
+ },
327
+ {
328
+ "name": "vae",
329
+ "type": "VAE",
330
+ "link": 40
331
+ }
332
+ ],
333
+ "outputs": [
334
+ {
335
+ "name": "IMAGE",
336
+ "type": "IMAGE",
337
+ "links": [
338
+ 41
339
+ ],
340
+ "shape": 3,
341
+ "slot_index": 0
342
+ }
343
+ ],
344
+ "properties": {
345
+ "Node name for S&R": "VAEDecode"
346
+ }
347
+ },
348
+ {
349
+ "id": 4,
350
+ "type": "CheckpointLoaderSimple",
351
+ "pos": [
352
+ -5,
353
+ 212
354
+ ],
355
+ "size": {
356
+ "0": 315,
357
+ "1": 98
358
+ },
359
+ "flags": {},
360
+ "order": 0,
361
+ "mode": 0,
362
+ "outputs": [
363
+ {
364
+ "name": "MODEL",
365
+ "type": "MODEL",
366
+ "links": [
367
+ 10
368
+ ],
369
+ "slot_index": 0
370
+ },
371
+ {
372
+ "name": "CLIP",
373
+ "type": "CLIP",
374
+ "links": [
375
+ 3,
376
+ 5,
377
+ 11,
378
+ 16
379
+ ],
380
+ "slot_index": 1
381
+ },
382
+ {
383
+ "name": "VAE",
384
+ "type": "VAE",
385
+ "links": [
386
+ 12,
387
+ 31
388
+ ],
389
+ "slot_index": 2
390
+ }
391
+ ],
392
+ "properties": {
393
+ "Node name for S&R": "CheckpointLoaderSimple"
394
+ },
395
+ "widgets_values": [
396
+ "V07_v07.safetensors"
397
+ ]
398
+ },
399
+ {
400
+ "id": 25,
401
+ "type": "PreviewImage",
402
+ "pos": [
403
+ 2175,
404
+ 1079
405
+ ],
406
+ "size": {
407
+ "0": 516,
408
+ "1": 424
409
+ },
410
+ "flags": {},
411
+ "order": 15,
412
+ "mode": 0,
413
+ "inputs": [
414
+ {
415
+ "name": "images",
416
+ "type": "IMAGE",
417
+ "link": 41
418
+ }
419
+ ],
420
+ "properties": {
421
+ "Node name for S&R": "PreviewImage"
422
+ }
423
+ },
424
+ {
425
+ "id": 13,
426
+ "type": "KSamplerAdvancedProvider",
427
+ "pos": [
428
+ 1727,
429
+ 192
430
+ ],
431
+ "size": {
432
+ "0": 355.20001220703125,
433
+ "1": 154
434
+ },
435
+ "flags": {},
436
+ "order": 7,
437
+ "mode": 0,
438
+ "inputs": [
439
+ {
440
+ "name": "basic_pipe",
441
+ "type": "BASIC_PIPE",
442
+ "link": 19
443
+ }
444
+ ],
445
+ "outputs": [
446
+ {
447
+ "name": "KSAMPLER_ADVANCED",
448
+ "type": "KSAMPLER_ADVANCED",
449
+ "links": [
450
+ 42
451
+ ],
452
+ "shape": 3,
453
+ "slot_index": 0
454
+ }
455
+ ],
456
+ "properties": {
457
+ "Node name for S&R": "KSamplerAdvancedProvider"
458
+ },
459
+ "widgets_values": [
460
+ 8,
461
+ "fixed",
462
+ "normal"
463
+ ]
464
+ },
465
+ {
466
+ "id": 16,
467
+ "type": "EmptyLatentImage",
468
+ "pos": [
469
+ 532,
470
+ 1143
471
+ ],
472
+ "size": {
473
+ "0": 315,
474
+ "1": 106
475
+ },
476
+ "flags": {},
477
+ "order": 1,
478
+ "mode": 0,
479
+ "outputs": [
480
+ {
481
+ "name": "LATENT",
482
+ "type": "LATENT",
483
+ "links": [
484
+ 28,
485
+ 45
486
+ ],
487
+ "shape": 3,
488
+ "slot_index": 0
489
+ }
490
+ ],
491
+ "properties": {
492
+ "Node name for S&R": "EmptyLatentImage"
493
+ },
494
+ "widgets_values": [
495
+ 792,
496
+ 512,
497
+ 1
498
+ ]
499
+ },
500
+ {
501
+ "id": 19,
502
+ "type": "KSampler",
503
+ "pos": [
504
+ 1194.657802060547,
505
+ 1075.971700888672
506
+ ],
507
+ "size": [
508
+ 315,
509
+ 473.9999771118164
510
+ ],
511
+ "flags": {},
512
+ "order": 10,
513
+ "mode": 0,
514
+ "inputs": [
515
+ {
516
+ "name": "model",
517
+ "type": "MODEL",
518
+ "link": 34
519
+ },
520
+ {
521
+ "name": "positive",
522
+ "type": "CONDITIONING",
523
+ "link": 35
524
+ },
525
+ {
526
+ "name": "negative",
527
+ "type": "CONDITIONING",
528
+ "link": 36
529
+ },
530
+ {
531
+ "name": "latent_image",
532
+ "type": "LATENT",
533
+ "link": 28
534
+ }
535
+ ],
536
+ "outputs": [
537
+ {
538
+ "name": "LATENT",
539
+ "type": "LATENT",
540
+ "links": [
541
+ 30
542
+ ],
543
+ "shape": 3,
544
+ "slot_index": 0
545
+ }
546
+ ],
547
+ "properties": {
548
+ "Node name for S&R": "KSampler"
549
+ },
550
+ "widgets_values": [
551
+ 1107040072933062,
552
+ "fixed",
553
+ 20,
554
+ 8,
555
+ "euler",
556
+ "normal",
557
+ 1
558
+ ]
559
+ },
560
+ {
561
+ "id": 27,
562
+ "type": "TwoAdvancedSamplersForMask",
563
+ "pos": [
564
+ 2187,
565
+ 266
566
+ ],
567
+ "size": [
568
+ 315,
569
+ 426.00000762939453
570
+ ],
571
+ "flags": {},
572
+ "order": 13,
573
+ "mode": 0,
574
+ "inputs": [
575
+ {
576
+ "name": "samples",
577
+ "type": "LATENT",
578
+ "link": 45
579
+ },
580
+ {
581
+ "name": "base_sampler",
582
+ "type": "KSAMPLER_ADVANCED",
583
+ "link": 42
584
+ },
585
+ {
586
+ "name": "mask_sampler",
587
+ "type": "KSAMPLER_ADVANCED",
588
+ "link": 43
589
+ },
590
+ {
591
+ "name": "mask",
592
+ "type": "MASK",
593
+ "link": 44
594
+ }
595
+ ],
596
+ "outputs": [
597
+ {
598
+ "name": "LATENT",
599
+ "type": "LATENT",
600
+ "links": [
601
+ 46
602
+ ],
603
+ "shape": 3,
604
+ "slot_index": 0
605
+ }
606
+ ],
607
+ "properties": {
608
+ "Node name for S&R": "TwoAdvancedSamplersForMask"
609
+ },
610
+ "widgets_values": [
611
+ 1107040072933062,
612
+ "fixed",
613
+ 20,
614
+ 1,
615
+ 10
616
+ ]
617
+ },
618
+ {
619
+ "id": 23,
620
+ "type": "PreviewBridge",
621
+ "pos": [
622
+ 1778,
623
+ 1098
624
+ ],
625
+ "size": {
626
+ "0": 315,
627
+ "1": 290
628
+ },
629
+ "flags": {},
630
+ "order": 12,
631
+ "mode": 0,
632
+ "inputs": [
633
+ {
634
+ "name": "images",
635
+ "type": "IMAGE",
636
+ "link": 37
637
+ }
638
+ ],
639
+ "outputs": [
640
+ {
641
+ "name": "IMAGE",
642
+ "type": "IMAGE",
643
+ "links": null,
644
+ "shape": 3
645
+ },
646
+ {
647
+ "name": "MASK",
648
+ "type": "MASK",
649
+ "links": [
650
+ 44
651
+ ],
652
+ "shape": 3,
653
+ "slot_index": 1
654
+ }
655
+ ],
656
+ "properties": {
657
+ "Node name for S&R": "PreviewBridge"
658
+ },
659
+ "widgets_values": [
660
+ {
661
+ "filename": "clipspace-mask-348148.69999999925.png",
662
+ "subfolder": "clipspace",
663
+ "type": "input",
664
+ "image_hash": 492469318636598500,
665
+ "forward_filename": "ComfyUI_00001_.png",
666
+ "forward_subfolder": "",
667
+ "forward_type": "temp"
668
+ }
669
+ ]
670
+ },
671
+ {
672
+ "id": 15,
673
+ "type": "KSamplerAdvancedProvider",
674
+ "pos": [
675
+ 1719,
676
+ 592
677
+ ],
678
+ "size": {
679
+ "0": 355.20001220703125,
680
+ "1": 154
681
+ },
682
+ "flags": {},
683
+ "order": 9,
684
+ "mode": 0,
685
+ "inputs": [
686
+ {
687
+ "name": "basic_pipe",
688
+ "type": "BASIC_PIPE",
689
+ "link": 20
690
+ }
691
+ ],
692
+ "outputs": [
693
+ {
694
+ "name": "KSAMPLER_ADVANCED",
695
+ "type": "KSAMPLER_ADVANCED",
696
+ "links": [
697
+ 43
698
+ ],
699
+ "shape": 3,
700
+ "slot_index": 0
701
+ }
702
+ ],
703
+ "properties": {
704
+ "Node name for S&R": "KSamplerAdvancedProvider"
705
+ },
706
+ "widgets_values": [
707
+ 8,
708
+ "fixed",
709
+ "normal"
710
+ ]
711
+ },
712
+ {
713
+ "id": 20,
714
+ "type": "VAEDecode",
715
+ "pos": [
716
+ 1546,
717
+ 972
718
+ ],
719
+ "size": {
720
+ "0": 210,
721
+ "1": 46
722
+ },
723
+ "flags": {},
724
+ "order": 11,
725
+ "mode": 0,
726
+ "inputs": [
727
+ {
728
+ "name": "samples",
729
+ "type": "LATENT",
730
+ "link": 30
731
+ },
732
+ {
733
+ "name": "vae",
734
+ "type": "VAE",
735
+ "link": 31
736
+ }
737
+ ],
738
+ "outputs": [
739
+ {
740
+ "name": "IMAGE",
741
+ "type": "IMAGE",
742
+ "links": [
743
+ 37
744
+ ],
745
+ "shape": 3,
746
+ "slot_index": 0
747
+ }
748
+ ],
749
+ "properties": {
750
+ "Node name for S&R": "VAEDecode"
751
+ }
752
+ }
753
+ ],
754
+ "links": [
755
+ [
756
+ 3,
757
+ 4,
758
+ 1,
759
+ 6,
760
+ 0,
761
+ "CLIP"
762
+ ],
763
+ [
764
+ 5,
765
+ 4,
766
+ 1,
767
+ 7,
768
+ 0,
769
+ "CLIP"
770
+ ],
771
+ [
772
+ 10,
773
+ 4,
774
+ 0,
775
+ 10,
776
+ 0,
777
+ "MODEL"
778
+ ],
779
+ [
780
+ 11,
781
+ 4,
782
+ 1,
783
+ 10,
784
+ 1,
785
+ "CLIP"
786
+ ],
787
+ [
788
+ 12,
789
+ 4,
790
+ 2,
791
+ 10,
792
+ 2,
793
+ "VAE"
794
+ ],
795
+ [
796
+ 13,
797
+ 6,
798
+ 0,
799
+ 10,
800
+ 3,
801
+ "CONDITIONING"
802
+ ],
803
+ [
804
+ 14,
805
+ 7,
806
+ 0,
807
+ 10,
808
+ 4,
809
+ "CONDITIONING"
810
+ ],
811
+ [
812
+ 15,
813
+ 10,
814
+ 0,
815
+ 11,
816
+ 0,
817
+ "BASIC_PIPE"
818
+ ],
819
+ [
820
+ 16,
821
+ 4,
822
+ 1,
823
+ 12,
824
+ 0,
825
+ "CLIP"
826
+ ],
827
+ [
828
+ 17,
829
+ 12,
830
+ 0,
831
+ 11,
832
+ 4,
833
+ "CONDITIONING"
834
+ ],
835
+ [
836
+ 19,
837
+ 10,
838
+ 0,
839
+ 13,
840
+ 0,
841
+ "BASIC_PIPE"
842
+ ],
843
+ [
844
+ 20,
845
+ 11,
846
+ 0,
847
+ 15,
848
+ 0,
849
+ "BASIC_PIPE"
850
+ ],
851
+ [
852
+ 28,
853
+ 16,
854
+ 0,
855
+ 19,
856
+ 3,
857
+ "LATENT"
858
+ ],
859
+ [
860
+ 30,
861
+ 19,
862
+ 0,
863
+ 20,
864
+ 0,
865
+ "LATENT"
866
+ ],
867
+ [
868
+ 31,
869
+ 4,
870
+ 2,
871
+ 20,
872
+ 1,
873
+ "VAE"
874
+ ],
875
+ [
876
+ 33,
877
+ 10,
878
+ 0,
879
+ 22,
880
+ 0,
881
+ "BASIC_PIPE"
882
+ ],
883
+ [
884
+ 34,
885
+ 22,
886
+ 0,
887
+ 19,
888
+ 0,
889
+ "MODEL"
890
+ ],
891
+ [
892
+ 35,
893
+ 22,
894
+ 3,
895
+ 19,
896
+ 1,
897
+ "CONDITIONING"
898
+ ],
899
+ [
900
+ 36,
901
+ 22,
902
+ 4,
903
+ 19,
904
+ 2,
905
+ "CONDITIONING"
906
+ ],
907
+ [
908
+ 37,
909
+ 20,
910
+ 0,
911
+ 23,
912
+ 0,
913
+ "IMAGE"
914
+ ],
915
+ [
916
+ 40,
917
+ 22,
918
+ 2,
919
+ 24,
920
+ 1,
921
+ "VAE"
922
+ ],
923
+ [
924
+ 41,
925
+ 24,
926
+ 0,
927
+ 25,
928
+ 0,
929
+ "IMAGE"
930
+ ],
931
+ [
932
+ 42,
933
+ 13,
934
+ 0,
935
+ 27,
936
+ 1,
937
+ "KSAMPLER_ADVANCED"
938
+ ],
939
+ [
940
+ 43,
941
+ 15,
942
+ 0,
943
+ 27,
944
+ 2,
945
+ "KSAMPLER_ADVANCED"
946
+ ],
947
+ [
948
+ 44,
949
+ 23,
950
+ 1,
951
+ 27,
952
+ 3,
953
+ "MASK"
954
+ ],
955
+ [
956
+ 45,
957
+ 16,
958
+ 0,
959
+ 27,
960
+ 0,
961
+ "LATENT"
962
+ ],
963
+ [
964
+ 46,
965
+ 27,
966
+ 0,
967
+ 24,
968
+ 0,
969
+ "LATENT"
970
+ ]
971
+ ],
972
+ "groups": [],
973
+ "config": {},
974
+ "extra": {},
975
+ "version": 0.4
976
+ }
ComfyUI-Impact-Pack/test/detailer-pipe-test.json ADDED
@@ -0,0 +1,3230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "last_node_id": 87,
3
+ "last_link_id": 214,
4
+ "nodes": [
5
+ {
6
+ "id": 7,
7
+ "type": "CLIPTextEncode",
8
+ "pos": [
9
+ 413,
10
+ 389
11
+ ],
12
+ "size": {
13
+ "0": 425.27801513671875,
14
+ "1": 180.6060791015625
15
+ },
16
+ "flags": {},
17
+ "order": 7,
18
+ "mode": 0,
19
+ "inputs": [
20
+ {
21
+ "name": "clip",
22
+ "type": "CLIP",
23
+ "link": 5
24
+ }
25
+ ],
26
+ "outputs": [
27
+ {
28
+ "name": "CONDITIONING",
29
+ "type": "CONDITIONING",
30
+ "links": [
31
+ 6
32
+ ],
33
+ "slot_index": 0
34
+ }
35
+ ],
36
+ "properties": {
37
+ "Node name for S&R": "CLIPTextEncode"
38
+ },
39
+ "widgets_values": [
40
+ "text, watermark, worst quality:1.4, low quality:1.4"
41
+ ]
42
+ },
43
+ {
44
+ "id": 6,
45
+ "type": "CLIPTextEncode",
46
+ "pos": [
47
+ 415,
48
+ 186
49
+ ],
50
+ "size": {
51
+ "0": 422.84503173828125,
52
+ "1": 164.31304931640625
53
+ },
54
+ "flags": {},
55
+ "order": 6,
56
+ "mode": 0,
57
+ "inputs": [
58
+ {
59
+ "name": "clip",
60
+ "type": "CLIP",
61
+ "link": 3
62
+ }
63
+ ],
64
+ "outputs": [
65
+ {
66
+ "name": "CONDITIONING",
67
+ "type": "CONDITIONING",
68
+ "links": [
69
+ 4
70
+ ],
71
+ "slot_index": 0
72
+ }
73
+ ],
74
+ "properties": {
75
+ "Node name for S&R": "CLIPTextEncode"
76
+ },
77
+ "widgets_values": [
78
+ "photorealistic:1.4, best quality:1.4, 2 girls on table "
79
+ ]
80
+ },
81
+ {
82
+ "id": 5,
83
+ "type": "EmptyLatentImage",
84
+ "pos": [
85
+ 473,
86
+ 609
87
+ ],
88
+ "size": {
89
+ "0": 315,
90
+ "1": 106
91
+ },
92
+ "flags": {},
93
+ "order": 0,
94
+ "mode": 0,
95
+ "outputs": [
96
+ {
97
+ "name": "LATENT",
98
+ "type": "LATENT",
99
+ "links": [
100
+ 2
101
+ ],
102
+ "slot_index": 0
103
+ }
104
+ ],
105
+ "properties": {
106
+ "Node name for S&R": "EmptyLatentImage"
107
+ },
108
+ "widgets_values": [
109
+ 1024,
110
+ 768,
111
+ 1
112
+ ]
113
+ },
114
+ {
115
+ "id": 4,
116
+ "type": "CheckpointLoaderSimple",
117
+ "pos": [
118
+ 26,
119
+ 474
120
+ ],
121
+ "size": {
122
+ "0": 315,
123
+ "1": 98
124
+ },
125
+ "flags": {},
126
+ "order": 1,
127
+ "mode": 0,
128
+ "outputs": [
129
+ {
130
+ "name": "MODEL",
131
+ "type": "MODEL",
132
+ "links": [
133
+ 1
134
+ ],
135
+ "slot_index": 0
136
+ },
137
+ {
138
+ "name": "CLIP",
139
+ "type": "CLIP",
140
+ "links": [
141
+ 3,
142
+ 5
143
+ ],
144
+ "slot_index": 1
145
+ },
146
+ {
147
+ "name": "VAE",
148
+ "type": "VAE",
149
+ "links": [
150
+ 8
151
+ ],
152
+ "slot_index": 2
153
+ }
154
+ ],
155
+ "properties": {
156
+ "Node name for S&R": "CheckpointLoaderSimple"
157
+ },
158
+ "widgets_values": [
159
+ "V07_v07.safetensors"
160
+ ]
161
+ },
162
+ {
163
+ "id": 8,
164
+ "type": "VAEDecode",
165
+ "pos": [
166
+ 1209,
167
+ 188
168
+ ],
169
+ "size": {
170
+ "0": 210,
171
+ "1": 46
172
+ },
173
+ "flags": {},
174
+ "order": 12,
175
+ "mode": 0,
176
+ "inputs": [
177
+ {
178
+ "name": "samples",
179
+ "type": "LATENT",
180
+ "link": 7
181
+ },
182
+ {
183
+ "name": "vae",
184
+ "type": "VAE",
185
+ "link": 8
186
+ }
187
+ ],
188
+ "outputs": [
189
+ {
190
+ "name": "IMAGE",
191
+ "type": "IMAGE",
192
+ "links": [
193
+ 10
194
+ ],
195
+ "slot_index": 0
196
+ }
197
+ ],
198
+ "properties": {
199
+ "Node name for S&R": "VAEDecode"
200
+ }
201
+ },
202
+ {
203
+ "id": 30,
204
+ "type": "PreviewImage",
205
+ "pos": [
206
+ 2532,
207
+ -7
208
+ ],
209
+ "size": {
210
+ "0": 575.2411499023438,
211
+ "1": 561.0116577148438
212
+ },
213
+ "flags": {},
214
+ "order": 16,
215
+ "mode": 0,
216
+ "inputs": [
217
+ {
218
+ "name": "images",
219
+ "type": "IMAGE",
220
+ "link": 179
221
+ }
222
+ ],
223
+ "properties": {
224
+ "Node name for S&R": "PreviewImage"
225
+ }
226
+ },
227
+ {
228
+ "id": 24,
229
+ "type": "SAMLoader",
230
+ "pos": [
231
+ 861,
232
+ 1300
233
+ ],
234
+ "size": {
235
+ "0": 315,
236
+ "1": 82
237
+ },
238
+ "flags": {},
239
+ "order": 2,
240
+ "mode": 0,
241
+ "outputs": [
242
+ {
243
+ "name": "SAM_MODEL",
244
+ "type": "SAM_MODEL",
245
+ "links": [
246
+ 19,
247
+ 33
248
+ ],
249
+ "shape": 3,
250
+ "slot_index": 0
251
+ }
252
+ ],
253
+ "properties": {
254
+ "Node name for S&R": "SAMLoader"
255
+ },
256
+ "widgets_values": [
257
+ "sam_vit_b_01ec64.pth",
258
+ "AUTO"
259
+ ]
260
+ },
261
+ {
262
+ "id": 19,
263
+ "type": "## make-basic_pipe [2c8c61]",
264
+ "pos": [
265
+ 502,
266
+ 860
267
+ ],
268
+ "size": {
269
+ "0": 400,
270
+ "1": 200
271
+ },
272
+ "flags": {},
273
+ "order": 3,
274
+ "mode": 0,
275
+ "inputs": [
276
+ {
277
+ "name": "vae_opt",
278
+ "type": "VAE",
279
+ "link": null
280
+ }
281
+ ],
282
+ "outputs": [
283
+ {
284
+ "name": "BASIC_PIPE",
285
+ "type": "BASIC_PIPE",
286
+ "links": [
287
+ 17,
288
+ 34
289
+ ],
290
+ "shape": 3,
291
+ "slot_index": 0
292
+ }
293
+ ],
294
+ "title": "## make-basic_pipe",
295
+ "properties": {
296
+ "Node name for S&R": "## make-basic_pipe [2c8c61]"
297
+ },
298
+ "widgets_values": [
299
+ "V07_v07.safetensors",
300
+ "",
301
+ "text, watermark, worst quality:1.4, low quality:1.4"
302
+ ]
303
+ },
304
+ {
305
+ "id": 32,
306
+ "type": "BasicPipeToDetailerPipe",
307
+ "pos": [
308
+ 1396,
309
+ 1143
310
+ ],
311
+ "size": {
312
+ "0": 400,
313
+ "1": 200
314
+ },
315
+ "flags": {},
316
+ "order": 9,
317
+ "mode": 0,
318
+ "inputs": [
319
+ {
320
+ "name": "basic_pipe",
321
+ "type": "BASIC_PIPE",
322
+ "link": 34
323
+ },
324
+ {
325
+ "name": "bbox_detector",
326
+ "type": "BBOX_DETECTOR",
327
+ "link": 202,
328
+ "slot_index": 1
329
+ },
330
+ {
331
+ "name": "sam_model_opt",
332
+ "type": "SAM_MODEL",
333
+ "link": 33,
334
+ "slot_index": 2
335
+ },
336
+ {
337
+ "name": "segm_detector_opt",
338
+ "type": "SEGM_DETECTOR",
339
+ "link": 213
340
+ }
341
+ ],
342
+ "outputs": [
343
+ {
344
+ "name": "detailer_pipe",
345
+ "type": "DETAILER_PIPE",
346
+ "links": [
347
+ 36
348
+ ],
349
+ "shape": 3,
350
+ "slot_index": 0
351
+ }
352
+ ],
353
+ "properties": {
354
+ "Node name for S&R": "BasicPipeToDetailerPipe"
355
+ },
356
+ "widgets_values": [
357
+ "photorealistic:1.4, best quality:1.4, detailed eyes, \n__face_loras__ [faint smile|surprise|laugh]"
358
+ ]
359
+ },
360
+ {
361
+ "id": 36,
362
+ "type": "MaskToImage",
363
+ "pos": [
364
+ 2650,
365
+ 1230
366
+ ],
367
+ "size": {
368
+ "0": 210,
369
+ "1": 26
370
+ },
371
+ "flags": {},
372
+ "order": 20,
373
+ "mode": 0,
374
+ "inputs": [
375
+ {
376
+ "name": "mask",
377
+ "type": "MASK",
378
+ "link": 182
379
+ }
380
+ ],
381
+ "outputs": [
382
+ {
383
+ "name": "IMAGE",
384
+ "type": "IMAGE",
385
+ "links": [
386
+ 59
387
+ ],
388
+ "shape": 3,
389
+ "slot_index": 0
390
+ }
391
+ ],
392
+ "properties": {
393
+ "Node name for S&R": "MaskToImage"
394
+ }
395
+ },
396
+ {
397
+ "id": 52,
398
+ "type": "BboxDetectorSEGS",
399
+ "pos": [
400
+ 4948,
401
+ 677
402
+ ],
403
+ "size": {
404
+ "0": 315,
405
+ "1": 150
406
+ },
407
+ "flags": {},
408
+ "order": 33,
409
+ "mode": 0,
410
+ "inputs": [
411
+ {
412
+ "name": "bbox_detector",
413
+ "type": "BBOX_DETECTOR",
414
+ "link": 85
415
+ },
416
+ {
417
+ "name": "image",
418
+ "type": "IMAGE",
419
+ "link": 188
420
+ }
421
+ ],
422
+ "outputs": [
423
+ {
424
+ "name": "SEGS",
425
+ "type": "SEGS",
426
+ "links": [
427
+ 87,
428
+ 160
429
+ ],
430
+ "shape": 3,
431
+ "slot_index": 0
432
+ }
433
+ ],
434
+ "properties": {
435
+ "Node name for S&R": "BboxDetectorSEGS"
436
+ },
437
+ "widgets_values": [
438
+ 0.5,
439
+ 10,
440
+ 3,
441
+ 10
442
+ ]
443
+ },
444
+ {
445
+ "id": 46,
446
+ "type": "DetailerPipeToBasicPipe",
447
+ "pos": [
448
+ 4753,
449
+ 1188
450
+ ],
451
+ "size": {
452
+ "0": 304.79998779296875,
453
+ "1": 26
454
+ },
455
+ "flags": {},
456
+ "order": 31,
457
+ "mode": 0,
458
+ "inputs": [
459
+ {
460
+ "name": "detailer_pipe",
461
+ "type": "DETAILER_PIPE",
462
+ "link": 77
463
+ }
464
+ ],
465
+ "outputs": [
466
+ {
467
+ "name": "basic_pipe",
468
+ "type": "BASIC_PIPE",
469
+ "links": [
470
+ 155,
471
+ 196
472
+ ],
473
+ "shape": 3,
474
+ "slot_index": 0
475
+ }
476
+ ],
477
+ "properties": {
478
+ "Node name for S&R": "DetailerPipeToBasicPipe"
479
+ }
480
+ },
481
+ {
482
+ "id": 60,
483
+ "type": "PreviewImage",
484
+ "pos": [
485
+ 6270,
486
+ 2420
487
+ ],
488
+ "size": {
489
+ "0": 600,
490
+ "1": 670
491
+ },
492
+ "flags": {},
493
+ "order": 39,
494
+ "mode": 0,
495
+ "inputs": [
496
+ {
497
+ "name": "images",
498
+ "type": "IMAGE",
499
+ "link": 166
500
+ }
501
+ ],
502
+ "properties": {
503
+ "Node name for S&R": "PreviewImage"
504
+ }
505
+ },
506
+ {
507
+ "id": 57,
508
+ "type": "PreviewImage",
509
+ "pos": [
510
+ 5997,
511
+ 1424
512
+ ],
513
+ "size": {
514
+ "0": 840,
515
+ "1": 640
516
+ },
517
+ "flags": {},
518
+ "order": 46,
519
+ "mode": 0,
520
+ "inputs": [
521
+ {
522
+ "name": "images",
523
+ "type": "IMAGE",
524
+ "link": 144
525
+ }
526
+ ],
527
+ "properties": {
528
+ "Node name for S&R": "PreviewImage"
529
+ }
530
+ },
531
+ {
532
+ "id": 54,
533
+ "type": "PreviewImage",
534
+ "pos": [
535
+ 6486,
536
+ 705
537
+ ],
538
+ "size": {
539
+ "0": 740,
540
+ "1": 580
541
+ },
542
+ "flags": {},
543
+ "order": 51,
544
+ "mode": 0,
545
+ "inputs": [
546
+ {
547
+ "name": "images",
548
+ "type": "IMAGE",
549
+ "link": 197
550
+ }
551
+ ],
552
+ "properties": {
553
+ "Node name for S&R": "PreviewImage"
554
+ }
555
+ },
556
+ {
557
+ "id": 64,
558
+ "type": "PreviewImage",
559
+ "pos": [
560
+ 6800,
561
+ -300
562
+ ],
563
+ "size": {
564
+ "0": 570,
565
+ "1": 590
566
+ },
567
+ "flags": {},
568
+ "order": 47,
569
+ "mode": 0,
570
+ "inputs": [
571
+ {
572
+ "name": "images",
573
+ "type": "IMAGE",
574
+ "link": 156
575
+ }
576
+ ],
577
+ "properties": {
578
+ "Node name for S&R": "PreviewImage"
579
+ }
580
+ },
581
+ {
582
+ "id": 42,
583
+ "type": "PreviewImage",
584
+ "pos": [
585
+ 4070,
586
+ 636
587
+ ],
588
+ "size": {
589
+ "0": 210,
590
+ "1": 246
591
+ },
592
+ "flags": {},
593
+ "order": 26,
594
+ "mode": 0,
595
+ "inputs": [
596
+ {
597
+ "name": "images",
598
+ "type": "IMAGE",
599
+ "link": 187
600
+ }
601
+ ],
602
+ "properties": {
603
+ "Node name for S&R": "PreviewImage"
604
+ }
605
+ },
606
+ {
607
+ "id": 43,
608
+ "type": "MaskToImage",
609
+ "pos": [
610
+ 4081,
611
+ 949
612
+ ],
613
+ "size": {
614
+ "0": 176.39999389648438,
615
+ "1": 26
616
+ },
617
+ "flags": {},
618
+ "order": 28,
619
+ "mode": 0,
620
+ "inputs": [
621
+ {
622
+ "name": "mask",
623
+ "type": "MASK",
624
+ "link": 190
625
+ }
626
+ ],
627
+ "outputs": [
628
+ {
629
+ "name": "IMAGE",
630
+ "type": "IMAGE",
631
+ "links": [
632
+ 75
633
+ ],
634
+ "shape": 3,
635
+ "slot_index": 0
636
+ }
637
+ ],
638
+ "properties": {
639
+ "Node name for S&R": "MaskToImage"
640
+ }
641
+ },
642
+ {
643
+ "id": 44,
644
+ "type": "PreviewImage",
645
+ "pos": [
646
+ 4072,
647
+ 1029
648
+ ],
649
+ "size": {
650
+ "0": 210,
651
+ "1": 246
652
+ },
653
+ "flags": {},
654
+ "order": 30,
655
+ "mode": 0,
656
+ "inputs": [
657
+ {
658
+ "name": "images",
659
+ "type": "IMAGE",
660
+ "link": 75
661
+ }
662
+ ],
663
+ "properties": {
664
+ "Node name for S&R": "PreviewImage"
665
+ }
666
+ },
667
+ {
668
+ "id": 37,
669
+ "type": "PreviewImage",
670
+ "pos": [
671
+ 2890,
672
+ 1250
673
+ ],
674
+ "size": {
675
+ "0": 210,
676
+ "1": 246
677
+ },
678
+ "flags": {},
679
+ "order": 22,
680
+ "mode": 0,
681
+ "inputs": [
682
+ {
683
+ "name": "images",
684
+ "type": "IMAGE",
685
+ "link": 59
686
+ }
687
+ ],
688
+ "properties": {
689
+ "Node name for S&R": "PreviewImage"
690
+ }
691
+ },
692
+ {
693
+ "id": 22,
694
+ "type": "BasicPipeToDetailerPipe",
695
+ "pos": [
696
+ 1396,
697
+ 866
698
+ ],
699
+ "size": {
700
+ "0": 400,
701
+ "1": 200
702
+ },
703
+ "flags": {},
704
+ "order": 8,
705
+ "mode": 0,
706
+ "inputs": [
707
+ {
708
+ "name": "basic_pipe",
709
+ "type": "BASIC_PIPE",
710
+ "link": 17
711
+ },
712
+ {
713
+ "name": "bbox_detector",
714
+ "type": "BBOX_DETECTOR",
715
+ "link": 201,
716
+ "slot_index": 1
717
+ },
718
+ {
719
+ "name": "sam_model_opt",
720
+ "type": "SAM_MODEL",
721
+ "link": 19,
722
+ "slot_index": 2
723
+ },
724
+ {
725
+ "name": "segm_detector_opt",
726
+ "type": "SEGM_DETECTOR",
727
+ "link": 212
728
+ }
729
+ ],
730
+ "outputs": [
731
+ {
732
+ "name": "detailer_pipe",
733
+ "type": "DETAILER_PIPE",
734
+ "links": [],
735
+ "shape": 3,
736
+ "slot_index": 0
737
+ }
738
+ ],
739
+ "properties": {
740
+ "Node name for S&R": "BasicPipeToDetailerPipe"
741
+ },
742
+ "widgets_values": [
743
+ "photorealistic:1.4, best quality:1.4, detailed eyes, \n[<lora:android_18_v110>|<lora:yorha_noDOT_2_type_b>|<lora:sailor_venus_v2>|<lora:JinxLol>] [faint smile|surprise|laugh]"
744
+ ]
745
+ },
746
+ {
747
+ "id": 75,
748
+ "type": "PreviewImage",
749
+ "pos": [
750
+ 2600,
751
+ 1330
752
+ ],
753
+ "size": {
754
+ "0": 210,
755
+ "1": 246
756
+ },
757
+ "flags": {},
758
+ "order": 19,
759
+ "mode": 0,
760
+ "inputs": [
761
+ {
762
+ "name": "images",
763
+ "type": "IMAGE",
764
+ "link": 181
765
+ }
766
+ ],
767
+ "properties": {
768
+ "Node name for S&R": "PreviewImage"
769
+ }
770
+ },
771
+ {
772
+ "id": 10,
773
+ "type": "PreviewBridge",
774
+ "pos": [
775
+ 1462,
776
+ 175
777
+ ],
778
+ "size": {
779
+ "0": 315,
780
+ "1": 290
781
+ },
782
+ "flags": {},
783
+ "order": 13,
784
+ "mode": 0,
785
+ "inputs": [
786
+ {
787
+ "name": "images",
788
+ "type": "IMAGE",
789
+ "link": 10
790
+ }
791
+ ],
792
+ "outputs": [
793
+ {
794
+ "name": "IMAGE",
795
+ "type": "IMAGE",
796
+ "links": [
797
+ 169,
798
+ 183
799
+ ],
800
+ "shape": 3,
801
+ "slot_index": 0
802
+ },
803
+ {
804
+ "name": "MASK",
805
+ "type": "MASK",
806
+ "links": null,
807
+ "shape": 3
808
+ }
809
+ ],
810
+ "properties": {
811
+ "Node name for S&R": "PreviewBridge"
812
+ },
813
+ "widgets_values": [
814
+ "#placeholder"
815
+ ]
816
+ },
817
+ {
818
+ "id": 41,
819
+ "type": "PreviewImage",
820
+ "pos": [
821
+ 4301,
822
+ 119
823
+ ],
824
+ "size": {
825
+ "0": 492.20916748046875,
826
+ "1": 448.6293029785156
827
+ },
828
+ "flags": {},
829
+ "order": 25,
830
+ "mode": 0,
831
+ "inputs": [
832
+ {
833
+ "name": "images",
834
+ "type": "IMAGE",
835
+ "link": 186
836
+ }
837
+ ],
838
+ "properties": {
839
+ "Node name for S&R": "PreviewImage"
840
+ }
841
+ },
842
+ {
843
+ "id": 78,
844
+ "type": "PreviewImage",
845
+ "pos": [
846
+ 4075,
847
+ 1364
848
+ ],
849
+ "size": {
850
+ "0": 210,
851
+ "1": 246
852
+ },
853
+ "flags": {},
854
+ "order": 27,
855
+ "mode": 0,
856
+ "inputs": [
857
+ {
858
+ "name": "images",
859
+ "type": "IMAGE",
860
+ "link": 189
861
+ }
862
+ ],
863
+ "properties": {
864
+ "Node name for S&R": "PreviewImage"
865
+ }
866
+ },
867
+ {
868
+ "id": 3,
869
+ "type": "KSampler",
870
+ "pos": [
871
+ 863,
872
+ 183
873
+ ],
874
+ "size": {
875
+ "0": 315,
876
+ "1": 474
877
+ },
878
+ "flags": {},
879
+ "order": 10,
880
+ "mode": 0,
881
+ "inputs": [
882
+ {
883
+ "name": "model",
884
+ "type": "MODEL",
885
+ "link": 1
886
+ },
887
+ {
888
+ "name": "positive",
889
+ "type": "CONDITIONING",
890
+ "link": 4
891
+ },
892
+ {
893
+ "name": "negative",
894
+ "type": "CONDITIONING",
895
+ "link": 6
896
+ },
897
+ {
898
+ "name": "latent_image",
899
+ "type": "LATENT",
900
+ "link": 2
901
+ }
902
+ ],
903
+ "outputs": [
904
+ {
905
+ "name": "LATENT",
906
+ "type": "LATENT",
907
+ "links": [
908
+ 7
909
+ ],
910
+ "slot_index": 0
911
+ }
912
+ ],
913
+ "properties": {
914
+ "Node name for S&R": "KSampler"
915
+ },
916
+ "widgets_values": [
917
+ 885412539640489,
918
+ "fixed",
919
+ 15,
920
+ 8,
921
+ "euler",
922
+ "normal",
923
+ 1
924
+ ]
925
+ },
926
+ {
927
+ "id": 45,
928
+ "type": "EditDetailerPipe",
929
+ "pos": [
930
+ 4338,
931
+ 950
932
+ ],
933
+ "size": {
934
+ "0": 284.0971374511719,
935
+ "1": 316.5133361816406
936
+ },
937
+ "flags": {},
938
+ "order": 29,
939
+ "mode": 0,
940
+ "inputs": [
941
+ {
942
+ "name": "detailer_pipe",
943
+ "type": "DETAILER_PIPE",
944
+ "link": 191
945
+ },
946
+ {
947
+ "name": "model",
948
+ "type": "MODEL",
949
+ "link": null
950
+ },
951
+ {
952
+ "name": "clip",
953
+ "type": "CLIP",
954
+ "link": null
955
+ },
956
+ {
957
+ "name": "vae",
958
+ "type": "VAE",
959
+ "link": null
960
+ },
961
+ {
962
+ "name": "positive",
963
+ "type": "CONDITIONING",
964
+ "link": null
965
+ },
966
+ {
967
+ "name": "negative",
968
+ "type": "CONDITIONING",
969
+ "link": null
970
+ },
971
+ {
972
+ "name": "bbox_detector",
973
+ "type": "BBOX_DETECTOR",
974
+ "link": null
975
+ },
976
+ {
977
+ "name": "sam_model",
978
+ "type": "SAM_MODEL",
979
+ "link": null
980
+ },
981
+ {
982
+ "name": "segm_detector_opt",
983
+ "type": "SEGM_DETECTOR",
984
+ "link": null
985
+ }
986
+ ],
987
+ "outputs": [
988
+ {
989
+ "name": "detailer_pipe",
990
+ "type": "DETAILER_PIPE",
991
+ "links": [
992
+ 77,
993
+ 82
994
+ ],
995
+ "shape": 3,
996
+ "slot_index": 0
997
+ }
998
+ ],
999
+ "properties": {
1000
+ "Node name for S&R": "EditDetailerPipe"
1001
+ },
1002
+ "widgets_values": [
1003
+ ""
1004
+ ]
1005
+ },
1006
+ {
1007
+ "id": 65,
1008
+ "type": "PreviewImage",
1009
+ "pos": [
1010
+ 6430,
1011
+ -300
1012
+ ],
1013
+ "size": {
1014
+ "0": 330,
1015
+ "1": 250
1016
+ },
1017
+ "flags": {},
1018
+ "order": 48,
1019
+ "mode": 0,
1020
+ "inputs": [
1021
+ {
1022
+ "name": "images",
1023
+ "type": "IMAGE",
1024
+ "link": 157
1025
+ }
1026
+ ],
1027
+ "properties": {
1028
+ "Node name for S&R": "PreviewImage"
1029
+ }
1030
+ },
1031
+ {
1032
+ "id": 53,
1033
+ "type": "MaskToSEGS",
1034
+ "pos": [
1035
+ 5558,
1036
+ 989
1037
+ ],
1038
+ "size": {
1039
+ "0": 315,
1040
+ "1": 130
1041
+ },
1042
+ "flags": {},
1043
+ "order": 38,
1044
+ "mode": 0,
1045
+ "inputs": [
1046
+ {
1047
+ "name": "mask",
1048
+ "type": "MASK",
1049
+ "link": 88
1050
+ }
1051
+ ],
1052
+ "outputs": [
1053
+ {
1054
+ "name": "SEGS",
1055
+ "type": "SEGS",
1056
+ "links": [
1057
+ 138,
1058
+ 154,
1059
+ 195
1060
+ ],
1061
+ "shape": 3,
1062
+ "slot_index": 0
1063
+ }
1064
+ ],
1065
+ "properties": {
1066
+ "Node name for S&R": "MaskToSEGS"
1067
+ },
1068
+ "widgets_values": [
1069
+ "False",
1070
+ 3,
1071
+ "disabled",
1072
+ 10
1073
+ ]
1074
+ },
1075
+ {
1076
+ "id": 81,
1077
+ "type": "DetailerForEachPipe",
1078
+ "pos": [
1079
+ 6092,
1080
+ 708
1081
+ ],
1082
+ "size": {
1083
+ "0": 329.5368957519531,
1084
+ "1": 598
1085
+ },
1086
+ "flags": {},
1087
+ "order": 45,
1088
+ "mode": 0,
1089
+ "inputs": [
1090
+ {
1091
+ "name": "image",
1092
+ "type": "IMAGE",
1093
+ "link": 194
1094
+ },
1095
+ {
1096
+ "name": "segs",
1097
+ "type": "SEGS",
1098
+ "link": 195
1099
+ },
1100
+ {
1101
+ "name": "basic_pipe",
1102
+ "type": "BASIC_PIPE",
1103
+ "link": 196
1104
+ }
1105
+ ],
1106
+ "outputs": [
1107
+ {
1108
+ "name": "IMAGE",
1109
+ "type": "IMAGE",
1110
+ "links": [
1111
+ 197
1112
+ ],
1113
+ "shape": 3,
1114
+ "slot_index": 0
1115
+ }
1116
+ ],
1117
+ "properties": {
1118
+ "Node name for S&R": "DetailerForEachPipe"
1119
+ },
1120
+ "widgets_values": [
1121
+ 256,
1122
+ "bbox",
1123
+ 768,
1124
+ 44457634171318,
1125
+ "fixed",
1126
+ 20,
1127
+ 8,
1128
+ "euler",
1129
+ "normal",
1130
+ 0.5,
1131
+ 5,
1132
+ "enabled",
1133
+ "disabled"
1134
+ ]
1135
+ },
1136
+ {
1137
+ "id": 72,
1138
+ "type": "DetailerForEachDebugPipe",
1139
+ "pos": [
1140
+ 5938,
1141
+ -58
1142
+ ],
1143
+ "size": {
1144
+ "0": 330,
1145
+ "1": 618
1146
+ },
1147
+ "flags": {},
1148
+ "order": 44,
1149
+ "mode": 0,
1150
+ "inputs": [
1151
+ {
1152
+ "name": "image",
1153
+ "type": "IMAGE",
1154
+ "link": 153
1155
+ },
1156
+ {
1157
+ "name": "segs",
1158
+ "type": "SEGS",
1159
+ "link": 154
1160
+ },
1161
+ {
1162
+ "name": "basic_pipe",
1163
+ "type": "BASIC_PIPE",
1164
+ "link": 155
1165
+ }
1166
+ ],
1167
+ "outputs": [
1168
+ {
1169
+ "name": "image",
1170
+ "type": "IMAGE",
1171
+ "links": [
1172
+ 156
1173
+ ],
1174
+ "shape": 3,
1175
+ "slot_index": 0
1176
+ },
1177
+ {
1178
+ "name": "cropped",
1179
+ "type": "IMAGE",
1180
+ "links": [
1181
+ 157
1182
+ ],
1183
+ "shape": 6,
1184
+ "slot_index": 1
1185
+ },
1186
+ {
1187
+ "name": "cropped_refined",
1188
+ "type": "IMAGE",
1189
+ "links": [
1190
+ 158
1191
+ ],
1192
+ "shape": 6,
1193
+ "slot_index": 2
1194
+ },
1195
+ {
1196
+ "name": "cropped_refined_alpha",
1197
+ "type": "IMAGE",
1198
+ "links": [
1199
+ 200
1200
+ ],
1201
+ "shape": 6,
1202
+ "slot_index": 3
1203
+ }
1204
+ ],
1205
+ "properties": {
1206
+ "Node name for S&R": "DetailerForEachDebugPipe"
1207
+ },
1208
+ "widgets_values": [
1209
+ 256,
1210
+ "bbox",
1211
+ 768,
1212
+ 0,
1213
+ "fixed",
1214
+ 20,
1215
+ 8,
1216
+ "euler",
1217
+ "normal",
1218
+ 0.5,
1219
+ 5,
1220
+ "enabled",
1221
+ "disabled"
1222
+ ]
1223
+ },
1224
+ {
1225
+ "id": 66,
1226
+ "type": "PreviewImage",
1227
+ "pos": [
1228
+ 6430,
1229
+ 30
1230
+ ],
1231
+ "size": {
1232
+ "0": 330,
1233
+ "1": 260
1234
+ },
1235
+ "flags": {},
1236
+ "order": 49,
1237
+ "mode": 0,
1238
+ "inputs": [
1239
+ {
1240
+ "name": "images",
1241
+ "type": "IMAGE",
1242
+ "link": 158
1243
+ }
1244
+ ],
1245
+ "properties": {
1246
+ "Node name for S&R": "PreviewImage"
1247
+ }
1248
+ },
1249
+ {
1250
+ "id": 82,
1251
+ "type": "PreviewImage",
1252
+ "pos": [
1253
+ 6435,
1254
+ 355
1255
+ ],
1256
+ "size": {
1257
+ "0": 319.2451171875,
1258
+ "1": 285.4361572265625
1259
+ },
1260
+ "flags": {},
1261
+ "order": 50,
1262
+ "mode": 0,
1263
+ "inputs": [
1264
+ {
1265
+ "name": "images",
1266
+ "type": "IMAGE",
1267
+ "link": 200
1268
+ }
1269
+ ],
1270
+ "properties": {
1271
+ "Node name for S&R": "PreviewImage"
1272
+ }
1273
+ },
1274
+ {
1275
+ "id": 83,
1276
+ "type": "UltralyticsDetectorProvider",
1277
+ "pos": [
1278
+ 860,
1279
+ 1160
1280
+ ],
1281
+ "size": {
1282
+ "0": 315,
1283
+ "1": 78
1284
+ },
1285
+ "flags": {},
1286
+ "order": 4,
1287
+ "mode": 0,
1288
+ "outputs": [
1289
+ {
1290
+ "name": "BBOX_DETECTOR",
1291
+ "type": "BBOX_DETECTOR",
1292
+ "links": [
1293
+ 201,
1294
+ 202
1295
+ ],
1296
+ "shape": 3,
1297
+ "slot_index": 0
1298
+ },
1299
+ {
1300
+ "name": "SEGM_DETECTOR",
1301
+ "type": "SEGM_DETECTOR",
1302
+ "links": null,
1303
+ "shape": 3,
1304
+ "slot_index": 1
1305
+ }
1306
+ ],
1307
+ "properties": {
1308
+ "Node name for S&R": "UltralyticsDetectorProvider"
1309
+ },
1310
+ "widgets_values": [
1311
+ "bbox/face_yolov8m.pt"
1312
+ ]
1313
+ },
1314
+ {
1315
+ "id": 69,
1316
+ "type": "DetailerForEach",
1317
+ "pos": [
1318
+ 5610,
1319
+ 1425
1320
+ ],
1321
+ "size": {
1322
+ "0": 315,
1323
+ "1": 678
1324
+ },
1325
+ "flags": {},
1326
+ "order": 43,
1327
+ "mode": 0,
1328
+ "inputs": [
1329
+ {
1330
+ "name": "image",
1331
+ "type": "IMAGE",
1332
+ "link": 137
1333
+ },
1334
+ {
1335
+ "name": "segs",
1336
+ "type": "SEGS",
1337
+ "link": 138
1338
+ },
1339
+ {
1340
+ "name": "model",
1341
+ "type": "MODEL",
1342
+ "link": 139
1343
+ },
1344
+ {
1345
+ "name": "clip",
1346
+ "type": "CLIP",
1347
+ "link": 140
1348
+ },
1349
+ {
1350
+ "name": "vae",
1351
+ "type": "VAE",
1352
+ "link": 141
1353
+ },
1354
+ {
1355
+ "name": "positive",
1356
+ "type": "CONDITIONING",
1357
+ "link": 142
1358
+ },
1359
+ {
1360
+ "name": "negative",
1361
+ "type": "CONDITIONING",
1362
+ "link": 143
1363
+ }
1364
+ ],
1365
+ "outputs": [
1366
+ {
1367
+ "name": "IMAGE",
1368
+ "type": "IMAGE",
1369
+ "links": [
1370
+ 144
1371
+ ],
1372
+ "shape": 3,
1373
+ "slot_index": 0
1374
+ }
1375
+ ],
1376
+ "properties": {
1377
+ "Node name for S&R": "DetailerForEach"
1378
+ },
1379
+ "widgets_values": [
1380
+ 256,
1381
+ "bbox",
1382
+ 768,
1383
+ 0,
1384
+ "fixed",
1385
+ 20,
1386
+ 8,
1387
+ "euler",
1388
+ "normal",
1389
+ 0.5,
1390
+ 5,
1391
+ "enabled",
1392
+ "disabled"
1393
+ ]
1394
+ },
1395
+ {
1396
+ "id": 50,
1397
+ "type": "FromDetailerPipe",
1398
+ "pos": [
1399
+ 4730,
1400
+ 1460
1401
+ ],
1402
+ "size": {
1403
+ "0": 342.5999755859375,
1404
+ "1": 166
1405
+ },
1406
+ "flags": {},
1407
+ "order": 32,
1408
+ "mode": 0,
1409
+ "inputs": [
1410
+ {
1411
+ "name": "detailer_pipe",
1412
+ "type": "DETAILER_PIPE",
1413
+ "link": 82
1414
+ }
1415
+ ],
1416
+ "outputs": [
1417
+ {
1418
+ "name": "model",
1419
+ "type": "MODEL",
1420
+ "links": [
1421
+ 139,
1422
+ 161
1423
+ ],
1424
+ "shape": 3,
1425
+ "slot_index": 0
1426
+ },
1427
+ {
1428
+ "name": "clip",
1429
+ "type": "CLIP",
1430
+ "links": [
1431
+ 140,
1432
+ 162
1433
+ ],
1434
+ "shape": 3,
1435
+ "slot_index": 1
1436
+ },
1437
+ {
1438
+ "name": "vae",
1439
+ "type": "VAE",
1440
+ "links": [
1441
+ 141,
1442
+ 163
1443
+ ],
1444
+ "shape": 3,
1445
+ "slot_index": 2
1446
+ },
1447
+ {
1448
+ "name": "positive",
1449
+ "type": "CONDITIONING",
1450
+ "links": [
1451
+ 142,
1452
+ 164
1453
+ ],
1454
+ "shape": 3,
1455
+ "slot_index": 3
1456
+ },
1457
+ {
1458
+ "name": "negative",
1459
+ "type": "CONDITIONING",
1460
+ "links": [
1461
+ 143,
1462
+ 165
1463
+ ],
1464
+ "shape": 3,
1465
+ "slot_index": 4
1466
+ },
1467
+ {
1468
+ "name": "bbox_detector",
1469
+ "type": "BBOX_DETECTOR",
1470
+ "links": [
1471
+ 85
1472
+ ],
1473
+ "shape": 3,
1474
+ "slot_index": 5
1475
+ },
1476
+ {
1477
+ "name": "sam_model_opt",
1478
+ "type": "SAM_MODEL",
1479
+ "links": [
1480
+ 83
1481
+ ],
1482
+ "shape": 3,
1483
+ "slot_index": 6
1484
+ },
1485
+ {
1486
+ "name": "segm_detector_opt",
1487
+ "type": "SEGM_DETECTOR",
1488
+ "links": [
1489
+ 204
1490
+ ],
1491
+ "shape": 3,
1492
+ "slot_index": 7
1493
+ }
1494
+ ],
1495
+ "properties": {
1496
+ "Node name for S&R": "FromDetailerPipe"
1497
+ }
1498
+ },
1499
+ {
1500
+ "id": 51,
1501
+ "type": "SAMDetectorCombined",
1502
+ "pos": [
1503
+ 5125,
1504
+ 894
1505
+ ],
1506
+ "size": {
1507
+ "0": 315,
1508
+ "1": 218
1509
+ },
1510
+ "flags": {},
1511
+ "order": 35,
1512
+ "mode": 0,
1513
+ "inputs": [
1514
+ {
1515
+ "name": "sam_model",
1516
+ "type": "SAM_MODEL",
1517
+ "link": 83
1518
+ },
1519
+ {
1520
+ "name": "segs",
1521
+ "type": "SEGS",
1522
+ "link": 87
1523
+ },
1524
+ {
1525
+ "name": "image",
1526
+ "type": "IMAGE",
1527
+ "link": 205
1528
+ }
1529
+ ],
1530
+ "outputs": [
1531
+ {
1532
+ "name": "MASK",
1533
+ "type": "MASK",
1534
+ "links": [
1535
+ 88
1536
+ ],
1537
+ "shape": 3,
1538
+ "slot_index": 0
1539
+ }
1540
+ ],
1541
+ "properties": {
1542
+ "Node name for S&R": "SAMDetectorCombined"
1543
+ },
1544
+ "widgets_values": [
1545
+ "center-1",
1546
+ 0,
1547
+ 0.93,
1548
+ 0,
1549
+ 0.7,
1550
+ "False"
1551
+ ]
1552
+ },
1553
+ {
1554
+ "id": 85,
1555
+ "type": "SEGSToImageList",
1556
+ "pos": [
1557
+ 5569.134812187498,
1558
+ 1289.240372597656
1559
+ ],
1560
+ "size": {
1561
+ "0": 304.79998779296875,
1562
+ "1": 46
1563
+ },
1564
+ "flags": {},
1565
+ "order": 37,
1566
+ "mode": 0,
1567
+ "inputs": [
1568
+ {
1569
+ "name": "segs",
1570
+ "type": "SEGS",
1571
+ "link": 207
1572
+ },
1573
+ {
1574
+ "name": "fallback_image_opt",
1575
+ "type": "IMAGE",
1576
+ "link": 208
1577
+ }
1578
+ ],
1579
+ "outputs": [
1580
+ {
1581
+ "name": "IMAGE",
1582
+ "type": "IMAGE",
1583
+ "links": [
1584
+ 209
1585
+ ],
1586
+ "shape": 6,
1587
+ "slot_index": 0
1588
+ }
1589
+ ],
1590
+ "properties": {
1591
+ "Node name for S&R": "SEGSToImageList"
1592
+ }
1593
+ },
1594
+ {
1595
+ "id": 86,
1596
+ "type": "PreviewImage",
1597
+ "pos": [
1598
+ 6910,
1599
+ 1420
1600
+ ],
1601
+ "size": {
1602
+ "0": 409.85064697265625,
1603
+ "1": 614.9011840820312
1604
+ },
1605
+ "flags": {},
1606
+ "order": 42,
1607
+ "mode": 0,
1608
+ "inputs": [
1609
+ {
1610
+ "name": "images",
1611
+ "type": "IMAGE",
1612
+ "link": 209
1613
+ }
1614
+ ],
1615
+ "properties": {
1616
+ "Node name for S&R": "PreviewImage"
1617
+ }
1618
+ },
1619
+ {
1620
+ "id": 39,
1621
+ "type": "ToDetailerPipe",
1622
+ "pos": [
1623
+ 3167,
1624
+ 631
1625
+ ],
1626
+ "size": {
1627
+ "0": 400,
1628
+ "1": 216
1629
+ },
1630
+ "flags": {},
1631
+ "order": 23,
1632
+ "mode": 0,
1633
+ "inputs": [
1634
+ {
1635
+ "name": "model",
1636
+ "type": "MODEL",
1637
+ "link": 61
1638
+ },
1639
+ {
1640
+ "name": "clip",
1641
+ "type": "CLIP",
1642
+ "link": 62
1643
+ },
1644
+ {
1645
+ "name": "vae",
1646
+ "type": "VAE",
1647
+ "link": 65
1648
+ },
1649
+ {
1650
+ "name": "positive",
1651
+ "type": "CONDITIONING",
1652
+ "link": 66
1653
+ },
1654
+ {
1655
+ "name": "negative",
1656
+ "type": "CONDITIONING",
1657
+ "link": 67
1658
+ },
1659
+ {
1660
+ "name": "bbox_detector",
1661
+ "type": "BBOX_DETECTOR",
1662
+ "link": 68
1663
+ },
1664
+ {
1665
+ "name": "sam_model_opt",
1666
+ "type": "SAM_MODEL",
1667
+ "link": 69
1668
+ },
1669
+ {
1670
+ "name": "segm_detector_opt",
1671
+ "type": "SEGM_DETECTOR",
1672
+ "link": 203
1673
+ }
1674
+ ],
1675
+ "outputs": [
1676
+ {
1677
+ "name": "detailer_pipe",
1678
+ "type": "DETAILER_PIPE",
1679
+ "links": [
1680
+ 210
1681
+ ],
1682
+ "shape": 3,
1683
+ "slot_index": 0
1684
+ }
1685
+ ],
1686
+ "properties": {
1687
+ "Node name for S&R": "ToDetailerPipe"
1688
+ },
1689
+ "widgets_values": [
1690
+ ""
1691
+ ]
1692
+ },
1693
+ {
1694
+ "id": 76,
1695
+ "type": "FaceDetailerPipe",
1696
+ "pos": [
1697
+ 3648,
1698
+ 641
1699
+ ],
1700
+ "size": {
1701
+ "0": 347.608154296875,
1702
+ "1": 1060.470947265625
1703
+ },
1704
+ "flags": {},
1705
+ "order": 24,
1706
+ "mode": 0,
1707
+ "inputs": [
1708
+ {
1709
+ "name": "image",
1710
+ "type": "IMAGE",
1711
+ "link": 184
1712
+ },
1713
+ {
1714
+ "name": "detailer_pipe",
1715
+ "type": "DETAILER_PIPE",
1716
+ "link": 210
1717
+ }
1718
+ ],
1719
+ "outputs": [
1720
+ {
1721
+ "name": "image",
1722
+ "type": "IMAGE",
1723
+ "links": [
1724
+ 186,
1725
+ 188
1726
+ ],
1727
+ "shape": 3,
1728
+ "slot_index": 0
1729
+ },
1730
+ {
1731
+ "name": "cropped_refined",
1732
+ "type": "IMAGE",
1733
+ "links": [
1734
+ 187
1735
+ ],
1736
+ "shape": 6,
1737
+ "slot_index": 1
1738
+ },
1739
+ {
1740
+ "name": "cropped_enhanced_alpha",
1741
+ "type": "IMAGE",
1742
+ "links": [
1743
+ 189
1744
+ ],
1745
+ "shape": 6,
1746
+ "slot_index": 2
1747
+ },
1748
+ {
1749
+ "name": "mask",
1750
+ "type": "MASK",
1751
+ "links": [
1752
+ 190
1753
+ ],
1754
+ "shape": 3,
1755
+ "slot_index": 3
1756
+ },
1757
+ {
1758
+ "name": "detailer_pipe",
1759
+ "type": "DETAILER_PIPE",
1760
+ "links": [
1761
+ 191
1762
+ ],
1763
+ "shape": 3,
1764
+ "slot_index": 4
1765
+ }
1766
+ ],
1767
+ "properties": {
1768
+ "Node name for S&R": "FaceDetailerPipe"
1769
+ },
1770
+ "widgets_values": [
1771
+ 256,
1772
+ "bbox",
1773
+ 768,
1774
+ 284739423125169,
1775
+ "fixed",
1776
+ 20,
1777
+ 8,
1778
+ "euler",
1779
+ "normal",
1780
+ 0.5,
1781
+ 5,
1782
+ "enabled",
1783
+ "disabled",
1784
+ 0.5,
1785
+ 10,
1786
+ 3,
1787
+ "center-1",
1788
+ 0,
1789
+ 0.93,
1790
+ 0,
1791
+ 0.7,
1792
+ "False",
1793
+ 10
1794
+ ]
1795
+ },
1796
+ {
1797
+ "id": 49,
1798
+ "type": "Reroute",
1799
+ "pos": [
1800
+ 4967,
1801
+ 568
1802
+ ],
1803
+ "size": [
1804
+ 75,
1805
+ 26
1806
+ ],
1807
+ "flags": {},
1808
+ "order": 17,
1809
+ "mode": 0,
1810
+ "inputs": [
1811
+ {
1812
+ "name": "",
1813
+ "type": "*",
1814
+ "link": 211
1815
+ }
1816
+ ],
1817
+ "outputs": [
1818
+ {
1819
+ "name": "",
1820
+ "type": "IMAGE",
1821
+ "links": [
1822
+ 137,
1823
+ 153,
1824
+ 159,
1825
+ 194
1826
+ ],
1827
+ "slot_index": 0
1828
+ }
1829
+ ],
1830
+ "properties": {
1831
+ "showOutputText": false,
1832
+ "horizontal": false
1833
+ }
1834
+ },
1835
+ {
1836
+ "id": 27,
1837
+ "type": "PreviewImage",
1838
+ "pos": [
1839
+ 2590,
1840
+ 920
1841
+ ],
1842
+ "size": {
1843
+ "0": 210,
1844
+ "1": 246
1845
+ },
1846
+ "flags": {},
1847
+ "order": 18,
1848
+ "mode": 0,
1849
+ "inputs": [
1850
+ {
1851
+ "name": "images",
1852
+ "type": "IMAGE",
1853
+ "link": 180
1854
+ }
1855
+ ],
1856
+ "properties": {
1857
+ "Node name for S&R": "PreviewImage"
1858
+ }
1859
+ },
1860
+ {
1861
+ "id": 74,
1862
+ "type": "FaceDetailer",
1863
+ "pos": [
1864
+ 2050,
1865
+ 580
1866
+ ],
1867
+ "size": {
1868
+ "0": 372.5969543457031,
1869
+ "1": 1103.0477294921875
1870
+ },
1871
+ "flags": {},
1872
+ "order": 14,
1873
+ "mode": 0,
1874
+ "inputs": [
1875
+ {
1876
+ "name": "image",
1877
+ "type": "IMAGE",
1878
+ "link": 169
1879
+ },
1880
+ {
1881
+ "name": "model",
1882
+ "type": "MODEL",
1883
+ "link": 170
1884
+ },
1885
+ {
1886
+ "name": "clip",
1887
+ "type": "CLIP",
1888
+ "link": 171
1889
+ },
1890
+ {
1891
+ "name": "vae",
1892
+ "type": "VAE",
1893
+ "link": 172
1894
+ },
1895
+ {
1896
+ "name": "positive",
1897
+ "type": "CONDITIONING",
1898
+ "link": 175
1899
+ },
1900
+ {
1901
+ "name": "negative",
1902
+ "type": "CONDITIONING",
1903
+ "link": 176,
1904
+ "slot_index": 5
1905
+ },
1906
+ {
1907
+ "name": "bbox_detector",
1908
+ "type": "BBOX_DETECTOR",
1909
+ "link": 177
1910
+ },
1911
+ {
1912
+ "name": "sam_model_opt",
1913
+ "type": "SAM_MODEL",
1914
+ "link": 178
1915
+ },
1916
+ {
1917
+ "name": "segm_detector_opt",
1918
+ "type": "SEGM_DETECTOR",
1919
+ "link": 214
1920
+ }
1921
+ ],
1922
+ "outputs": [
1923
+ {
1924
+ "name": "image",
1925
+ "type": "IMAGE",
1926
+ "links": [
1927
+ 179,
1928
+ 211
1929
+ ],
1930
+ "shape": 3,
1931
+ "slot_index": 0
1932
+ },
1933
+ {
1934
+ "name": "cropped_refined",
1935
+ "type": "IMAGE",
1936
+ "links": [
1937
+ 180
1938
+ ],
1939
+ "shape": 6,
1940
+ "slot_index": 1
1941
+ },
1942
+ {
1943
+ "name": "cropped_enhanced_alpha",
1944
+ "type": "IMAGE",
1945
+ "links": [
1946
+ 181
1947
+ ],
1948
+ "shape": 6,
1949
+ "slot_index": 2
1950
+ },
1951
+ {
1952
+ "name": "mask",
1953
+ "type": "MASK",
1954
+ "links": [
1955
+ 182
1956
+ ],
1957
+ "shape": 3,
1958
+ "slot_index": 3
1959
+ },
1960
+ {
1961
+ "name": "detailer_pipe",
1962
+ "type": "DETAILER_PIPE",
1963
+ "links": [
1964
+ 193
1965
+ ],
1966
+ "shape": 3,
1967
+ "slot_index": 4
1968
+ }
1969
+ ],
1970
+ "properties": {
1971
+ "Node name for S&R": "FaceDetailer"
1972
+ },
1973
+ "widgets_values": [
1974
+ 256,
1975
+ "bbox",
1976
+ 768,
1977
+ 872368928997833,
1978
+ "fixed",
1979
+ 20,
1980
+ 8,
1981
+ "euler",
1982
+ "normal",
1983
+ 0.5,
1984
+ 5,
1985
+ "enabled",
1986
+ "disabled",
1987
+ 0.5,
1988
+ 10,
1989
+ 3,
1990
+ "center-1",
1991
+ 0,
1992
+ 0.93,
1993
+ 0,
1994
+ 0.7,
1995
+ "False",
1996
+ 10,
1997
+ ""
1998
+ ]
1999
+ },
2000
+ {
2001
+ "id": 38,
2002
+ "type": "FromDetailerPipe",
2003
+ "pos": [
2004
+ 2740,
2005
+ 630
2006
+ ],
2007
+ "size": {
2008
+ "0": 342.5999755859375,
2009
+ "1": 166
2010
+ },
2011
+ "flags": {},
2012
+ "order": 21,
2013
+ "mode": 0,
2014
+ "inputs": [
2015
+ {
2016
+ "name": "detailer_pipe",
2017
+ "type": "DETAILER_PIPE",
2018
+ "link": 193
2019
+ }
2020
+ ],
2021
+ "outputs": [
2022
+ {
2023
+ "name": "model",
2024
+ "type": "MODEL",
2025
+ "links": [
2026
+ 61
2027
+ ],
2028
+ "shape": 3,
2029
+ "slot_index": 0
2030
+ },
2031
+ {
2032
+ "name": "clip",
2033
+ "type": "CLIP",
2034
+ "links": [
2035
+ 62
2036
+ ],
2037
+ "shape": 3,
2038
+ "slot_index": 1
2039
+ },
2040
+ {
2041
+ "name": "vae",
2042
+ "type": "VAE",
2043
+ "links": [
2044
+ 65
2045
+ ],
2046
+ "shape": 3,
2047
+ "slot_index": 2
2048
+ },
2049
+ {
2050
+ "name": "positive",
2051
+ "type": "CONDITIONING",
2052
+ "links": [
2053
+ 66
2054
+ ],
2055
+ "shape": 3,
2056
+ "slot_index": 3
2057
+ },
2058
+ {
2059
+ "name": "negative",
2060
+ "type": "CONDITIONING",
2061
+ "links": [
2062
+ 67
2063
+ ],
2064
+ "shape": 3,
2065
+ "slot_index": 4
2066
+ },
2067
+ {
2068
+ "name": "bbox_detector",
2069
+ "type": "BBOX_DETECTOR",
2070
+ "links": [
2071
+ 68
2072
+ ],
2073
+ "shape": 3,
2074
+ "slot_index": 5
2075
+ },
2076
+ {
2077
+ "name": "sam_model_opt",
2078
+ "type": "SAM_MODEL",
2079
+ "links": [
2080
+ 69
2081
+ ],
2082
+ "shape": 3,
2083
+ "slot_index": 6
2084
+ },
2085
+ {
2086
+ "name": "segm_detector_opt",
2087
+ "type": "SEGM_DETECTOR",
2088
+ "links": [
2089
+ 203
2090
+ ],
2091
+ "shape": 3,
2092
+ "slot_index": 7
2093
+ }
2094
+ ],
2095
+ "properties": {
2096
+ "Node name for S&R": "FromDetailerPipe"
2097
+ }
2098
+ },
2099
+ {
2100
+ "id": 87,
2101
+ "type": "UltralyticsDetectorProvider",
2102
+ "pos": [
2103
+ 862,
2104
+ 1445
2105
+ ],
2106
+ "size": {
2107
+ "0": 315,
2108
+ "1": 78
2109
+ },
2110
+ "flags": {},
2111
+ "order": 5,
2112
+ "mode": 0,
2113
+ "outputs": [
2114
+ {
2115
+ "name": "BBOX_DETECTOR",
2116
+ "type": "BBOX_DETECTOR",
2117
+ "links": [],
2118
+ "shape": 3,
2119
+ "slot_index": 0
2120
+ },
2121
+ {
2122
+ "name": "SEGM_DETECTOR",
2123
+ "type": "SEGM_DETECTOR",
2124
+ "links": [
2125
+ 212,
2126
+ 213
2127
+ ],
2128
+ "shape": 3,
2129
+ "slot_index": 1
2130
+ }
2131
+ ],
2132
+ "properties": {
2133
+ "Node name for S&R": "UltralyticsDetectorProvider"
2134
+ },
2135
+ "widgets_values": [
2136
+ "segm/person_yolov8m-seg.pt"
2137
+ ]
2138
+ },
2139
+ {
2140
+ "id": 77,
2141
+ "type": "Reroute",
2142
+ "pos": [
2143
+ 3500,
2144
+ 170
2145
+ ],
2146
+ "size": [
2147
+ 75,
2148
+ 26
2149
+ ],
2150
+ "flags": {},
2151
+ "order": 15,
2152
+ "mode": 0,
2153
+ "inputs": [
2154
+ {
2155
+ "name": "",
2156
+ "type": "*",
2157
+ "link": 183
2158
+ }
2159
+ ],
2160
+ "outputs": [
2161
+ {
2162
+ "name": "",
2163
+ "type": "IMAGE",
2164
+ "links": [
2165
+ 184,
2166
+ 205,
2167
+ 206,
2168
+ 208
2169
+ ],
2170
+ "slot_index": 0
2171
+ }
2172
+ ],
2173
+ "properties": {
2174
+ "showOutputText": false,
2175
+ "horizontal": false
2176
+ }
2177
+ },
2178
+ {
2179
+ "id": 84,
2180
+ "type": "SegmDetectorSEGS",
2181
+ "pos": [
2182
+ 5130,
2183
+ 1240
2184
+ ],
2185
+ "size": {
2186
+ "0": 315,
2187
+ "1": 150
2188
+ },
2189
+ "flags": {},
2190
+ "order": 34,
2191
+ "mode": 0,
2192
+ "inputs": [
2193
+ {
2194
+ "name": "segm_detector",
2195
+ "type": "SEGM_DETECTOR",
2196
+ "link": 204
2197
+ },
2198
+ {
2199
+ "name": "image",
2200
+ "type": "IMAGE",
2201
+ "link": 206
2202
+ }
2203
+ ],
2204
+ "outputs": [
2205
+ {
2206
+ "name": "SEGS",
2207
+ "type": "SEGS",
2208
+ "links": [
2209
+ 207
2210
+ ],
2211
+ "shape": 3,
2212
+ "slot_index": 0
2213
+ }
2214
+ ],
2215
+ "properties": {
2216
+ "Node name for S&R": "SegmDetectorSEGS"
2217
+ },
2218
+ "widgets_values": [
2219
+ 0.5,
2220
+ 10,
2221
+ 3,
2222
+ 1
2223
+ ]
2224
+ },
2225
+ {
2226
+ "id": 34,
2227
+ "type": "FromDetailerPipe",
2228
+ "pos": [
2229
+ 1737,
2230
+ -34
2231
+ ],
2232
+ "size": {
2233
+ "0": 342.5999755859375,
2234
+ "1": 166
2235
+ },
2236
+ "flags": {},
2237
+ "order": 11,
2238
+ "mode": 0,
2239
+ "inputs": [
2240
+ {
2241
+ "name": "detailer_pipe",
2242
+ "type": "DETAILER_PIPE",
2243
+ "link": 36
2244
+ }
2245
+ ],
2246
+ "outputs": [
2247
+ {
2248
+ "name": "model",
2249
+ "type": "MODEL",
2250
+ "links": [
2251
+ 170
2252
+ ],
2253
+ "shape": 3,
2254
+ "slot_index": 0
2255
+ },
2256
+ {
2257
+ "name": "clip",
2258
+ "type": "CLIP",
2259
+ "links": [
2260
+ 171
2261
+ ],
2262
+ "shape": 3,
2263
+ "slot_index": 1
2264
+ },
2265
+ {
2266
+ "name": "vae",
2267
+ "type": "VAE",
2268
+ "links": [
2269
+ 172
2270
+ ],
2271
+ "shape": 3,
2272
+ "slot_index": 2
2273
+ },
2274
+ {
2275
+ "name": "positive",
2276
+ "type": "CONDITIONING",
2277
+ "links": [
2278
+ 175
2279
+ ],
2280
+ "shape": 3,
2281
+ "slot_index": 3
2282
+ },
2283
+ {
2284
+ "name": "negative",
2285
+ "type": "CONDITIONING",
2286
+ "links": [
2287
+ 176
2288
+ ],
2289
+ "shape": 3,
2290
+ "slot_index": 4
2291
+ },
2292
+ {
2293
+ "name": "bbox_detector",
2294
+ "type": "BBOX_DETECTOR",
2295
+ "links": [
2296
+ 177
2297
+ ],
2298
+ "shape": 3,
2299
+ "slot_index": 5
2300
+ },
2301
+ {
2302
+ "name": "sam_model_opt",
2303
+ "type": "SAM_MODEL",
2304
+ "links": [
2305
+ 178
2306
+ ],
2307
+ "shape": 3,
2308
+ "slot_index": 6
2309
+ },
2310
+ {
2311
+ "name": "segm_detector_opt",
2312
+ "type": "SEGM_DETECTOR",
2313
+ "links": [
2314
+ 214
2315
+ ],
2316
+ "shape": 3,
2317
+ "slot_index": 7
2318
+ }
2319
+ ],
2320
+ "properties": {
2321
+ "Node name for S&R": "FromDetailerPipe"
2322
+ }
2323
+ },
2324
+ {
2325
+ "id": 73,
2326
+ "type": "DetailerForEachDebug",
2327
+ "pos": [
2328
+ 5603,
2329
+ 2282
2330
+ ],
2331
+ "size": {
2332
+ "0": 315,
2333
+ "1": 678
2334
+ },
2335
+ "flags": {},
2336
+ "order": 36,
2337
+ "mode": 0,
2338
+ "inputs": [
2339
+ {
2340
+ "name": "image",
2341
+ "type": "IMAGE",
2342
+ "link": 159
2343
+ },
2344
+ {
2345
+ "name": "segs",
2346
+ "type": "SEGS",
2347
+ "link": 160
2348
+ },
2349
+ {
2350
+ "name": "model",
2351
+ "type": "MODEL",
2352
+ "link": 161
2353
+ },
2354
+ {
2355
+ "name": "clip",
2356
+ "type": "CLIP",
2357
+ "link": 162
2358
+ },
2359
+ {
2360
+ "name": "vae",
2361
+ "type": "VAE",
2362
+ "link": 163
2363
+ },
2364
+ {
2365
+ "name": "positive",
2366
+ "type": "CONDITIONING",
2367
+ "link": 164
2368
+ },
2369
+ {
2370
+ "name": "negative",
2371
+ "type": "CONDITIONING",
2372
+ "link": 165
2373
+ }
2374
+ ],
2375
+ "outputs": [
2376
+ {
2377
+ "name": "image",
2378
+ "type": "IMAGE",
2379
+ "links": [
2380
+ 166
2381
+ ],
2382
+ "shape": 3,
2383
+ "slot_index": 0
2384
+ },
2385
+ {
2386
+ "name": "cropped",
2387
+ "type": "IMAGE",
2388
+ "links": [
2389
+ 167
2390
+ ],
2391
+ "shape": 6,
2392
+ "slot_index": 1
2393
+ },
2394
+ {
2395
+ "name": "cropped_refined",
2396
+ "type": "IMAGE",
2397
+ "links": [
2398
+ 168
2399
+ ],
2400
+ "shape": 6,
2401
+ "slot_index": 2
2402
+ },
2403
+ {
2404
+ "name": "cropped_refined_alpha",
2405
+ "type": "IMAGE",
2406
+ "links": null,
2407
+ "shape": 6
2408
+ }
2409
+ ],
2410
+ "properties": {
2411
+ "Node name for S&R": "DetailerForEachDebug"
2412
+ },
2413
+ "widgets_values": [
2414
+ 256,
2415
+ "bbox",
2416
+ 768,
2417
+ 225176759887640,
2418
+ "fixed",
2419
+ 20,
2420
+ 8,
2421
+ "euler",
2422
+ "normal",
2423
+ 0.5,
2424
+ 5,
2425
+ "enabled",
2426
+ "disabled"
2427
+ ]
2428
+ },
2429
+ {
2430
+ "id": 61,
2431
+ "type": "PreviewImage",
2432
+ "pos": [
2433
+ 6000,
2434
+ 2450
2435
+ ],
2436
+ "size": {
2437
+ "0": 210,
2438
+ "1": 246
2439
+ },
2440
+ "flags": {},
2441
+ "order": 40,
2442
+ "mode": 0,
2443
+ "inputs": [
2444
+ {
2445
+ "name": "images",
2446
+ "type": "IMAGE",
2447
+ "link": 167
2448
+ }
2449
+ ],
2450
+ "properties": {
2451
+ "Node name for S&R": "PreviewImage"
2452
+ }
2453
+ },
2454
+ {
2455
+ "id": 62,
2456
+ "type": "PreviewImage",
2457
+ "pos": [
2458
+ 5990,
2459
+ 2780
2460
+ ],
2461
+ "size": {
2462
+ "0": 210,
2463
+ "1": 246
2464
+ },
2465
+ "flags": {},
2466
+ "order": 41,
2467
+ "mode": 0,
2468
+ "inputs": [
2469
+ {
2470
+ "name": "images",
2471
+ "type": "IMAGE",
2472
+ "link": 168
2473
+ }
2474
+ ],
2475
+ "properties": {
2476
+ "Node name for S&R": "PreviewImage"
2477
+ }
2478
+ }
2479
+ ],
2480
+ "links": [
2481
+ [
2482
+ 1,
2483
+ 4,
2484
+ 0,
2485
+ 3,
2486
+ 0,
2487
+ "MODEL"
2488
+ ],
2489
+ [
2490
+ 2,
2491
+ 5,
2492
+ 0,
2493
+ 3,
2494
+ 3,
2495
+ "LATENT"
2496
+ ],
2497
+ [
2498
+ 3,
2499
+ 4,
2500
+ 1,
2501
+ 6,
2502
+ 0,
2503
+ "CLIP"
2504
+ ],
2505
+ [
2506
+ 4,
2507
+ 6,
2508
+ 0,
2509
+ 3,
2510
+ 1,
2511
+ "CONDITIONING"
2512
+ ],
2513
+ [
2514
+ 5,
2515
+ 4,
2516
+ 1,
2517
+ 7,
2518
+ 0,
2519
+ "CLIP"
2520
+ ],
2521
+ [
2522
+ 6,
2523
+ 7,
2524
+ 0,
2525
+ 3,
2526
+ 2,
2527
+ "CONDITIONING"
2528
+ ],
2529
+ [
2530
+ 7,
2531
+ 3,
2532
+ 0,
2533
+ 8,
2534
+ 0,
2535
+ "LATENT"
2536
+ ],
2537
+ [
2538
+ 8,
2539
+ 4,
2540
+ 2,
2541
+ 8,
2542
+ 1,
2543
+ "VAE"
2544
+ ],
2545
+ [
2546
+ 10,
2547
+ 8,
2548
+ 0,
2549
+ 10,
2550
+ 0,
2551
+ "IMAGE"
2552
+ ],
2553
+ [
2554
+ 17,
2555
+ 19,
2556
+ 0,
2557
+ 22,
2558
+ 0,
2559
+ "BASIC_PIPE"
2560
+ ],
2561
+ [
2562
+ 19,
2563
+ 24,
2564
+ 0,
2565
+ 22,
2566
+ 2,
2567
+ "SAM_MODEL"
2568
+ ],
2569
+ [
2570
+ 33,
2571
+ 24,
2572
+ 0,
2573
+ 32,
2574
+ 2,
2575
+ "SAM_MODEL"
2576
+ ],
2577
+ [
2578
+ 34,
2579
+ 19,
2580
+ 0,
2581
+ 32,
2582
+ 0,
2583
+ "BASIC_PIPE"
2584
+ ],
2585
+ [
2586
+ 36,
2587
+ 32,
2588
+ 0,
2589
+ 34,
2590
+ 0,
2591
+ "DETAILER_PIPE"
2592
+ ],
2593
+ [
2594
+ 59,
2595
+ 36,
2596
+ 0,
2597
+ 37,
2598
+ 0,
2599
+ "IMAGE"
2600
+ ],
2601
+ [
2602
+ 61,
2603
+ 38,
2604
+ 0,
2605
+ 39,
2606
+ 0,
2607
+ "MODEL"
2608
+ ],
2609
+ [
2610
+ 62,
2611
+ 38,
2612
+ 1,
2613
+ 39,
2614
+ 1,
2615
+ "CLIP"
2616
+ ],
2617
+ [
2618
+ 65,
2619
+ 38,
2620
+ 2,
2621
+ 39,
2622
+ 2,
2623
+ "VAE"
2624
+ ],
2625
+ [
2626
+ 66,
2627
+ 38,
2628
+ 3,
2629
+ 39,
2630
+ 3,
2631
+ "CONDITIONING"
2632
+ ],
2633
+ [
2634
+ 67,
2635
+ 38,
2636
+ 4,
2637
+ 39,
2638
+ 4,
2639
+ "CONDITIONING"
2640
+ ],
2641
+ [
2642
+ 68,
2643
+ 38,
2644
+ 5,
2645
+ 39,
2646
+ 5,
2647
+ "BBOX_DETECTOR"
2648
+ ],
2649
+ [
2650
+ 69,
2651
+ 38,
2652
+ 6,
2653
+ 39,
2654
+ 6,
2655
+ "SAM_MODEL"
2656
+ ],
2657
+ [
2658
+ 75,
2659
+ 43,
2660
+ 0,
2661
+ 44,
2662
+ 0,
2663
+ "IMAGE"
2664
+ ],
2665
+ [
2666
+ 77,
2667
+ 45,
2668
+ 0,
2669
+ 46,
2670
+ 0,
2671
+ "DETAILER_PIPE"
2672
+ ],
2673
+ [
2674
+ 82,
2675
+ 45,
2676
+ 0,
2677
+ 50,
2678
+ 0,
2679
+ "DETAILER_PIPE"
2680
+ ],
2681
+ [
2682
+ 83,
2683
+ 50,
2684
+ 6,
2685
+ 51,
2686
+ 0,
2687
+ "SAM_MODEL"
2688
+ ],
2689
+ [
2690
+ 85,
2691
+ 50,
2692
+ 5,
2693
+ 52,
2694
+ 0,
2695
+ "BBOX_DETECTOR"
2696
+ ],
2697
+ [
2698
+ 87,
2699
+ 52,
2700
+ 0,
2701
+ 51,
2702
+ 1,
2703
+ "SEGS"
2704
+ ],
2705
+ [
2706
+ 88,
2707
+ 51,
2708
+ 0,
2709
+ 53,
2710
+ 0,
2711
+ "MASK"
2712
+ ],
2713
+ [
2714
+ 137,
2715
+ 49,
2716
+ 0,
2717
+ 69,
2718
+ 0,
2719
+ "IMAGE"
2720
+ ],
2721
+ [
2722
+ 138,
2723
+ 53,
2724
+ 0,
2725
+ 69,
2726
+ 1,
2727
+ "SEGS"
2728
+ ],
2729
+ [
2730
+ 139,
2731
+ 50,
2732
+ 0,
2733
+ 69,
2734
+ 2,
2735
+ "MODEL"
2736
+ ],
2737
+ [
2738
+ 140,
2739
+ 50,
2740
+ 1,
2741
+ 69,
2742
+ 3,
2743
+ "CLIP"
2744
+ ],
2745
+ [
2746
+ 141,
2747
+ 50,
2748
+ 2,
2749
+ 69,
2750
+ 4,
2751
+ "VAE"
2752
+ ],
2753
+ [
2754
+ 142,
2755
+ 50,
2756
+ 3,
2757
+ 69,
2758
+ 5,
2759
+ "CONDITIONING"
2760
+ ],
2761
+ [
2762
+ 143,
2763
+ 50,
2764
+ 4,
2765
+ 69,
2766
+ 6,
2767
+ "CONDITIONING"
2768
+ ],
2769
+ [
2770
+ 144,
2771
+ 69,
2772
+ 0,
2773
+ 57,
2774
+ 0,
2775
+ "IMAGE"
2776
+ ],
2777
+ [
2778
+ 153,
2779
+ 49,
2780
+ 0,
2781
+ 72,
2782
+ 0,
2783
+ "IMAGE"
2784
+ ],
2785
+ [
2786
+ 154,
2787
+ 53,
2788
+ 0,
2789
+ 72,
2790
+ 1,
2791
+ "SEGS"
2792
+ ],
2793
+ [
2794
+ 155,
2795
+ 46,
2796
+ 0,
2797
+ 72,
2798
+ 2,
2799
+ "BASIC_PIPE"
2800
+ ],
2801
+ [
2802
+ 156,
2803
+ 72,
2804
+ 0,
2805
+ 64,
2806
+ 0,
2807
+ "IMAGE"
2808
+ ],
2809
+ [
2810
+ 157,
2811
+ 72,
2812
+ 1,
2813
+ 65,
2814
+ 0,
2815
+ "IMAGE"
2816
+ ],
2817
+ [
2818
+ 158,
2819
+ 72,
2820
+ 2,
2821
+ 66,
2822
+ 0,
2823
+ "IMAGE"
2824
+ ],
2825
+ [
2826
+ 159,
2827
+ 49,
2828
+ 0,
2829
+ 73,
2830
+ 0,
2831
+ "IMAGE"
2832
+ ],
2833
+ [
2834
+ 160,
2835
+ 52,
2836
+ 0,
2837
+ 73,
2838
+ 1,
2839
+ "SEGS"
2840
+ ],
2841
+ [
2842
+ 161,
2843
+ 50,
2844
+ 0,
2845
+ 73,
2846
+ 2,
2847
+ "MODEL"
2848
+ ],
2849
+ [
2850
+ 162,
2851
+ 50,
2852
+ 1,
2853
+ 73,
2854
+ 3,
2855
+ "CLIP"
2856
+ ],
2857
+ [
2858
+ 163,
2859
+ 50,
2860
+ 2,
2861
+ 73,
2862
+ 4,
2863
+ "VAE"
2864
+ ],
2865
+ [
2866
+ 164,
2867
+ 50,
2868
+ 3,
2869
+ 73,
2870
+ 5,
2871
+ "CONDITIONING"
2872
+ ],
2873
+ [
2874
+ 165,
2875
+ 50,
2876
+ 4,
2877
+ 73,
2878
+ 6,
2879
+ "CONDITIONING"
2880
+ ],
2881
+ [
2882
+ 166,
2883
+ 73,
2884
+ 0,
2885
+ 60,
2886
+ 0,
2887
+ "IMAGE"
2888
+ ],
2889
+ [
2890
+ 167,
2891
+ 73,
2892
+ 1,
2893
+ 61,
2894
+ 0,
2895
+ "IMAGE"
2896
+ ],
2897
+ [
2898
+ 168,
2899
+ 73,
2900
+ 2,
2901
+ 62,
2902
+ 0,
2903
+ "IMAGE"
2904
+ ],
2905
+ [
2906
+ 169,
2907
+ 10,
2908
+ 0,
2909
+ 74,
2910
+ 0,
2911
+ "IMAGE"
2912
+ ],
2913
+ [
2914
+ 170,
2915
+ 34,
2916
+ 0,
2917
+ 74,
2918
+ 1,
2919
+ "MODEL"
2920
+ ],
2921
+ [
2922
+ 171,
2923
+ 34,
2924
+ 1,
2925
+ 74,
2926
+ 2,
2927
+ "CLIP"
2928
+ ],
2929
+ [
2930
+ 172,
2931
+ 34,
2932
+ 2,
2933
+ 74,
2934
+ 3,
2935
+ "VAE"
2936
+ ],
2937
+ [
2938
+ 175,
2939
+ 34,
2940
+ 3,
2941
+ 74,
2942
+ 4,
2943
+ "CONDITIONING"
2944
+ ],
2945
+ [
2946
+ 176,
2947
+ 34,
2948
+ 4,
2949
+ 74,
2950
+ 5,
2951
+ "CONDITIONING"
2952
+ ],
2953
+ [
2954
+ 177,
2955
+ 34,
2956
+ 5,
2957
+ 74,
2958
+ 6,
2959
+ "BBOX_DETECTOR"
2960
+ ],
2961
+ [
2962
+ 178,
2963
+ 34,
2964
+ 6,
2965
+ 74,
2966
+ 7,
2967
+ "SAM_MODEL"
2968
+ ],
2969
+ [
2970
+ 179,
2971
+ 74,
2972
+ 0,
2973
+ 30,
2974
+ 0,
2975
+ "IMAGE"
2976
+ ],
2977
+ [
2978
+ 180,
2979
+ 74,
2980
+ 1,
2981
+ 27,
2982
+ 0,
2983
+ "IMAGE"
2984
+ ],
2985
+ [
2986
+ 181,
2987
+ 74,
2988
+ 2,
2989
+ 75,
2990
+ 0,
2991
+ "IMAGE"
2992
+ ],
2993
+ [
2994
+ 182,
2995
+ 74,
2996
+ 3,
2997
+ 36,
2998
+ 0,
2999
+ "MASK"
3000
+ ],
3001
+ [
3002
+ 183,
3003
+ 10,
3004
+ 0,
3005
+ 77,
3006
+ 0,
3007
+ "*"
3008
+ ],
3009
+ [
3010
+ 184,
3011
+ 77,
3012
+ 0,
3013
+ 76,
3014
+ 0,
3015
+ "IMAGE"
3016
+ ],
3017
+ [
3018
+ 186,
3019
+ 76,
3020
+ 0,
3021
+ 41,
3022
+ 0,
3023
+ "IMAGE"
3024
+ ],
3025
+ [
3026
+ 187,
3027
+ 76,
3028
+ 1,
3029
+ 42,
3030
+ 0,
3031
+ "IMAGE"
3032
+ ],
3033
+ [
3034
+ 188,
3035
+ 76,
3036
+ 0,
3037
+ 52,
3038
+ 1,
3039
+ "IMAGE"
3040
+ ],
3041
+ [
3042
+ 189,
3043
+ 76,
3044
+ 2,
3045
+ 78,
3046
+ 0,
3047
+ "IMAGE"
3048
+ ],
3049
+ [
3050
+ 190,
3051
+ 76,
3052
+ 3,
3053
+ 43,
3054
+ 0,
3055
+ "MASK"
3056
+ ],
3057
+ [
3058
+ 191,
3059
+ 76,
3060
+ 4,
3061
+ 45,
3062
+ 0,
3063
+ "DETAILER_PIPE"
3064
+ ],
3065
+ [
3066
+ 193,
3067
+ 74,
3068
+ 4,
3069
+ 38,
3070
+ 0,
3071
+ "DETAILER_PIPE"
3072
+ ],
3073
+ [
3074
+ 194,
3075
+ 49,
3076
+ 0,
3077
+ 81,
3078
+ 0,
3079
+ "IMAGE"
3080
+ ],
3081
+ [
3082
+ 195,
3083
+ 53,
3084
+ 0,
3085
+ 81,
3086
+ 1,
3087
+ "SEGS"
3088
+ ],
3089
+ [
3090
+ 196,
3091
+ 46,
3092
+ 0,
3093
+ 81,
3094
+ 2,
3095
+ "BASIC_PIPE"
3096
+ ],
3097
+ [
3098
+ 197,
3099
+ 81,
3100
+ 0,
3101
+ 54,
3102
+ 0,
3103
+ "IMAGE"
3104
+ ],
3105
+ [
3106
+ 200,
3107
+ 72,
3108
+ 3,
3109
+ 82,
3110
+ 0,
3111
+ "IMAGE"
3112
+ ],
3113
+ [
3114
+ 201,
3115
+ 83,
3116
+ 0,
3117
+ 22,
3118
+ 1,
3119
+ "BBOX_DETECTOR"
3120
+ ],
3121
+ [
3122
+ 202,
3123
+ 83,
3124
+ 0,
3125
+ 32,
3126
+ 1,
3127
+ "BBOX_DETECTOR"
3128
+ ],
3129
+ [
3130
+ 203,
3131
+ 38,
3132
+ 7,
3133
+ 39,
3134
+ 7,
3135
+ "SEGM_DETECTOR"
3136
+ ],
3137
+ [
3138
+ 204,
3139
+ 50,
3140
+ 7,
3141
+ 84,
3142
+ 0,
3143
+ "SEGM_DETECTOR"
3144
+ ],
3145
+ [
3146
+ 205,
3147
+ 77,
3148
+ 0,
3149
+ 51,
3150
+ 2,
3151
+ "IMAGE"
3152
+ ],
3153
+ [
3154
+ 206,
3155
+ 77,
3156
+ 0,
3157
+ 84,
3158
+ 1,
3159
+ "IMAGE"
3160
+ ],
3161
+ [
3162
+ 207,
3163
+ 84,
3164
+ 0,
3165
+ 85,
3166
+ 0,
3167
+ "SEGS"
3168
+ ],
3169
+ [
3170
+ 208,
3171
+ 77,
3172
+ 0,
3173
+ 85,
3174
+ 1,
3175
+ "IMAGE"
3176
+ ],
3177
+ [
3178
+ 209,
3179
+ 85,
3180
+ 0,
3181
+ 86,
3182
+ 0,
3183
+ "IMAGE"
3184
+ ],
3185
+ [
3186
+ 210,
3187
+ 39,
3188
+ 0,
3189
+ 76,
3190
+ 1,
3191
+ "DETAILER_PIPE"
3192
+ ],
3193
+ [
3194
+ 211,
3195
+ 74,
3196
+ 0,
3197
+ 49,
3198
+ 0,
3199
+ "*"
3200
+ ],
3201
+ [
3202
+ 212,
3203
+ 87,
3204
+ 1,
3205
+ 22,
3206
+ 3,
3207
+ "SEGM_DETECTOR"
3208
+ ],
3209
+ [
3210
+ 213,
3211
+ 87,
3212
+ 1,
3213
+ 32,
3214
+ 3,
3215
+ "SEGM_DETECTOR"
3216
+ ],
3217
+ [
3218
+ 214,
3219
+ 34,
3220
+ 7,
3221
+ 74,
3222
+ 8,
3223
+ "SEGM_DETECTOR"
3224
+ ]
3225
+ ],
3226
+ "groups": [],
3227
+ "config": {},
3228
+ "extra": {},
3229
+ "version": 0.4
3230
+ }
ComfyUI-Impact-Pack/test/loop-test.json ADDED
@@ -0,0 +1,1114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "last_node_id": 43,
3
+ "last_link_id": 49,
4
+ "nodes": [
5
+ {
6
+ "id": 7,
7
+ "type": "CLIPTextEncode",
8
+ "pos": [
9
+ 413,
10
+ 389
11
+ ],
12
+ "size": {
13
+ "0": 425.27801513671875,
14
+ "1": 180.6060791015625
15
+ },
16
+ "flags": {},
17
+ "order": 8,
18
+ "mode": 0,
19
+ "inputs": [
20
+ {
21
+ "name": "clip",
22
+ "type": "CLIP",
23
+ "link": 5
24
+ }
25
+ ],
26
+ "outputs": [
27
+ {
28
+ "name": "CONDITIONING",
29
+ "type": "CONDITIONING",
30
+ "links": [
31
+ 6
32
+ ],
33
+ "slot_index": 0
34
+ }
35
+ ],
36
+ "properties": {
37
+ "Node name for S&R": "CLIPTextEncode"
38
+ },
39
+ "widgets_values": [
40
+ "text, watermark"
41
+ ]
42
+ },
43
+ {
44
+ "id": 6,
45
+ "type": "CLIPTextEncode",
46
+ "pos": [
47
+ 415,
48
+ 186
49
+ ],
50
+ "size": {
51
+ "0": 422.84503173828125,
52
+ "1": 164.31304931640625
53
+ },
54
+ "flags": {},
55
+ "order": 7,
56
+ "mode": 0,
57
+ "inputs": [
58
+ {
59
+ "name": "clip",
60
+ "type": "CLIP",
61
+ "link": 3
62
+ }
63
+ ],
64
+ "outputs": [
65
+ {
66
+ "name": "CONDITIONING",
67
+ "type": "CONDITIONING",
68
+ "links": [
69
+ 4
70
+ ],
71
+ "slot_index": 0
72
+ }
73
+ ],
74
+ "properties": {
75
+ "Node name for S&R": "CLIPTextEncode"
76
+ },
77
+ "widgets_values": [
78
+ "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,"
79
+ ]
80
+ },
81
+ {
82
+ "id": 9,
83
+ "type": "SaveImage",
84
+ "pos": [
85
+ 1451,
86
+ 189
87
+ ],
88
+ "size": {
89
+ "0": 210,
90
+ "1": 270
91
+ },
92
+ "flags": {},
93
+ "order": 11,
94
+ "mode": 0,
95
+ "inputs": [
96
+ {
97
+ "name": "images",
98
+ "type": "IMAGE",
99
+ "link": 9
100
+ }
101
+ ],
102
+ "properties": {},
103
+ "widgets_values": [
104
+ "ComfyUI"
105
+ ]
106
+ },
107
+ {
108
+ "id": 4,
109
+ "type": "CheckpointLoaderSimple",
110
+ "pos": [
111
+ 26,
112
+ 474
113
+ ],
114
+ "size": {
115
+ "0": 315,
116
+ "1": 98
117
+ },
118
+ "flags": {},
119
+ "order": 0,
120
+ "mode": 0,
121
+ "outputs": [
122
+ {
123
+ "name": "MODEL",
124
+ "type": "MODEL",
125
+ "links": [
126
+ 1
127
+ ],
128
+ "slot_index": 0
129
+ },
130
+ {
131
+ "name": "CLIP",
132
+ "type": "CLIP",
133
+ "links": [
134
+ 3,
135
+ 5
136
+ ],
137
+ "slot_index": 1
138
+ },
139
+ {
140
+ "name": "VAE",
141
+ "type": "VAE",
142
+ "links": [
143
+ 8
144
+ ],
145
+ "slot_index": 2
146
+ }
147
+ ],
148
+ "properties": {
149
+ "Node name for S&R": "CheckpointLoaderSimple"
150
+ },
151
+ "widgets_values": [
152
+ "V07_v07.safetensors"
153
+ ]
154
+ },
155
+ {
156
+ "id": 8,
157
+ "type": "VAEDecode",
158
+ "pos": [
159
+ 1209,
160
+ 188
161
+ ],
162
+ "size": {
163
+ "0": 210,
164
+ "1": 46
165
+ },
166
+ "flags": {},
167
+ "order": 10,
168
+ "mode": 0,
169
+ "inputs": [
170
+ {
171
+ "name": "samples",
172
+ "type": "LATENT",
173
+ "link": 7
174
+ },
175
+ {
176
+ "name": "vae",
177
+ "type": "VAE",
178
+ "link": 8
179
+ }
180
+ ],
181
+ "outputs": [
182
+ {
183
+ "name": "IMAGE",
184
+ "type": "IMAGE",
185
+ "links": [
186
+ 9,
187
+ 12
188
+ ],
189
+ "slot_index": 0
190
+ }
191
+ ],
192
+ "properties": {
193
+ "Node name for S&R": "VAEDecode"
194
+ }
195
+ },
196
+ {
197
+ "id": 19,
198
+ "type": "ImpactMinMax",
199
+ "pos": [
200
+ 2480,
201
+ 1160
202
+ ],
203
+ "size": {
204
+ "0": 210,
205
+ "1": 78
206
+ },
207
+ "flags": {},
208
+ "order": 16,
209
+ "mode": 0,
210
+ "inputs": [
211
+ {
212
+ "name": "a",
213
+ "type": "*",
214
+ "link": 24
215
+ },
216
+ {
217
+ "name": "b",
218
+ "type": "*",
219
+ "link": 25,
220
+ "slot_index": 1
221
+ }
222
+ ],
223
+ "outputs": [
224
+ {
225
+ "name": "INT",
226
+ "type": "INT",
227
+ "links": [
228
+ 34
229
+ ],
230
+ "shape": 3,
231
+ "slot_index": 0
232
+ }
233
+ ],
234
+ "properties": {
235
+ "Node name for S&R": "ImpactMinMax"
236
+ },
237
+ "widgets_values": [
238
+ false
239
+ ]
240
+ },
241
+ {
242
+ "id": 15,
243
+ "type": "ImpactValueSender",
244
+ "pos": [
245
+ 3520,
246
+ 1140
247
+ ],
248
+ "size": {
249
+ "0": 210,
250
+ "1": 58
251
+ },
252
+ "flags": {},
253
+ "order": 20,
254
+ "mode": 0,
255
+ "inputs": [
256
+ {
257
+ "name": "value",
258
+ "type": "*",
259
+ "link": 39
260
+ }
261
+ ],
262
+ "properties": {
263
+ "Node name for S&R": "ImpactValueSender"
264
+ },
265
+ "widgets_values": [
266
+ 0
267
+ ]
268
+ },
269
+ {
270
+ "id": 11,
271
+ "type": "ImageMaskSwitch",
272
+ "pos": [
273
+ 1297,
274
+ 893
275
+ ],
276
+ "size": {
277
+ "0": 315,
278
+ "1": 198
279
+ },
280
+ "flags": {},
281
+ "order": 12,
282
+ "mode": 0,
283
+ "inputs": [
284
+ {
285
+ "name": "images1",
286
+ "type": "IMAGE",
287
+ "link": 12
288
+ },
289
+ {
290
+ "name": "mask1_opt",
291
+ "type": "MASK",
292
+ "link": null
293
+ },
294
+ {
295
+ "name": "images2_opt",
296
+ "type": "IMAGE",
297
+ "link": 11
298
+ },
299
+ {
300
+ "name": "mask2_opt",
301
+ "type": "MASK",
302
+ "link": null
303
+ },
304
+ {
305
+ "name": "images3_opt",
306
+ "type": "IMAGE",
307
+ "link": null
308
+ },
309
+ {
310
+ "name": "mask3_opt",
311
+ "type": "MASK",
312
+ "link": null
313
+ },
314
+ {
315
+ "name": "images4_opt",
316
+ "type": "IMAGE",
317
+ "link": null
318
+ },
319
+ {
320
+ "name": "mask4_opt",
321
+ "type": "MASK",
322
+ "link": null
323
+ },
324
+ {
325
+ "name": "select",
326
+ "type": "INT",
327
+ "link": 43,
328
+ "widget": {
329
+ "name": "select",
330
+ "config": [
331
+ "INT",
332
+ {
333
+ "default": 1,
334
+ "min": 1,
335
+ "max": 4,
336
+ "step": 1
337
+ }
338
+ ]
339
+ },
340
+ "slot_index": 8
341
+ }
342
+ ],
343
+ "outputs": [
344
+ {
345
+ "name": "IMAGE",
346
+ "type": "IMAGE",
347
+ "links": [
348
+ 13
349
+ ],
350
+ "shape": 3,
351
+ "slot_index": 0
352
+ },
353
+ {
354
+ "name": "MASK",
355
+ "type": "MASK",
356
+ "links": null,
357
+ "shape": 3
358
+ }
359
+ ],
360
+ "properties": {
361
+ "Node name for S&R": "ImageMaskSwitch"
362
+ },
363
+ "widgets_values": [
364
+ 1
365
+ ]
366
+ },
367
+ {
368
+ "id": 34,
369
+ "type": "ImpactConditionalBranch",
370
+ "pos": [
371
+ 3264,
372
+ 1006
373
+ ],
374
+ "size": {
375
+ "0": 210,
376
+ "1": 66
377
+ },
378
+ "flags": {},
379
+ "order": 18,
380
+ "mode": 0,
381
+ "inputs": [
382
+ {
383
+ "name": "cond",
384
+ "type": "BOOLEAN",
385
+ "link": 36,
386
+ "slot_index": 0
387
+ },
388
+ {
389
+ "name": "tt_value",
390
+ "type": "*",
391
+ "link": 37
392
+ },
393
+ {
394
+ "name": "ff_value",
395
+ "type": "*",
396
+ "link": 38
397
+ }
398
+ ],
399
+ "outputs": [
400
+ {
401
+ "name": "*",
402
+ "type": "*",
403
+ "links": [
404
+ 39
405
+ ],
406
+ "shape": 3,
407
+ "slot_index": 0
408
+ }
409
+ ],
410
+ "properties": {
411
+ "Node name for S&R": "ImpactConditionalBranch"
412
+ }
413
+ },
414
+ {
415
+ "id": 33,
416
+ "type": "ImpactInt",
417
+ "pos": [
418
+ 3010,
419
+ 930
420
+ ],
421
+ "size": {
422
+ "0": 210,
423
+ "1": 58
424
+ },
425
+ "flags": {},
426
+ "order": 1,
427
+ "mode": 0,
428
+ "outputs": [
429
+ {
430
+ "name": "INT",
431
+ "type": "INT",
432
+ "links": [
433
+ 37
434
+ ],
435
+ "shape": 3,
436
+ "slot_index": 0
437
+ }
438
+ ],
439
+ "properties": {
440
+ "Node name for S&R": "ImpactInt"
441
+ },
442
+ "widgets_values": [
443
+ 2
444
+ ]
445
+ },
446
+ {
447
+ "id": 35,
448
+ "type": "ImpactInt",
449
+ "pos": [
450
+ 3000,
451
+ 1140
452
+ ],
453
+ "size": {
454
+ "0": 210,
455
+ "1": 58
456
+ },
457
+ "flags": {},
458
+ "order": 2,
459
+ "mode": 0,
460
+ "outputs": [
461
+ {
462
+ "name": "INT",
463
+ "type": "INT",
464
+ "links": [
465
+ 38
466
+ ],
467
+ "shape": 3,
468
+ "slot_index": 0
469
+ }
470
+ ],
471
+ "properties": {
472
+ "Node name for S&R": "ImpactInt"
473
+ },
474
+ "widgets_values": [
475
+ 1
476
+ ]
477
+ },
478
+ {
479
+ "id": 5,
480
+ "type": "EmptyLatentImage",
481
+ "pos": [
482
+ 473,
483
+ 609
484
+ ],
485
+ "size": {
486
+ "0": 315,
487
+ "1": 106
488
+ },
489
+ "flags": {},
490
+ "order": 3,
491
+ "mode": 0,
492
+ "outputs": [
493
+ {
494
+ "name": "LATENT",
495
+ "type": "LATENT",
496
+ "links": [
497
+ 2
498
+ ],
499
+ "slot_index": 0
500
+ }
501
+ ],
502
+ "properties": {
503
+ "Node name for S&R": "EmptyLatentImage"
504
+ },
505
+ "widgets_values": [
506
+ 256,
507
+ 256,
508
+ 1
509
+ ]
510
+ },
511
+ {
512
+ "id": 13,
513
+ "type": "ImageScaleBy",
514
+ "pos": [
515
+ 1730,
516
+ 920
517
+ ],
518
+ "size": {
519
+ "0": 210,
520
+ "1": 82
521
+ },
522
+ "flags": {},
523
+ "order": 13,
524
+ "mode": 0,
525
+ "inputs": [
526
+ {
527
+ "name": "image",
528
+ "type": "IMAGE",
529
+ "link": 13
530
+ }
531
+ ],
532
+ "outputs": [
533
+ {
534
+ "name": "IMAGE",
535
+ "type": "IMAGE",
536
+ "links": [
537
+ 23,
538
+ 40
539
+ ],
540
+ "shape": 3,
541
+ "slot_index": 0
542
+ }
543
+ ],
544
+ "properties": {
545
+ "Node name for S&R": "ImageScaleBy"
546
+ },
547
+ "widgets_values": [
548
+ "nearest-exact",
549
+ 1.2
550
+ ]
551
+ },
552
+ {
553
+ "id": 41,
554
+ "type": "ImpactConditionalStopIteration",
555
+ "pos": [
556
+ 3607,
557
+ 774
558
+ ],
559
+ "size": {
560
+ "0": 252,
561
+ "1": 26
562
+ },
563
+ "flags": {},
564
+ "order": 21,
565
+ "mode": 0,
566
+ "inputs": [
567
+ {
568
+ "name": "cond",
569
+ "type": "BOOLEAN",
570
+ "link": 49
571
+ }
572
+ ],
573
+ "properties": {
574
+ "Node name for S&R": "ImpactConditionalStopIteration"
575
+ }
576
+ },
577
+ {
578
+ "id": 32,
579
+ "type": "ImpactCompare",
580
+ "pos": [
581
+ 2760,
582
+ 1040
583
+ ],
584
+ "size": {
585
+ "0": 210,
586
+ "1": 78
587
+ },
588
+ "flags": {},
589
+ "order": 17,
590
+ "mode": 0,
591
+ "inputs": [
592
+ {
593
+ "name": "a",
594
+ "type": "*",
595
+ "link": 47
596
+ },
597
+ {
598
+ "name": "b",
599
+ "type": "*",
600
+ "link": 34,
601
+ "slot_index": 1
602
+ }
603
+ ],
604
+ "outputs": [
605
+ {
606
+ "name": "BOOLEAN",
607
+ "type": "BOOLEAN",
608
+ "links": [
609
+ 36,
610
+ 48
611
+ ],
612
+ "shape": 3,
613
+ "slot_index": 0
614
+ }
615
+ ],
616
+ "properties": {
617
+ "Node name for S&R": "ImpactCompare"
618
+ },
619
+ "widgets_values": [
620
+ "a > b"
621
+ ]
622
+ },
623
+ {
624
+ "id": 43,
625
+ "type": "ImpactNeg",
626
+ "pos": [
627
+ 3210.6906854687495,
628
+ 698.6871511123657
629
+ ],
630
+ "size": {
631
+ "0": 210,
632
+ "1": 26
633
+ },
634
+ "flags": {},
635
+ "order": 19,
636
+ "mode": 0,
637
+ "inputs": [
638
+ {
639
+ "name": "value",
640
+ "type": "BOOLEAN",
641
+ "link": 48
642
+ }
643
+ ],
644
+ "outputs": [
645
+ {
646
+ "name": "BOOLEAN",
647
+ "type": "BOOLEAN",
648
+ "links": [
649
+ 49
650
+ ],
651
+ "shape": 3,
652
+ "slot_index": 0
653
+ }
654
+ ],
655
+ "properties": {
656
+ "Node name for S&R": "ImpactNeg"
657
+ }
658
+ },
659
+ {
660
+ "id": 10,
661
+ "type": "ImageReceiver",
662
+ "pos": [
663
+ 641,
664
+ 932
665
+ ],
666
+ "size": {
667
+ "0": 315,
668
+ "1": 200
669
+ },
670
+ "flags": {},
671
+ "order": 4,
672
+ "mode": 0,
673
+ "outputs": [
674
+ {
675
+ "name": "IMAGE",
676
+ "type": "IMAGE",
677
+ "links": [
678
+ 11
679
+ ],
680
+ "shape": 3,
681
+ "slot_index": 0
682
+ },
683
+ {
684
+ "name": "MASK",
685
+ "type": "MASK",
686
+ "links": null,
687
+ "shape": 3
688
+ }
689
+ ],
690
+ "properties": {
691
+ "Node name for S&R": "ImageReceiver"
692
+ },
693
+ "widgets_values": [
694
+ "ImgSender_temp_vxhgs_00001_.png [temp]",
695
+ 0
696
+ ]
697
+ },
698
+ {
699
+ "id": 24,
700
+ "type": "ImpactImageInfo",
701
+ "pos": [
702
+ 2077,
703
+ 1117
704
+ ],
705
+ "size": {
706
+ "0": 210,
707
+ "1": 86
708
+ },
709
+ "flags": {},
710
+ "order": 14,
711
+ "mode": 0,
712
+ "inputs": [
713
+ {
714
+ "name": "value",
715
+ "type": "IMAGE",
716
+ "link": 23
717
+ }
718
+ ],
719
+ "outputs": [
720
+ {
721
+ "name": "batch",
722
+ "type": "INT",
723
+ "links": null,
724
+ "shape": 3
725
+ },
726
+ {
727
+ "name": "height",
728
+ "type": "INT",
729
+ "links": [
730
+ 24
731
+ ],
732
+ "shape": 3,
733
+ "slot_index": 1
734
+ },
735
+ {
736
+ "name": "width",
737
+ "type": "INT",
738
+ "links": [
739
+ 25
740
+ ],
741
+ "shape": 3
742
+ },
743
+ {
744
+ "name": "channel",
745
+ "type": "INT",
746
+ "links": null,
747
+ "shape": 3
748
+ }
749
+ ],
750
+ "properties": {
751
+ "Node name for S&R": "ImpactImageInfo"
752
+ }
753
+ },
754
+ {
755
+ "id": 42,
756
+ "type": "ImpactInt",
757
+ "pos": [
758
+ 2483,
759
+ 983
760
+ ],
761
+ "size": {
762
+ "0": 210,
763
+ "1": 58
764
+ },
765
+ "flags": {},
766
+ "order": 5,
767
+ "mode": 0,
768
+ "outputs": [
769
+ {
770
+ "name": "INT",
771
+ "type": "INT",
772
+ "links": [
773
+ 47
774
+ ],
775
+ "shape": 3,
776
+ "slot_index": 0
777
+ }
778
+ ],
779
+ "properties": {
780
+ "Node name for S&R": "ImpactInt"
781
+ },
782
+ "widgets_values": [
783
+ 768
784
+ ]
785
+ },
786
+ {
787
+ "id": 39,
788
+ "type": "ImpactValueReceiver",
789
+ "pos": [
790
+ 1021,
791
+ 1137
792
+ ],
793
+ "size": {
794
+ "0": 210,
795
+ "1": 106
796
+ },
797
+ "flags": {},
798
+ "order": 6,
799
+ "mode": 0,
800
+ "outputs": [
801
+ {
802
+ "name": "*",
803
+ "type": "*",
804
+ "links": [
805
+ 43
806
+ ],
807
+ "shape": 3
808
+ }
809
+ ],
810
+ "properties": {
811
+ "Node name for S&R": "ImpactValueReceiver"
812
+ },
813
+ "widgets_values": [
814
+ "INT",
815
+ 1,
816
+ 0
817
+ ]
818
+ },
819
+ {
820
+ "id": 3,
821
+ "type": "KSampler",
822
+ "pos": [
823
+ 872,
824
+ 217
825
+ ],
826
+ "size": {
827
+ "0": 315,
828
+ "1": 474
829
+ },
830
+ "flags": {},
831
+ "order": 9,
832
+ "mode": 0,
833
+ "inputs": [
834
+ {
835
+ "name": "model",
836
+ "type": "MODEL",
837
+ "link": 1
838
+ },
839
+ {
840
+ "name": "positive",
841
+ "type": "CONDITIONING",
842
+ "link": 4
843
+ },
844
+ {
845
+ "name": "negative",
846
+ "type": "CONDITIONING",
847
+ "link": 6
848
+ },
849
+ {
850
+ "name": "latent_image",
851
+ "type": "LATENT",
852
+ "link": 2
853
+ }
854
+ ],
855
+ "outputs": [
856
+ {
857
+ "name": "LATENT",
858
+ "type": "LATENT",
859
+ "links": [
860
+ 7
861
+ ],
862
+ "slot_index": 0
863
+ }
864
+ ],
865
+ "properties": {
866
+ "Node name for S&R": "KSampler"
867
+ },
868
+ "widgets_values": [
869
+ 901257808527154,
870
+ "fixed",
871
+ 5,
872
+ 8,
873
+ "euler",
874
+ "normal",
875
+ 1
876
+ ]
877
+ },
878
+ {
879
+ "id": 36,
880
+ "type": "ImageSender",
881
+ "pos": [
882
+ 2046,
883
+ -116
884
+ ],
885
+ "size": [
886
+ 914.2697004627885,
887
+ 989.0802794506753
888
+ ],
889
+ "flags": {},
890
+ "order": 15,
891
+ "mode": 0,
892
+ "inputs": [
893
+ {
894
+ "name": "images",
895
+ "type": "IMAGE",
896
+ "link": 40
897
+ }
898
+ ],
899
+ "properties": {
900
+ "Node name for S&R": "ImageSender"
901
+ },
902
+ "widgets_values": [
903
+ "ImgSender",
904
+ 0
905
+ ]
906
+ }
907
+ ],
908
+ "links": [
909
+ [
910
+ 1,
911
+ 4,
912
+ 0,
913
+ 3,
914
+ 0,
915
+ "MODEL"
916
+ ],
917
+ [
918
+ 2,
919
+ 5,
920
+ 0,
921
+ 3,
922
+ 3,
923
+ "LATENT"
924
+ ],
925
+ [
926
+ 3,
927
+ 4,
928
+ 1,
929
+ 6,
930
+ 0,
931
+ "CLIP"
932
+ ],
933
+ [
934
+ 4,
935
+ 6,
936
+ 0,
937
+ 3,
938
+ 1,
939
+ "CONDITIONING"
940
+ ],
941
+ [
942
+ 5,
943
+ 4,
944
+ 1,
945
+ 7,
946
+ 0,
947
+ "CLIP"
948
+ ],
949
+ [
950
+ 6,
951
+ 7,
952
+ 0,
953
+ 3,
954
+ 2,
955
+ "CONDITIONING"
956
+ ],
957
+ [
958
+ 7,
959
+ 3,
960
+ 0,
961
+ 8,
962
+ 0,
963
+ "LATENT"
964
+ ],
965
+ [
966
+ 8,
967
+ 4,
968
+ 2,
969
+ 8,
970
+ 1,
971
+ "VAE"
972
+ ],
973
+ [
974
+ 9,
975
+ 8,
976
+ 0,
977
+ 9,
978
+ 0,
979
+ "IMAGE"
980
+ ],
981
+ [
982
+ 11,
983
+ 10,
984
+ 0,
985
+ 11,
986
+ 2,
987
+ "IMAGE"
988
+ ],
989
+ [
990
+ 12,
991
+ 8,
992
+ 0,
993
+ 11,
994
+ 0,
995
+ "IMAGE"
996
+ ],
997
+ [
998
+ 13,
999
+ 11,
1000
+ 0,
1001
+ 13,
1002
+ 0,
1003
+ "IMAGE"
1004
+ ],
1005
+ [
1006
+ 23,
1007
+ 13,
1008
+ 0,
1009
+ 24,
1010
+ 0,
1011
+ "IMAGE"
1012
+ ],
1013
+ [
1014
+ 24,
1015
+ 24,
1016
+ 1,
1017
+ 19,
1018
+ 0,
1019
+ "*"
1020
+ ],
1021
+ [
1022
+ 25,
1023
+ 24,
1024
+ 2,
1025
+ 19,
1026
+ 1,
1027
+ "*"
1028
+ ],
1029
+ [
1030
+ 34,
1031
+ 19,
1032
+ 0,
1033
+ 32,
1034
+ 1,
1035
+ "*"
1036
+ ],
1037
+ [
1038
+ 36,
1039
+ 32,
1040
+ 0,
1041
+ 34,
1042
+ 0,
1043
+ "BOOLEAN"
1044
+ ],
1045
+ [
1046
+ 37,
1047
+ 33,
1048
+ 0,
1049
+ 34,
1050
+ 1,
1051
+ "*"
1052
+ ],
1053
+ [
1054
+ 38,
1055
+ 35,
1056
+ 0,
1057
+ 34,
1058
+ 2,
1059
+ "*"
1060
+ ],
1061
+ [
1062
+ 39,
1063
+ 34,
1064
+ 0,
1065
+ 15,
1066
+ 0,
1067
+ "*"
1068
+ ],
1069
+ [
1070
+ 40,
1071
+ 13,
1072
+ 0,
1073
+ 36,
1074
+ 0,
1075
+ "IMAGE"
1076
+ ],
1077
+ [
1078
+ 43,
1079
+ 39,
1080
+ 0,
1081
+ 11,
1082
+ 8,
1083
+ "INT"
1084
+ ],
1085
+ [
1086
+ 47,
1087
+ 42,
1088
+ 0,
1089
+ 32,
1090
+ 0,
1091
+ "*"
1092
+ ],
1093
+ [
1094
+ 48,
1095
+ 32,
1096
+ 0,
1097
+ 43,
1098
+ 0,
1099
+ "BOOLEAN"
1100
+ ],
1101
+ [
1102
+ 49,
1103
+ 43,
1104
+ 0,
1105
+ 41,
1106
+ 0,
1107
+ "BOOLEAN"
1108
+ ]
1109
+ ],
1110
+ "groups": [],
1111
+ "config": {},
1112
+ "extra": {},
1113
+ "version": 0.4
1114
+ }
ComfyUI-Impact-Pack/test/masks.json ADDED
@@ -0,0 +1,622 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "last_node_id": 38,
3
+ "last_link_id": 52,
4
+ "nodes": [
5
+ {
6
+ "id": 21,
7
+ "type": "SEGSToImageList",
8
+ "pos": [
9
+ 2160,
10
+ 970
11
+ ],
12
+ "size": {
13
+ "0": 304.79998779296875,
14
+ "1": 46
15
+ },
16
+ "flags": {},
17
+ "order": 10,
18
+ "mode": 0,
19
+ "inputs": [
20
+ {
21
+ "name": "segs",
22
+ "type": "SEGS",
23
+ "link": 41
24
+ },
25
+ {
26
+ "name": "fallback_image_opt",
27
+ "type": "IMAGE",
28
+ "link": 26,
29
+ "slot_index": 1
30
+ }
31
+ ],
32
+ "outputs": [
33
+ {
34
+ "name": "IMAGE",
35
+ "type": "IMAGE",
36
+ "links": [
37
+ 27
38
+ ],
39
+ "shape": 6,
40
+ "slot_index": 0
41
+ }
42
+ ],
43
+ "properties": {
44
+ "Node name for S&R": "SEGSToImageList"
45
+ }
46
+ },
47
+ {
48
+ "id": 5,
49
+ "type": "MaskToSEGS",
50
+ "pos": [
51
+ 1520,
52
+ 980
53
+ ],
54
+ "size": {
55
+ "0": 210,
56
+ "1": 130
57
+ },
58
+ "flags": {},
59
+ "order": 4,
60
+ "mode": 0,
61
+ "inputs": [
62
+ {
63
+ "name": "mask",
64
+ "type": "MASK",
65
+ "link": 5
66
+ }
67
+ ],
68
+ "outputs": [
69
+ {
70
+ "name": "SEGS",
71
+ "type": "SEGS",
72
+ "links": [
73
+ 35,
74
+ 46
75
+ ],
76
+ "shape": 3,
77
+ "slot_index": 0
78
+ }
79
+ ],
80
+ "properties": {
81
+ "Node name for S&R": "MaskToSEGS"
82
+ },
83
+ "widgets_values": [
84
+ "False",
85
+ 3,
86
+ "disabled",
87
+ 10
88
+ ]
89
+ },
90
+ {
91
+ "id": 36,
92
+ "type": "MasksToMaskList",
93
+ "pos": [
94
+ 2270,
95
+ 680
96
+ ],
97
+ "size": {
98
+ "0": 158.000244140625,
99
+ "1": 26
100
+ },
101
+ "flags": {},
102
+ "order": 8,
103
+ "mode": 0,
104
+ "inputs": [
105
+ {
106
+ "name": "masks",
107
+ "type": "MASKS",
108
+ "link": 51
109
+ }
110
+ ],
111
+ "outputs": [
112
+ {
113
+ "name": "MASK",
114
+ "type": "MASK",
115
+ "links": [
116
+ 52
117
+ ],
118
+ "shape": 6,
119
+ "slot_index": 0
120
+ }
121
+ ],
122
+ "properties": {
123
+ "Node name for S&R": "MasksToMaskList"
124
+ },
125
+ "color": "#223",
126
+ "bgcolor": "#335"
127
+ },
128
+ {
129
+ "id": 35,
130
+ "type": "MaskToImage",
131
+ "pos": [
132
+ 2480,
133
+ 680
134
+ ],
135
+ "size": {
136
+ "0": 176.39999389648438,
137
+ "1": 38.59991455078125
138
+ },
139
+ "flags": {},
140
+ "order": 11,
141
+ "mode": 0,
142
+ "inputs": [
143
+ {
144
+ "name": "mask",
145
+ "type": "MASK",
146
+ "link": 52
147
+ }
148
+ ],
149
+ "outputs": [
150
+ {
151
+ "name": "IMAGE",
152
+ "type": "IMAGE",
153
+ "links": [
154
+ 50
155
+ ],
156
+ "shape": 3,
157
+ "slot_index": 0
158
+ }
159
+ ],
160
+ "properties": {
161
+ "Node name for S&R": "MaskToImage"
162
+ }
163
+ },
164
+ {
165
+ "id": 28,
166
+ "type": "Segs & Mask ForEach",
167
+ "pos": [
168
+ 1800,
169
+ 980
170
+ ],
171
+ "size": {
172
+ "0": 243.60000610351562,
173
+ "1": 46
174
+ },
175
+ "flags": {},
176
+ "order": 7,
177
+ "mode": 0,
178
+ "inputs": [
179
+ {
180
+ "name": "segs",
181
+ "type": "SEGS",
182
+ "link": 35,
183
+ "slot_index": 0
184
+ },
185
+ {
186
+ "name": "masks",
187
+ "type": "MASKS",
188
+ "link": 43
189
+ }
190
+ ],
191
+ "outputs": [
192
+ {
193
+ "name": "SEGS",
194
+ "type": "SEGS",
195
+ "links": [
196
+ 41
197
+ ],
198
+ "shape": 3,
199
+ "slot_index": 0
200
+ }
201
+ ],
202
+ "properties": {
203
+ "Node name for S&R": "Segs & Mask ForEach"
204
+ }
205
+ },
206
+ {
207
+ "id": 22,
208
+ "type": "PreviewImage",
209
+ "pos": [
210
+ 2510,
211
+ 970
212
+ ],
213
+ "size": {
214
+ "0": 210,
215
+ "1": 246
216
+ },
217
+ "flags": {},
218
+ "order": 12,
219
+ "mode": 0,
220
+ "inputs": [
221
+ {
222
+ "name": "images",
223
+ "type": "IMAGE",
224
+ "link": 27
225
+ }
226
+ ],
227
+ "properties": {
228
+ "Node name for S&R": "PreviewImage"
229
+ }
230
+ },
231
+ {
232
+ "id": 4,
233
+ "type": "LoadImage",
234
+ "pos": [
235
+ 1150,
236
+ 460
237
+ ],
238
+ "size": {
239
+ "0": 315,
240
+ "1": 314
241
+ },
242
+ "flags": {},
243
+ "order": 0,
244
+ "mode": 0,
245
+ "outputs": [
246
+ {
247
+ "name": "IMAGE",
248
+ "type": "IMAGE",
249
+ "links": [
250
+ 26,
251
+ 47
252
+ ],
253
+ "shape": 3,
254
+ "slot_index": 0
255
+ },
256
+ {
257
+ "name": "MASK",
258
+ "type": "MASK",
259
+ "links": [
260
+ 5
261
+ ],
262
+ "shape": 3,
263
+ "slot_index": 1
264
+ }
265
+ ],
266
+ "properties": {
267
+ "Node name for S&R": "LoadImage"
268
+ },
269
+ "widgets_values": [
270
+ "clipspace/clipspace-mask-416378.30000000075.png [input]",
271
+ "image"
272
+ ]
273
+ },
274
+ {
275
+ "id": 33,
276
+ "type": "SAMDetectorSegmented",
277
+ "pos": [
278
+ 1740,
279
+ 310
280
+ ],
281
+ "size": {
282
+ "0": 315,
283
+ "1": 218
284
+ },
285
+ "flags": {},
286
+ "order": 5,
287
+ "mode": 0,
288
+ "inputs": [
289
+ {
290
+ "name": "sam_model",
291
+ "type": "SAM_MODEL",
292
+ "link": 45
293
+ },
294
+ {
295
+ "name": "segs",
296
+ "type": "SEGS",
297
+ "link": 46
298
+ },
299
+ {
300
+ "name": "image",
301
+ "type": "IMAGE",
302
+ "link": 47
303
+ }
304
+ ],
305
+ "outputs": [
306
+ {
307
+ "name": "combined_mask",
308
+ "type": "MASK",
309
+ "links": [
310
+ 44
311
+ ],
312
+ "shape": 3,
313
+ "slot_index": 0
314
+ },
315
+ {
316
+ "name": "batch_masks",
317
+ "type": "MASKS",
318
+ "links": [
319
+ 43,
320
+ 51
321
+ ],
322
+ "shape": 3,
323
+ "slot_index": 1
324
+ }
325
+ ],
326
+ "properties": {
327
+ "Node name for S&R": "SAMDetectorSegmented"
328
+ },
329
+ "widgets_values": [
330
+ "center-1",
331
+ 0,
332
+ 0.7,
333
+ 0,
334
+ 0.7,
335
+ "False"
336
+ ]
337
+ },
338
+ {
339
+ "id": 2,
340
+ "type": "SAMLoader",
341
+ "pos": [
342
+ 1160,
343
+ 310
344
+ ],
345
+ "size": {
346
+ "0": 315,
347
+ "1": 82
348
+ },
349
+ "flags": {},
350
+ "order": 1,
351
+ "mode": 0,
352
+ "outputs": [
353
+ {
354
+ "name": "SAM_MODEL",
355
+ "type": "SAM_MODEL",
356
+ "links": [
357
+ 45
358
+ ],
359
+ "shape": 3,
360
+ "slot_index": 0
361
+ }
362
+ ],
363
+ "properties": {
364
+ "Node name for S&R": "SAMLoader"
365
+ },
366
+ "widgets_values": [
367
+ "sam_vit_b_01ec64.pth",
368
+ "AUTO"
369
+ ]
370
+ },
371
+ {
372
+ "id": 6,
373
+ "type": "MaskToImage",
374
+ "pos": [
375
+ 2300,
376
+ 310
377
+ ],
378
+ "size": {
379
+ "0": 176.39999389648438,
380
+ "1": 26
381
+ },
382
+ "flags": {},
383
+ "order": 6,
384
+ "mode": 0,
385
+ "inputs": [
386
+ {
387
+ "name": "mask",
388
+ "type": "MASK",
389
+ "link": 44
390
+ }
391
+ ],
392
+ "outputs": [
393
+ {
394
+ "name": "IMAGE",
395
+ "type": "IMAGE",
396
+ "links": [
397
+ 8
398
+ ],
399
+ "shape": 3,
400
+ "slot_index": 0
401
+ }
402
+ ],
403
+ "properties": {
404
+ "Node name for S&R": "MaskToImage"
405
+ }
406
+ },
407
+ {
408
+ "id": 7,
409
+ "type": "PreviewImage",
410
+ "pos": [
411
+ 2720,
412
+ 310
413
+ ],
414
+ "size": {
415
+ "0": 210,
416
+ "1": 246
417
+ },
418
+ "flags": {},
419
+ "order": 9,
420
+ "mode": 0,
421
+ "inputs": [
422
+ {
423
+ "name": "images",
424
+ "type": "IMAGE",
425
+ "link": 8
426
+ }
427
+ ],
428
+ "properties": {
429
+ "Node name for S&R": "PreviewImage"
430
+ }
431
+ },
432
+ {
433
+ "id": 9,
434
+ "type": "PreviewImage",
435
+ "pos": [
436
+ 2720,
437
+ 680
438
+ ],
439
+ "size": {
440
+ "0": 210,
441
+ "1": 246
442
+ },
443
+ "flags": {},
444
+ "order": 13,
445
+ "mode": 0,
446
+ "inputs": [
447
+ {
448
+ "name": "images",
449
+ "type": "IMAGE",
450
+ "link": 50
451
+ }
452
+ ],
453
+ "properties": {
454
+ "Node name for S&R": "PreviewImage"
455
+ }
456
+ },
457
+ {
458
+ "id": 38,
459
+ "type": "Note",
460
+ "pos": [
461
+ 2032,
462
+ 698
463
+ ],
464
+ "size": [
465
+ 210,
466
+ 81.49969482421875
467
+ ],
468
+ "flags": {},
469
+ "order": 2,
470
+ "mode": 0,
471
+ "properties": {
472
+ "text": ""
473
+ },
474
+ "widgets_values": [
475
+ "MasksToMaskList node introduced\n"
476
+ ],
477
+ "color": "#432",
478
+ "bgcolor": "#653"
479
+ },
480
+ {
481
+ "id": 37,
482
+ "type": "Note",
483
+ "pos": [
484
+ 2071,
485
+ 384
486
+ ],
487
+ "size": [
488
+ 281.500244140625,
489
+ 65.09967041015625
490
+ ],
491
+ "flags": {},
492
+ "order": 3,
493
+ "mode": 0,
494
+ "properties": {
495
+ "text": ""
496
+ },
497
+ "widgets_values": [
498
+ "type of batch_masks => MASKS instead of MASK\n"
499
+ ],
500
+ "color": "#432",
501
+ "bgcolor": "#653"
502
+ }
503
+ ],
504
+ "links": [
505
+ [
506
+ 5,
507
+ 4,
508
+ 1,
509
+ 5,
510
+ 0,
511
+ "MASK"
512
+ ],
513
+ [
514
+ 8,
515
+ 6,
516
+ 0,
517
+ 7,
518
+ 0,
519
+ "IMAGE"
520
+ ],
521
+ [
522
+ 26,
523
+ 4,
524
+ 0,
525
+ 21,
526
+ 1,
527
+ "IMAGE"
528
+ ],
529
+ [
530
+ 27,
531
+ 21,
532
+ 0,
533
+ 22,
534
+ 0,
535
+ "IMAGE"
536
+ ],
537
+ [
538
+ 35,
539
+ 5,
540
+ 0,
541
+ 28,
542
+ 0,
543
+ "SEGS"
544
+ ],
545
+ [
546
+ 41,
547
+ 28,
548
+ 0,
549
+ 21,
550
+ 0,
551
+ "SEGS"
552
+ ],
553
+ [
554
+ 43,
555
+ 33,
556
+ 1,
557
+ 28,
558
+ 1,
559
+ "MASKS"
560
+ ],
561
+ [
562
+ 44,
563
+ 33,
564
+ 0,
565
+ 6,
566
+ 0,
567
+ "MASK"
568
+ ],
569
+ [
570
+ 45,
571
+ 2,
572
+ 0,
573
+ 33,
574
+ 0,
575
+ "SAM_MODEL"
576
+ ],
577
+ [
578
+ 46,
579
+ 5,
580
+ 0,
581
+ 33,
582
+ 1,
583
+ "SEGS"
584
+ ],
585
+ [
586
+ 47,
587
+ 4,
588
+ 0,
589
+ 33,
590
+ 2,
591
+ "IMAGE"
592
+ ],
593
+ [
594
+ 50,
595
+ 35,
596
+ 0,
597
+ 9,
598
+ 0,
599
+ "IMAGE"
600
+ ],
601
+ [
602
+ 51,
603
+ 33,
604
+ 1,
605
+ 36,
606
+ 0,
607
+ "MASKS"
608
+ ],
609
+ [
610
+ 52,
611
+ 36,
612
+ 0,
613
+ 35,
614
+ 0,
615
+ "MASK"
616
+ ]
617
+ ],
618
+ "groups": [],
619
+ "config": {},
620
+ "extra": {},
621
+ "version": 0.4
622
+ }
ComfyUI-Impact-Pack/test/regional_prompt.json ADDED
@@ -0,0 +1,975 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "last_node_id": 22,
3
+ "last_link_id": 28,
4
+ "nodes": [
5
+ {
6
+ "id": 7,
7
+ "type": "VAEDecode",
8
+ "pos": [
9
+ 2400,
10
+ 270
11
+ ],
12
+ "size": {
13
+ "0": 210,
14
+ "1": 46
15
+ },
16
+ "flags": {},
17
+ "order": 16,
18
+ "mode": 0,
19
+ "inputs": [
20
+ {
21
+ "name": "samples",
22
+ "type": "LATENT",
23
+ "link": 7
24
+ },
25
+ {
26
+ "name": "vae",
27
+ "type": "VAE",
28
+ "link": 8
29
+ }
30
+ ],
31
+ "outputs": [
32
+ {
33
+ "name": "IMAGE",
34
+ "type": "IMAGE",
35
+ "links": [
36
+ 9
37
+ ],
38
+ "shape": 3,
39
+ "slot_index": 0
40
+ }
41
+ ],
42
+ "properties": {
43
+ "Node name for S&R": "VAEDecode"
44
+ }
45
+ },
46
+ {
47
+ "id": 1,
48
+ "type": "LoadImage",
49
+ "pos": [
50
+ -250,
51
+ 747
52
+ ],
53
+ "size": {
54
+ "0": 915.1032104492188,
55
+ "1": 860.6505126953125
56
+ },
57
+ "flags": {},
58
+ "order": 0,
59
+ "mode": 0,
60
+ "outputs": [
61
+ {
62
+ "name": "IMAGE",
63
+ "type": "IMAGE",
64
+ "links": null,
65
+ "shape": 3
66
+ },
67
+ {
68
+ "name": "MASK",
69
+ "type": "MASK",
70
+ "links": [
71
+ 15
72
+ ],
73
+ "shape": 3,
74
+ "slot_index": 1
75
+ }
76
+ ],
77
+ "properties": {
78
+ "Node name for S&R": "LoadImage"
79
+ },
80
+ "widgets_values": [
81
+ "clipspace/clipspace-mask-1650741.700000003.png [input]",
82
+ "image"
83
+ ]
84
+ },
85
+ {
86
+ "id": 9,
87
+ "type": "EditBasicPipe",
88
+ "pos": [
89
+ 888,
90
+ 222
91
+ ],
92
+ "size": {
93
+ "0": 267,
94
+ "1": 126
95
+ },
96
+ "flags": {},
97
+ "order": 8,
98
+ "mode": 0,
99
+ "inputs": [
100
+ {
101
+ "name": "basic_pipe",
102
+ "type": "BASIC_PIPE",
103
+ "link": 11
104
+ },
105
+ {
106
+ "name": "model",
107
+ "type": "MODEL",
108
+ "link": null
109
+ },
110
+ {
111
+ "name": "clip",
112
+ "type": "CLIP",
113
+ "link": null
114
+ },
115
+ {
116
+ "name": "vae",
117
+ "type": "VAE",
118
+ "link": null
119
+ },
120
+ {
121
+ "name": "positive",
122
+ "type": "CONDITIONING",
123
+ "link": 13
124
+ },
125
+ {
126
+ "name": "negative",
127
+ "type": "CONDITIONING",
128
+ "link": null
129
+ }
130
+ ],
131
+ "outputs": [
132
+ {
133
+ "name": "basic_pipe",
134
+ "type": "BASIC_PIPE",
135
+ "links": [
136
+ 16
137
+ ],
138
+ "shape": 3,
139
+ "slot_index": 0
140
+ }
141
+ ],
142
+ "properties": {
143
+ "Node name for S&R": "EditBasicPipe"
144
+ }
145
+ },
146
+ {
147
+ "id": 10,
148
+ "type": "CLIPTextEncode",
149
+ "pos": [
150
+ 460,
151
+ 242
152
+ ],
153
+ "size": {
154
+ "0": 292.0009765625,
155
+ "1": 115.41679382324219
156
+ },
157
+ "flags": {},
158
+ "order": 6,
159
+ "mode": 0,
160
+ "inputs": [
161
+ {
162
+ "name": "clip",
163
+ "type": "CLIP",
164
+ "link": 12
165
+ }
166
+ ],
167
+ "outputs": [
168
+ {
169
+ "name": "CONDITIONING",
170
+ "type": "CONDITIONING",
171
+ "links": [
172
+ 13
173
+ ],
174
+ "shape": 3,
175
+ "slot_index": 0
176
+ }
177
+ ],
178
+ "properties": {
179
+ "Node name for S&R": "CLIPTextEncode"
180
+ },
181
+ "widgets_values": [
182
+ "photorealistic:1.4, 1girl wear red hat"
183
+ ]
184
+ },
185
+ {
186
+ "id": 14,
187
+ "type": "EmptyLatentImage",
188
+ "pos": [
189
+ 1050,
190
+ 877
191
+ ],
192
+ "size": {
193
+ "0": 315,
194
+ "1": 106
195
+ },
196
+ "flags": {},
197
+ "order": 1,
198
+ "mode": 0,
199
+ "outputs": [
200
+ {
201
+ "name": "LATENT",
202
+ "type": "LATENT",
203
+ "links": [
204
+ 19
205
+ ],
206
+ "shape": 3
207
+ }
208
+ ],
209
+ "properties": {
210
+ "Node name for S&R": "EmptyLatentImage"
211
+ },
212
+ "widgets_values": [
213
+ 1024,
214
+ 768,
215
+ 1
216
+ ]
217
+ },
218
+ {
219
+ "id": 8,
220
+ "type": "PreviewImage",
221
+ "pos": [
222
+ 2476,
223
+ 319
224
+ ],
225
+ "size": [
226
+ 1069.308299510546,
227
+ 1128.9237824485897
228
+ ],
229
+ "flags": {},
230
+ "order": 17,
231
+ "mode": 0,
232
+ "inputs": [
233
+ {
234
+ "name": "images",
235
+ "type": "IMAGE",
236
+ "link": 9
237
+ }
238
+ ],
239
+ "properties": {
240
+ "Node name for S&R": "PreviewImage"
241
+ }
242
+ },
243
+ {
244
+ "id": 6,
245
+ "type": "FromBasicPipe",
246
+ "pos": [
247
+ 167,
248
+ 238
249
+ ],
250
+ "size": {
251
+ "0": 241.79998779296875,
252
+ "1": 106
253
+ },
254
+ "flags": {},
255
+ "order": 5,
256
+ "mode": 0,
257
+ "inputs": [
258
+ {
259
+ "name": "basic_pipe",
260
+ "type": "BASIC_PIPE",
261
+ "link": 3
262
+ }
263
+ ],
264
+ "outputs": [
265
+ {
266
+ "name": "model",
267
+ "type": "MODEL",
268
+ "links": null,
269
+ "shape": 3
270
+ },
271
+ {
272
+ "name": "clip",
273
+ "type": "CLIP",
274
+ "links": [
275
+ 12,
276
+ 20
277
+ ],
278
+ "shape": 3,
279
+ "slot_index": 1
280
+ },
281
+ {
282
+ "name": "vae",
283
+ "type": "VAE",
284
+ "links": [
285
+ 8
286
+ ],
287
+ "shape": 3,
288
+ "slot_index": 2
289
+ },
290
+ {
291
+ "name": "positive",
292
+ "type": "CONDITIONING",
293
+ "links": [],
294
+ "shape": 3,
295
+ "slot_index": 3
296
+ },
297
+ {
298
+ "name": "negative",
299
+ "type": "CONDITIONING",
300
+ "links": null,
301
+ "shape": 3
302
+ }
303
+ ],
304
+ "properties": {
305
+ "Node name for S&R": "FromBasicPipe"
306
+ }
307
+ },
308
+ {
309
+ "id": 18,
310
+ "type": "CLIPTextEncode",
311
+ "pos": [
312
+ 502,
313
+ 507
314
+ ],
315
+ "size": {
316
+ "0": 292.0009765625,
317
+ "1": 115.41679382324219
318
+ },
319
+ "flags": {},
320
+ "order": 7,
321
+ "mode": 0,
322
+ "inputs": [
323
+ {
324
+ "name": "clip",
325
+ "type": "CLIP",
326
+ "link": 20
327
+ }
328
+ ],
329
+ "outputs": [
330
+ {
331
+ "name": "CONDITIONING",
332
+ "type": "CONDITIONING",
333
+ "links": [
334
+ 21
335
+ ],
336
+ "shape": 3,
337
+ "slot_index": 0
338
+ }
339
+ ],
340
+ "properties": {
341
+ "Node name for S&R": "CLIPTextEncode"
342
+ },
343
+ "widgets_values": [
344
+ "photorealistic:1.4, 1 man wear jeans"
345
+ ]
346
+ },
347
+ {
348
+ "id": 5,
349
+ "type": "## make-basic_pipe [2c8c61]",
350
+ "pos": [
351
+ -227,
352
+ -290
353
+ ],
354
+ "size": {
355
+ "0": 400,
356
+ "1": 200
357
+ },
358
+ "flags": {},
359
+ "order": 2,
360
+ "mode": 0,
361
+ "inputs": [
362
+ {
363
+ "name": "vae_opt",
364
+ "type": "VAE",
365
+ "link": null
366
+ }
367
+ ],
368
+ "outputs": [
369
+ {
370
+ "name": "BASIC_PIPE",
371
+ "type": "BASIC_PIPE",
372
+ "links": [
373
+ 1,
374
+ 3,
375
+ 11,
376
+ 22
377
+ ],
378
+ "shape": 3,
379
+ "slot_index": 0
380
+ }
381
+ ],
382
+ "title": "## make-basic_pipe",
383
+ "properties": {
384
+ "Node name for S&R": "## make-basic_pipe [2c8c61]"
385
+ },
386
+ "widgets_values": [
387
+ "V07_v07.safetensors",
388
+ "photorealistic:1.4, 1girl and 1man sitting in the cafe",
389
+ ""
390
+ ]
391
+ },
392
+ {
393
+ "id": 17,
394
+ "type": "EditBasicPipe",
395
+ "pos": [
396
+ 975,
397
+ 597
398
+ ],
399
+ "size": {
400
+ "0": 267,
401
+ "1": 126
402
+ },
403
+ "flags": {},
404
+ "order": 9,
405
+ "mode": 0,
406
+ "inputs": [
407
+ {
408
+ "name": "basic_pipe",
409
+ "type": "BASIC_PIPE",
410
+ "link": 22
411
+ },
412
+ {
413
+ "name": "model",
414
+ "type": "MODEL",
415
+ "link": null
416
+ },
417
+ {
418
+ "name": "clip",
419
+ "type": "CLIP",
420
+ "link": null
421
+ },
422
+ {
423
+ "name": "vae",
424
+ "type": "VAE",
425
+ "link": null
426
+ },
427
+ {
428
+ "name": "positive",
429
+ "type": "CONDITIONING",
430
+ "link": 21
431
+ },
432
+ {
433
+ "name": "negative",
434
+ "type": "CONDITIONING",
435
+ "link": null
436
+ }
437
+ ],
438
+ "outputs": [
439
+ {
440
+ "name": "basic_pipe",
441
+ "type": "BASIC_PIPE",
442
+ "links": [
443
+ 24
444
+ ],
445
+ "shape": 3,
446
+ "slot_index": 0
447
+ }
448
+ ],
449
+ "properties": {
450
+ "Node name for S&R": "EditBasicPipe"
451
+ }
452
+ },
453
+ {
454
+ "id": 2,
455
+ "type": "RegionalSampler",
456
+ "pos": [
457
+ 2050,
458
+ 200
459
+ ],
460
+ "size": [
461
+ 315,
462
+ 406
463
+ ],
464
+ "flags": {},
465
+ "order": 15,
466
+ "mode": 0,
467
+ "inputs": [
468
+ {
469
+ "name": "samples",
470
+ "type": "LATENT",
471
+ "link": 19,
472
+ "slot_index": 0
473
+ },
474
+ {
475
+ "name": "base_sampler",
476
+ "type": "KSAMPLER_ADVANCED",
477
+ "link": 10
478
+ },
479
+ {
480
+ "name": "regional_prompts",
481
+ "type": "REGIONAL_PROMPTS",
482
+ "link": 27
483
+ }
484
+ ],
485
+ "outputs": [
486
+ {
487
+ "name": "LATENT",
488
+ "type": "LATENT",
489
+ "links": [
490
+ 7
491
+ ],
492
+ "shape": 3,
493
+ "slot_index": 0
494
+ }
495
+ ],
496
+ "properties": {
497
+ "Node name for S&R": "RegionalSampler"
498
+ },
499
+ "widgets_values": [
500
+ 212608453650633,
501
+ "randomize",
502
+ 20,
503
+ 1,
504
+ 10
505
+ ]
506
+ },
507
+ {
508
+ "id": 12,
509
+ "type": "RegionalPrompt",
510
+ "pos": [
511
+ 1361,
512
+ 497
513
+ ],
514
+ "size": {
515
+ "0": 418.1999816894531,
516
+ "1": 46
517
+ },
518
+ "flags": {},
519
+ "order": 12,
520
+ "mode": 0,
521
+ "inputs": [
522
+ {
523
+ "name": "mask",
524
+ "type": "MASK",
525
+ "link": 15
526
+ },
527
+ {
528
+ "name": "advanced_sampler",
529
+ "type": "KSAMPLER_ADVANCED",
530
+ "link": 17
531
+ }
532
+ ],
533
+ "outputs": [
534
+ {
535
+ "name": "REGIONAL_PROMPTS",
536
+ "type": "REGIONAL_PROMPTS",
537
+ "links": [
538
+ 25
539
+ ],
540
+ "shape": 3,
541
+ "slot_index": 0
542
+ }
543
+ ],
544
+ "properties": {
545
+ "Node name for S&R": "RegionalPrompt"
546
+ }
547
+ },
548
+ {
549
+ "id": 20,
550
+ "type": "RegionalPrompt",
551
+ "pos": [
552
+ 1520,
553
+ 940
554
+ ],
555
+ "size": {
556
+ "0": 418.1999816894531,
557
+ "1": 46
558
+ },
559
+ "flags": {},
560
+ "order": 13,
561
+ "mode": 0,
562
+ "inputs": [
563
+ {
564
+ "name": "mask",
565
+ "type": "MASK",
566
+ "link": 28
567
+ },
568
+ {
569
+ "name": "advanced_sampler",
570
+ "type": "KSAMPLER_ADVANCED",
571
+ "link": 23
572
+ }
573
+ ],
574
+ "outputs": [
575
+ {
576
+ "name": "REGIONAL_PROMPTS",
577
+ "type": "REGIONAL_PROMPTS",
578
+ "links": [
579
+ 26
580
+ ],
581
+ "shape": 3,
582
+ "slot_index": 0
583
+ }
584
+ ],
585
+ "properties": {
586
+ "Node name for S&R": "RegionalPrompt"
587
+ }
588
+ },
589
+ {
590
+ "id": 22,
591
+ "type": "CombineRegionalPrompts",
592
+ "pos": [
593
+ 1851.5471568957514,
594
+ 660.6109041998288
595
+ ],
596
+ "size": {
597
+ "0": 430.8000183105469,
598
+ "1": 46
599
+ },
600
+ "flags": {},
601
+ "order": 14,
602
+ "mode": 0,
603
+ "inputs": [
604
+ {
605
+ "name": "regional_prompts1",
606
+ "type": "REGIONAL_PROMPTS",
607
+ "link": 25
608
+ },
609
+ {
610
+ "name": "regional_prompts2",
611
+ "type": "REGIONAL_PROMPTS",
612
+ "link": 26
613
+ }
614
+ ],
615
+ "outputs": [
616
+ {
617
+ "name": "REGIONAL_PROMPTS",
618
+ "type": "REGIONAL_PROMPTS",
619
+ "links": [
620
+ 27
621
+ ],
622
+ "shape": 3,
623
+ "slot_index": 0
624
+ }
625
+ ],
626
+ "properties": {
627
+ "Node name for S&R": "CombineRegionalPrompts"
628
+ }
629
+ },
630
+ {
631
+ "id": 15,
632
+ "type": "LoadImage",
633
+ "pos": [
634
+ -278,
635
+ 1721
636
+ ],
637
+ "size": [
638
+ 1069.0971236588748,
639
+ 886.818909225281
640
+ ],
641
+ "flags": {},
642
+ "order": 3,
643
+ "mode": 0,
644
+ "outputs": [
645
+ {
646
+ "name": "IMAGE",
647
+ "type": "IMAGE",
648
+ "links": null,
649
+ "shape": 3
650
+ },
651
+ {
652
+ "name": "MASK",
653
+ "type": "MASK",
654
+ "links": [
655
+ 28
656
+ ],
657
+ "shape": 3,
658
+ "slot_index": 1
659
+ }
660
+ ],
661
+ "properties": {
662
+ "Node name for S&R": "LoadImage"
663
+ },
664
+ "widgets_values": [
665
+ "clipspace/clipspace-mask-1683237.5.png [input]",
666
+ "image"
667
+ ]
668
+ },
669
+ {
670
+ "id": 13,
671
+ "type": "KSamplerAdvancedProvider",
672
+ "pos": [
673
+ 1209,
674
+ 225
675
+ ],
676
+ "size": {
677
+ "0": 355.20001220703125,
678
+ "1": 106
679
+ },
680
+ "flags": {},
681
+ "order": 10,
682
+ "mode": 0,
683
+ "inputs": [
684
+ {
685
+ "name": "basic_pipe",
686
+ "type": "BASIC_PIPE",
687
+ "link": 16
688
+ }
689
+ ],
690
+ "outputs": [
691
+ {
692
+ "name": "KSAMPLER_ADVANCED",
693
+ "type": "KSAMPLER_ADVANCED",
694
+ "links": [
695
+ 17
696
+ ],
697
+ "shape": 3,
698
+ "slot_index": 0
699
+ }
700
+ ],
701
+ "properties": {
702
+ "Node name for S&R": "KSamplerAdvancedProvider"
703
+ },
704
+ "widgets_values": [
705
+ 8,
706
+ "euler",
707
+ "normal"
708
+ ]
709
+ },
710
+ {
711
+ "id": 21,
712
+ "type": "KSamplerAdvancedProvider",
713
+ "pos": [
714
+ 1360,
715
+ 670
716
+ ],
717
+ "size": {
718
+ "0": 355.20001220703125,
719
+ "1": 106
720
+ },
721
+ "flags": {},
722
+ "order": 11,
723
+ "mode": 0,
724
+ "inputs": [
725
+ {
726
+ "name": "basic_pipe",
727
+ "type": "BASIC_PIPE",
728
+ "link": 24
729
+ }
730
+ ],
731
+ "outputs": [
732
+ {
733
+ "name": "KSAMPLER_ADVANCED",
734
+ "type": "KSAMPLER_ADVANCED",
735
+ "links": [
736
+ 23
737
+ ],
738
+ "shape": 3,
739
+ "slot_index": 0
740
+ }
741
+ ],
742
+ "properties": {
743
+ "Node name for S&R": "KSamplerAdvancedProvider"
744
+ },
745
+ "widgets_values": [
746
+ 8,
747
+ "euler",
748
+ "normal"
749
+ ]
750
+ },
751
+ {
752
+ "id": 4,
753
+ "type": "KSamplerAdvancedProvider",
754
+ "pos": [
755
+ 1289,
756
+ -267
757
+ ],
758
+ "size": {
759
+ "0": 355.20001220703125,
760
+ "1": 106
761
+ },
762
+ "flags": {},
763
+ "order": 4,
764
+ "mode": 0,
765
+ "inputs": [
766
+ {
767
+ "name": "basic_pipe",
768
+ "type": "BASIC_PIPE",
769
+ "link": 1
770
+ }
771
+ ],
772
+ "outputs": [
773
+ {
774
+ "name": "KSAMPLER_ADVANCED",
775
+ "type": "KSAMPLER_ADVANCED",
776
+ "links": [
777
+ 10
778
+ ],
779
+ "shape": 3,
780
+ "slot_index": 0
781
+ }
782
+ ],
783
+ "properties": {
784
+ "Node name for S&R": "KSamplerAdvancedProvider"
785
+ },
786
+ "widgets_values": [
787
+ 8,
788
+ "euler",
789
+ "normal"
790
+ ]
791
+ }
792
+ ],
793
+ "links": [
794
+ [
795
+ 1,
796
+ 5,
797
+ 0,
798
+ 4,
799
+ 0,
800
+ "BASIC_PIPE"
801
+ ],
802
+ [
803
+ 3,
804
+ 5,
805
+ 0,
806
+ 6,
807
+ 0,
808
+ "BASIC_PIPE"
809
+ ],
810
+ [
811
+ 7,
812
+ 2,
813
+ 0,
814
+ 7,
815
+ 0,
816
+ "LATENT"
817
+ ],
818
+ [
819
+ 8,
820
+ 6,
821
+ 2,
822
+ 7,
823
+ 1,
824
+ "VAE"
825
+ ],
826
+ [
827
+ 9,
828
+ 7,
829
+ 0,
830
+ 8,
831
+ 0,
832
+ "IMAGE"
833
+ ],
834
+ [
835
+ 10,
836
+ 4,
837
+ 0,
838
+ 2,
839
+ 1,
840
+ "KSAMPLER_ADVANCED"
841
+ ],
842
+ [
843
+ 11,
844
+ 5,
845
+ 0,
846
+ 9,
847
+ 0,
848
+ "BASIC_PIPE"
849
+ ],
850
+ [
851
+ 12,
852
+ 6,
853
+ 1,
854
+ 10,
855
+ 0,
856
+ "CLIP"
857
+ ],
858
+ [
859
+ 13,
860
+ 10,
861
+ 0,
862
+ 9,
863
+ 4,
864
+ "CONDITIONING"
865
+ ],
866
+ [
867
+ 15,
868
+ 1,
869
+ 1,
870
+ 12,
871
+ 0,
872
+ "MASK"
873
+ ],
874
+ [
875
+ 16,
876
+ 9,
877
+ 0,
878
+ 13,
879
+ 0,
880
+ "BASIC_PIPE"
881
+ ],
882
+ [
883
+ 17,
884
+ 13,
885
+ 0,
886
+ 12,
887
+ 1,
888
+ "KSAMPLER_ADVANCED"
889
+ ],
890
+ [
891
+ 19,
892
+ 14,
893
+ 0,
894
+ 2,
895
+ 0,
896
+ "LATENT"
897
+ ],
898
+ [
899
+ 20,
900
+ 6,
901
+ 1,
902
+ 18,
903
+ 0,
904
+ "CLIP"
905
+ ],
906
+ [
907
+ 21,
908
+ 18,
909
+ 0,
910
+ 17,
911
+ 4,
912
+ "CONDITIONING"
913
+ ],
914
+ [
915
+ 22,
916
+ 5,
917
+ 0,
918
+ 17,
919
+ 0,
920
+ "BASIC_PIPE"
921
+ ],
922
+ [
923
+ 23,
924
+ 21,
925
+ 0,
926
+ 20,
927
+ 1,
928
+ "KSAMPLER_ADVANCED"
929
+ ],
930
+ [
931
+ 24,
932
+ 17,
933
+ 0,
934
+ 21,
935
+ 0,
936
+ "BASIC_PIPE"
937
+ ],
938
+ [
939
+ 25,
940
+ 12,
941
+ 0,
942
+ 22,
943
+ 0,
944
+ "REGIONAL_PROMPTS"
945
+ ],
946
+ [
947
+ 26,
948
+ 20,
949
+ 0,
950
+ 22,
951
+ 1,
952
+ "REGIONAL_PROMPTS"
953
+ ],
954
+ [
955
+ 27,
956
+ 22,
957
+ 0,
958
+ 2,
959
+ 2,
960
+ "REGIONAL_PROMPTS"
961
+ ],
962
+ [
963
+ 28,
964
+ 15,
965
+ 1,
966
+ 20,
967
+ 0,
968
+ "MASK"
969
+ ]
970
+ ],
971
+ "groups": [],
972
+ "config": {},
973
+ "extra": {},
974
+ "version": 0.4
975
+ }
ComfyUI-Impact-Pack/troubleshooting/TROUBLESHOOTING.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## When a permission error occurs during the installation process (on Windows)
2
+
3
+ * There are cases where the package you are trying to install is already being used by another custom node that has been loaded.
4
+ * This issue occurs only on Windows.
5
+ * Please close ComfyUI and execute install.py directly using Python in the custom_nodes/ComfyUI-Impact-Pack directory.
6
+ * In case **portable** version:
7
+ 1. goto **ComfyUI_windows_portable** directory in **cmd**
8
+ 2. execute ```.\python_embeded\python -s -m custom_nodes\ComfyUI-Impact-Pack\install.py```
9
+ * In case **venv**:
10
+ 1. activate venv
11
+ 2. execute ```python -s -m custom_nodes\ComfyUI-Impact-Pack\install.py```
12
+ * Others:
13
+ 1. Please modify the path of 'python' according to your Python environment.
14
+ 2. execute ```(YOUR PYTHON) -s -m custom_nodes\ComfyUI-Impact-Pack\install.py```
15
+
16
+
17
+
18
+ ## Destortion on Detailer
19
+
20
+ * Please also note that this issue may be caused by a bug in xformers 0.0.18. If you encounter this problem, please try adjusting the guide_size parameter.
21
+
22
+ ![example](black1.png)
23
+
24
+ ![example](black2.png)
25
+ * guide_size changed from 256 -> 192
ComfyUI-Impact-Pack/troubleshooting/black1.png ADDED

Git LFS Details

  • SHA256: 6e32fe1606d35a26ddf08d2a3ff24c8fcd62831b9ed11eeaa76468e27a2b5f0f
  • Pointer size: 131 Bytes
  • Size of remote file: 753 kB
ComfyUI-Impact-Pack/troubleshooting/black2.png ADDED

Git LFS Details

  • SHA256: 829d72c3cc1034f72bbd0945e1a2aed69e1f38060126159c0b911c4c102e2fcc
  • Pointer size: 131 Bytes
  • Size of remote file: 710 kB
ComfyUI-Impact-Pack/uninstall.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
+
ComfyUI-Impact-Pack/wildcards/put_wildcards_here ADDED
File without changes
ComfyUI-Impact-Pack/wildcards/samples/flower.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ rose
2
+ orchid
3
+ iris
4
+ carnation
5
+ lily
6
+ daisy
7
+ chrysanthemum
8
+ daffodil
9
+ dahlia
ComfyUI-Impact-Pack/wildcards/samples/jewel.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ diamond
2
+ emerald
3
+ sapphire
4
+ opal
5
+ ruby
6
+ topaz
7
+ pearl
8
+ rubyamethyst
9
+ aquamarine