RioShiina commited on
Commit
20698a7
·
1 Parent(s): 3b2fcb1

Refactor UI event handlers into subpackage

Browse files
LICENSE 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>.
README.md CHANGED
@@ -9,4 +9,96 @@ app_file: app.py
9
  python_version: 3.12
10
  short_description: Multi-task image generator with dynamic, chainable workflows
11
  pinned: true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
 
9
  python_version: 3.12
10
  short_description: Multi-task image generator with dynamic, chainable workflows
11
  pinned: true
12
+ models:
13
+ - AiAF/Illustrious-XL-v0.1.safetensors
14
+ - alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union-2.1
15
+ - black-forest-labs/FLUX.1-Redux-dev
16
+ - black-forest-labs/FLUX.2-klein-4b-fp8
17
+ - black-forest-labs/FLUX.2-klein-9b-fp8
18
+ - black-forest-labs/FLUX.2-klein-9b-kv-fp8
19
+ - black-forest-labs/FLUX.2-klein-base-4b-fp8
20
+ - black-forest-labs/FLUX.2-klein-base-9b-fp8
21
+ - bluepen5805/4nima_pencil-XL
22
+ - bluepen5805/anima-models
23
+ - bluepen5805/anima_pencil-XL
24
+ - bluepen5805/blue_pencil-XL
25
+ - bluepen5805/illustrious_pencil-XL
26
+ - bluepen5805/mellow_pencil-XL
27
+ - bluepen5805/noob_v_pencil-XL
28
+ - bluepen5805/pony_pencil-XL
29
+ - cagliostrolab/animagine-xl-3.1
30
+ - cagliostrolab/animagine-xl-4.0
31
+ - ChenkinNoob/ChenkinNoob-XL-V0.5
32
+ - circlestone-labs/Anima
33
+ - Clybius/Chroma-fp8-scaled
34
+ - comfyanonymous/ControlNet-v1-1_fp16_safetensors
35
+ - comfyanonymous/flux_text_encoders
36
+ - Comfy-Org/ERNIE-Image
37
+ - Comfy-Org/FLUX.1-Krea-dev_ComfyUI
38
+ - Comfy-Org/flux1-kontext-dev_ComfyUI
39
+ - Comfy-Org/flux2-dev
40
+ - Comfy-Org/HiDream-I1_ComfyUI
41
+ - Comfy-Org/HiDream-O1-Image
42
+ - Comfy-Org/HunyuanImage_2.1_ComfyUI
43
+ - Comfy-Org/LongCat-Image
44
+ - Comfy-Org/Lumina_Image_2.0_Repackaged
45
+ - Comfy-Org/NewBie-image-Exp0.1_repackaged
46
+ - Comfy-Org/Omnigen2_ComfyUI_repackaged
47
+ - Comfy-Org/Ovis-Image
48
+ - Comfy-Org/Qwen-Image_ComfyUI
49
+ - Comfy-Org/sigclip_vision_384
50
+ - Comfy-Org/stable-diffusion-3.5-fp8
51
+ - Comfy-Org/vae-text-encorder-for-flux-klein-4b
52
+ - Comfy-Org/vae-text-encorder-for-flux-klein-9b
53
+ - Comfy-Org/z_image
54
+ - Comfy-Org/z_image_turbo
55
+ - cyberdelia/CyberRealisticPony
56
+ - diffusionmodels1254ani/waiANIMA
57
+ - duongve/AnimaYume
58
+ - Eugeoter/noob-sdxl-controlnet-canny
59
+ - Eugeoter/noob-sdxl-controlnet-depth
60
+ - Eugeoter/noob-sdxl-controlnet-lineart_anime
61
+ - Eugeoter/noob-sdxl-controlnet-lineart_realistic
62
+ - Eugeoter/noob-sdxl-controlnet-manga_line
63
+ - Eugeoter/noob-sdxl-controlnet-normal
64
+ - Eugeoter/noob-sdxl-controlnet-softedge_hed
65
+ - Eugeoter/noob-sdxl-controlnet-tile
66
+ - h94/IP-Adapter
67
+ - h94/IP-Adapter-FaceID
68
+ - InstantX/FLUX.1-dev-IP-Adapter
69
+ - InstantX/Qwen-Image-ControlNet-Inpainting
70
+ - InstantX/Qwen-Image-ControlNet-Union
71
+ - InstantX/SD3.5-Large-IP-Adapter
72
+ - Kijai/flux-fp8
73
+ - kohya-ss/Anima-LLLite
74
+ - Laxhar/noob_openpose
75
+ - Laxhar/noobai-XL-1.1
76
+ - Laxhar/noobai-XL-Vpred-1.0
77
+ - licyk/sd_control_collection
78
+ - lightx2v/Qwen-Image-2512-Lightning
79
+ - lightx2v/Qwen-Image-Lightning
80
+ - LyliaEngine/Pony_Diffusion_V6_XL
81
+ - MIC-Lab/illustriousXLv0.1_controlnet
82
+ - MIC-Lab/illustriousXLv1.1_controlnet
83
+ - misri/hassakuXLIllustrious_v30
84
+ - OnomaAIResearch/Illustrious-XL-v1.0
85
+ - OnomaAIResearch/Illustrious-XL-v1.1
86
+ - OnomaAIResearch/Illustrious-XL-v2.0
87
+ - RedRayz/hikari_noob_v-pred_1.2.4
88
+ - Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0
89
+ - silveroxides/Chroma1-Radiance-fp8-scaled
90
+ - stabilityai/stable-diffusion-3.5-controlnets
91
+ - stabilityai/stable-diffusion-xl-base-1.0
92
+ - stable-diffusion-v1-5/stable-diffusion-v1-5
93
+ - Wenaka/NoobAI_XL_Inpainting_ControlNet_Full
94
+ - xinsir/anime-painter
95
+ - xinsir/controlnet-canny-sdxl-1.0
96
+ - xinsir/controlnet-depth-sdxl-1.0
97
+ - xinsir/controlnet-openpose-sdxl-1.0
98
+ - xinsir/controlnet-scribble-sdxl-1.0
99
+ - xinsir/controlnet-tile-sdxl-1.0
100
+ - xinsir/controlnet-union-sdxl-1.0
101
+ - XLabs-AI/flux-controlnet-collections
102
+ - Yevrey921/novaAnimeXL_ilV160
103
+ - zhenshipo/waiIllustriousSDXL_v170
104
  ---
app.py CHANGED
@@ -46,19 +46,9 @@ def dummy_gpu_for_startup():
46
 
47
 
48
  def main():
49
- from utils.app_utils import print_welcome_message
50
- from scripts import build_sage_attention
51
  from comfy_integration import setup as setup_comfyui
52
-
53
- print_welcome_message()
54
 
55
- print("--- [Setup] Attempting to build and install SageAttention... ---")
56
- try:
57
- build_sage_attention.install_sage_attention()
58
- print("--- [Setup] ✅ SageAttention installation process finished. ---")
59
- except Exception as e:
60
- print(f"--- [Setup] ❌ SageAttention installation failed: {e}. Continuing with default attention. ---")
61
-
62
  print("--- [Setup] Starting ComfyUI initialization ---")
63
  setup_comfyui.initialize_comfyui()
64
 
@@ -75,8 +65,6 @@ def main():
75
  except Exception as e:
76
  print(f"--- [GPU Startup] ⚠️ Warning: Startup check failed: {e} ---")
77
 
78
- from utils.app_utils import load_ipadapter_presets
79
-
80
  print("--- Starting Application Setup ---")
81
 
82
  print("--- Loading IPAdapter presets ---")
 
46
 
47
 
48
  def main():
 
 
49
  from comfy_integration import setup as setup_comfyui
50
+ from utils.app_utils import load_ipadapter_presets
 
51
 
 
 
 
 
 
 
 
52
  print("--- [Setup] Starting ComfyUI initialization ---")
53
  setup_comfyui.initialize_comfyui()
54
 
 
65
  except Exception as e:
66
  print(f"--- [GPU Startup] ⚠️ Warning: Startup check failed: {e} ---")
67
 
 
 
68
  print("--- Starting Application Setup ---")
69
 
70
  print("--- Loading IPAdapter presets ---")
chain_injectors/anima_controlnet_lllite_injector.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def inject(assembler, chain_definition, chain_items):
2
+ if not chain_items:
3
+ return
4
+
5
+ ksampler_name = chain_definition.get('ksampler_node', 'ksampler')
6
+ if ksampler_name not in assembler.node_map:
7
+ print(f"Warning: KSampler node '{ksampler_name}' not found for Anima LLLite chain. Skipping.")
8
+ return
9
+
10
+ ksampler_id = assembler.node_map[ksampler_name]
11
+
12
+ if 'model' not in assembler.workflow[ksampler_id]['inputs']:
13
+ print(f"Warning: KSampler node '{ksampler_name}' is missing 'model' input. Skipping.")
14
+ return
15
+
16
+ current_model_connection = assembler.workflow[ksampler_id]['inputs']['model']
17
+
18
+ for item_data in chain_items:
19
+ image_loader_id = assembler._get_unique_id()
20
+ image_loader_node = assembler._get_node_template("LoadImage")
21
+ image_loader_node['inputs']['image'] = item_data['image']
22
+ assembler.workflow[image_loader_id] = image_loader_node
23
+
24
+ image_scaler_id = assembler._get_unique_id()
25
+ image_scaler_node = assembler._get_node_template("ImageScaleToTotalPixels")
26
+ image_scaler_node['inputs']['image'] = [image_loader_id, 0]
27
+ image_scaler_node['inputs']['upscale_method'] = 'nearest-exact'
28
+ image_scaler_node['inputs']['megapixels'] = 1.0
29
+ assembler.workflow[image_scaler_id] = image_scaler_node
30
+
31
+ apply_cn_id = assembler._get_unique_id()
32
+ apply_cn_node = assembler._get_node_template("AnimaLLLiteApply")
33
+
34
+ apply_cn_node['inputs']['lllite_name'] = item_data['control_net_name']
35
+ apply_cn_node['inputs']['strength'] = item_data['strength']
36
+ apply_cn_node['inputs']['start_percent'] = item_data.get('start_percent', 0.0)
37
+ apply_cn_node['inputs']['end_percent'] = item_data.get('end_percent', 1.0)
38
+
39
+ apply_cn_node['inputs']['model'] = current_model_connection
40
+ apply_cn_node['inputs']['image'] = [image_scaler_id, 0]
41
+
42
+ assembler.workflow[apply_cn_id] = apply_cn_node
43
+
44
+ current_model_connection = [apply_cn_id, 0]
45
+
46
+ assembler.workflow[ksampler_id]['inputs']['model'] = current_model_connection
47
+
48
+ print(f"Anima LLLite injector applied. KSampler model input re-routed through {len(chain_items)} LLLite(s).")
chain_injectors/hidream_o1_reference_injector.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def inject(assembler, chain_definition, chain_items):
2
+ if not chain_items:
3
+ return
4
+
5
+ ksampler_name = chain_definition.get('ksampler_node', 'ksampler')
6
+
7
+ if ksampler_name not in assembler.node_map:
8
+ print(f"Warning: KSampler node '{ksampler_name}' not found for HiDream-O1 Reference chain. Skipping.")
9
+ return
10
+
11
+ ksampler_id = assembler.node_map[ksampler_name]
12
+
13
+ if 'positive' not in assembler.workflow[ksampler_id]['inputs'] or 'negative' not in assembler.workflow[ksampler_id]['inputs']:
14
+ print(f"Warning: KSampler node '{ksampler_name}' missing positive/negative inputs. Skipping.")
15
+ return
16
+
17
+ current_pos_conditioning = assembler.workflow[ksampler_id]['inputs']['positive']
18
+ current_neg_conditioning = assembler.workflow[ksampler_id]['inputs']['negative']
19
+
20
+ ref_images_id = assembler._get_unique_id()
21
+ ref_images_node = assembler._get_node_template("HiDreamO1ReferenceImages")
22
+
23
+ if 'images' in ref_images_node['inputs']:
24
+ del ref_images_node['inputs']['images']
25
+
26
+ ref_images_node['inputs']['positive'] = current_pos_conditioning
27
+ ref_images_node['inputs']['negative'] = current_neg_conditioning
28
+
29
+ for i, img_filename in enumerate(chain_items):
30
+ if i >= 10:
31
+ break
32
+
33
+ load_id = assembler._get_unique_id()
34
+ load_node = assembler._get_node_template("LoadImage")
35
+ load_node['inputs']['image'] = img_filename
36
+ load_node['_meta']['title'] = f"Load Reference Image {i+1}"
37
+ assembler.workflow[load_id] = load_node
38
+
39
+ scale_id = assembler._get_unique_id()
40
+ scale_node = assembler._get_node_template("ImageScaleToTotalPixels")
41
+ scale_node['inputs']['megapixels'] = 1.0
42
+ scale_node['inputs']['upscale_method'] = "lanczos"
43
+ scale_node['inputs']['image'] = [load_id, 0]
44
+ scale_node['_meta']['title'] = f"Scale Reference {i+1}"
45
+ assembler.workflow[scale_id] = scale_node
46
+
47
+ ref_images_node['inputs'][f'images.image_{i+1}'] = [scale_id, 0]
48
+
49
+ assembler.workflow[ref_images_id] = ref_images_node
50
+
51
+ assembler.workflow[ksampler_id]['inputs']['positive'] = [ref_images_id, 0]
52
+ assembler.workflow[ksampler_id]['inputs']['negative'] = [ref_images_id, 1]
53
+
54
+ print(f"HiDream-O1 Reference injector applied. Re-routed inputs through {min(len(chain_items), 10)} reference images.")
chain_injectors/hidream_o1_smoothing_injector.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from copy import deepcopy
2
+
3
+ def inject(assembler, chain_definition, chain_items):
4
+ if not chain_items:
5
+ return
6
+
7
+ target_node_name = chain_definition.get('target_node')
8
+ if not target_node_name or target_node_name not in assembler.node_map:
9
+ print(f"Warning: Target node '{target_node_name}' not found for HiDream-O1 Smoothing. Skipping.")
10
+ return
11
+
12
+ target_node_id = assembler.node_map[target_node_name]
13
+
14
+ if 'model' not in assembler.workflow[target_node_id]['inputs']:
15
+ print(f"Warning: Target node '{target_node_name}' has no 'model' input. Skipping.")
16
+ return
17
+
18
+ current_model_connection = assembler.workflow[target_node_id]['inputs']['model']
19
+
20
+ for _ in chain_items:
21
+ template = assembler._get_node_template("HiDreamO1PatchSeamSmoothing")
22
+ node_data = deepcopy(template)
23
+
24
+ node_data['inputs']['start_percent'] = 0.8
25
+ node_data['inputs']['end_percent'] = 1.0
26
+ node_data['inputs']['pattern'] = "single_shift"
27
+ node_data['inputs']['passes'] = "ramp_2_4"
28
+ node_data['inputs']['blend'] = "median"
29
+ node_data['inputs']['strength'] = 1.0
30
+
31
+ node_data['inputs']['model'] = current_model_connection
32
+
33
+ new_node_id = assembler._get_unique_id()
34
+ assembler.workflow[new_node_id] = node_data
35
+
36
+ current_model_connection = [new_node_id, 0]
37
+
38
+ assembler.workflow[target_node_id]['inputs']['model'] = current_model_connection
39
+ print("HiDream-O1 Patch Seam Smoothing injector applied.")
comfy_integration/setup.py CHANGED
@@ -74,6 +74,14 @@ def initialize_comfyui():
74
  else:
75
  print("✅ ComfyUI-Newbie-Nodes extension already exists.")
76
 
 
 
 
 
 
 
 
 
77
  print(f"✅ Current working directory is: {os.getcwd()}")
78
 
79
  import comfy.model_management
 
74
  else:
75
  print("✅ ComfyUI-Newbie-Nodes extension already exists.")
76
 
77
+ # 5. ComfyUI-Anima-LLLite
78
+ anima_controlnet_lllite_nodes_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-Anima-LLLite")
79
+ if not os.path.exists(anima_controlnet_lllite_nodes_path):
80
+ os.system(f"git clone https://github.com/kohya-ss/ComfyUI-Anima-LLLite.git {anima_controlnet_lllite_nodes_path}")
81
+ print("✅ ComfyUI-Anima-LLLite extension cloned.")
82
+ else:
83
+ print("✅ ComfyUI-Anima-LLLite extension already exists.")
84
+
85
  print(f"✅ Current working directory is: {os.getcwd()}")
86
 
87
  import comfy.model_management
core/pipelines/sd_image_pipeline.py CHANGED
@@ -96,9 +96,17 @@ class SdImagePipeline(BasePipeline):
96
  raise RuntimeError(f"Workflow integrity error: Output of node {source_node_id} needed for {node_id} but not yet computed.")
97
 
98
  source_output_tuple = computed_outputs[source_node_id]
99
- kwargs[param_name] = get_value_at_index(source_output_tuple, output_index)
100
  else:
101
- kwargs[param_name] = param_value
 
 
 
 
 
 
 
 
102
 
103
  function_name = getattr(node_class, 'FUNCTION')
104
  execution_method = getattr(node_instance, function_name)
@@ -198,13 +206,14 @@ class SdImagePipeline(BasePipeline):
198
 
199
  if task_type == 'img2img':
200
  input_image_pil = ui_inputs.get('img2img_image')
201
- if input_image_pil:
202
- temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")
203
- input_image_pil.save(temp_file_path, "PNG")
204
- ui_inputs['input_image'] = os.path.basename(temp_file_path)
205
- temp_files_to_clean.append(temp_file_path)
206
- ui_inputs['width'] = input_image_pil.width
207
- ui_inputs['height'] = input_image_pil.height
 
208
 
209
  elif task_type == 'inpaint':
210
  inpaint_dict = ui_inputs.get('inpaint_image_dict')
@@ -231,22 +240,24 @@ class SdImagePipeline(BasePipeline):
231
 
232
  elif task_type == 'outpaint':
233
  input_image_pil = ui_inputs.get('outpaint_image')
234
- if input_image_pil:
235
- temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")
236
- input_image_pil.save(temp_file_path, "PNG")
237
- ui_inputs['input_image'] = os.path.basename(temp_file_path)
238
- temp_files_to_clean.append(temp_file_path)
 
239
 
240
  ui_inputs['megapixels'] = 0.25
241
  ui_inputs['grow_mask_by'] = ui_inputs.get('feathering', 10)
242
 
243
  elif task_type == 'hires_fix':
244
  input_image_pil = ui_inputs.get('hires_image')
245
- if input_image_pil:
246
- temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")
247
- input_image_pil.save(temp_file_path, "PNG")
248
- ui_inputs['input_image'] = os.path.basename(temp_file_path)
249
- temp_files_to_clean.append(temp_file_path)
 
250
 
251
  embedding_data = ui_inputs.get('embedding_data', [])
252
  embedding_filenames = []
@@ -287,7 +298,24 @@ class SdImagePipeline(BasePipeline):
287
  "image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],
288
  "start_percent": 0.0, "end_percent": 1.0, "control_net_name": cn_filepaths[i]
289
  })
290
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  diffsynth_controlnet_data = ui_inputs.get('diffsynth_controlnet_data', [])
292
  active_diffsynth_controlnets = []
293
  if diffsynth_controlnet_data:
@@ -416,6 +444,17 @@ class SdImagePipeline(BasePipeline):
416
  img.save(temp_path, "PNG")
417
  temp_files_to_clean.append(temp_path)
418
  active_reference_latents.append(os.path.basename(temp_path))
 
 
 
 
 
 
 
 
 
 
 
419
 
420
  from utils.app_utils import get_vae_path
421
  vae_source = ui_inputs.get('vae_source')
@@ -471,6 +510,10 @@ class SdImagePipeline(BasePipeline):
471
  recipe_path = os.path.join(os.path.dirname(__file__), "workflow_recipes", "sd_unified_recipe.yaml")
472
  assembler = WorkflowAssembler(recipe_path, dynamic_values=dynamic_values)
473
 
 
 
 
 
474
  workflow_inputs = {
475
  **ui_inputs,
476
  "positive_prompt": ui_inputs['positive_prompt'], "negative_prompt": ui_inputs['negative_prompt'],
@@ -482,7 +525,8 @@ class SdImagePipeline(BasePipeline):
482
  "vae_name": ui_inputs.get('vae_name'),
483
  "guidance": ui_inputs.get('guidance', 3.5),
484
  "lora_chain": active_loras_for_gpu,
485
- "controlnet_chain": active_controlnets,
 
486
  "diffsynth_controlnet_chain": active_diffsynth_controlnets,
487
  "ipadapter_chain": active_ipadapters,
488
  "flux1_ipadapter_chain": active_flux1_ipadapters,
@@ -490,7 +534,9 @@ class SdImagePipeline(BasePipeline):
490
  "style_chain": active_styles,
491
  "conditioning_chain": active_conditioning,
492
  "reference_latent_chain": active_reference_latents,
 
493
  "vae_chain": [ui_inputs.get('vae_name')] if ui_inputs.get('vae_name') else [],
 
494
  }
495
 
496
  if isinstance(path_or_components, dict):
 
96
  raise RuntimeError(f"Workflow integrity error: Output of node {source_node_id} needed for {node_id} but not yet computed.")
97
 
98
  source_output_tuple = computed_outputs[source_node_id]
99
+ actual_value = get_value_at_index(source_output_tuple, output_index)
100
  else:
101
+ actual_value = param_value
102
+
103
+ if '.' in param_name:
104
+ parent_key, child_key = param_name.split('.', 1)
105
+ if parent_key not in kwargs or not isinstance(kwargs[parent_key], dict):
106
+ kwargs[parent_key] = {}
107
+ kwargs[parent_key][child_key] = actual_value
108
+ else:
109
+ kwargs[param_name] = actual_value
110
 
111
  function_name = getattr(node_class, 'FUNCTION')
112
  execution_method = getattr(node_instance, function_name)
 
206
 
207
  if task_type == 'img2img':
208
  input_image_pil = ui_inputs.get('img2img_image')
209
+ if not input_image_pil:
210
+ raise gr.Error("Please upload an image for Image-to-Image.")
211
+ temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")
212
+ input_image_pil.save(temp_file_path, "PNG")
213
+ ui_inputs['input_image'] = os.path.basename(temp_file_path)
214
+ temp_files_to_clean.append(temp_file_path)
215
+ ui_inputs['width'] = input_image_pil.width
216
+ ui_inputs['height'] = input_image_pil.height
217
 
218
  elif task_type == 'inpaint':
219
  inpaint_dict = ui_inputs.get('inpaint_image_dict')
 
240
 
241
  elif task_type == 'outpaint':
242
  input_image_pil = ui_inputs.get('outpaint_image')
243
+ if not input_image_pil:
244
+ raise gr.Error("Please upload an image for Outpainting.")
245
+ temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")
246
+ input_image_pil.save(temp_file_path, "PNG")
247
+ ui_inputs['input_image'] = os.path.basename(temp_file_path)
248
+ temp_files_to_clean.append(temp_file_path)
249
 
250
  ui_inputs['megapixels'] = 0.25
251
  ui_inputs['grow_mask_by'] = ui_inputs.get('feathering', 10)
252
 
253
  elif task_type == 'hires_fix':
254
  input_image_pil = ui_inputs.get('hires_image')
255
+ if not input_image_pil:
256
+ raise gr.Error("Please upload an image for Hires Fix.")
257
+ temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")
258
+ input_image_pil.save(temp_file_path, "PNG")
259
+ ui_inputs['input_image'] = os.path.basename(temp_file_path)
260
+ temp_files_to_clean.append(temp_file_path)
261
 
262
  embedding_data = ui_inputs.get('embedding_data', [])
263
  embedding_filenames = []
 
298
  "image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],
299
  "start_percent": 0.0, "end_percent": 1.0, "control_net_name": cn_filepaths[i]
300
  })
301
+
302
+ anima_controlnet_lllite_data = ui_inputs.get('anima_controlnet_lllite_data', [])
303
+ active_anima_controlnets = []
304
+ if anima_controlnet_lllite_data:
305
+ (cn_images, _, _, cn_strengths, cn_filepaths, cn_starts, cn_ends) = [anima_controlnet_lllite_data[i::7] for i in range(7)]
306
+ for i in range(len(cn_images)):
307
+ if cn_images[i] and cn_strengths[i] > 0 and cn_filepaths[i] and cn_filepaths[i] != "None":
308
+ from utils.app_utils import _ensure_model_downloaded
309
+ _ensure_model_downloaded(cn_filepaths[i], progress)
310
+ if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
311
+ cn_temp_path = os.path.join(INPUT_DIR, f"temp_anima_cn_{i}_{random.randint(1000, 9999)}.png")
312
+ cn_images[i].save(cn_temp_path, "PNG")
313
+ temp_files_to_clean.append(cn_temp_path)
314
+ active_anima_controlnets.append({
315
+ "image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],
316
+ "start_percent": cn_starts[i], "end_percent": cn_ends[i], "control_net_name": cn_filepaths[i]
317
+ })
318
+
319
  diffsynth_controlnet_data = ui_inputs.get('diffsynth_controlnet_data', [])
320
  active_diffsynth_controlnets = []
321
  if diffsynth_controlnet_data:
 
444
  img.save(temp_path, "PNG")
445
  temp_files_to_clean.append(temp_path)
446
  active_reference_latents.append(os.path.basename(temp_path))
447
+
448
+ hidream_o1_reference_data = ui_inputs.get('hidream_o1_reference_data', [])
449
+ active_hidream_o1_reference = []
450
+ if hidream_o1_reference_data:
451
+ for img in hidream_o1_reference_data:
452
+ if img:
453
+ if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)
454
+ temp_path = os.path.join(INPUT_DIR, f"temp_ho1_ref_{random.randint(1000, 9999)}.png")
455
+ img.save(temp_path, "PNG")
456
+ temp_files_to_clean.append(temp_path)
457
+ active_hidream_o1_reference.append(os.path.basename(temp_path))
458
 
459
  from utils.app_utils import get_vae_path
460
  vae_source = ui_inputs.get('vae_source')
 
510
  recipe_path = os.path.join(os.path.dirname(__file__), "workflow_recipes", "sd_unified_recipe.yaml")
511
  assembler = WorkflowAssembler(recipe_path, dynamic_values=dynamic_values)
512
 
513
+ hidream_o1_smoothing_data = []
514
+ if workflow_model_type == 'hidream-o1' and model_display_name == "HiDream-O1-Image":
515
+ hidream_o1_smoothing_data.append({})
516
+
517
  workflow_inputs = {
518
  **ui_inputs,
519
  "positive_prompt": ui_inputs['positive_prompt'], "negative_prompt": ui_inputs['negative_prompt'],
 
525
  "vae_name": ui_inputs.get('vae_name'),
526
  "guidance": ui_inputs.get('guidance', 3.5),
527
  "lora_chain": active_loras_for_gpu,
528
+ "controlnet_chain": active_controlnets if not active_anima_controlnets else [],
529
+ "anima_controlnet_lllite_chain": active_anima_controlnets,
530
  "diffsynth_controlnet_chain": active_diffsynth_controlnets,
531
  "ipadapter_chain": active_ipadapters,
532
  "flux1_ipadapter_chain": active_flux1_ipadapters,
 
534
  "style_chain": active_styles,
535
  "conditioning_chain": active_conditioning,
536
  "reference_latent_chain": active_reference_latents,
537
+ "hidream_o1_reference_chain": active_hidream_o1_reference,
538
  "vae_chain": [ui_inputs.get('vae_name')] if ui_inputs.get('vae_name') else [],
539
+ "hidream_o1_smoothing_chain": hidream_o1_smoothing_data,
540
  }
541
 
542
  if isinstance(path_or_components, dict):
core/pipelines/workflow_recipes/_partials/conditioning/anima.yaml CHANGED
@@ -43,6 +43,10 @@ dynamic_lora_chains:
43
  "model": ["ksampler:model"]
44
  "clip": ["pos_prompt:clip", "neg_prompt:clip"]
45
 
 
 
 
 
46
  dynamic_conditioning_chains:
47
  conditioning_chain:
48
  ksampler_node: "ksampler"
 
43
  "model": ["ksampler:model"]
44
  "clip": ["pos_prompt:clip", "neg_prompt:clip"]
45
 
46
+ dynamic_anima_controlnet_lllite_chains:
47
+ anima_controlnet_lllite_chain:
48
+ ksampler_node: "ksampler"
49
+
50
  dynamic_conditioning_chains:
51
  conditioning_chain:
52
  ksampler_node: "ksampler"
core/pipelines/workflow_recipes/_partials/conditioning/{hidream.yaml → hidream-i1.yaml} RENAMED
@@ -1,15 +1,15 @@
1
  nodes:
2
  unet_loader:
3
  class_type: UNETLoader
4
- title: "Load HiDream UNET"
5
  params:
6
  weight_dtype: "default"
7
  vae_loader:
8
  class_type: VAELoader
9
- title: "Load HiDream VAE"
10
  clip_loader:
11
  class_type: QuadrupleCLIPLoader
12
- title: "Load HiDream Quadruple CLIP"
13
 
14
  model_sampler:
15
  class_type: ModelSamplingSD3
 
1
  nodes:
2
  unet_loader:
3
  class_type: UNETLoader
4
+ title: "Load HiDream-I1 UNET"
5
  params:
6
  weight_dtype: "default"
7
  vae_loader:
8
  class_type: VAELoader
9
+ title: "Load HiDream-I1 VAE"
10
  clip_loader:
11
  class_type: QuadrupleCLIPLoader
12
+ title: "Load HiDream-I1 Quadruple CLIP"
13
 
14
  model_sampler:
15
  class_type: ModelSamplingSD3
core/pipelines/workflow_recipes/_partials/conditioning/hidream-o1.yaml ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ nodes:
2
+ ckpt_loader:
3
+ class_type: CheckpointLoaderSimple
4
+ title: "Load Checkpoint"
5
+
6
+ model_noise_scale:
7
+ class_type: ModelNoiseScale
8
+ title: "ModelNoiseScale"
9
+ params:
10
+ noise_scale: 8
11
+
12
+ connections:
13
+ - from: "ckpt_loader:0"
14
+ to: "model_noise_scale:model"
15
+
16
+ - from: "model_noise_scale:0"
17
+ to: "ksampler:model"
18
+
19
+ - from: "ckpt_loader:1"
20
+ to: "pos_prompt:clip"
21
+ - from: "ckpt_loader:1"
22
+ to: "neg_prompt:clip"
23
+
24
+ - from: "pos_prompt:0"
25
+ to: "ksampler:positive"
26
+ - from: "neg_prompt:0"
27
+ to: "ksampler:negative"
28
+
29
+ - from: "ckpt_loader:2"
30
+ to: "vae_decode:vae"
31
+ - from: "ckpt_loader:2"
32
+ to: "vae_encode:vae"
33
+
34
+ dynamic_vae_chains:
35
+ vae_chain:
36
+ targets:
37
+ - "vae_decode:vae"
38
+ - "vae_encode:vae"
39
+
40
+ dynamic_lora_chains:
41
+ lora_chain:
42
+ template: "LoraLoader"
43
+ start: "ckpt_loader"
44
+ output_map:
45
+ "0": "model"
46
+ "1": "clip"
47
+ input_map:
48
+ "model": "model"
49
+ "clip": "clip"
50
+ end_input_map:
51
+ "model": ["model_noise_scale:model"]
52
+ "clip": ["pos_prompt:clip", "neg_prompt:clip"]
53
+
54
+ dynamic_hidream_o1_smoothing_chains:
55
+ hidream_o1_smoothing_chain:
56
+ target_node: "ksampler"
57
+
58
+ dynamic_conditioning_chains:
59
+ conditioning_chain:
60
+ ksampler_node: "ksampler"
61
+ clip_source: "ckpt_loader:1"
62
+
63
+ dynamic_hidream_o1_reference_chains:
64
+ hidream_o1_reference_chain:
65
+ ksampler_node: "ksampler"
66
+
67
+ ui_map:
68
+ model_name: "ckpt_loader:ckpt_name"
core/pipelines/workflow_recipes/_partials/input/txt2img_hidream_o1_latent.yaml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ nodes:
2
+ latent_source:
3
+ class_type: "EmptyHiDreamO1LatentImage"
4
+ title: "Empty HiDream-O1 Latent Image"
5
+
6
+ connections: []
7
+
8
+ ui_map:
9
+ width: "latent_source:width"
10
+ height: "latent_source:height"
11
+ batch_size: "latent_source:batch_size"
requirements.txt CHANGED
@@ -1,10 +1,10 @@
1
- comfyui-frontend-package==1.42.15
2
- comfyui-workflow-templates==0.9.66
3
- comfyui-embedded-docs==0.4.4
4
- torch==2.10.0
5
  torchsde
6
- torchvision==0.25.0
7
- torchaudio==2.10.0
8
  numpy>=1.25.0
9
  einops
10
  transformers>=4.50.3
@@ -23,7 +23,7 @@ SQLAlchemy>=2.0.0
23
  filelock
24
  av>=14.2.0
25
  comfy-kitchen>=0.2.8
26
- comfy-aimdo==0.3.0
27
  requests
28
  simpleeval>=1.0.0
29
  blake3
@@ -37,26 +37,10 @@ PyOpenGL
37
  glfw
38
 
39
 
40
- addict
41
- albumentations
42
- ftfy
43
- fvcore
44
  huggingface-hub
45
- imageio[ffmpeg]
46
- importlib_metadata
47
- matplotlib
48
- mediapipe
49
- ninja
50
- omegaconf
51
- opencv-python>=4.7.0.72
52
- python-dateutil
53
- scikit-image
54
- scikit-learn
55
- soundfile
56
  spaces
57
- svglib
58
- trimesh[easy]
59
- yacs
60
- yapf
61
- onnxruntime-gpu
62
- diffusers
 
1
+ comfyui-frontend-package==1.44.19
2
+ comfyui-workflow-templates==0.9.82
3
+ comfyui-embedded-docs==0.5.1
4
+ torch
5
  torchsde
6
+ torchvision
7
+ torchaudio
8
  numpy>=1.25.0
9
  einops
10
  transformers>=4.50.3
 
23
  filelock
24
  av>=14.2.0
25
  comfy-kitchen>=0.2.8
26
+ comfy-aimdo==0.4.5
27
  requests
28
  simpleeval>=1.0.0
29
  blake3
 
37
  glfw
38
 
39
 
40
+ diffusers
41
+ protobuf
 
 
42
  huggingface-hub
43
+ imageio
44
+
 
 
 
 
 
 
 
 
 
45
  spaces
46
+ sageattention @ https://huggingface.co/RioShiina/Sage-Attention-ZeroGPU-Space-Build/resolve/main/sageattention-2.2.0-cp312-cp312-linux_x86_64.whl
 
 
 
 
 
scripts/__init__.py DELETED
File without changes
scripts/build_sage_attention.py DELETED
@@ -1,99 +0,0 @@
1
- import os
2
- import subprocess
3
- import sys
4
- import textwrap
5
-
6
- REPO_URL = "https://github.com/thu-ml/SageAttention.git"
7
- REPO_DIR = "SageAttention"
8
-
9
- def run_command(command, cwd=None, env=None):
10
- print(f"🚀 Running command: {' '.join(command)}")
11
- result = subprocess.run(
12
- command,
13
- cwd=cwd,
14
- env=env,
15
- stdout=subprocess.PIPE,
16
- stderr=subprocess.STDOUT,
17
- text=True
18
- )
19
-
20
- if result.returncode != 0:
21
- print(result.stdout)
22
- raise subprocess.CalledProcessError(result.returncode, command)
23
-
24
- def patch_setup_py(setup_py_path):
25
- print(f"--- [SageAttention Build] Applying patches to {setup_py_path} ---")
26
-
27
- with open(setup_py_path, 'r', encoding='utf-8') as f:
28
- content = f.read()
29
-
30
- original_cxx_flags = 'CXX_FLAGS = ["-g", "-O3", "-fopenmp", "-lgomp", "-std=c++17", "-DENABLE_BF16"]'
31
- modified_cxx_flags = 'CXX_FLAGS = ["-g", "-O3", "-std=c++17", "-DENABLE_BF16"]'
32
-
33
- if original_cxx_flags in content:
34
- content = content.replace(original_cxx_flags, modified_cxx_flags)
35
- print("🔧 Patch 1/1: Removed '-fopenmp' and '-lgomp' from CXX_FLAGS.")
36
- else:
37
- print("⚠️ Patch 1/1: CXX_FLAGS line not found as expected. It might have been changed upstream. Skipping.")
38
-
39
- with open(setup_py_path, 'w', encoding='utf-8') as f:
40
- f.write(content)
41
-
42
- print("✅ Patches applied successfully.")
43
-
44
-
45
- def install_sage_attention():
46
- print("--- [SageAttention Build] Checking environment ---")
47
-
48
- if os.path.isdir(REPO_DIR):
49
- print(f"✅ Directory '{REPO_DIR}' already exists, assuming SageAttention is installed. Skipping build.")
50
- return
51
-
52
- print(f"⏳ Directory '{REPO_DIR}' not found. Starting a fresh installation of SageAttention.")
53
-
54
- try:
55
- print(f"--- [SageAttention Build] Step 1/3: Cloning repository ---")
56
- run_command(["git", "clone", REPO_URL])
57
- print("✅ Repository cloned successfully.")
58
-
59
- print(f"--- [SageAttention Build] Step 2/3: Patching setup.py ---")
60
- setup_py_path = os.path.join(REPO_DIR, "setup.py")
61
- patch_setup_py(setup_py_path)
62
-
63
- print(f"--- [SageAttention Build] Step 3/3: Compiling and installing ---")
64
-
65
- build_env = os.environ.copy()
66
- build_env.update({
67
- "TORCH_CUDA_ARCH_LIST": "9.0",
68
- "EXT_PARALLEL": "4",
69
- "NVCC_APPEND_FLAGS": "--threads 8",
70
- "MAX_JOBS": "32"
71
- })
72
- print("🔧 Setting build environment variables:")
73
- print(f" - TORCH_CUDA_ARCH_LIST='{build_env['TORCH_CUDA_ARCH_LIST']}'")
74
- print(f" - EXT_PARALLEL={build_env['EXT_PARALLEL']}")
75
- print(f" - NVCC_APPEND_FLAGS='{build_env['NVCC_APPEND_FLAGS']}'")
76
- print(f" - MAX_JOBS={build_env['MAX_JOBS']}")
77
-
78
- install_command = [sys.executable, "setup.py", "install"]
79
-
80
- run_command(install_command, cwd=REPO_DIR, env=build_env)
81
-
82
- print("🎉 SageAttention compiled and installed successfully! ---")
83
-
84
- except FileNotFoundError:
85
- print("❌ ERROR: 'git' command not found. Please ensure Git is installed in your environment.")
86
- sys.exit(1)
87
- except subprocess.CalledProcessError as e:
88
- print(f"❌ Command failed with return code: {e.returncode}")
89
- print(f"❌ Command: {' '.join(e.cmd)}")
90
- print("❌ SageAttention installation failed. Please check the logs above for details.")
91
- sys.exit(1)
92
- except Exception as e:
93
- print(f"❌ An unknown error occurred: {e}")
94
- sys.exit(1)
95
-
96
- if __name__ == "__main__":
97
- if os.path.isdir(REPO_DIR):
98
- print(f"Note: To force a rebuild, please delete the '{REPO_DIR}' directory first.")
99
- install_sage_attention()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/events.py DELETED
@@ -1,1258 +0,0 @@
1
- import gradio as gr
2
- import yaml
3
- import os
4
- import shutil
5
- from functools import lru_cache
6
- from core.settings import *
7
- from utils.app_utils import *
8
- from core.generation_logic import *
9
- from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
10
-
11
- from utils.app_utils import save_uploaded_file_with_hash
12
- from ui.shared.ui_components import RESOLUTION_MAP, MAX_CONTROLNETS, MAX_IPADAPTERS, MAX_EMBEDDINGS, MAX_CONDITIONINGS, MAX_LORAS
13
-
14
-
15
- @lru_cache(maxsize=1)
16
- def load_controlnet_config():
17
- _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
18
- _CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'controlnet_models.yaml')
19
- try:
20
- print("--- Loading controlnet_models.yaml ---")
21
- with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
22
- config = yaml.safe_load(f)
23
- print("--- ✅ controlnet_models.yaml loaded successfully ---")
24
- return config.get("ControlNet", {})
25
- except Exception as e:
26
- print(f"Error loading controlnet_models.yaml: {e}")
27
- return {}
28
-
29
-
30
- def get_cn_defaults(arch_val):
31
- cn_full_config = load_controlnet_config()
32
- cn_config = cn_full_config.get(arch_val, [])
33
-
34
- if not cn_config:
35
- return [], None, [], None, "None"
36
-
37
- all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", []))))
38
- default_type = all_types[0] if all_types else None
39
-
40
- series_choices = []
41
- if default_type:
42
- series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", []))))
43
- default_series = series_choices[0] if series_choices else None
44
-
45
- filepath = "None"
46
- if default_series and default_type:
47
- for model in cn_config:
48
- if model.get("Series") == default_series and default_type in model.get("Type", []):
49
- filepath = model.get("Filepath")
50
- break
51
-
52
- return all_types, default_type, series_choices, default_series, filepath
53
-
54
- @lru_cache(maxsize=1)
55
- def load_diffsynth_controlnet_config():
56
- _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
57
- _CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'diffsynth_controlnet_models.yaml')
58
- try:
59
- print("--- Loading diffsynth_controlnet_models.yaml ---")
60
- with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
61
- config = yaml.safe_load(f)
62
- print("--- ✅ diffsynth_controlnet_models.yaml loaded successfully ---")
63
- return config.get("DiffSynth_ControlNet", {})
64
- except Exception as e:
65
- print(f"Error loading diffsynth_controlnet_models.yaml: {e}")
66
- return {}
67
-
68
- def get_diffsynth_cn_defaults(arch_val):
69
- cn_full_config = load_diffsynth_controlnet_config()
70
- cn_config = cn_full_config.get(arch_val, [])
71
-
72
- if not cn_config:
73
- return [], None, [], None, "None"
74
-
75
- all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", []))))
76
- default_type = all_types[0] if all_types else None
77
-
78
- series_choices = []
79
- if default_type:
80
- series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", []))))
81
- default_series = series_choices[0] if series_choices else None
82
-
83
- filepath = "None"
84
- if default_series and default_type:
85
- for model in cn_config:
86
- if model.get("Series") == default_series and default_type in model.get("Type", []):
87
- filepath = model.get("Filepath")
88
- break
89
-
90
- return all_types, default_type, series_choices, default_series, filepath
91
-
92
-
93
- @lru_cache(maxsize=1)
94
- def load_ipadapter_config():
95
- _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
96
- _IPA_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'ipadapter.yaml')
97
- try:
98
- print("--- Loading ipadapter.yaml ---")
99
- with open(_IPA_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
100
- config = yaml.safe_load(f)
101
- print("--- ✅ ipadapter.yaml loaded successfully ---")
102
- return config
103
- except Exception as e:
104
- print(f"Error loading ipadapter.yaml: {e}")
105
- return {}
106
-
107
-
108
- def apply_data_to_ui(data, prefix, ui_components):
109
- final_sampler = data.get('sampler') if data.get('sampler') in SAMPLER_CHOICES else SAMPLER_CHOICES[0]
110
- default_scheduler = 'normal' if 'normal' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0]
111
- final_scheduler = data.get('scheduler') if data.get('scheduler') in SCHEDULER_CHOICES else default_scheduler
112
-
113
- updates = {}
114
- base_model_name = data.get('base_model')
115
-
116
- model_map = MODEL_MAP_CHECKPOINT
117
-
118
- if f'base_model_{prefix}' in ui_components:
119
- model_dropdown_component = ui_components[f'base_model_{prefix}']
120
- if base_model_name and base_model_name in model_map:
121
- updates[model_dropdown_component] = base_model_name
122
- if f'model_arch_{prefix}' in ui_components:
123
- m_type = MODEL_TYPE_MAP.get(base_model_name, "SDXL")
124
- updates[ui_components[f'model_arch_{prefix}']] = m_type
125
- if f'model_cat_{prefix}' in ui_components:
126
- m_info = model_map.get(base_model_name)
127
- m_cat = m_info[4] if m_info and len(m_info) > 4 else None
128
- updates[ui_components[f'model_cat_{prefix}']] = m_cat if m_cat else "ALL"
129
- else:
130
- updates[model_dropdown_component] = gr.update()
131
-
132
- common_params = {
133
- f'prompt_{prefix}': data.get('prompt', ''),
134
- f'neg_prompt_{prefix}': data.get('negative_prompt', ''),
135
- f'seed_{prefix}': data.get('seed', -1),
136
- f'cfg_{prefix}': data.get('cfg_scale', 7.5),
137
- f'steps_{prefix}': data.get('steps', 28),
138
- f'sampler_{prefix}': final_sampler,
139
- f'scheduler_{prefix}': final_scheduler,
140
- }
141
-
142
- for comp_name, value in common_params.items():
143
- if comp_name in ui_components:
144
- updates[ui_components[comp_name]] = value
145
-
146
- if prefix == 'txt2img':
147
- if f'width_{prefix}' in ui_components:
148
- updates[ui_components[f'width_{prefix}']] = data.get('width', 1024)
149
- if f'height_{prefix}' in ui_components:
150
- updates[ui_components[f'height_{prefix}']] = data.get('height', 1024)
151
-
152
- tab_indices = {"txt2img": 0, "img2img": 1, "inpaint": 2, "outpaint": 3, "hires_fix": 4}
153
- tab_index = tab_indices.get(prefix, 0)
154
-
155
- updates[ui_components['tabs']] = gr.Tabs(selected=tab_index)
156
-
157
- return updates
158
-
159
-
160
- def send_info_to_tab(image, prefix, ui_components):
161
- if not image or not image.info.get('parameters', ''):
162
- all_comps = [comp for comp_or_list in ui_components.values() for comp in (comp_or_list if isinstance(comp_or_list, list) else [comp_or_list])]
163
- return {comp: gr.update() for comp in all_comps}
164
-
165
- data = parse_parameters(image.info['parameters'])
166
-
167
- image_input_map = {
168
- "img2img": 'input_image_img2img',
169
- "inpaint": 'input_image_dict_inpaint',
170
- "outpaint": 'input_image_outpaint',
171
- "hires_fix": 'input_image_hires_fix'
172
- }
173
-
174
- updates = apply_data_to_ui(data, prefix, ui_components)
175
-
176
- if prefix in image_input_map and image_input_map[prefix] in ui_components:
177
- component_key = image_input_map[prefix]
178
- updates[ui_components[component_key]] = gr.update(value=image)
179
-
180
- return updates
181
-
182
-
183
- def send_info_by_hash(image, ui_components):
184
- if not image or not image.info.get('parameters', ''):
185
- all_comps = [comp for comp_or_list in ui_components.values() for comp in (comp_or_list if isinstance(comp_or_list, list) else [comp_or_list])]
186
- return {comp: gr.update() for comp in all_comps}
187
-
188
- data = parse_parameters(image.info['parameters'])
189
-
190
- return apply_data_to_ui(data, "txt2img", ui_components)
191
-
192
-
193
- def attach_event_handlers(ui_components, demo):
194
-
195
- def create_lora_event_handlers(prefix):
196
- lora_rows = ui_components.get(f'lora_rows_{prefix}')
197
- if not lora_rows: return
198
- lora_ids = ui_components[f'lora_ids_{prefix}']
199
- lora_scales = ui_components[f'lora_scales_{prefix}']
200
- lora_uploads = ui_components[f'lora_uploads_{prefix}']
201
- count_state = ui_components[f'lora_count_state_{prefix}']
202
- add_button = ui_components[f'add_lora_button_{prefix}']
203
- del_button = ui_components[f'delete_lora_button_{prefix}']
204
-
205
- def add_lora_row(c):
206
- updates = {}
207
- if c < MAX_LORAS:
208
- c += 1
209
- updates[lora_rows[c - 1]] = gr.update(visible=True)
210
-
211
- updates[count_state] = c
212
- updates[add_button] = gr.update(visible=c < MAX_LORAS)
213
- updates[del_button] = gr.update(visible=c > 1)
214
- return updates
215
-
216
- def del_lora_row(c):
217
- updates = {}
218
- if c > 1:
219
- updates[lora_rows[c - 1]] = gr.update(visible=False)
220
- updates[lora_ids[c - 1]] = ""
221
- updates[lora_scales[c - 1]] = 0.0
222
- updates[lora_uploads[c - 1]] = None
223
- c -= 1
224
-
225
- updates[count_state] = c
226
- updates[add_button] = gr.update(visible=True)
227
- updates[del_button] = gr.update(visible=c > 1)
228
- return updates
229
-
230
- add_outputs = [count_state, add_button, del_button] + lora_rows
231
- del_outputs = [count_state, add_button, del_button] + lora_rows + lora_ids + lora_scales + lora_uploads
232
-
233
- add_button.click(add_lora_row, [count_state], add_outputs, show_progress=False)
234
- del_button.click(del_lora_row, [count_state], del_outputs, show_progress=False)
235
-
236
- def create_controlnet_event_handlers(prefix):
237
- cn_rows = ui_components.get(f'controlnet_rows_{prefix}')
238
- if not cn_rows: return
239
- cn_types = ui_components[f'controlnet_types_{prefix}']
240
- cn_series = ui_components[f'controlnet_series_{prefix}']
241
- cn_filepaths = ui_components[f'controlnet_filepaths_{prefix}']
242
- cn_images = ui_components[f'controlnet_images_{prefix}']
243
- cn_strengths = ui_components[f'controlnet_strengths_{prefix}']
244
-
245
- count_state = ui_components[f'controlnet_count_state_{prefix}']
246
- add_button = ui_components[f'add_controlnet_button_{prefix}']
247
- del_button = ui_components[f'delete_controlnet_button_{prefix}']
248
- accordion = ui_components[f'controlnet_accordion_{prefix}']
249
-
250
- arch_comp = ui_components.get(f'model_arch_{prefix}')
251
- actual_arch_comp = arch_comp if arch_comp else gr.State("SDXL")
252
-
253
- def add_cn_row(c):
254
- c += 1
255
- updates = {
256
- count_state: c,
257
- cn_rows[c-1]: gr.update(visible=True),
258
- add_button: gr.update(visible=c < MAX_CONTROLNETS),
259
- del_button: gr.update(visible=True)
260
- }
261
- return updates
262
-
263
- def del_cn_row(c):
264
- c -= 1
265
- updates = {
266
- count_state: c,
267
- cn_rows[c]: gr.update(visible=False),
268
- cn_images[c]: None,
269
- cn_strengths[c]: 1.0,
270
- add_button: gr.update(visible=True),
271
- del_button: gr.update(visible=c > 0)
272
- }
273
- return updates
274
-
275
- add_outputs = [count_state, add_button, del_button] + cn_rows
276
- del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths
277
- add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
278
- del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
279
-
280
- def on_cn_type_change(selected_type, arch_val):
281
- cn_full_config = load_controlnet_config()
282
-
283
- architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
284
- controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
285
-
286
- cn_config = cn_full_config.get(controlnet_key, [])
287
- series_choices = []
288
- if selected_type:
289
- series_choices = sorted(list(set(
290
- model.get("Series", "Default") for model in cn_config
291
- if selected_type in model.get("Type", [])
292
- )))
293
- default_series = series_choices[0] if series_choices else None
294
- filepath = "None"
295
- if default_series:
296
- for model in cn_config:
297
- if model.get("Series") == default_series and selected_type in model.get("Type", []):
298
- filepath = model.get("Filepath")
299
- break
300
- return gr.update(choices=series_choices, value=default_series), filepath
301
-
302
- def on_cn_series_change(selected_series, selected_type, arch_val):
303
- cn_full_config = load_controlnet_config()
304
-
305
- architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
306
- controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
307
-
308
- cn_config = cn_full_config.get(controlnet_key, [])
309
- filepath = "None"
310
- if selected_series and selected_type:
311
- for model in cn_config:
312
- if model.get("Series") == selected_series and selected_type in model.get("Type", []):
313
- filepath = model.get("Filepath")
314
- break
315
- return filepath
316
-
317
- for i in range(MAX_CONTROLNETS):
318
- cn_types[i].change(
319
- fn=on_cn_type_change,
320
- inputs=[cn_types[i], actual_arch_comp],
321
- outputs=[cn_series[i], cn_filepaths[i]],
322
- show_progress=False
323
- )
324
- cn_series[i].change(
325
- fn=on_cn_series_change,
326
- inputs=[cn_series[i], cn_types[i], actual_arch_comp],
327
- outputs=[cn_filepaths[i]],
328
- show_progress=False
329
- )
330
-
331
- def on_accordion_expand(*images):
332
- return [gr.update() for _ in images]
333
-
334
- accordion.expand(
335
- fn=on_accordion_expand,
336
- inputs=cn_images,
337
- outputs=cn_images,
338
- show_progress=False
339
- )
340
-
341
- def create_diffsynth_controlnet_event_handlers(prefix):
342
- cn_rows = ui_components.get(f'diffsynth_controlnet_rows_{prefix}')
343
- if not cn_rows: return
344
- cn_types = ui_components[f'diffsynth_controlnet_types_{prefix}']
345
- cn_series = ui_components[f'diffsynth_controlnet_series_{prefix}']
346
- cn_filepaths = ui_components[f'diffsynth_controlnet_filepaths_{prefix}']
347
- cn_images = ui_components[f'diffsynth_controlnet_images_{prefix}']
348
- cn_strengths = ui_components[f'diffsynth_controlnet_strengths_{prefix}']
349
-
350
- count_state = ui_components[f'diffsynth_controlnet_count_state_{prefix}']
351
- add_button = ui_components[f'add_diffsynth_controlnet_button_{prefix}']
352
- del_button = ui_components[f'delete_diffsynth_controlnet_button_{prefix}']
353
- accordion = ui_components[f'diffsynth_controlnet_accordion_{prefix}']
354
-
355
- arch_comp = ui_components.get(f'model_arch_{prefix}')
356
- actual_arch_comp = arch_comp if arch_comp else gr.State("Z-Image")
357
-
358
- def add_cn_row(c):
359
- c += 1
360
- updates = {
361
- count_state: c,
362
- cn_rows[c-1]: gr.update(visible=True),
363
- add_button: gr.update(visible=c < MAX_CONTROLNETS),
364
- del_button: gr.update(visible=True)
365
- }
366
- return updates
367
-
368
- def del_cn_row(c):
369
- c -= 1
370
- updates = {
371
- count_state: c,
372
- cn_rows[c]: gr.update(visible=False),
373
- cn_images[c]: None,
374
- cn_strengths[c]: 1.0,
375
- add_button: gr.update(visible=True),
376
- del_button: gr.update(visible=c > 0)
377
- }
378
- return updates
379
-
380
- add_outputs = [count_state, add_button, del_button] + cn_rows
381
- del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths
382
- add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
383
- del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
384
-
385
- def on_cn_type_change(selected_type, arch_val):
386
- cn_full_config = load_diffsynth_controlnet_config()
387
-
388
- architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
389
- controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
390
-
391
- cn_config = cn_full_config.get(controlnet_key, [])
392
- series_choices = []
393
- if selected_type:
394
- series_choices = sorted(list(set(
395
- model.get("Series", "Default") for model in cn_config
396
- if selected_type in model.get("Type", [])
397
- )))
398
- default_series = series_choices[0] if series_choices else None
399
- filepath = "None"
400
- if default_series:
401
- for model in cn_config:
402
- if model.get("Series") == default_series and selected_type in model.get("Type", []):
403
- filepath = model.get("Filepath")
404
- break
405
- return gr.update(choices=series_choices, value=default_series), filepath
406
-
407
- def on_cn_series_change(selected_series, selected_type, arch_val):
408
- cn_full_config = load_diffsynth_controlnet_config()
409
-
410
- architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
411
- controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
412
-
413
- cn_config = cn_full_config.get(controlnet_key, [])
414
- filepath = "None"
415
- if selected_series and selected_type:
416
- for model in cn_config:
417
- if model.get("Series") == selected_series and selected_type in model.get("Type", []):
418
- filepath = model.get("Filepath")
419
- break
420
- return filepath
421
-
422
- for i in range(MAX_CONTROLNETS):
423
- cn_types[i].change(
424
- fn=on_cn_type_change,
425
- inputs=[cn_types[i], actual_arch_comp],
426
- outputs=[cn_series[i], cn_filepaths[i]],
427
- show_progress=False
428
- )
429
- cn_series[i].change(
430
- fn=on_cn_series_change,
431
- inputs=[cn_series[i], cn_types[i], actual_arch_comp],
432
- outputs=[cn_filepaths[i]],
433
- show_progress=False
434
- )
435
-
436
- def on_accordion_expand(*images):
437
- return [gr.update() for _ in images]
438
-
439
- accordion.expand(
440
- fn=on_accordion_expand,
441
- inputs=cn_images,
442
- outputs=cn_images,
443
- show_progress=False
444
- )
445
-
446
- def create_flux1_ipadapter_event_handlers(prefix):
447
- fipa_rows = ui_components.get(f'flux1_ipadapter_rows_{prefix}')
448
- if not fipa_rows: return
449
- count_state = ui_components[f'flux1_ipadapter_count_state_{prefix}']
450
- add_button = ui_components[f'add_flux1_ipadapter_button_{prefix}']
451
- del_button = ui_components[f'delete_flux1_ipadapter_button_{prefix}']
452
-
453
- def add_fipa_row(c):
454
- c += 1
455
- return {
456
- count_state: c,
457
- fipa_rows[c - 1]: gr.update(visible=True),
458
- add_button: gr.update(visible=c < MAX_IPADAPTERS),
459
- del_button: gr.update(visible=True),
460
- }
461
-
462
- def del_fipa_row(c):
463
- c -= 1
464
- return {
465
- count_state: c,
466
- fipa_rows[c]: gr.update(visible=False),
467
- add_button: gr.update(visible=True),
468
- del_button: gr.update(visible=c > 0),
469
- }
470
-
471
- add_outputs = [count_state, add_button, del_button] + fipa_rows
472
- del_outputs = [count_state, add_button, del_button] + fipa_rows
473
- add_button.click(fn=add_fipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
474
- del_button.click(fn=del_fipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
475
-
476
- def create_style_event_handlers(prefix):
477
- style_rows = ui_components.get(f'style_rows_{prefix}')
478
- if not style_rows: return
479
- count_state = ui_components[f'style_count_state_{prefix}']
480
- add_button = ui_components[f'add_style_button_{prefix}']
481
- del_button = ui_components[f'delete_style_button_{prefix}']
482
-
483
- def add_style_row(c):
484
- c += 1
485
- return {
486
- count_state: c,
487
- style_rows[c - 1]: gr.update(visible=True),
488
- add_button: gr.update(visible=c < 5),
489
- del_button: gr.update(visible=True),
490
- }
491
-
492
- def del_style_row(c):
493
- c -= 1
494
- return {
495
- count_state: c,
496
- style_rows[c]: gr.update(visible=False),
497
- add_button: gr.update(visible=True),
498
- del_button: gr.update(visible=c > 0),
499
- }
500
-
501
- add_outputs = [count_state, add_button, del_button] + style_rows
502
- del_outputs = [count_state, add_button, del_button] + style_rows
503
- add_button.click(fn=add_style_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
504
- del_button.click(fn=del_style_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
505
-
506
- def create_ipadapter_event_handlers(prefix):
507
- ipa_rows = ui_components.get(f'ipadapter_rows_{prefix}')
508
- if not ipa_rows: return
509
- ipa_lora_strengths = ui_components[f'ipadapter_lora_strengths_{prefix}']
510
- ipa_final_preset = ui_components[f'ipadapter_final_preset_{prefix}']
511
- ipa_final_lora_strength = ui_components[f'ipadapter_final_lora_strength_{prefix}']
512
- count_state = ui_components[f'ipadapter_count_state_{prefix}']
513
- add_button = ui_components[f'add_ipadapter_button_{prefix}']
514
- del_button = ui_components[f'delete_ipadapter_button_{prefix}']
515
- accordion = ui_components[f'ipadapter_accordion_{prefix}']
516
-
517
- def add_ipa_row(c):
518
- c += 1
519
- return {
520
- count_state: c,
521
- ipa_rows[c - 1]: gr.update(visible=True),
522
- add_button: gr.update(visible=c < MAX_IPADAPTERS),
523
- del_button: gr.update(visible=True),
524
- }
525
-
526
- def del_ipa_row(c):
527
- c -= 1
528
- return {
529
- count_state: c,
530
- ipa_rows[c]: gr.update(visible=False),
531
- add_button: gr.update(visible=True),
532
- del_button: gr.update(visible=c > 0),
533
- }
534
-
535
- add_outputs = [count_state, add_button, del_button] + ipa_rows
536
- del_outputs = [count_state, add_button, del_button] + ipa_rows
537
- add_button.click(fn=add_ipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
538
- del_button.click(fn=del_ipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
539
-
540
- def on_preset_change(preset_value):
541
- config = load_ipadapter_config()
542
- faceid_presets = []
543
- if config:
544
- faceid_presets.extend(config.get("IPAdapter_FaceID_presets", {}).get("SDXL", []))
545
- faceid_presets.extend(config.get("IPAdapter_FaceID_presets", {}).get("SD1.5", []))
546
-
547
- is_visible = preset_value in faceid_presets
548
- updates = [gr.update(visible=is_visible)] * (MAX_IPADAPTERS + 1)
549
- return updates
550
-
551
- all_lora_strength_sliders = [ipa_final_lora_strength] + ipa_lora_strengths
552
- ipa_final_preset.change(fn=on_preset_change, inputs=[ipa_final_preset], outputs=all_lora_strength_sliders, show_progress=False)
553
-
554
- accordion.expand(fn=lambda *imgs: [gr.update() for _ in imgs], inputs=ui_components[f'ipadapter_images_{prefix}'], outputs=ui_components[f'ipadapter_images_{prefix}'], show_progress=False)
555
-
556
- def create_reference_latent_event_handlers(prefix):
557
- ref_rows = ui_components.get(f'reference_latent_rows_{prefix}')
558
- if not ref_rows: return
559
- count_state = ui_components[f'reference_latent_count_state_{prefix}']
560
- add_button = ui_components[f'add_reference_latent_button_{prefix}']
561
- del_button = ui_components[f'delete_reference_latent_button_{prefix}']
562
- images = ui_components[f'reference_latent_images_{prefix}']
563
-
564
- def add_ref_row(c):
565
- c += 1
566
- return {
567
- count_state: c,
568
- ref_rows[c - 1]: gr.update(visible=True),
569
- add_button: gr.update(visible=c < 10),
570
- del_button: gr.update(visible=True),
571
- }
572
-
573
- def del_ref_row(c):
574
- c -= 1
575
- return {
576
- count_state: c,
577
- ref_rows[c]: gr.update(visible=False),
578
- images[c]: None,
579
- add_button: gr.update(visible=True),
580
- del_button: gr.update(visible=c > 0),
581
- }
582
-
583
- add_outputs = [count_state, add_button, del_button] + ref_rows
584
- del_outputs = [count_state, add_button, del_button] + ref_rows + images
585
- add_button.click(fn=add_ref_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
586
- del_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
587
-
588
-
589
- def create_embedding_event_handlers(prefix):
590
- rows = ui_components.get(f'embedding_rows_{prefix}')
591
- if not rows: return
592
- ids = ui_components[f'embeddings_ids_{prefix}']
593
- files = ui_components[f'embeddings_files_{prefix}']
594
- count_state = ui_components[f'embedding_count_state_{prefix}']
595
- add_button = ui_components[f'add_embedding_button_{prefix}']
596
- del_button = ui_components[f'delete_embedding_button_{prefix}']
597
-
598
- def add_row(c):
599
- c += 1
600
- return {
601
- count_state: c,
602
- rows[c - 1]: gr.update(visible=True),
603
- add_button: gr.update(visible=c < MAX_EMBEDDINGS),
604
- del_button: gr.update(visible=True)
605
- }
606
-
607
- def del_row(c):
608
- c -= 1
609
- return {
610
- count_state: c,
611
- rows[c]: gr.update(visible=False),
612
- ids[c]: "",
613
- files[c]: None,
614
- add_button: gr.update(visible=True),
615
- del_button: gr.update(visible=c > 0)
616
- }
617
-
618
- add_outputs = [count_state, add_button, del_button] + rows
619
- del_outputs = [count_state, add_button, del_button] + rows + ids + files
620
- add_button.click(fn=add_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
621
- del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
622
-
623
- def create_conditioning_event_handlers(prefix):
624
- rows = ui_components.get(f'conditioning_rows_{prefix}')
625
- if not rows: return
626
- prompts = ui_components[f'conditioning_prompts_{prefix}']
627
- count_state = ui_components[f'conditioning_count_state_{prefix}']
628
- add_button = ui_components[f'add_conditioning_button_{prefix}']
629
- del_button = ui_components[f'delete_conditioning_button_{prefix}']
630
-
631
- def add_row(c):
632
- c += 1
633
- return {
634
- count_state: c,
635
- rows[c - 1]: gr.update(visible=True),
636
- add_button: gr.update(visible=c < MAX_CONDITIONINGS),
637
- del_button: gr.update(visible=True),
638
- }
639
-
640
- def del_row(c):
641
- c -= 1
642
- return {
643
- count_state: c,
644
- rows[c]: gr.update(visible=False),
645
- prompts[c]: "",
646
- add_button: gr.update(visible=True),
647
- del_button: gr.update(visible=c > 0),
648
- }
649
-
650
- add_outputs = [count_state, add_button, del_button] + rows
651
- del_outputs = [count_state, add_button, del_button] + rows + prompts
652
- add_button.click(fn=add_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
653
- del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
654
-
655
- def on_vae_upload(file_obj):
656
- if not file_obj:
657
- return gr.update(), gr.update(), None
658
-
659
- hashed_filename = save_uploaded_file_with_hash(file_obj, VAE_DIR)
660
- return hashed_filename, "File", file_obj
661
-
662
- def on_lora_upload(file_obj):
663
- if not file_obj:
664
- return gr.update(), gr.update()
665
-
666
- hashed_filename = save_uploaded_file_with_hash(file_obj, LORA_DIR)
667
- return hashed_filename, "File"
668
-
669
- def on_embedding_upload(file_obj):
670
- if not file_obj:
671
- return gr.update(), gr.update(), None
672
-
673
- hashed_filename = save_uploaded_file_with_hash(file_obj, EMBEDDING_DIR)
674
- return hashed_filename, "File", file_obj
675
-
676
-
677
- def create_run_event(prefix: str, task_type: str):
678
- run_inputs_map = {
679
- 'model_display_name': ui_components[f'base_model_{prefix}'],
680
- 'positive_prompt': ui_components.get(f'prompt_{prefix}') or ui_components.get(f'{prefix}_positive_prompt'),
681
- 'negative_prompt': ui_components.get(f'neg_prompt_{prefix}') or ui_components.get(f'{prefix}_negative_prompt'),
682
- 'seed': ui_components.get(f'seed_{prefix}') or ui_components.get(f'{prefix}_seed'),
683
- 'batch_size': ui_components.get(f'batch_size_{prefix}') or ui_components.get(f'{prefix}_batch_size'),
684
- 'guidance_scale': ui_components.get(f'cfg_{prefix}') or ui_components.get(f'{prefix}_cfg'),
685
- 'num_inference_steps': ui_components.get(f'steps_{prefix}') or ui_components.get(f'{prefix}_steps'),
686
- 'sampler': ui_components.get(f'sampler_{prefix}') or ui_components.get(f'{prefix}_sampler_name'),
687
- 'scheduler': ui_components.get(f'scheduler_{prefix}') or ui_components.get(f'{prefix}_scheduler'),
688
- 'zero_gpu_duration': ui_components.get(f'zero_gpu_{prefix}'),
689
-
690
- 'clip_skip': ui_components.get(f'clip_skip_{prefix}'),
691
- 'guidance': ui_components.get(f'guidance_{prefix}'),
692
- 'task_type': gr.State(task_type)
693
- }
694
-
695
- if task_type not in ['img2img', 'inpaint']:
696
- run_inputs_map.update({
697
- 'width': ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width'),
698
- 'height': ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
699
- })
700
-
701
- task_specific_map = {
702
- 'img2img': {'img2img_image': f'input_image_{prefix}', 'img2img_denoise': f'denoise_{prefix}'},
703
- 'inpaint': {'inpaint_image_dict': f'input_image_dict_{prefix}', 'grow_mask_by': f'grow_mask_by_{prefix}'},
704
- 'outpaint': {'outpaint_image': f'input_image_{prefix}', 'left': f'left_{prefix}', 'top': f'top_{prefix}', 'right': f'right_{prefix}', 'bottom': f'bottom_{prefix}', 'feathering': f'feathering_{prefix}'},
705
- 'hires_fix': {'hires_image': f'input_image_{prefix}', 'hires_upscaler': f'hires_upscaler_{prefix}', 'hires_scale_by': f'hires_scale_by_{prefix}', 'hires_denoise': f'denoise_{prefix}'}
706
- }
707
- if task_type in task_specific_map:
708
- for key, comp_name in task_specific_map[task_type].items():
709
- if comp_name in ui_components:
710
- run_inputs_map[key] = ui_components[comp_name]
711
-
712
- lora_data_components = ui_components.get(f'all_lora_components_flat_{prefix}', [])
713
- controlnet_data_components = ui_components.get(f'all_controlnet_components_flat_{prefix}', [])
714
- diffsynth_controlnet_data_components = ui_components.get(f'all_diffsynth_controlnet_components_flat_{prefix}', [])
715
- ipadapter_data_components = ui_components.get(f'all_ipadapter_components_flat_{prefix}', [])
716
- sd3_ipadapter_data_components = ui_components.get(f'all_sd3_ipadapter_components_flat_{prefix}', [])
717
- flux1_ipadapter_data_components = ui_components.get(f'all_flux1_ipadapter_components_flat_{prefix}', [])
718
- style_data_components = ui_components.get(f'all_style_components_flat_{prefix}', [])
719
- embedding_data_components = ui_components.get(f'all_embedding_components_flat_{prefix}', [])
720
- conditioning_data_components = ui_components.get(f'all_conditioning_components_flat_{prefix}', [])
721
- reference_latent_data_components = ui_components.get(f'all_reference_latent_components_flat_{prefix}', [])
722
-
723
- run_inputs_map['vae_source'] = ui_components.get(f'vae_source_{prefix}')
724
- run_inputs_map['vae_id'] = ui_components.get(f'vae_id_{prefix}')
725
- run_inputs_map['vae_file'] = ui_components.get(f'vae_file_{prefix}')
726
-
727
- input_keys = list(run_inputs_map.keys())
728
- input_list_flat = [v for v in run_inputs_map.values() if v is not None]
729
- all_chains = [
730
- lora_data_components, controlnet_data_components, diffsynth_controlnet_data_components, ipadapter_data_components,
731
- sd3_ipadapter_data_components, flux1_ipadapter_data_components, style_data_components,
732
- embedding_data_components, conditioning_data_components, reference_latent_data_components
733
- ]
734
- for chain in all_chains:
735
- if chain:
736
- input_list_flat.extend(chain)
737
-
738
- def create_ui_inputs_dict(*args):
739
- valid_keys = [k for k in input_keys if run_inputs_map[k] is not None]
740
- ui_dict = dict(zip(valid_keys, args[:len(valid_keys)]))
741
- arg_idx = len(valid_keys)
742
-
743
- def assign_chain_data(chain_key, components_list):
744
- nonlocal arg_idx
745
- if components_list:
746
- ui_dict[chain_key] = list(args[arg_idx : arg_idx + len(components_list)])
747
- arg_idx += len(components_list)
748
-
749
- assign_chain_data('lora_data', lora_data_components)
750
- assign_chain_data('controlnet_data', controlnet_data_components)
751
- assign_chain_data('diffsynth_controlnet_data', diffsynth_controlnet_data_components)
752
- assign_chain_data('ipadapter_data', ipadapter_data_components)
753
- assign_chain_data('sd3_ipadapter_chain', sd3_ipadapter_data_components)
754
- assign_chain_data('flux1_ipadapter_data', flux1_ipadapter_data_components)
755
- assign_chain_data('style_data', style_data_components)
756
- assign_chain_data('embedding_data', embedding_data_components)
757
- assign_chain_data('conditioning_data', conditioning_data_components)
758
- assign_chain_data('reference_latent_data', reference_latent_data_components)
759
-
760
- return ui_dict
761
-
762
- run_btn = ui_components.get(f'run_{prefix}') or ui_components.get(f'{prefix}_run_button')
763
- res_gal = ui_components.get(f'result_{prefix}') or ui_components.get(f'{prefix}_output_gallery')
764
- if run_btn and res_gal:
765
- run_btn.click(
766
- fn=lambda *args, progress=gr.Progress(track_tqdm=True): generate_image_wrapper(create_ui_inputs_dict(*args), progress),
767
- inputs=input_list_flat,
768
- outputs=[res_gal]
769
- )
770
-
771
- def make_update_fn(m_comp, cat_comp, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, ipa_preset, lora_acc, cn_acc, diffsynth_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp):
772
- def update_fn(*args):
773
- arch = args[0]
774
- category = args[1]
775
- current_ar = args[2] if len(args) > 2 else None
776
- from core.settings import MODEL_TYPE_MAP, MODEL_MAP_CHECKPOINT, FEATURES_CONFIG, ARCHITECTURES_CONFIG, MODEL_DEFAULTS_CONFIG, ARCH_CATEGORIES_MAP
777
- from utils.app_utils import get_model_generation_defaults
778
-
779
- if arch == "ALL":
780
- valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
781
- else:
782
- valid_cats = ARCH_CATEGORIES_MAP.get(arch, [])
783
-
784
- cat_choices = ["ALL"] + sorted(valid_cats)
785
- new_category = category if category in cat_choices else "ALL"
786
-
787
- choices = []
788
- for name, info in MODEL_MAP_CHECKPOINT.items():
789
- m_arch = info[2]
790
- m_cat = info[4] if len(info) > 4 else None
791
- arch_match = (arch == "ALL" or m_arch == arch)
792
- cat_match = (new_category == "ALL" or m_cat == new_category)
793
- if arch_match and cat_match:
794
- choices.append(name)
795
-
796
- val = choices[0] if choices else None
797
-
798
- updates = {
799
- m_comp: gr.update(choices=choices, value=val),
800
- cat_comp: gr.update(choices=cat_choices, value=new_category)
801
- }
802
-
803
- m_type = MODEL_TYPE_MAP.get(val, "SDXL") if val else "SDXL"
804
-
805
- architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
806
- arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
807
-
808
- arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {}))
809
- enabled_chains = arch_features.get('enabled_chains', [])
810
-
811
- if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains))
812
- if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
813
- if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
814
- if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
815
- if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
816
- if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
817
- if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains))
818
- if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains))
819
- if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains))
820
- if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains))
821
-
822
- if cs_comp:
823
- updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15"))
824
- if guidance_comp:
825
- updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1"))
826
-
827
- if ar_comp:
828
- res_key = arch_model_type
829
- if res_key not in RESOLUTION_MAP:
830
- res_key = 'sdxl'
831
- res_map = RESOLUTION_MAP.get(res_key, {})
832
- target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)")
833
- updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar)
834
- if width_comp and height_comp and target_ar in res_map:
835
- updates[width_comp] = gr.update(value=res_map[target_ar][0])
836
- updates[height_comp] = gr.update(value=res_map[target_ar][1])
837
-
838
- controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
839
-
840
- all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
841
- for t_comp in cn_types:
842
- updates[t_comp] = gr.update(choices=all_types, value=default_type)
843
- for s_comp in cn_series:
844
- updates[s_comp] = gr.update(choices=series_choices, value=default_series)
845
- for f_comp in cn_filepaths:
846
- updates[f_comp] = filepath
847
-
848
- diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
849
- for t_comp in diffsynth_cn_types:
850
- updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
851
- for s_comp in diffsynth_cn_series:
852
- updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
853
- for f_comp in diffsynth_cn_filepaths:
854
- updates[f_comp] = diffsynth_filepath
855
-
856
- if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
857
- config = load_ipadapter_config()
858
- ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
859
- std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
860
- face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
861
- all_ipa_presets = std_presets + face_presets
862
- default_ipa = all_ipa_presets[0] if all_ipa_presets else None
863
- updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa)
864
-
865
- defaults = get_model_generation_defaults(val, arch_model_type, MODEL_DEFAULTS_CONFIG)
866
- if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps'))
867
- if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg'))
868
- if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name'))
869
- if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler'))
870
- if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt'))
871
- if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt'))
872
-
873
- return updates
874
- return update_fn
875
-
876
- def make_model_change_fn(cat_comp_ref, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, diffsynth_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp):
877
- def change_fn(*args):
878
- model_name = args[0]
879
- idx = 1
880
- current_arch = args[idx] if arch_comp_ref and idx < len(args) else None
881
- if arch_comp_ref: idx += 1
882
- current_cat = args[idx] if cat_comp_ref and idx < len(args) else None
883
- if cat_comp_ref: idx += 1
884
- current_ar = args[idx] if idx < len(args) else None
885
- from core.settings import MODEL_TYPE_MAP, FEATURES_CONFIG, ARCHITECTURES_CONFIG, MODEL_DEFAULTS_CONFIG, ARCH_CATEGORIES_MAP, MODEL_MAP_CHECKPOINT
886
- from utils.app_utils import get_model_generation_defaults
887
- m_type = MODEL_TYPE_MAP.get(model_name, "SDXL")
888
-
889
- m_info = MODEL_MAP_CHECKPOINT.get(model_name)
890
- m_cat = m_info[4] if m_info and len(m_info) > 4 else None
891
- if not m_cat: m_cat = "ALL"
892
-
893
- updates = {}
894
- target_arch = m_type
895
- if arch_comp_ref:
896
- if current_arch == "ALL":
897
- updates[arch_comp_ref] = gr.update()
898
- target_arch = "ALL"
899
- else:
900
- updates[arch_comp_ref] = m_type
901
-
902
- if cat_comp_ref:
903
- if target_arch == "ALL":
904
- valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
905
- else:
906
- valid_cats = ARCH_CATEGORIES_MAP.get(target_arch, [])
907
- cat_choices = ["ALL"] + sorted(valid_cats)
908
-
909
- if current_cat == "ALL":
910
- updates[cat_comp_ref] = gr.update(choices=cat_choices)
911
- else:
912
- updates[cat_comp_ref] = gr.update(choices=cat_choices, value=m_cat)
913
-
914
- architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
915
- arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
916
-
917
- arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {}))
918
- enabled_chains = arch_features.get('enabled_chains', [])
919
-
920
- if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains))
921
- if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
922
- if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
923
- if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
924
- if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
925
- if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
926
- if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains))
927
- if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains))
928
- if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains))
929
- if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains))
930
-
931
- if cs_comp:
932
- updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15"))
933
- if guidance_comp:
934
- updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1"))
935
-
936
- if ar_comp:
937
- res_key = arch_model_type
938
- if res_key not in RESOLUTION_MAP:
939
- res_key = 'sdxl'
940
- res_map = RESOLUTION_MAP.get(res_key, {})
941
- target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)")
942
- updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar)
943
- if width_comp and height_comp and target_ar in res_map:
944
- updates[width_comp] = gr.update(value=res_map[target_ar][0])
945
- updates[height_comp] = gr.update(value=res_map[target_ar][1])
946
-
947
- controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
948
-
949
- all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
950
- for t_comp in cn_types:
951
- updates[t_comp] = gr.update(choices=all_types, value=default_type)
952
- for s_comp in cn_series:
953
- updates[s_comp] = gr.update(choices=series_choices, value=default_series)
954
- for f_comp in cn_filepaths:
955
- updates[f_comp] = filepath
956
-
957
- diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
958
- for t_comp in diffsynth_cn_types:
959
- updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
960
- for s_comp in diffsynth_cn_series:
961
- updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
962
- for f_comp in diffsynth_cn_filepaths:
963
- updates[f_comp] = diffsynth_filepath
964
-
965
- if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
966
- config = load_ipadapter_config()
967
- ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
968
- std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
969
- face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
970
- all_ipa_presets = std_presets + face_presets
971
- default_ipa = all_ipa_presets[0] if all_ipa_presets else None
972
- updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa)
973
-
974
- defaults = get_model_generation_defaults(model_name, arch_model_type, MODEL_DEFAULTS_CONFIG)
975
- if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps'))
976
- if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg'))
977
- if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name'))
978
- if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler'))
979
- if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt'))
980
- if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt'))
981
-
982
- return updates
983
- return change_fn
984
-
985
-
986
- for prefix, task_type in [
987
- ("txt2img", "txt2img"), ("img2img", "img2img"), ("inpaint", "inpaint"),
988
- ("outpaint", "outpaint"), ("hires_fix", "hires_fix"),
989
- ]:
990
-
991
- arch_comp = ui_components.get(f'model_arch_{prefix}')
992
- cat_comp = ui_components.get(f'model_cat_{prefix}')
993
- model_comp = ui_components.get(f'base_model_{prefix}')
994
- clip_skip_comp = ui_components.get(f'clip_skip_{prefix}') or ui_components.get(f'{prefix}_clip_skip')
995
- guidance_comp = ui_components.get(f'guidance_{prefix}') or ui_components.get(f'{prefix}_guidance')
996
- aspect_ratio_comp = ui_components.get(f'aspect_ratio_{prefix}') or ui_components.get(f'{prefix}_aspect_ratio_dropdown')
997
- width_comp = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
998
- height_comp = ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
999
-
1000
- cn_types_list = ui_components.get(f'controlnet_types_{prefix}', [])
1001
- cn_series_list = ui_components.get(f'controlnet_series_{prefix}', [])
1002
- cn_filepaths_list = ui_components.get(f'controlnet_filepaths_{prefix}', [])
1003
-
1004
- diffsynth_cn_types_list = ui_components.get(f'diffsynth_controlnet_types_{prefix}', [])
1005
- diffsynth_cn_series_list = ui_components.get(f'diffsynth_controlnet_series_{prefix}', [])
1006
- diffsynth_cn_filepaths_list = ui_components.get(f'diffsynth_controlnet_filepaths_{prefix}', [])
1007
-
1008
- lora_accordion = ui_components.get(f'lora_accordion_{prefix}')
1009
- cn_accordion = ui_components.get(f'controlnet_accordion_{prefix}')
1010
- diffsynth_cn_accordion = ui_components.get(f'diffsynth_controlnet_accordion_{prefix}')
1011
- ipa_accordion = ui_components.get(f'ipadapter_accordion_{prefix}')
1012
- sd3_ipa_accordion = ui_components.get(f'sd3_ipadapter_accordion_{prefix}')
1013
- flux1_ipa_accordion = ui_components.get(f'flux1_ipadapter_accordion_{prefix}')
1014
- style_accordion = ui_components.get(f'style_accordion_{prefix}')
1015
- embedding_accordion = ui_components.get(f'embedding_accordion_{prefix}')
1016
- conditioning_accordion = ui_components.get(f'conditioning_accordion_{prefix}')
1017
- ref_latent_accordion = ui_components.get(f'reference_latent_accordion_{prefix}')
1018
-
1019
- ipa_preset_list = ui_components.get(f'ipadapter_final_preset_{prefix}')
1020
-
1021
- prompt_comp = ui_components.get(f'prompt_{prefix}') or ui_components.get(f'{prefix}_positive_prompt')
1022
- neg_prompt_comp = ui_components.get(f'neg_prompt_{prefix}') or ui_components.get(f'{prefix}_negative_prompt')
1023
- steps_comp = ui_components.get(f'steps_{prefix}') or ui_components.get(f'{prefix}_steps')
1024
- cfg_comp = ui_components.get(f'cfg_{prefix}') or ui_components.get(f'{prefix}_cfg')
1025
- sampler_comp = ui_components.get(f'sampler_{prefix}') or ui_components.get(f'{prefix}_sampler_name')
1026
- scheduler_comp = ui_components.get(f'scheduler_{prefix}') or ui_components.get(f'{prefix}_scheduler')
1027
-
1028
- extra_comps = [prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, width_comp, height_comp]
1029
- valid_extra_comps = [c for c in extra_comps if c is not None]
1030
-
1031
- if arch_comp and cat_comp and model_comp:
1032
- outputs = [model_comp, cat_comp]
1033
- if clip_skip_comp: outputs.append(clip_skip_comp)
1034
- if guidance_comp: outputs.append(guidance_comp)
1035
- if aspect_ratio_comp: outputs.append(aspect_ratio_comp)
1036
- outputs.extend(cn_types_list + cn_series_list + cn_filepaths_list)
1037
- outputs.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
1038
- if lora_accordion: outputs.append(lora_accordion)
1039
- if cn_accordion: outputs.append(cn_accordion)
1040
- if diffsynth_cn_accordion: outputs.append(diffsynth_cn_accordion)
1041
- if ipa_accordion: outputs.append(ipa_accordion)
1042
- if sd3_ipa_accordion: outputs.append(sd3_ipa_accordion)
1043
- if flux1_ipa_accordion: outputs.append(flux1_ipa_accordion)
1044
- if style_accordion: outputs.append(style_accordion)
1045
- if embedding_accordion: outputs.append(embedding_accordion)
1046
- if conditioning_accordion: outputs.append(conditioning_accordion)
1047
- if ref_latent_accordion: outputs.append(ref_latent_accordion)
1048
- if ipa_preset_list: outputs.append(ipa_preset_list)
1049
-
1050
- outputs.extend(valid_extra_comps)
1051
-
1052
- update_fn = make_update_fn(
1053
- model_comp, cat_comp, clip_skip_comp, aspect_ratio_comp, width_comp, height_comp,
1054
- cn_types_list, cn_series_list, cn_filepaths_list,
1055
- diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
1056
- ipa_preset_list, lora_accordion, cn_accordion, diffsynth_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
1057
- ref_latent_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp
1058
- )
1059
- inputs = [arch_comp, cat_comp]
1060
- if aspect_ratio_comp:
1061
- inputs.append(aspect_ratio_comp)
1062
- arch_comp.change(fn=update_fn, inputs=inputs, outputs=outputs)
1063
- cat_comp.change(fn=update_fn, inputs=inputs, outputs=outputs)
1064
-
1065
- if model_comp:
1066
- outputs2 = []
1067
- if arch_comp: outputs2.append(arch_comp)
1068
- if cat_comp: outputs2.append(cat_comp)
1069
- if clip_skip_comp: outputs2.append(clip_skip_comp)
1070
- if guidance_comp: outputs2.append(guidance_comp)
1071
- if aspect_ratio_comp: outputs2.append(aspect_ratio_comp)
1072
- outputs2.extend(cn_types_list + cn_series_list + cn_filepaths_list)
1073
- outputs2.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
1074
- if lora_accordion: outputs2.append(lora_accordion)
1075
- if cn_accordion: outputs2.append(cn_accordion)
1076
- if diffsynth_cn_accordion: outputs2.append(diffsynth_cn_accordion)
1077
- if ipa_accordion: outputs2.append(ipa_accordion)
1078
- if sd3_ipa_accordion: outputs2.append(sd3_ipa_accordion)
1079
- if flux1_ipa_accordion: outputs2.append(flux1_ipa_accordion)
1080
- if style_accordion: outputs2.append(style_accordion)
1081
- if embedding_accordion: outputs2.append(embedding_accordion)
1082
- if conditioning_accordion: outputs2.append(conditioning_accordion)
1083
- if ref_latent_accordion: outputs2.append(ref_latent_accordion)
1084
- if ipa_preset_list: outputs2.append(ipa_preset_list)
1085
-
1086
- outputs2.extend(valid_extra_comps)
1087
-
1088
- if outputs2:
1089
- inputs2 = [model_comp]
1090
- if arch_comp: inputs2.append(arch_comp)
1091
- if cat_comp: inputs2.append(cat_comp)
1092
- if aspect_ratio_comp: inputs2.append(aspect_ratio_comp)
1093
- change_fn = make_model_change_fn(
1094
- cat_comp, clip_skip_comp, aspect_ratio_comp, width_comp, height_comp,
1095
- cn_types_list, cn_series_list, cn_filepaths_list,
1096
- diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
1097
- arch_comp, ipa_preset_list, lora_accordion, cn_accordion, diffsynth_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
1098
- ref_latent_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp
1099
- )
1100
- model_comp.change(fn=change_fn, inputs=inputs2, outputs=outputs2)
1101
-
1102
- create_lora_event_handlers(prefix)
1103
- create_controlnet_event_handlers(prefix)
1104
- create_diffsynth_controlnet_event_handlers(prefix)
1105
- create_ipadapter_event_handlers(prefix)
1106
- create_embedding_event_handlers(prefix)
1107
- create_conditioning_event_handlers(prefix)
1108
- create_flux1_ipadapter_event_handlers(prefix)
1109
- create_style_event_handlers(prefix)
1110
- create_reference_latent_event_handlers(prefix)
1111
- create_run_event(prefix, task_type)
1112
-
1113
-
1114
- if 'view_mode_inpaint' in ui_components:
1115
- def toggle_inpaint_fullscreen_view(view_mode):
1116
- is_fullscreen = (view_mode == "Fullscreen View")
1117
- other_elements_visible = not is_fullscreen
1118
- editor_height = 800 if is_fullscreen else 272
1119
-
1120
- updates = {
1121
- ui_components['prompts_column_inpaint']: gr.update(visible=other_elements_visible),
1122
- ui_components['params_and_gallery_row_inpaint']: gr.update(visible=other_elements_visible),
1123
- ui_components['accordion_wrapper_inpaint']: gr.update(visible=other_elements_visible),
1124
- ui_components['input_image_dict_inpaint']: gr.update(height=editor_height),
1125
- }
1126
-
1127
- model_and_run_rows = ui_components.get('model_and_run_row_inpaint', [])
1128
- for row in model_and_run_rows:
1129
- updates[row] = gr.update(visible=other_elements_visible)
1130
-
1131
- return updates
1132
-
1133
- output_components = []
1134
- model_and_run_rows = ui_components.get('model_and_run_row_inpaint', [])
1135
- if isinstance(model_and_run_rows, list):
1136
- output_components.extend(model_and_run_rows)
1137
- else:
1138
- output_components.append(model_and_run_rows)
1139
-
1140
- output_components.extend([
1141
- ui_components['prompts_column_inpaint'],
1142
- ui_components['params_and_gallery_row_inpaint'],
1143
- ui_components['accordion_wrapper_inpaint'],
1144
- ui_components['input_image_dict_inpaint']
1145
- ])
1146
-
1147
- ui_components['view_mode_inpaint'].change(
1148
- fn=toggle_inpaint_fullscreen_view,
1149
- inputs=[ui_components['view_mode_inpaint']],
1150
- outputs=output_components,
1151
- show_progress=False
1152
- )
1153
-
1154
- def initialize_all_cn_dropdowns():
1155
- from core.settings import MODEL_TYPE_MAP, MODEL_MAP_CHECKPOINT, ARCHITECTURES_CONFIG
1156
- default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
1157
- default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
1158
- architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
1159
- controlnet_key = architectures_dict.get(default_m_type, {}).get("controlnet_key", default_m_type)
1160
-
1161
- all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
1162
- diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
1163
-
1164
- updates = {}
1165
- for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
1166
- if f'controlnet_types_{prefix}' in ui_components:
1167
- for type_dd in ui_components[f'controlnet_types_{prefix}']:
1168
- updates[type_dd] = gr.update(choices=all_types, value=default_type)
1169
- for series_dd in ui_components[f'controlnet_series_{prefix}']:
1170
- updates[series_dd] = gr.update(choices=series_choices, value=default_series)
1171
- for filepath_state in ui_components[f'controlnet_filepaths_{prefix}']:
1172
- updates[filepath_state] = filepath
1173
-
1174
- if f'diffsynth_controlnet_types_{prefix}' in ui_components:
1175
- for type_dd in ui_components[f'diffsynth_controlnet_types_{prefix}']:
1176
- updates[type_dd] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
1177
- for series_dd in ui_components[f'diffsynth_controlnet_series_{prefix}']:
1178
- updates[series_dd] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
1179
- for filepath_state in ui_components[f'diffsynth_controlnet_filepaths_{prefix}']:
1180
- updates[filepath_state] = diffsynth_filepath
1181
-
1182
- return updates
1183
-
1184
- def initialize_all_ipa_dropdowns():
1185
- config = load_ipadapter_config()
1186
- if not config: return {}
1187
-
1188
- from core.settings import MODEL_TYPE_MAP, MODEL_MAP_CHECKPOINT, ARCHITECTURES_CONFIG
1189
- default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
1190
- default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
1191
- architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
1192
- arch_model_type = architectures_dict.get(default_m_type, {}).get("model_type", default_m_type.lower().replace(" ", "").replace(".", ""))
1193
- ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
1194
-
1195
- unified_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
1196
- faceid_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
1197
-
1198
- all_presets = unified_presets + faceid_presets
1199
- default_preset = all_presets[0] if all_presets else None
1200
- is_faceid_default = default_preset in faceid_presets
1201
-
1202
- lora_strength_update = gr.update(visible=is_faceid_default)
1203
-
1204
- updates = {}
1205
- for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
1206
- if f'ipadapter_final_preset_{prefix}' in ui_components:
1207
- for lora_strength_slider in ui_components[f'ipadapter_lora_strengths_{prefix}']:
1208
- updates[lora_strength_slider] = lora_strength_update
1209
- updates[ui_components[f'ipadapter_final_preset_{prefix}']] = gr.update(choices=all_presets, value=default_preset)
1210
- updates[ui_components[f'ipadapter_final_lora_strength_{prefix}']] = lora_strength_update
1211
- return updates
1212
-
1213
- def run_on_load():
1214
- cn_updates = initialize_all_cn_dropdowns()
1215
- ipa_updates = initialize_all_ipa_dropdowns()
1216
-
1217
- all_updates = {**cn_updates, **ipa_updates}
1218
-
1219
- return all_updates
1220
-
1221
- all_load_outputs = []
1222
- for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
1223
- if f'controlnet_types_{prefix}' in ui_components:
1224
- all_load_outputs.extend(ui_components[f'controlnet_types_{prefix}'])
1225
- all_load_outputs.extend(ui_components[f'controlnet_series_{prefix}'])
1226
- all_load_outputs.extend(ui_components[f'controlnet_filepaths_{prefix}'])
1227
- if f'diffsynth_controlnet_types_{prefix}' in ui_components:
1228
- all_load_outputs.extend(ui_components[f'diffsynth_controlnet_types_{prefix}'])
1229
- all_load_outputs.extend(ui_components[f'diffsynth_controlnet_series_{prefix}'])
1230
- all_load_outputs.extend(ui_components[f'diffsynth_controlnet_filepaths_{prefix}'])
1231
- if f'ipadapter_final_preset_{prefix}' in ui_components:
1232
- all_load_outputs.extend(ui_components[f'ipadapter_lora_strengths_{prefix}'])
1233
- all_load_outputs.append(ui_components[f'ipadapter_final_preset_{prefix}'])
1234
- all_load_outputs.append(ui_components[f'ipadapter_final_lora_strength_{prefix}'])
1235
-
1236
- if all_load_outputs:
1237
- demo.load(
1238
- fn=run_on_load,
1239
- outputs=all_load_outputs
1240
- )
1241
-
1242
- def on_aspect_ratio_change(ratio_key, model_display_name):
1243
- from core.settings import MODEL_TYPE_MAP, ARCHITECTURES_CONFIG
1244
- m_type = MODEL_TYPE_MAP.get(model_display_name, 'SDXL')
1245
- architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
1246
- arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
1247
-
1248
- res_map = RESOLUTION_MAP.get(arch_model_type, RESOLUTION_MAP.get("sdxl", {}))
1249
- w, h = res_map.get(ratio_key, (1024, 1024))
1250
- return w, h
1251
-
1252
- for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
1253
- aspect_ratio_dropdown = ui_components.get(f'aspect_ratio_{prefix}') or ui_components.get(f'{prefix}_aspect_ratio_dropdown')
1254
- width_component = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
1255
- height_component = ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
1256
- model_dropdown = ui_components.get(f'base_model_{prefix}')
1257
- if aspect_ratio_dropdown and width_component and height_component and model_dropdown:
1258
- aspect_ratio_dropdown.change(fn=on_aspect_ratio_change, inputs=[aspect_ratio_dropdown, model_dropdown], outputs=[width_component, height_component], show_progress=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/events/__init__.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from .main import attach_event_handlers
2
+ from .config_loaders import (
3
+ load_controlnet_config,
4
+ get_cn_defaults,
5
+ load_anima_controlnet_lllite_config,
6
+ get_anima_cn_defaults,
7
+ load_diffsynth_controlnet_config,
8
+ get_diffsynth_cn_defaults,
9
+ load_ipadapter_config
10
+ )
ui/events/chain_handlers.py ADDED
@@ -0,0 +1,680 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from core.settings import VAE_DIR, LORA_DIR, EMBEDDING_DIR, ARCHITECTURES_CONFIG
3
+ from utils.app_utils import save_uploaded_file_with_hash
4
+ from ui.shared.ui_components import (
5
+ MAX_CONTROLNETS,
6
+ MAX_IPADAPTERS,
7
+ MAX_EMBEDDINGS,
8
+ MAX_CONDITIONINGS,
9
+ MAX_LORAS
10
+ )
11
+ from .config_loaders import (
12
+ load_controlnet_config,
13
+ load_anima_controlnet_lllite_config,
14
+ load_diffsynth_controlnet_config,
15
+ load_ipadapter_config
16
+ )
17
+
18
+ def on_vae_upload(file_obj):
19
+ if not file_obj:
20
+ return gr.update(), gr.update(), None
21
+
22
+ hashed_filename = save_uploaded_file_with_hash(file_obj, VAE_DIR)
23
+ return hashed_filename, "File", file_obj
24
+
25
+
26
+ def on_lora_upload(file_obj):
27
+ if not file_obj:
28
+ return gr.update(), gr.update()
29
+
30
+ hashed_filename = save_uploaded_file_with_hash(file_obj, LORA_DIR)
31
+ return hashed_filename, "File"
32
+
33
+
34
+ def on_embedding_upload(file_obj):
35
+ if not file_obj:
36
+ return gr.update(), gr.update(), None
37
+
38
+ hashed_filename = save_uploaded_file_with_hash(file_obj, EMBEDDING_DIR)
39
+ return hashed_filename, "File", file_obj
40
+
41
+
42
+ def create_lora_event_handlers(prefix, ui_components):
43
+ lora_rows = ui_components.get(f'lora_rows_{prefix}')
44
+ if not lora_rows: return
45
+ lora_ids = ui_components[f'lora_ids_{prefix}']
46
+ lora_scales = ui_components[f'lora_scales_{prefix}']
47
+ lora_uploads = ui_components[f'lora_uploads_{prefix}']
48
+ count_state = ui_components[f'lora_count_state_{prefix}']
49
+ add_button = ui_components[f'add_lora_button_{prefix}']
50
+ del_button = ui_components[f'delete_lora_button_{prefix}']
51
+
52
+ def add_lora_row(c):
53
+ updates = {}
54
+ if c < MAX_LORAS:
55
+ c += 1
56
+ updates[lora_rows[c - 1]] = gr.update(visible=True)
57
+
58
+ updates[count_state] = c
59
+ updates[add_button] = gr.update(visible=c < MAX_LORAS)
60
+ updates[del_button] = gr.update(visible=c > 1)
61
+ return updates
62
+
63
+ def del_lora_row(c):
64
+ updates = {}
65
+ if c > 1:
66
+ updates[lora_rows[c - 1]] = gr.update(visible=False)
67
+ updates[lora_ids[c - 1]] = ""
68
+ updates[lora_scales[c - 1]] = 0.0
69
+ updates[lora_uploads[c - 1]] = None
70
+ c -= 1
71
+
72
+ updates[count_state] = c
73
+ updates[add_button] = gr.update(visible=True)
74
+ updates[del_button] = gr.update(visible=c > 1)
75
+ return updates
76
+
77
+ add_outputs = [count_state, add_button, del_button] + lora_rows
78
+ del_outputs = [count_state, add_button, del_button] + lora_rows + lora_ids + lora_scales + lora_uploads
79
+
80
+ add_button.click(add_lora_row, [count_state], add_outputs, show_progress=False)
81
+ del_button.click(del_lora_row, [count_state], del_outputs, show_progress=False)
82
+
83
+
84
+ def create_controlnet_event_handlers(prefix, ui_components):
85
+ cn_rows = ui_components.get(f'controlnet_rows_{prefix}')
86
+ if not cn_rows: return
87
+ cn_types = ui_components[f'controlnet_types_{prefix}']
88
+ cn_series = ui_components[f'controlnet_series_{prefix}']
89
+ cn_filepaths = ui_components[f'controlnet_filepaths_{prefix}']
90
+ cn_images = ui_components[f'controlnet_images_{prefix}']
91
+ cn_strengths = ui_components[f'controlnet_strengths_{prefix}']
92
+
93
+ count_state = ui_components[f'controlnet_count_state_{prefix}']
94
+ add_button = ui_components[f'add_controlnet_button_{prefix}']
95
+ del_button = ui_components[f'delete_controlnet_button_{prefix}']
96
+ accordion = ui_components[f'controlnet_accordion_{prefix}']
97
+
98
+ base_model_comp = ui_components.get(f'base_model_{prefix}')
99
+ actual_arch_comp = base_model_comp if base_model_comp else gr.State("SDXL")
100
+
101
+ def add_cn_row(c):
102
+ c += 1
103
+ updates = {
104
+ count_state: c,
105
+ cn_rows[c-1]: gr.update(visible=True),
106
+ add_button: gr.update(visible=c < MAX_CONTROLNETS),
107
+ del_button: gr.update(visible=True)
108
+ }
109
+ return updates
110
+
111
+ def del_cn_row(c):
112
+ c -= 1
113
+ updates = {
114
+ count_state: c,
115
+ cn_rows[c]: gr.update(visible=False),
116
+ cn_images[c]: None,
117
+ cn_strengths[c]: 1.0,
118
+ add_button: gr.update(visible=True),
119
+ del_button: gr.update(visible=c > 0)
120
+ }
121
+ return updates
122
+
123
+ add_outputs = [count_state, add_button, del_button] + cn_rows
124
+ del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths
125
+ add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
126
+ del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
127
+
128
+ def on_cn_type_change(selected_type, model_name):
129
+ from core.settings import MODEL_TYPE_MAP
130
+ m_type = MODEL_TYPE_MAP.get(model_name, "SDXL") if model_name else "SDXL"
131
+ cn_full_config = load_controlnet_config()
132
+
133
+ architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
134
+ controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
135
+
136
+ cn_config = cn_full_config.get(controlnet_key, [])
137
+ series_choices = []
138
+ if selected_type:
139
+ series_choices = sorted(list(set(
140
+ model.get("Series", "Default") for model in cn_config
141
+ if selected_type in model.get("Type", [])
142
+ )))
143
+ default_series = series_choices[0] if series_choices else None
144
+ filepath = "None"
145
+ if default_series:
146
+ for model in cn_config:
147
+ if model.get("Series") == default_series and selected_type in model.get("Type", []):
148
+ filepath = model.get("Filepath")
149
+ break
150
+ return gr.update(choices=series_choices, value=default_series), filepath
151
+
152
+ def on_cn_series_change(selected_series, selected_type, model_name):
153
+ from core.settings import MODEL_TYPE_MAP
154
+ m_type = MODEL_TYPE_MAP.get(model_name, "SDXL") if model_name else "SDXL"
155
+ cn_full_config = load_controlnet_config()
156
+
157
+ architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
158
+ controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
159
+
160
+ cn_config = cn_full_config.get(controlnet_key, [])
161
+ filepath = "None"
162
+ if selected_series and selected_type:
163
+ for model in cn_config:
164
+ if model.get("Series") == selected_series and selected_type in model.get("Type", []):
165
+ filepath = model.get("Filepath")
166
+ break
167
+ return filepath
168
+
169
+ for i in range(MAX_CONTROLNETS):
170
+ cn_types[i].change(
171
+ fn=on_cn_type_change,
172
+ inputs=[cn_types[i], actual_arch_comp],
173
+ outputs=[cn_series[i], cn_filepaths[i]],
174
+ show_progress=False
175
+ )
176
+ cn_series[i].change(
177
+ fn=on_cn_series_change,
178
+ inputs=[cn_series[i], cn_types[i], actual_arch_comp],
179
+ outputs=[cn_filepaths[i]],
180
+ show_progress=False
181
+ )
182
+
183
+ def on_accordion_expand(*images):
184
+ return [gr.update() for _ in images]
185
+
186
+ accordion.expand(
187
+ fn=on_accordion_expand,
188
+ inputs=cn_images,
189
+ outputs=cn_images,
190
+ show_progress=False
191
+ )
192
+
193
+
194
+ def create_anima_controlnet_lllite_event_handlers(prefix, ui_components):
195
+ cn_rows = ui_components.get(f'anima_controlnet_lllite_rows_{prefix}')
196
+ if not cn_rows: return
197
+ cn_types = ui_components[f'anima_controlnet_lllite_types_{prefix}']
198
+ cn_series = ui_components[f'anima_controlnet_lllite_series_{prefix}']
199
+ cn_filepaths = ui_components[f'anima_controlnet_lllite_filepaths_{prefix}']
200
+ cn_images = ui_components[f'anima_controlnet_lllite_images_{prefix}']
201
+ cn_strengths = ui_components[f'anima_controlnet_lllite_strengths_{prefix}']
202
+
203
+ count_state = ui_components[f'anima_controlnet_lllite_count_state_{prefix}']
204
+ add_button = ui_components[f'add_anima_controlnet_lllite_button_{prefix}']
205
+ del_button = ui_components[f'delete_anima_controlnet_lllite_button_{prefix}']
206
+ accordion = ui_components[f'anima_controlnet_lllite_accordion_{prefix}']
207
+
208
+ def add_cn_row(c):
209
+ c += 1
210
+ updates = {
211
+ count_state: c,
212
+ cn_rows[c-1]: gr.update(visible=True),
213
+ add_button: gr.update(visible=c < MAX_CONTROLNETS),
214
+ del_button: gr.update(visible=True)
215
+ }
216
+ return updates
217
+
218
+ def del_cn_row(c):
219
+ c -= 1
220
+ updates = {
221
+ count_state: c,
222
+ cn_rows[c]: gr.update(visible=False),
223
+ cn_images[c]: None,
224
+ cn_strengths[c]: 1.0,
225
+ add_button: gr.update(visible=True),
226
+ del_button: gr.update(visible=c > 0)
227
+ }
228
+ return updates
229
+
230
+ add_outputs = [count_state, add_button, del_button] + cn_rows
231
+ del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths
232
+ add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
233
+ del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
234
+
235
+ def on_cn_type_change(selected_type):
236
+ cn_config = load_anima_controlnet_lllite_config()
237
+ series_choices = []
238
+ if selected_type:
239
+ series_choices = sorted(list(set(
240
+ model.get("Series", "Default") for model in cn_config
241
+ if selected_type in model.get("Type", [])
242
+ )))
243
+ default_series = series_choices[0] if series_choices else None
244
+ filepath = "None"
245
+ if default_series:
246
+ for model in cn_config:
247
+ if model.get("Series") == default_series and selected_type in model.get("Type", []):
248
+ filepath = model.get("Filepath")
249
+ break
250
+ return gr.update(choices=series_choices, value=default_series), filepath
251
+
252
+ def on_cn_series_change(selected_series, selected_type):
253
+ cn_config = load_anima_controlnet_lllite_config()
254
+ filepath = "None"
255
+ if selected_series and selected_type:
256
+ for model in cn_config:
257
+ if model.get("Series") == selected_series and selected_type in model.get("Type", []):
258
+ filepath = model.get("Filepath")
259
+ break
260
+ return filepath
261
+
262
+ for i in range(MAX_CONTROLNETS):
263
+ cn_types[i].change(
264
+ fn=on_cn_type_change,
265
+ inputs=[cn_types[i]],
266
+ outputs=[cn_series[i], cn_filepaths[i]],
267
+ show_progress=False
268
+ )
269
+ cn_series[i].change(
270
+ fn=on_cn_series_change,
271
+ inputs=[cn_series[i], cn_types[i]],
272
+ outputs=[cn_filepaths[i]],
273
+ show_progress=False
274
+ )
275
+
276
+ def on_accordion_expand(*images):
277
+ return [gr.update() for _ in images]
278
+
279
+ accordion.expand(
280
+ fn=on_accordion_expand,
281
+ inputs=cn_images,
282
+ outputs=cn_images,
283
+ show_progress=False
284
+ )
285
+
286
+
287
+ def create_diffsynth_controlnet_event_handlers(prefix, ui_components):
288
+ cn_rows = ui_components.get(f'diffsynth_controlnet_rows_{prefix}')
289
+ if not cn_rows: return
290
+ cn_types = ui_components[f'diffsynth_controlnet_types_{prefix}']
291
+ cn_series = ui_components[f'diffsynth_controlnet_series_{prefix}']
292
+ cn_filepaths = ui_components[f'diffsynth_controlnet_filepaths_{prefix}']
293
+ cn_images = ui_components[f'diffsynth_controlnet_images_{prefix}']
294
+ cn_strengths = ui_components[f'diffsynth_controlnet_strengths_{prefix}']
295
+
296
+ count_state = ui_components[f'diffsynth_controlnet_count_state_{prefix}']
297
+ add_button = ui_components[f'add_diffsynth_controlnet_button_{prefix}']
298
+ del_button = ui_components[f'delete_diffsynth_controlnet_button_{prefix}']
299
+ accordion = ui_components[f'diffsynth_controlnet_accordion_{prefix}']
300
+
301
+ base_model_comp = ui_components.get(f'base_model_{prefix}')
302
+ actual_arch_comp = base_model_comp if base_model_comp else gr.State("SDXL")
303
+
304
+ def add_cn_row(c):
305
+ c += 1
306
+ updates = {
307
+ count_state: c,
308
+ cn_rows[c-1]: gr.update(visible=True),
309
+ add_button: gr.update(visible=c < MAX_CONTROLNETS),
310
+ del_button: gr.update(visible=True)
311
+ }
312
+ return updates
313
+
314
+ def del_cn_row(c):
315
+ c -= 1
316
+ updates = {
317
+ count_state: c,
318
+ cn_rows[c]: gr.update(visible=False),
319
+ cn_images[c]: None,
320
+ cn_strengths[c]: 1.0,
321
+ add_button: gr.update(visible=True),
322
+ del_button: gr.update(visible=c > 0)
323
+ }
324
+ return updates
325
+
326
+ add_outputs = [count_state, add_button, del_button] + cn_rows
327
+ del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths
328
+ add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
329
+ del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
330
+
331
+ def on_cn_type_change(selected_type, model_name):
332
+ from core.settings import MODEL_TYPE_MAP
333
+ m_type = MODEL_TYPE_MAP.get(model_name, "SDXL") if model_name else "SDXL"
334
+ cn_full_config = load_diffsynth_controlnet_config()
335
+
336
+ architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
337
+ controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
338
+
339
+ cn_config = cn_full_config.get(controlnet_key, [])
340
+ series_choices = []
341
+ if selected_type:
342
+ series_choices = sorted(list(set(
343
+ model.get("Series", "Default") for model in cn_config
344
+ if selected_type in model.get("Type", [])
345
+ )))
346
+ default_series = series_choices[0] if series_choices else None
347
+ filepath = "None"
348
+ if default_series:
349
+ for model in cn_config:
350
+ if model.get("Series") == default_series and selected_type in model.get("Type", []):
351
+ filepath = model.get("Filepath")
352
+ break
353
+ return gr.update(choices=series_choices, value=default_series), filepath
354
+
355
+ def on_cn_series_change(selected_series, selected_type, model_name):
356
+ from core.settings import MODEL_TYPE_MAP
357
+ m_type = MODEL_TYPE_MAP.get(model_name, "SDXL") if model_name else "SDXL"
358
+ cn_full_config = load_diffsynth_controlnet_config()
359
+
360
+ architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
361
+ controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
362
+
363
+ cn_config = cn_full_config.get(controlnet_key, [])
364
+ filepath = "None"
365
+ if selected_series and selected_type:
366
+ for model in cn_config:
367
+ if model.get("Series") == selected_series and selected_type in model.get("Type", []):
368
+ filepath = model.get("Filepath")
369
+ break
370
+ return filepath
371
+
372
+ for i in range(MAX_CONTROLNETS):
373
+ cn_types[i].change(
374
+ fn=on_cn_type_change,
375
+ inputs=[cn_types[i], actual_arch_comp],
376
+ outputs=[cn_series[i], cn_filepaths[i]],
377
+ show_progress=False
378
+ )
379
+ cn_series[i].change(
380
+ fn=on_cn_series_change,
381
+ inputs=[cn_series[i], cn_types[i], actual_arch_comp],
382
+ outputs=[cn_filepaths[i]],
383
+ show_progress=False
384
+ )
385
+
386
+ def on_accordion_expand(*images):
387
+ return [gr.update() for _ in images]
388
+
389
+ accordion.expand(
390
+ fn=on_accordion_expand,
391
+ inputs=cn_images,
392
+ outputs=cn_images,
393
+ show_progress=False
394
+ )
395
+
396
+
397
+ def create_flux1_ipadapter_event_handlers(prefix, ui_components):
398
+ fipa_rows = ui_components.get(f'flux1_ipadapter_rows_{prefix}')
399
+ if not fipa_rows: return
400
+ count_state = ui_components[f'flux1_ipadapter_count_state_{prefix}']
401
+ add_button = ui_components[f'add_flux1_ipadapter_button_{prefix}']
402
+ del_button = ui_components[f'delete_flux1_ipadapter_button_{prefix}']
403
+
404
+ def add_fipa_row(c):
405
+ c += 1
406
+ return {
407
+ count_state: c,
408
+ fipa_rows[c - 1]: gr.update(visible=True),
409
+ add_button: gr.update(visible=c < MAX_IPADAPTERS),
410
+ del_button: gr.update(visible=True),
411
+ }
412
+
413
+ def del_fipa_row(c):
414
+ c -= 1
415
+ return {
416
+ count_state: c,
417
+ fipa_rows[c]: gr.update(visible=False),
418
+ add_button: gr.update(visible=True),
419
+ del_button: gr.update(visible=c > 0),
420
+ }
421
+
422
+ add_outputs = [count_state, add_button, del_button] + fipa_rows
423
+ del_outputs = [count_state, add_button, del_button] + fipa_rows
424
+ add_button.click(fn=add_fipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
425
+ del_button.click(fn=del_fipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
426
+
427
+
428
+ def create_sd3_ipadapter_event_handlers(prefix, ui_components):
429
+ ipa_rows = ui_components.get(f'sd3_ipadapter_rows_{prefix}')
430
+ if not ipa_rows: return
431
+ count_state = ui_components[f'sd3_ipadapter_count_state_{prefix}']
432
+ add_button = ui_components[f'add_sd3_ipadapter_button_{prefix}']
433
+ del_button = ui_components[f'delete_sd3_ipadapter_button_{prefix}']
434
+ images = ui_components[f'sd3_ipadapter_images_{prefix}']
435
+ weights = ui_components[f'sd3_ipadapter_weights_{prefix}']
436
+ start_percents = ui_components[f'sd3_ipadapter_start_percents_{prefix}']
437
+ end_percents = ui_components[f'sd3_ipadapter_end_percents_{prefix}']
438
+
439
+ def add_ipa_row(c):
440
+ c += 1
441
+ return {
442
+ count_state: c,
443
+ ipa_rows[c - 1]: gr.update(visible=True),
444
+ add_button: gr.update(visible=c < MAX_IPADAPTERS),
445
+ del_button: gr.update(visible=True),
446
+ }
447
+
448
+ def del_ipa_row(c):
449
+ c -= 1
450
+ return {
451
+ count_state: c,
452
+ ipa_rows[c]: gr.update(visible=False),
453
+ images[c]: None,
454
+ weights[c]: 0.5,
455
+ start_percents[c]: 0.0,
456
+ end_percents[c]: 1.0,
457
+ add_button: gr.update(visible=True),
458
+ del_button: gr.update(visible=c > 0),
459
+ }
460
+
461
+ add_outputs = [count_state, add_button, del_button] + ipa_rows
462
+ del_outputs = [count_state, add_button, del_button] + ipa_rows + images + weights + start_percents + end_percents
463
+ add_button.click(fn=add_ipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
464
+ del_button.click(fn=del_ipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
465
+
466
+
467
+ def create_style_event_handlers(prefix, ui_components):
468
+ style_rows = ui_components.get(f'style_rows_{prefix}')
469
+ if not style_rows: return
470
+ count_state = ui_components[f'style_count_state_{prefix}']
471
+ add_button = ui_components[f'add_style_button_{prefix}']
472
+ del_button = ui_components[f'delete_style_button_{prefix}']
473
+
474
+ def add_style_row(c):
475
+ c += 1
476
+ return {
477
+ count_state: c,
478
+ style_rows[c - 1]: gr.update(visible=True),
479
+ add_button: gr.update(visible=c < 5),
480
+ del_button: gr.update(visible=True),
481
+ }
482
+
483
+ def del_style_row(c):
484
+ c -= 1
485
+ return {
486
+ count_state: c,
487
+ style_rows[c]: gr.update(visible=False),
488
+ add_button: gr.update(visible=True),
489
+ del_button: gr.update(visible=c > 0),
490
+ }
491
+
492
+ add_outputs = [count_state, add_button, del_button] + style_rows
493
+ del_outputs = [count_state, add_button, del_button] + style_rows
494
+ add_button.click(fn=add_style_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
495
+ del_button.click(fn=del_style_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
496
+
497
+
498
+ def create_ipadapter_event_handlers(prefix, ui_components):
499
+ ipa_rows = ui_components.get(f'ipadapter_rows_{prefix}')
500
+ if not ipa_rows: return
501
+ ipa_lora_strengths = ui_components[f'ipadapter_lora_strengths_{prefix}']
502
+ ipa_final_preset = ui_components[f'ipadapter_final_preset_{prefix}']
503
+ ipa_final_lora_strength = ui_components[f'ipadapter_final_lora_strength_{prefix}']
504
+ count_state = ui_components[f'ipadapter_count_state_{prefix}']
505
+ add_button = ui_components[f'add_ipadapter_button_{prefix}']
506
+ del_button = ui_components[f'delete_ipadapter_button_{prefix}']
507
+ accordion = ui_components[f'ipadapter_accordion_{prefix}']
508
+
509
+ def add_ipa_row(c):
510
+ c += 1
511
+ return {
512
+ count_state: c,
513
+ ipa_rows[c - 1]: gr.update(visible=True),
514
+ add_button: gr.update(visible=c < MAX_IPADAPTERS),
515
+ del_button: gr.update(visible=True),
516
+ }
517
+
518
+ def del_ipa_row(c):
519
+ c -= 1
520
+ return {
521
+ count_state: c,
522
+ ipa_rows[c]: gr.update(visible=False),
523
+ add_button: gr.update(visible=True),
524
+ del_button: gr.update(visible=c > 0),
525
+ }
526
+
527
+ add_outputs = [count_state, add_button, del_button] + ipa_rows
528
+ del_outputs = [count_state, add_button, del_button] + ipa_rows
529
+ add_button.click(fn=add_ipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
530
+ del_button.click(fn=del_ipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
531
+
532
+ def on_preset_change(preset_value):
533
+ config = load_ipadapter_config()
534
+ faceid_presets = []
535
+ if config:
536
+ faceid_presets.extend(config.get("IPAdapter_FaceID_presets", {}).get("SDXL", []))
537
+ faceid_presets.extend(config.get("IPAdapter_FaceID_presets", {}).get("SD1.5", []))
538
+
539
+ is_visible = preset_value in faceid_presets
540
+ updates = [gr.update(visible=is_visible)] * (MAX_IPADAPTERS + 1)
541
+ return updates
542
+
543
+ all_lora_strength_sliders = [ipa_final_lora_strength] + ipa_lora_strengths
544
+ ipa_final_preset.change(fn=on_preset_change, inputs=[ipa_final_preset], outputs=all_lora_strength_sliders, show_progress=False)
545
+
546
+ accordion.expand(fn=lambda *imgs: [gr.update() for _ in imgs], inputs=ui_components[f'ipadapter_images_{prefix}'], outputs=ui_components[f'ipadapter_images_{prefix}'], show_progress=False)
547
+
548
+
549
+ def create_reference_latent_event_handlers(prefix, ui_components):
550
+ ref_rows = ui_components.get(f'reference_latent_rows_{prefix}')
551
+ if not ref_rows: return
552
+ count_state = ui_components[f'reference_latent_count_state_{prefix}']
553
+ add_button = ui_components[f'add_reference_latent_button_{prefix}']
554
+ del_button = ui_components[f'delete_reference_latent_button_{prefix}']
555
+ images = ui_components[f'reference_latent_images_{prefix}']
556
+
557
+ def add_ref_row(c):
558
+ c += 1
559
+ return {
560
+ count_state: c,
561
+ ref_rows[c - 1]: gr.update(visible=True),
562
+ add_button: gr.update(visible=c < 10),
563
+ del_button: gr.update(visible=True),
564
+ }
565
+
566
+ def del_ref_row(c):
567
+ c -= 1
568
+ return {
569
+ count_state: c,
570
+ ref_rows[c]: gr.update(visible=False),
571
+ images[c]: None,
572
+ add_button: gr.update(visible=True),
573
+ del_button: gr.update(visible=c > 0),
574
+ }
575
+
576
+ add_outputs = [count_state, add_button, del_button] + ref_rows
577
+ del_outputs = [count_state, add_button, del_button] + ref_rows + images
578
+ add_button.click(fn=add_ref_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
579
+ del_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
580
+
581
+
582
+ def create_hidream_o1_reference_event_handlers(prefix, ui_components):
583
+ ref_rows = ui_components.get(f'hidream_o1_reference_rows_{prefix}')
584
+ if not ref_rows: return
585
+ count_state = ui_components[f'hidream_o1_reference_count_state_{prefix}']
586
+ add_button = ui_components[f'add_hidream_o1_reference_button_{prefix}']
587
+ del_button = ui_components[f'delete_hidream_o1_reference_button_{prefix}']
588
+ images = ui_components[f'hidream_o1_reference_images_{prefix}']
589
+
590
+ def add_ref_row(c):
591
+ c += 1
592
+ return {
593
+ count_state: c,
594
+ ref_rows[c - 1]: gr.update(visible=True),
595
+ add_button: gr.update(visible=c < 10),
596
+ del_button: gr.update(visible=True),
597
+ }
598
+
599
+ def del_ref_row(c):
600
+ c -= 1
601
+ return {
602
+ count_state: c,
603
+ ref_rows[c]: gr.update(visible=False),
604
+ images[c]: None,
605
+ add_button: gr.update(visible=True),
606
+ del_button: gr.update(visible=c > 0),
607
+ }
608
+
609
+ add_outputs = [count_state, add_button, del_button] + ref_rows
610
+ del_outputs = [count_state, add_button, del_button] + ref_rows + images
611
+ add_button.click(fn=add_ref_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
612
+ del_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
613
+
614
+
615
+ def create_embedding_event_handlers(prefix, ui_components):
616
+ rows = ui_components.get(f'embedding_rows_{prefix}')
617
+ if not rows: return
618
+ ids = ui_components[f'embeddings_ids_{prefix}']
619
+ files = ui_components[f'embeddings_files_{prefix}']
620
+ count_state = ui_components[f'embedding_count_state_{prefix}']
621
+ add_button = ui_components[f'add_embedding_button_{prefix}']
622
+ del_button = ui_components[f'delete_embedding_button_{prefix}']
623
+
624
+ def add_row(c):
625
+ c += 1
626
+ return {
627
+ count_state: c,
628
+ rows[c - 1]: gr.update(visible=True),
629
+ add_button: gr.update(visible=c < MAX_EMBEDDINGS),
630
+ del_button: gr.update(visible=True)
631
+ }
632
+
633
+ def del_row(c):
634
+ c -= 1
635
+ return {
636
+ count_state: c,
637
+ rows[c]: gr.update(visible=False),
638
+ ids[c]: "",
639
+ files[c]: None,
640
+ add_button: gr.update(visible=True),
641
+ del_button: gr.update(visible=c > 0)
642
+ }
643
+
644
+ add_outputs = [count_state, add_button, del_button] + rows
645
+ del_outputs = [count_state, add_button, del_button] + rows + ids + files
646
+ add_button.click(fn=add_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
647
+ del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
648
+
649
+
650
+ def create_conditioning_event_handlers(prefix, ui_components):
651
+ rows = ui_components.get(f'conditioning_rows_{prefix}')
652
+ if not rows: return
653
+ prompts = ui_components[f'conditioning_prompts_{prefix}']
654
+ count_state = ui_components[f'conditioning_count_state_{prefix}']
655
+ add_button = ui_components[f'add_conditioning_button_{prefix}']
656
+ del_button = ui_components[f'delete_conditioning_button_{prefix}']
657
+
658
+ def add_row(c):
659
+ c += 1
660
+ return {
661
+ count_state: c,
662
+ rows[c - 1]: gr.update(visible=True),
663
+ add_button: gr.update(visible=c < MAX_CONDITIONINGS),
664
+ del_button: gr.update(visible=True),
665
+ }
666
+
667
+ def del_row(c):
668
+ c -= 1
669
+ return {
670
+ count_state: c,
671
+ rows[c]: gr.update(visible=False),
672
+ prompts[c]: "",
673
+ add_button: gr.update(visible=True),
674
+ del_button: gr.update(visible=c > 0),
675
+ }
676
+
677
+ add_outputs = [count_state, add_button, del_button] + rows
678
+ del_outputs = [count_state, add_button, del_button] + rows + prompts
679
+ add_button.click(fn=add_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
680
+ del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
ui/events/change_handlers.py ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from core.settings import (
3
+ MODEL_TYPE_MAP,
4
+ MODEL_MAP_CHECKPOINT,
5
+ FEATURES_CONFIG,
6
+ ARCHITECTURES_CONFIG,
7
+ MODEL_DEFAULTS_CONFIG,
8
+ ARCH_CATEGORIES_MAP
9
+ )
10
+ from utils.app_utils import get_model_generation_defaults
11
+ from ui.shared.ui_components import RESOLUTION_MAP
12
+ from .config_loaders import (
13
+ get_cn_defaults,
14
+ get_anima_cn_defaults,
15
+ get_diffsynth_cn_defaults,
16
+ load_ipadapter_config
17
+ )
18
+
19
+ def make_update_fn(m_comp, cat_comp, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp):
20
+ def update_fn(*args):
21
+ arch = args[0]
22
+ category = args[1]
23
+ current_ar = args[2] if len(args) > 2 else None
24
+
25
+ if arch == "ALL":
26
+ valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
27
+ else:
28
+ valid_cats = ARCH_CATEGORIES_MAP.get(arch, [])
29
+
30
+ cat_choices = ["ALL"] + sorted(valid_cats)
31
+ new_category = category if category in cat_choices else "ALL"
32
+
33
+ choices = []
34
+ for name, info in MODEL_MAP_CHECKPOINT.items():
35
+ m_arch = info[2]
36
+ m_cat = info[4] if len(info) > 4 else None
37
+ arch_match = (arch == "ALL" or m_arch == arch)
38
+ cat_match = (new_category == "ALL" or m_cat == new_category)
39
+ if arch_match and cat_match:
40
+ choices.append(name)
41
+
42
+ val = choices[0] if choices else None
43
+
44
+ updates = {
45
+ m_comp: gr.update(choices=choices, value=val),
46
+ cat_comp: gr.update(choices=cat_choices, value=new_category)
47
+ }
48
+
49
+ m_type = MODEL_TYPE_MAP.get(val, "SDXL") if val else "SDXL"
50
+
51
+ architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
52
+ arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
53
+
54
+ arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {}))
55
+ enabled_chains = arch_features.get('enabled_chains', [])
56
+
57
+ if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains))
58
+ if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
59
+ if anima_cn_acc: updates[anima_cn_acc] = gr.update(visible=('anima_controlnet_lllite' in enabled_chains))
60
+ if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
61
+ if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
62
+ if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
63
+ if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
64
+ if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains))
65
+ if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains))
66
+ if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains))
67
+ if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains))
68
+ if hidream_o1_ref_acc: updates[hidream_o1_ref_acc] = gr.update(visible=('hidream_o1_reference' in enabled_chains))
69
+
70
+ if cs_comp:
71
+ updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15"))
72
+ if guidance_comp:
73
+ updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1"))
74
+
75
+ if ar_comp:
76
+ res_key = arch_model_type
77
+ if res_key not in RESOLUTION_MAP:
78
+ res_key = 'sdxl'
79
+ res_map = RESOLUTION_MAP.get(res_key, {})
80
+ target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)")
81
+ updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar)
82
+ if width_comp and height_comp and target_ar in res_map:
83
+ updates[width_comp] = gr.update(value=res_map[target_ar][0])
84
+ updates[height_comp] = gr.update(value=res_map[target_ar][1])
85
+
86
+ controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
87
+
88
+ all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
89
+ for t_comp in cn_types:
90
+ updates[t_comp] = gr.update(choices=all_types, value=default_type)
91
+ for s_comp in cn_series:
92
+ updates[s_comp] = gr.update(choices=series_choices, value=default_series)
93
+ for f_comp in cn_filepaths:
94
+ updates[f_comp] = filepath
95
+
96
+ anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults()
97
+ for t_comp in anima_cn_types:
98
+ updates[t_comp] = gr.update(choices=anima_all_types, value=anima_default_type)
99
+ for s_comp in anima_cn_series:
100
+ updates[s_comp] = gr.update(choices=anima_series_choices, value=anima_default_series)
101
+ for f_comp in anima_cn_filepaths:
102
+ updates[f_comp] = anima_filepath
103
+
104
+ diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
105
+ for t_comp in diffsynth_cn_types:
106
+ updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
107
+ for s_comp in diffsynth_cn_series:
108
+ updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
109
+ for f_comp in diffsynth_cn_filepaths:
110
+ updates[f_comp] = diffsynth_filepath
111
+
112
+ if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
113
+ config = load_ipadapter_config()
114
+ ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
115
+ std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
116
+ face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
117
+ all_ipa_presets = std_presets + face_presets
118
+ default_ipa = all_ipa_presets[0] if all_ipa_presets else None
119
+ updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa)
120
+
121
+ defaults = get_model_generation_defaults(val, arch_model_type, MODEL_DEFAULTS_CONFIG)
122
+ if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps'))
123
+ if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg'))
124
+ if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name'))
125
+ if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler'))
126
+ if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt'))
127
+ if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt'))
128
+
129
+ return updates
130
+ return update_fn
131
+
132
+
133
+ def make_model_change_fn(cat_comp_ref, cs_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp):
134
+ def change_fn(*args):
135
+ model_name = args[0]
136
+ idx = 1
137
+ current_arch = args[idx] if arch_comp_ref and idx < len(args) else None
138
+ if arch_comp_ref: idx += 1
139
+ current_cat = args[idx] if cat_comp_ref and idx < len(args) else None
140
+ if cat_comp_ref: idx += 1
141
+ current_ar = args[idx] if idx < len(args) else None
142
+
143
+ m_type = MODEL_TYPE_MAP.get(model_name, "SDXL")
144
+
145
+ m_info = MODEL_MAP_CHECKPOINT.get(model_name)
146
+ m_cat = m_info[4] if m_info and len(m_info) > 4 else None
147
+ if not m_cat: m_cat = "ALL"
148
+
149
+ updates = {}
150
+ target_arch = m_type
151
+ if arch_comp_ref:
152
+ if current_arch == "ALL":
153
+ updates[arch_comp_ref] = gr.update()
154
+ target_arch = "ALL"
155
+ else:
156
+ updates[arch_comp_ref] = m_type
157
+
158
+ if cat_comp_ref:
159
+ if target_arch == "ALL":
160
+ valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
161
+ else:
162
+ valid_cats = ARCH_CATEGORIES_MAP.get(target_arch, [])
163
+ cat_choices = ["ALL"] + sorted(valid_cats)
164
+
165
+ if current_cat == "ALL":
166
+ updates[cat_comp_ref] = gr.update(choices=cat_choices)
167
+ else:
168
+ updates[cat_comp_ref] = gr.update(choices=cat_choices, value=m_cat)
169
+
170
+ architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
171
+ arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
172
+
173
+ arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {}))
174
+ enabled_chains = arch_features.get('enabled_chains', [])
175
+
176
+ if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains))
177
+ if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
178
+ if anima_cn_acc: updates[anima_cn_acc] = gr.update(visible=('anima_controlnet_lllite' in enabled_chains))
179
+ if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
180
+ if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
181
+ if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
182
+ if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
183
+ if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains))
184
+ if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains))
185
+ if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains))
186
+ if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains))
187
+ if hidream_o1_ref_acc: updates[hidream_o1_ref_acc] = gr.update(visible=('hidream_o1_reference' in enabled_chains))
188
+
189
+ if cs_comp:
190
+ updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15"))
191
+ if guidance_comp:
192
+ updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1"))
193
+
194
+ if ar_comp:
195
+ res_key = arch_model_type
196
+ if res_key not in RESOLUTION_MAP:
197
+ res_key = 'sdxl'
198
+ res_map = RESOLUTION_MAP.get(res_key, {})
199
+ target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)")
200
+ updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar)
201
+ if width_comp and height_comp and target_ar in res_map:
202
+ updates[width_comp] = gr.update(value=res_map[target_ar][0])
203
+ updates[height_comp] = gr.update(value=res_map[target_ar][1])
204
+
205
+ controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
206
+
207
+ all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
208
+ for t_comp in cn_types:
209
+ updates[t_comp] = gr.update(choices=all_types, value=default_type)
210
+ for s_comp in cn_series:
211
+ updates[s_comp] = gr.update(choices=series_choices, value=default_series)
212
+ for f_comp in cn_filepaths:
213
+ updates[f_comp] = filepath
214
+
215
+ anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults()
216
+ for t_comp in anima_cn_types:
217
+ updates[t_comp] = gr.update(choices=anima_all_types, value=anima_default_type)
218
+ for s_comp in anima_cn_series:
219
+ updates[s_comp] = gr.update(choices=anima_series_choices, value=anima_default_series)
220
+ for f_comp in anima_cn_filepaths:
221
+ updates[f_comp] = anima_filepath
222
+
223
+ diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
224
+ for t_comp in diffsynth_cn_types:
225
+ updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
226
+ for s_comp in diffsynth_cn_series:
227
+ updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
228
+ for f_comp in diffsynth_cn_filepaths:
229
+ updates[f_comp] = diffsynth_filepath
230
+
231
+ if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
232
+ config = load_ipadapter_config()
233
+ ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
234
+ std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
235
+ face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
236
+ all_ipa_presets = std_presets + face_presets
237
+ default_ipa = all_ipa_presets[0] if all_ipa_presets else None
238
+ updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa)
239
+
240
+ defaults = get_model_generation_defaults(model_name, arch_model_type, MODEL_DEFAULTS_CONFIG)
241
+ if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps'))
242
+ if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg'))
243
+ if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name'))
244
+ if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler'))
245
+ if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt'))
246
+ if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt'))
247
+
248
+ return updates
249
+ return change_fn
250
+
251
+
252
+ def initialize_all_cn_dropdowns(ui_components):
253
+ default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
254
+ default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
255
+ architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
256
+ controlnet_key = architectures_dict.get(default_m_type, {}).get("controlnet_key", default_m_type)
257
+
258
+ all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
259
+ anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults()
260
+ diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
261
+
262
+ updates = {}
263
+ for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
264
+ if f'controlnet_types_{prefix}' in ui_components:
265
+ for type_dd in ui_components[f'controlnet_types_{prefix}']:
266
+ updates[type_dd] = gr.update(choices=all_types, value=default_type)
267
+ for series_dd in ui_components[f'controlnet_series_{prefix}']:
268
+ updates[series_dd] = gr.update(choices=series_choices, value=default_series)
269
+ for filepath_state in ui_components[f'controlnet_filepaths_{prefix}']:
270
+ updates[filepath_state] = filepath
271
+
272
+ if f'anima_controlnet_lllite_types_{prefix}' in ui_components:
273
+ for type_dd in ui_components[f'anima_controlnet_lllite_types_{prefix}']:
274
+ updates[type_dd] = gr.update(choices=anima_all_types, value=anima_default_type)
275
+ for series_dd in ui_components[f'anima_controlnet_lllite_series_{prefix}']:
276
+ updates[series_dd] = gr.update(choices=anima_series_choices, value=anima_default_series)
277
+ for filepath_state in ui_components[f'anima_controlnet_lllite_filepaths_{prefix}']:
278
+ updates[filepath_state] = anima_filepath
279
+
280
+ if f'diffsynth_controlnet_types_{prefix}' in ui_components:
281
+ for type_dd in ui_components[f'diffsynth_controlnet_types_{prefix}']:
282
+ updates[type_dd] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
283
+ for series_dd in ui_components[f'diffsynth_controlnet_series_{prefix}']:
284
+ updates[series_dd] = gr.update(choices=diffsynth_series_choices, value=default_series)
285
+ for filepath_state in ui_components[f'diffsynth_controlnet_filepaths_{prefix}']:
286
+ updates[filepath_state] = diffsynth_filepath
287
+
288
+ return updates
289
+
290
+
291
+ def initialize_all_ipa_dropdowns(ui_components):
292
+ config = load_ipadapter_config()
293
+ if not config: return {}
294
+
295
+ default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
296
+ default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
297
+ architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
298
+ arch_model_type = architectures_dict.get(default_m_type, {}).get("model_type", default_m_type.lower().replace(" ", "").replace(".", ""))
299
+ ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
300
+
301
+ unified_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
302
+ faceid_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
303
+
304
+ all_presets = unified_presets + faceid_presets
305
+ default_preset = all_presets[0] if all_presets else None
306
+ is_faceid_default = default_preset in faceid_presets
307
+
308
+ lora_strength_update = gr.update(visible=is_faceid_default)
309
+
310
+ updates = {}
311
+ for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
312
+ if f'ipadapter_final_preset_{prefix}' in ui_components:
313
+ for lora_strength_slider in ui_components[f'ipadapter_lora_strengths_{prefix}']:
314
+ updates[lora_strength_slider] = lora_strength_update
315
+ updates[ui_components[f'ipadapter_final_preset_{prefix}']] = gr.update(choices=all_presets, value=default_preset)
316
+ updates[ui_components[f'ipadapter_final_lora_strength_{prefix}']] = lora_strength_update
317
+ return updates
318
+
319
+
320
+ def run_on_load(ui_components):
321
+ cn_updates = initialize_all_cn_dropdowns(ui_components)
322
+ ipa_updates = initialize_all_ipa_dropdowns(ui_components)
323
+ return {**cn_updates, **ipa_updates}
324
+
325
+
326
+ def on_aspect_ratio_change(ratio_key, model_display_name):
327
+ m_type = MODEL_TYPE_MAP.get(model_display_name, 'SDXL')
328
+ architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
329
+ arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
330
+
331
+ res_map = RESOLUTION_MAP.get(arch_model_type, RESOLUTION_MAP.get("sdxl", {}))
332
+ w, h = res_map.get(ratio_key, (1024, 1024))
333
+ return w, h
ui/events/config_loaders.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import yaml
3
+ from functools import lru_cache
4
+
5
+ @lru_cache(maxsize=1)
6
+ def load_controlnet_config():
7
+ _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8
+ _CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'controlnet_models.yaml')
9
+ try:
10
+ print("--- Loading controlnet_models.yaml ---")
11
+ with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
12
+ config = yaml.safe_load(f)
13
+ print("--- ✅ controlnet_models.yaml loaded successfully ---")
14
+ return config.get("ControlNet", {})
15
+ except Exception as e:
16
+ print(f"Error loading controlnet_models.yaml: {e}")
17
+ return {}
18
+
19
+
20
+ def get_cn_defaults(arch_val):
21
+ cn_full_config = load_controlnet_config()
22
+ cn_config = cn_full_config.get(arch_val, [])
23
+
24
+ if not cn_config:
25
+ return [], None, [], None, "None"
26
+
27
+ all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", []))))
28
+ default_type = all_types[0] if all_types else None
29
+
30
+ series_choices = []
31
+ if default_type:
32
+ series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", []))))
33
+ default_series = series_choices[0] if series_choices else None
34
+
35
+ filepath = "None"
36
+ if default_series and default_type:
37
+ for model in cn_config:
38
+ if model.get("Series") == default_series and default_type in model.get("Type", []):
39
+ filepath = model.get("Filepath")
40
+ break
41
+
42
+ return all_types, default_type, series_choices, default_series, filepath
43
+
44
+
45
+ @lru_cache(maxsize=1)
46
+ def load_anima_controlnet_lllite_config():
47
+ _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
48
+ _CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'anima_controlnet_lllite_models.yaml')
49
+ try:
50
+ print("--- Loading anima_controlnet_lllite_models.yaml ---")
51
+ with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
52
+ config = yaml.safe_load(f)
53
+ print("--- ✅ anima_controlnet_lllite_models.yaml loaded successfully ---")
54
+ return config.get("Anima_ControlNet_Lllite", [])
55
+ except Exception as e:
56
+ print(f"Error loading anima_controlnet_lllite_models.yaml: {e}")
57
+ return []
58
+
59
+
60
+ def get_anima_cn_defaults():
61
+ cn_config = load_anima_controlnet_lllite_config()
62
+ if not cn_config:
63
+ return [], None, [], None, "None"
64
+ all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", []))))
65
+ default_type = all_types[0] if all_types else None
66
+ series_choices = []
67
+ if default_type:
68
+ series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", []))))
69
+ default_series = series_choices[0] if series_choices else None
70
+ filepath = "None"
71
+ if default_series and default_type:
72
+ for model in cn_config:
73
+ if model.get("Series") == default_series and default_type in model.get("Type", []):
74
+ filepath = model.get("Filepath")
75
+ break
76
+ return all_types, default_type, series_choices, default_series, filepath
77
+
78
+
79
+ @lru_cache(maxsize=1)
80
+ def load_diffsynth_controlnet_config():
81
+ _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
82
+ _CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'diffsynth_controlnet_models.yaml')
83
+ try:
84
+ print("--- Loading diffsynth_controlnet_models.yaml ---")
85
+ with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
86
+ config = yaml.safe_load(f)
87
+ print("--- ✅ diffsynth_controlnet_models.yaml loaded successfully ---")
88
+ return config.get("DiffSynth_ControlNet", {})
89
+ except Exception as e:
90
+ print(f"Error loading diffsynth_controlnet_models.yaml: {e}")
91
+ return {}
92
+
93
+
94
+ def get_diffsynth_cn_defaults(arch_val):
95
+ cn_full_config = load_diffsynth_controlnet_config()
96
+ cn_config = cn_full_config.get(arch_val, [])
97
+
98
+ if not cn_config:
99
+ return [], None, [], None, "None"
100
+
101
+ all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", []))))
102
+ default_type = all_types[0] if all_types else None
103
+
104
+ series_choices = []
105
+ if default_type:
106
+ series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", []))))
107
+ default_series = series_choices[0] if series_choices else None
108
+
109
+ filepath = "None"
110
+ if default_series and default_type:
111
+ for model in cn_config:
112
+ if model.get("Series") == default_series and default_type in model.get("Type", []):
113
+ filepath = model.get("Filepath")
114
+ break
115
+
116
+ return all_types, default_type, series_choices, default_series, filepath
117
+
118
+
119
+ @lru_cache(maxsize=1)
120
+ def load_ipadapter_config():
121
+ _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
122
+ _IPA_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'ipadapter.yaml')
123
+ try:
124
+ print("--- Loading ipadapter.yaml ---")
125
+ with open(_IPA_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
126
+ config = yaml.safe_load(f)
127
+ print("--- ✅ ipadapter.yaml loaded successfully ---")
128
+ return config
129
+ except Exception as e:
130
+ print(f"Error loading ipadapter.yaml: {e}")
131
+ return {}
ui/events/main.py ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from .chain_handlers import (
3
+ create_lora_event_handlers,
4
+ create_controlnet_event_handlers,
5
+ create_anima_controlnet_lllite_event_handlers,
6
+ create_diffsynth_controlnet_event_handlers,
7
+ create_ipadapter_event_handlers,
8
+ create_embedding_event_handlers,
9
+ create_conditioning_event_handlers,
10
+ create_flux1_ipadapter_event_handlers,
11
+ create_sd3_ipadapter_event_handlers,
12
+ create_style_event_handlers,
13
+ create_reference_latent_event_handlers,
14
+ create_hidream_o1_reference_event_handlers
15
+ )
16
+ from .change_handlers import (
17
+ make_update_fn,
18
+ make_model_change_fn,
19
+ run_on_load,
20
+ on_aspect_ratio_change
21
+ )
22
+ from .run_handlers import create_run_event
23
+
24
+ def attach_event_handlers(ui_components, demo):
25
+ for prefix, task_type in [
26
+ ("txt2img", "txt2img"), ("img2img", "img2img"), ("inpaint", "inpaint"),
27
+ ("outpaint", "outpaint"), ("hires_fix", "hires_fix"),
28
+ ]:
29
+
30
+ arch_comp = ui_components.get(f'model_arch_{prefix}')
31
+ cat_comp = ui_components.get(f'model_cat_{prefix}')
32
+ model_comp = ui_components.get(f'base_model_{prefix}')
33
+ clip_skip_comp = ui_components.get(f'clip_skip_{prefix}') or ui_components.get(f'{prefix}_clip_skip')
34
+ guidance_comp = ui_components.get(f'guidance_{prefix}') or ui_components.get(f'{prefix}_guidance')
35
+ aspect_ratio_comp = ui_components.get(f'aspect_ratio_{prefix}') or ui_components.get(f'{prefix}_aspect_ratio_dropdown')
36
+ width_comp = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
37
+ height_comp = ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
38
+
39
+ cn_types_list = ui_components.get(f'controlnet_types_{prefix}', [])
40
+ cn_series_list = ui_components.get(f'controlnet_series_{prefix}', [])
41
+ cn_filepaths_list = ui_components.get(f'controlnet_filepaths_{prefix}', [])
42
+
43
+ anima_cn_types_list = ui_components.get(f'anima_controlnet_lllite_types_{prefix}', [])
44
+ anima_cn_series_list = ui_components.get(f'anima_controlnet_lllite_series_{prefix}', [])
45
+ anima_cn_filepaths_list = ui_components.get(f'anima_controlnet_lllite_filepaths_{prefix}', [])
46
+
47
+ diffsynth_cn_types_list = ui_components.get(f'diffsynth_controlnet_types_{prefix}', [])
48
+ diffsynth_cn_series_list = ui_components.get(f'diffsynth_controlnet_series_{prefix}', [])
49
+ diffsynth_cn_filepaths_list = ui_components.get(f'diffsynth_controlnet_filepaths_{prefix}', [])
50
+
51
+ lora_accordion = ui_components.get(f'lora_accordion_{prefix}')
52
+ cn_accordion = ui_components.get(f'controlnet_accordion_{prefix}')
53
+ anima_cn_accordion = ui_components.get(f'anima_controlnet_lllite_accordion_{prefix}')
54
+ diffsynth_cn_accordion = ui_components.get(f'diffsynth_controlnet_accordion_{prefix}')
55
+ ipa_accordion = ui_components.get(f'ipadapter_accordion_{prefix}')
56
+ sd3_ipa_accordion = ui_components.get(f'sd3_ipadapter_accordion_{prefix}')
57
+ flux1_ipa_accordion = ui_components.get(f'flux1_ipadapter_accordion_{prefix}')
58
+ style_accordion = ui_components.get(f'style_accordion_{prefix}')
59
+ embedding_accordion = ui_components.get(f'embedding_accordion_{prefix}')
60
+ conditioning_accordion = ui_components.get(f'conditioning_accordion_{prefix}')
61
+ ref_latent_accordion = ui_components.get(f'reference_latent_accordion_{prefix}')
62
+ hidream_o1_ref_accordion = ui_components.get(f'hidream_o1_reference_accordion_{prefix}')
63
+
64
+ ipa_preset_list = ui_components.get(f'ipadapter_final_preset_{prefix}')
65
+
66
+ prompt_comp = ui_components.get(f'prompt_{prefix}') or ui_components.get(f'{prefix}_positive_prompt')
67
+ neg_prompt_comp = ui_components.get(f'neg_prompt_{prefix}') or ui_components.get(f'{prefix}_negative_prompt')
68
+ steps_comp = ui_components.get(f'steps_{prefix}') or ui_components.get(f'{prefix}_steps')
69
+ cfg_comp = ui_components.get(f'cfg_{prefix}') or ui_components.get(f'{prefix}_cfg')
70
+ sampler_comp = ui_components.get(f'sampler_{prefix}') or ui_components.get(f'{prefix}_sampler_name')
71
+ scheduler_comp = ui_components.get(f'scheduler_{prefix}') or ui_components.get(f'{prefix}_scheduler')
72
+
73
+ extra_comps = [prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, width_comp, height_comp]
74
+ valid_extra_comps = [c for c in extra_comps if c is not None]
75
+
76
+ if arch_comp and cat_comp and model_comp:
77
+ outputs = [model_comp, cat_comp]
78
+ if clip_skip_comp: outputs.append(clip_skip_comp)
79
+ if guidance_comp: outputs.append(guidance_comp)
80
+ if aspect_ratio_comp: outputs.append(aspect_ratio_comp)
81
+ outputs.extend(cn_types_list + cn_series_list + cn_filepaths_list)
82
+ outputs.extend(anima_cn_types_list + anima_cn_series_list + anima_cn_filepaths_list)
83
+ outputs.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
84
+ if lora_accordion: outputs.append(lora_accordion)
85
+ if cn_accordion: outputs.append(cn_accordion)
86
+ if anima_cn_accordion: outputs.append(anima_cn_accordion)
87
+ if diffsynth_cn_accordion: outputs.append(diffsynth_cn_accordion)
88
+ if ipa_accordion: outputs.append(ipa_accordion)
89
+ if sd3_ipa_accordion: outputs.append(sd3_ipa_accordion)
90
+ if flux1_ipa_accordion: outputs.append(flux1_ipa_accordion)
91
+ if style_accordion: outputs.append(style_accordion)
92
+ if embedding_accordion: outputs.append(embedding_accordion)
93
+ if conditioning_accordion: outputs.append(conditioning_accordion)
94
+ if ref_latent_accordion: outputs.append(ref_latent_accordion)
95
+ if hidream_o1_ref_accordion: outputs.append(hidream_o1_ref_accordion)
96
+ if ipa_preset_list: outputs.append(ipa_preset_list)
97
+
98
+ outputs.extend(valid_extra_comps)
99
+
100
+ update_fn = make_update_fn(
101
+ model_comp, cat_comp, clip_skip_comp, aspect_ratio_comp, width_comp, height_comp,
102
+ cn_types_list, cn_series_list, cn_filepaths_list,
103
+ anima_cn_types_list, anima_cn_series_list, anima_cn_filepaths_list,
104
+ diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
105
+ ipa_preset_list, lora_accordion, cn_accordion, anima_cn_accordion, diffsynth_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
106
+ ref_latent_accordion, hidream_o1_ref_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp
107
+ )
108
+ inputs = [arch_comp, cat_comp]
109
+ if aspect_ratio_comp:
110
+ inputs.append(aspect_ratio_comp)
111
+ arch_comp.change(fn=update_fn, inputs=inputs, outputs=outputs)
112
+ cat_comp.change(fn=update_fn, inputs=inputs, outputs=outputs)
113
+
114
+ if model_comp:
115
+ outputs2 = []
116
+ if arch_comp: outputs2.append(arch_comp)
117
+ if cat_comp: outputs2.append(cat_comp)
118
+ if clip_skip_comp: outputs2.append(clip_skip_comp)
119
+ if guidance_comp: outputs2.append(guidance_comp)
120
+ if aspect_ratio_comp: outputs2.append(aspect_ratio_comp)
121
+ outputs2.extend(cn_types_list + cn_series_list + cn_filepaths_list)
122
+ outputs2.extend(anima_cn_types_list + anima_cn_series_list + anima_cn_filepaths_list)
123
+ outputs2.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
124
+ if lora_accordion: outputs2.append(lora_accordion)
125
+ if cn_accordion: outputs2.append(cn_accordion)
126
+ if anima_cn_accordion: outputs2.append(anima_cn_accordion)
127
+ if diffsynth_cn_accordion: outputs2.append(diffsynth_cn_accordion)
128
+ if ipa_accordion: outputs2.append(ipa_accordion)
129
+ if sd3_ipa_accordion: outputs2.append(sd3_ipa_accordion)
130
+ if flux1_ipa_accordion: outputs2.append(flux1_ipa_accordion)
131
+ if style_accordion: outputs2.append(style_accordion)
132
+ if embedding_accordion: outputs2.append(embedding_accordion)
133
+ if conditioning_accordion: outputs2.append(conditioning_accordion)
134
+ if ref_latent_accordion: outputs2.append(ref_latent_accordion)
135
+ if hidream_o1_ref_accordion: outputs2.append(hidream_o1_ref_accordion)
136
+ if ipa_preset_list: outputs2.append(ipa_preset_list)
137
+
138
+ outputs2.extend(valid_extra_comps)
139
+
140
+ if outputs2:
141
+ inputs2 = [model_comp]
142
+ if arch_comp: inputs2.append(arch_comp)
143
+ if cat_comp: inputs2.append(cat_comp)
144
+ if aspect_ratio_comp: inputs2.append(aspect_ratio_comp)
145
+ change_fn = make_model_change_fn(
146
+ cat_comp, clip_skip_comp, aspect_ratio_comp, width_comp, height_comp,
147
+ cn_types_list, cn_series_list, cn_filepaths_list,
148
+ anima_cn_types_list, anima_cn_series_list, anima_cn_filepaths_list,
149
+ diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
150
+ arch_comp, ipa_preset_list, lora_accordion, cn_accordion, anima_cn_accordion, diffsynth_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
151
+ ref_latent_accordion, hidream_o1_ref_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp
152
+ )
153
+ model_comp.change(fn=change_fn, inputs=inputs2, outputs=outputs2)
154
+
155
+ create_lora_event_handlers(prefix, ui_components)
156
+ create_controlnet_event_handlers(prefix, ui_components)
157
+ create_anima_controlnet_lllite_event_handlers(prefix, ui_components)
158
+ create_diffsynth_controlnet_event_handlers(prefix, ui_components)
159
+ create_ipadapter_event_handlers(prefix, ui_components)
160
+ create_embedding_event_handlers(prefix, ui_components)
161
+ create_conditioning_event_handlers(prefix, ui_components)
162
+ create_flux1_ipadapter_event_handlers(prefix, ui_components)
163
+ create_sd3_ipadapter_event_handlers(prefix, ui_components)
164
+ create_style_event_handlers(prefix, ui_components)
165
+ create_reference_latent_event_handlers(prefix, ui_components)
166
+ create_hidream_o1_reference_event_handlers(prefix, ui_components)
167
+ create_run_event(prefix, task_type, ui_components)
168
+
169
+ if 'view_mode_inpaint' in ui_components:
170
+ def toggle_inpaint_fullscreen_view(view_mode):
171
+ is_fullscreen = (view_mode == "Fullscreen View")
172
+ other_elements_visible = not is_fullscreen
173
+ editor_height = 800 if is_fullscreen else 272
174
+
175
+ updates = {
176
+ ui_components['prompts_column_inpaint']: gr.update(visible=other_elements_visible),
177
+ ui_components['params_and_gallery_row_inpaint']: gr.update(visible=other_elements_visible),
178
+ ui_components['accordion_wrapper_inpaint']: gr.update(visible=other_elements_visible),
179
+ ui_components['input_image_dict_inpaint']: gr.update(height=editor_height),
180
+ }
181
+
182
+ model_and_run_rows = ui_components.get('model_and_run_row_inpaint', [])
183
+ for row in model_and_run_rows:
184
+ updates[row] = gr.update(visible=other_elements_visible)
185
+
186
+ return updates
187
+
188
+ output_components = []
189
+ model_and_run_rows = ui_components.get('model_and_run_row_inpaint', [])
190
+ if isinstance(model_and_run_rows, list):
191
+ output_components.extend(model_and_run_rows)
192
+ else:
193
+ output_components.append(model_and_run_rows)
194
+
195
+ output_components.extend([
196
+ ui_components['prompts_column_inpaint'],
197
+ ui_components['params_and_gallery_row_inpaint'],
198
+ ui_components['accordion_wrapper_inpaint'],
199
+ ui_components['input_image_dict_inpaint']
200
+ ])
201
+
202
+ ui_components['view_mode_inpaint'].change(
203
+ fn=toggle_inpaint_fullscreen_view,
204
+ inputs=[ui_components['view_mode_inpaint']],
205
+ outputs=output_components,
206
+ show_progress=False
207
+ )
208
+
209
+ all_load_outputs = []
210
+ for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
211
+ if f'controlnet_types_{prefix}' in ui_components:
212
+ all_load_outputs.extend(ui_components[f'controlnet_types_{prefix}'])
213
+ all_load_outputs.extend(ui_components[f'controlnet_series_{prefix}'])
214
+ all_load_outputs.extend(ui_components[f'controlnet_filepaths_{prefix}'])
215
+ if f'anima_controlnet_lllite_types_{prefix}' in ui_components:
216
+ all_load_outputs.extend(ui_components[f'anima_controlnet_lllite_types_{prefix}'])
217
+ all_load_outputs.extend(ui_components[f'anima_controlnet_lllite_series_{prefix}'])
218
+ all_load_outputs.extend(ui_components[f'anima_controlnet_lllite_filepaths_{prefix}'])
219
+ if f'diffsynth_controlnet_types_{prefix}' in ui_components:
220
+ all_load_outputs.extend(ui_components[f'diffsynth_controlnet_types_{prefix}'])
221
+ all_load_outputs.extend(ui_components[f'diffsynth_controlnet_series_{prefix}'])
222
+ all_load_outputs.extend(ui_components[f'diffsynth_controlnet_filepaths_{prefix}'])
223
+ if f'ipadapter_final_preset_{prefix}' in ui_components:
224
+ all_load_outputs.extend(ui_components[f'ipadapter_lora_strengths_{prefix}'])
225
+ all_load_outputs.append(ui_components[f'ipadapter_final_preset_{prefix}'])
226
+ all_load_outputs.append(ui_components[f'ipadapter_final_lora_strength_{prefix}'])
227
+
228
+ if all_load_outputs:
229
+ demo.load(
230
+ fn=lambda: run_on_load(ui_components),
231
+ outputs=all_load_outputs
232
+ )
233
+
234
+ for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
235
+ aspect_ratio_dropdown = ui_components.get(f'aspect_ratio_{prefix}') or ui_components.get(f'{prefix}_aspect_ratio_dropdown')
236
+ width_component = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
237
+ height_component = ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
238
+ model_dropdown = ui_components.get(f'base_model_{prefix}')
239
+ if aspect_ratio_dropdown and width_component and height_component and model_dropdown:
240
+ aspect_ratio_dropdown.change(fn=on_aspect_ratio_change, inputs=[aspect_ratio_dropdown, model_dropdown], outputs=[width_component, height_component], show_progress=False)
ui/events/run_handlers.py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from core.generation_logic import generate_image_wrapper
3
+
4
+ def create_run_event(prefix: str, task_type: str, ui_components: dict):
5
+ run_inputs_map = {
6
+ 'model_display_name': ui_components[f'base_model_{prefix}'],
7
+ 'positive_prompt': ui_components.get(f'prompt_{prefix}') or ui_components.get(f'{prefix}_positive_prompt'),
8
+ 'negative_prompt': ui_components.get(f'neg_prompt_{prefix}') or ui_components.get(f'{prefix}_negative_prompt'),
9
+ 'seed': ui_components.get(f'seed_{prefix}') or ui_components.get(f'{prefix}_seed'),
10
+ 'batch_size': ui_components.get(f'batch_size_{prefix}') or ui_components.get(f'{prefix}_batch_size'),
11
+ 'guidance_scale': ui_components.get(f'cfg_{prefix}') or ui_components.get(f'{prefix}_cfg'),
12
+ 'num_inference_steps': ui_components.get(f'steps_{prefix}') or ui_components.get(f'{prefix}_steps'),
13
+ 'sampler': ui_components.get(f'sampler_{prefix}') or ui_components.get(f'{prefix}_sampler_name'),
14
+ 'scheduler': ui_components.get(f'scheduler_{prefix}') or ui_components.get(f'{prefix}_scheduler'),
15
+ 'zero_gpu_duration': ui_components.get(f'zero_gpu_{prefix}'),
16
+
17
+ 'clip_skip': ui_components.get(f'clip_skip_{prefix}'),
18
+ 'guidance': ui_components.get(f'guidance_{prefix}'),
19
+ 'task_type': gr.State(task_type)
20
+ }
21
+
22
+ if task_type not in ['img2img', 'inpaint']:
23
+ run_inputs_map.update({
24
+ 'width': ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width'),
25
+ 'height': ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
26
+ })
27
+
28
+ task_specific_map = {
29
+ 'img2img': {'img2img_image': f'input_image_{prefix}', 'img2img_denoise': f'denoise_{prefix}'},
30
+ 'inpaint': {'inpaint_image_dict': f'input_image_dict_{prefix}', 'grow_mask_by': f'grow_mask_by_{prefix}'},
31
+ 'outpaint': {'outpaint_image': f'input_image_{prefix}', 'left': f'left_{prefix}', 'top': f'top_{prefix}', 'right': f'right_{prefix}', 'bottom': f'bottom_{prefix}', 'feathering': f'feathering_{prefix}'},
32
+ 'hires_fix': {'hires_image': f'input_image_{prefix}', 'hires_upscaler': f'hires_upscaler_{prefix}', 'hires_scale_by': f'hires_scale_by_{prefix}', 'hires_denoise': f'denoise_{prefix}'}
33
+ }
34
+ if task_type in task_specific_map:
35
+ for key, comp_name in task_specific_map[task_type].items():
36
+ if comp_name in ui_components:
37
+ run_inputs_map[key] = ui_components[comp_name]
38
+
39
+ lora_data_components = ui_components.get(f'all_lora_components_flat_{prefix}', [])
40
+ controlnet_data_components = ui_components.get(f'all_controlnet_components_flat_{prefix}', [])
41
+ anima_controlnet_lllite_data_components = ui_components.get(f'all_anima_controlnet_lllite_components_flat_{prefix}', [])
42
+ diffsynth_controlnet_data_components = ui_components.get(f'all_diffsynth_controlnet_components_flat_{prefix}', [])
43
+ ipadapter_data_components = ui_components.get(f'all_ipadapter_components_flat_{prefix}', [])
44
+ sd3_ipadapter_data_components = ui_components.get(f'all_sd3_ipadapter_components_flat_{prefix}', [])
45
+ flux1_ipadapter_data_components = ui_components.get(f'all_flux1_ipadapter_components_flat_{prefix}', [])
46
+ style_data_components = ui_components.get(f'all_style_components_flat_{prefix}', [])
47
+ embedding_data_components = ui_components.get(f'all_embedding_components_flat_{prefix}', [])
48
+ conditioning_data_components = ui_components.get(f'all_conditioning_components_flat_{prefix}', [])
49
+ reference_latent_data_components = ui_components.get(f'all_reference_latent_components_flat_{prefix}', [])
50
+ hidream_o1_reference_data_components = ui_components.get(f'all_hidream_o1_reference_components_flat_{prefix}', [])
51
+
52
+ run_inputs_map['vae_source'] = ui_components.get(f'vae_source_{prefix}')
53
+ run_inputs_map['vae_id'] = ui_components.get(f'vae_id_{prefix}')
54
+ run_inputs_map['vae_file'] = ui_components.get(f'vae_file_{prefix}')
55
+
56
+ input_keys = list(run_inputs_map.keys())
57
+ input_list_flat = [v for v in run_inputs_map.values() if v is not None]
58
+ all_chains = [
59
+ lora_data_components, controlnet_data_components, anima_controlnet_lllite_data_components, diffsynth_controlnet_data_components, ipadapter_data_components,
60
+ sd3_ipadapter_data_components, flux1_ipadapter_data_components, style_data_components,
61
+ embedding_data_components, conditioning_data_components, reference_latent_data_components, hidream_o1_reference_data_components
62
+ ]
63
+ for chain in all_chains:
64
+ if chain:
65
+ input_list_flat.extend(chain)
66
+
67
+ def create_ui_inputs_dict(*args):
68
+ valid_keys = [k for k in input_keys if run_inputs_map[k] is not None]
69
+ ui_dict = dict(zip(valid_keys, args[:len(valid_keys)]))
70
+ arg_idx = len(valid_keys)
71
+
72
+ def assign_chain_data(chain_key, components_list):
73
+ nonlocal arg_idx
74
+ if components_list:
75
+ ui_dict[chain_key] = list(args[arg_idx : arg_idx + len(components_list)])
76
+ arg_idx += len(components_list)
77
+
78
+ assign_chain_data('lora_data', lora_data_components)
79
+ assign_chain_data('controlnet_data', controlnet_data_components)
80
+ assign_chain_data('anima_controlnet_lllite_data', anima_controlnet_lllite_data_components)
81
+ assign_chain_data('diffsynth_controlnet_data', diffsynth_controlnet_data_components)
82
+ assign_chain_data('ipadapter_data', ipadapter_data_components)
83
+ assign_chain_data('sd3_ipadapter_chain', sd3_ipadapter_data_components)
84
+ assign_chain_data('flux1_ipadapter_data', flux1_ipadapter_data_components)
85
+ assign_chain_data('style_data', style_data_components)
86
+ assign_chain_data('embedding_data', embedding_data_components)
87
+ assign_chain_data('conditioning_data', conditioning_data_components)
88
+ assign_chain_data('reference_latent_data', reference_latent_data_components)
89
+ assign_chain_data('hidream_o1_reference_data', hidream_o1_reference_data_components)
90
+
91
+ return ui_dict
92
+
93
+ run_btn = ui_components.get(f'run_{prefix}') or ui_components.get(f'{prefix}_run_button')
94
+ res_gal = ui_components.get(f'result_{prefix}') or ui_components.get(f'{prefix}_output_gallery')
95
+ if run_btn and res_gal:
96
+ run_btn.click(
97
+ fn=lambda *args, progress=gr.Progress(track_tqdm=True): generate_image_wrapper(create_ui_inputs_dict(*args), progress),
98
+ inputs=input_list_flat,
99
+ outputs=[res_gal]
100
+ )
ui/layout.py CHANGED
@@ -10,14 +10,17 @@ def build_ui(event_handler_function):
10
  ui_components = {}
11
 
12
  with gr.Blocks() as demo:
13
- gr.Markdown("# ImageGen - FLUX.2-KV")
14
  gr.Markdown(
15
  "This demo is a streamlined version of the [Comfy web UI](https://github.com/RioShiina47/comfy-webui)'s [ImageGen](https://huggingface.co/spaces/RioShiina/ImageGen) functionality. "
16
- "Other versions are also available: "
17
- "[Anima](https://huggingface.co/spaces/RioShiina/ImageGen-Anima), "
18
- "[Illustrious](https://huggingface.co/spaces/RioShiina/ImageGen-Illustrious), "
19
- "[NoobAI](https://huggingface.co/spaces/RioShiina/ImageGen-NoobAI), "
20
- "[Pony](https://huggingface.co/spaces/RioShiina/ImageGen-Pony)"
 
 
 
21
  )
22
  with gr.Tabs(elem_id="tabs_container") as tabs:
23
  with gr.TabItem("Txt2Img", id=0):
 
10
  ui_components = {}
11
 
12
  with gr.Blocks() as demo:
13
+ gr.Markdown("# ImageGen")
14
  gr.Markdown(
15
  "This demo is a streamlined version of the [Comfy web UI](https://github.com/RioShiina47/comfy-webui)'s [ImageGen](https://huggingface.co/spaces/RioShiina/ImageGen) functionality. "
16
+ "Other spaces: [ImageGen1](https://huggingface.co/spaces/RioShiina/ImageGen1), "
17
+ "[ImageGen2](https://huggingface.co/spaces/RioShiina/ImageGen2), "
18
+ "[ImageGen3](https://huggingface.co/spaces/RioShiina/ImageGen3), "
19
+ "[ImageGen4](https://huggingface.co/spaces/RioShiina/ImageGen4), "
20
+ "[ImageGen5](https://huggingface.co/spaces/RioShiina/ImageGen5), "
21
+ "[ImageGen6](https://huggingface.co/spaces/RioShiina/ImageGen6), "
22
+ "[ImageGen7](https://huggingface.co/spaces/RioShiina/ImageGen7), "
23
+ "[ImageGen8](https://huggingface.co/spaces/RioShiina/ImageGen8)"
24
  )
25
  with gr.Tabs(elem_id="tabs_container") as tabs:
26
  with gr.TabItem("Txt2Img", id=0):
ui/shared/hires_fix_ui.py CHANGED
@@ -3,11 +3,11 @@ from core.settings import MODEL_MAP_CHECKPOINT
3
  from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
4
  from .ui_components import (
5
  create_lora_settings_ui,
6
- create_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
7
  create_conditioning_ui, create_vae_override_ui,
8
  create_model_architecture_filter_ui, create_category_filter_ui,
9
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
10
- create_reference_latent_ui
11
  )
12
 
13
  def create_ui():
@@ -74,6 +74,7 @@ def create_ui():
74
 
75
  components.update(create_lora_settings_ui(prefix))
76
  components.update(create_controlnet_ui(prefix))
 
77
  components.update(create_ipadapter_ui(prefix))
78
  components.update(create_flux1_ipadapter_ui(prefix))
79
  components.update(create_sd3_ipadapter_ui(prefix))
@@ -81,6 +82,7 @@ def create_ui():
81
  components.update(create_embedding_ui(prefix))
82
  components.update(create_conditioning_ui(prefix))
83
  components.update(create_reference_latent_ui(prefix))
 
84
  components.update(create_vae_override_ui(prefix))
85
 
86
  return components
 
3
  from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
4
  from .ui_components import (
5
  create_lora_settings_ui,
6
+ create_controlnet_ui, create_anima_controlnet_lllite_ui, create_ipadapter_ui, create_embedding_ui,
7
  create_conditioning_ui, create_vae_override_ui,
8
  create_model_architecture_filter_ui, create_category_filter_ui,
9
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
10
+ create_reference_latent_ui, create_hidream_o1_reference_ui
11
  )
12
 
13
  def create_ui():
 
74
 
75
  components.update(create_lora_settings_ui(prefix))
76
  components.update(create_controlnet_ui(prefix))
77
+ components.update(create_anima_controlnet_lllite_ui(prefix))
78
  components.update(create_ipadapter_ui(prefix))
79
  components.update(create_flux1_ipadapter_ui(prefix))
80
  components.update(create_sd3_ipadapter_ui(prefix))
 
82
  components.update(create_embedding_ui(prefix))
83
  components.update(create_conditioning_ui(prefix))
84
  components.update(create_reference_latent_ui(prefix))
85
+ components.update(create_hidream_o1_reference_ui(prefix))
86
  components.update(create_vae_override_ui(prefix))
87
 
88
  return components
ui/shared/img2img_ui.py CHANGED
@@ -3,11 +3,11 @@ from core.settings import MODEL_MAP_CHECKPOINT
3
  from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
4
  from .ui_components import (
5
  create_lora_settings_ui,
6
- create_controlnet_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
7
  create_conditioning_ui, create_vae_override_ui,
8
  create_model_architecture_filter_ui, create_category_filter_ui,
9
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
10
- create_reference_latent_ui
11
  )
12
 
13
  def create_ui():
@@ -55,6 +55,7 @@ def create_ui():
55
 
56
  components.update(create_lora_settings_ui(prefix))
57
  components.update(create_controlnet_ui(prefix))
 
58
  components.update(create_diffsynth_controlnet_ui(prefix))
59
  components.update(create_ipadapter_ui(prefix))
60
  components.update(create_flux1_ipadapter_ui(prefix))
@@ -63,6 +64,7 @@ def create_ui():
63
  components.update(create_style_ui(prefix))
64
  components.update(create_conditioning_ui(prefix))
65
  components.update(create_reference_latent_ui(prefix))
 
66
  components.update(create_vae_override_ui(prefix))
67
 
68
  return components
 
3
  from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
4
  from .ui_components import (
5
  create_lora_settings_ui,
6
+ create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
7
  create_conditioning_ui, create_vae_override_ui,
8
  create_model_architecture_filter_ui, create_category_filter_ui,
9
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
10
+ create_reference_latent_ui, create_hidream_o1_reference_ui
11
  )
12
 
13
  def create_ui():
 
55
 
56
  components.update(create_lora_settings_ui(prefix))
57
  components.update(create_controlnet_ui(prefix))
58
+ components.update(create_anima_controlnet_lllite_ui(prefix))
59
  components.update(create_diffsynth_controlnet_ui(prefix))
60
  components.update(create_ipadapter_ui(prefix))
61
  components.update(create_flux1_ipadapter_ui(prefix))
 
64
  components.update(create_style_ui(prefix))
65
  components.update(create_conditioning_ui(prefix))
66
  components.update(create_reference_latent_ui(prefix))
67
+ components.update(create_hidream_o1_reference_ui(prefix))
68
  components.update(create_vae_override_ui(prefix))
69
 
70
  return components
ui/shared/inpaint_ui.py CHANGED
@@ -2,11 +2,11 @@ import gradio as gr
2
  from core.settings import MODEL_MAP_CHECKPOINT
3
  from .ui_components import (
4
  create_base_parameter_ui, create_lora_settings_ui,
5
- create_controlnet_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
6
  create_conditioning_ui, create_vae_override_ui,
7
  create_model_architecture_filter_ui, create_category_filter_ui,
8
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
9
- create_reference_latent_ui
10
  )
11
 
12
  def create_ui():
@@ -87,6 +87,7 @@ def create_ui():
87
 
88
  components.update(create_lora_settings_ui(prefix))
89
  components.update(create_controlnet_ui(prefix))
 
90
  components.update(create_diffsynth_controlnet_ui(prefix))
91
  components.update(create_ipadapter_ui(prefix))
92
  components.update(create_flux1_ipadapter_ui(prefix))
@@ -95,6 +96,7 @@ def create_ui():
95
  components.update(create_embedding_ui(prefix))
96
  components.update(create_conditioning_ui(prefix))
97
  components.update(create_reference_latent_ui(prefix))
 
98
  components.update(create_vae_override_ui(prefix))
99
  components[f'accordion_wrapper_{prefix}'] = accordion_wrapper
100
 
 
2
  from core.settings import MODEL_MAP_CHECKPOINT
3
  from .ui_components import (
4
  create_base_parameter_ui, create_lora_settings_ui,
5
+ create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
6
  create_conditioning_ui, create_vae_override_ui,
7
  create_model_architecture_filter_ui, create_category_filter_ui,
8
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
9
+ create_reference_latent_ui, create_hidream_o1_reference_ui
10
  )
11
 
12
  def create_ui():
 
87
 
88
  components.update(create_lora_settings_ui(prefix))
89
  components.update(create_controlnet_ui(prefix))
90
+ components.update(create_anima_controlnet_lllite_ui(prefix))
91
  components.update(create_diffsynth_controlnet_ui(prefix))
92
  components.update(create_ipadapter_ui(prefix))
93
  components.update(create_flux1_ipadapter_ui(prefix))
 
96
  components.update(create_embedding_ui(prefix))
97
  components.update(create_conditioning_ui(prefix))
98
  components.update(create_reference_latent_ui(prefix))
99
+ components.update(create_hidream_o1_reference_ui(prefix))
100
  components.update(create_vae_override_ui(prefix))
101
  components[f'accordion_wrapper_{prefix}'] = accordion_wrapper
102
 
ui/shared/outpaint_ui.py CHANGED
@@ -3,11 +3,11 @@ from core.settings import MODEL_MAP_CHECKPOINT
3
  from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
4
  from .ui_components import (
5
  create_lora_settings_ui,
6
- create_controlnet_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
7
  create_conditioning_ui, create_vae_override_ui,
8
  create_model_architecture_filter_ui, create_category_filter_ui,
9
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
10
- create_reference_latent_ui
11
  )
12
 
13
  def create_ui():
@@ -70,6 +70,7 @@ def create_ui():
70
 
71
  components.update(create_lora_settings_ui(prefix))
72
  components.update(create_controlnet_ui(prefix))
 
73
  components.update(create_diffsynth_controlnet_ui(prefix))
74
  components.update(create_ipadapter_ui(prefix))
75
  components.update(create_flux1_ipadapter_ui(prefix))
@@ -78,6 +79,7 @@ def create_ui():
78
  components.update(create_embedding_ui(prefix))
79
  components.update(create_conditioning_ui(prefix))
80
  components.update(create_reference_latent_ui(prefix))
 
81
  components.update(create_vae_override_ui(prefix))
82
 
83
  return components
 
3
  from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
4
  from .ui_components import (
5
  create_lora_settings_ui,
6
+ create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
7
  create_conditioning_ui, create_vae_override_ui,
8
  create_model_architecture_filter_ui, create_category_filter_ui,
9
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
10
+ create_reference_latent_ui, create_hidream_o1_reference_ui
11
  )
12
 
13
  def create_ui():
 
70
 
71
  components.update(create_lora_settings_ui(prefix))
72
  components.update(create_controlnet_ui(prefix))
73
+ components.update(create_anima_controlnet_lllite_ui(prefix))
74
  components.update(create_diffsynth_controlnet_ui(prefix))
75
  components.update(create_ipadapter_ui(prefix))
76
  components.update(create_flux1_ipadapter_ui(prefix))
 
79
  components.update(create_embedding_ui(prefix))
80
  components.update(create_conditioning_ui(prefix))
81
  components.update(create_reference_latent_ui(prefix))
82
+ components.update(create_hidream_o1_reference_ui(prefix))
83
  components.update(create_vae_override_ui(prefix))
84
 
85
  return components
ui/shared/txt2img_ui.py CHANGED
@@ -2,11 +2,11 @@ import gradio as gr
2
  from core.settings import MODEL_MAP_CHECKPOINT
3
  from .ui_components import (
4
  create_base_parameter_ui, create_lora_settings_ui,
5
- create_controlnet_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
6
  create_conditioning_ui, create_vae_override_ui,
7
  create_model_architecture_filter_ui, create_category_filter_ui,
8
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
9
- create_reference_latent_ui
10
  )
11
 
12
  def create_ui():
@@ -42,6 +42,7 @@ def create_ui():
42
 
43
  components.update(create_lora_settings_ui(prefix))
44
  components.update(create_controlnet_ui(prefix))
 
45
  components.update(create_diffsynth_controlnet_ui(prefix))
46
  components.update(create_ipadapter_ui(prefix))
47
  components.update(create_flux1_ipadapter_ui(prefix))
@@ -50,6 +51,7 @@ def create_ui():
50
  components.update(create_style_ui(prefix))
51
  components.update(create_conditioning_ui(prefix))
52
  components.update(create_reference_latent_ui(prefix))
 
53
  components.update(create_vae_override_ui(prefix))
54
 
55
  return components
 
2
  from core.settings import MODEL_MAP_CHECKPOINT
3
  from .ui_components import (
4
  create_base_parameter_ui, create_lora_settings_ui,
5
+ create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
6
  create_conditioning_ui, create_vae_override_ui,
7
  create_model_architecture_filter_ui, create_category_filter_ui,
8
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
9
+ create_reference_latent_ui, create_hidream_o1_reference_ui
10
  )
11
 
12
  def create_ui():
 
42
 
43
  components.update(create_lora_settings_ui(prefix))
44
  components.update(create_controlnet_ui(prefix))
45
+ components.update(create_anima_controlnet_lllite_ui(prefix))
46
  components.update(create_diffsynth_controlnet_ui(prefix))
47
  components.update(create_ipadapter_ui(prefix))
48
  components.update(create_flux1_ipadapter_ui(prefix))
 
51
  components.update(create_style_ui(prefix))
52
  components.update(create_conditioning_ui(prefix))
53
  components.update(create_reference_latent_ui(prefix))
54
+ components.update(create_hidream_o1_reference_ui(prefix))
55
  components.update(create_vae_override_ui(prefix))
56
 
57
  return components
ui/shared/ui_components.py CHANGED
@@ -3,11 +3,13 @@ from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
3
  from core.settings import (
4
  MAX_LORAS, LORA_SOURCE_CHOICES, MAX_EMBEDDINGS, MAX_CONDITIONINGS,
5
  MAX_CONTROLNETS, MAX_IPADAPTERS, RESOLUTION_MAP, ARCHITECTURES_CONFIG,
6
- MODEL_MAP_CHECKPOINT, MODEL_TYPE_MAP, FEATURES_CONFIG, ARCH_CATEGORIES_MAP
 
7
  )
8
  import yaml
9
  import os
10
  from functools import lru_cache
 
11
 
12
  default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
13
  default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
@@ -51,7 +53,7 @@ def create_model_architecture_filter_ui(prefix):
51
  choices=choices,
52
  value="ALL",
53
  interactive=True,
54
- visible=False
55
  )
56
  return components
57
 
@@ -186,6 +188,54 @@ def create_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):
186
 
187
  return components
188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  def create_diffsynth_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):
190
  components = {}
191
  key = lambda name: f"{name}_{prefix}"
@@ -237,7 +287,7 @@ def create_ipadapter_ui(prefix: str, max_units=MAX_IPADAPTERS):
237
 
238
  with gr.Accordion("IPAdapter Settings", open=False, visible=('ipadapter' in default_enabled_chains)) as accordion:
239
  components[key('ipadapter_accordion')] = accordion
240
- gr.Markdown("Powered by [cubiq/ComfyUI_IPAdapter_plus](https://github.com/cubiq/ComfyUI_IPAdapter_plus).")
241
 
242
  with gr.Row():
243
  components[key('ipadapter_final_preset')] = gr.Dropdown(
@@ -306,6 +356,7 @@ def create_flux1_ipadapter_ui(prefix: str, max_units=MAX_IPADAPTERS):
306
 
307
  with gr.Accordion("IPAdapter Settings (FLUX.1)", open=False, visible=('flux1_ipadapter' in default_enabled_chains)) as accordion:
308
  components[key('flux1_ipadapter_accordion')] = accordion
 
309
 
310
  ipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []
311
  components.update({
@@ -343,6 +394,7 @@ def create_sd3_ipadapter_ui(prefix: str, max_units=MAX_IPADAPTERS):
343
 
344
  with gr.Accordion("IPAdapter Settings (SD3)", open=False, visible=('sd3_ipadapter' in default_enabled_chains)) as accordion:
345
  components[key('sd3_ipadapter_accordion')] = accordion
 
346
 
347
  ipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []
348
  components.update({
@@ -483,7 +535,14 @@ def create_conditioning_ui(prefix: str):
483
  components[key('all_conditioning_components_flat')] = all_cond_components_flat
484
 
485
  return components
 
 
 
 
486
 
 
 
 
487
  def create_vae_override_ui(prefix: str):
488
  components = {}
489
  key = lambda name: f"{name}_{prefix}"
@@ -515,6 +574,12 @@ def create_vae_override_ui(prefix: str):
515
  components[key('vae_upload_button')] = upload_btn
516
  components[key('vae_file')] = gr.State(None)
517
 
 
 
 
 
 
 
518
  return components
519
 
520
  def create_reference_latent_ui(prefix: str, max_units=10):
@@ -523,7 +588,7 @@ def create_reference_latent_ui(prefix: str, max_units=10):
523
 
524
  with gr.Accordion("Reference Edit Settings", open=False, visible=('reference_latent' in default_enabled_chains)) as ref_accordion:
525
  components[key('reference_latent_accordion')] = ref_accordion
526
- gr.Markdown("💡 **Tip:** For multimodal models (like FLUX.2 or OmniGen), this feature enables powerful editing and combining capabilities. In txt2img mode, adding a single reference image performs an **Image Edit**, while adding multiple images performs an **Image Combine**.")
527
 
528
  ref_image_groups = []
529
  ref_image_inputs = []
@@ -544,4 +609,33 @@ def create_reference_latent_ui(prefix: str, max_units=10):
544
 
545
  components[key('all_reference_latent_components_flat')] = ref_image_inputs
546
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
547
  return components
 
3
  from core.settings import (
4
  MAX_LORAS, LORA_SOURCE_CHOICES, MAX_EMBEDDINGS, MAX_CONDITIONINGS,
5
  MAX_CONTROLNETS, MAX_IPADAPTERS, RESOLUTION_MAP, ARCHITECTURES_CONFIG,
6
+ MODEL_MAP_CHECKPOINT, MODEL_TYPE_MAP, FEATURES_CONFIG, ARCH_CATEGORIES_MAP,
7
+ VAE_DIR
8
  )
9
  import yaml
10
  import os
11
  from functools import lru_cache
12
+ from utils.app_utils import save_uploaded_file_with_hash
13
 
14
  default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
15
  default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
 
53
  choices=choices,
54
  value="ALL",
55
  interactive=True,
56
+ visible=True
57
  )
58
  return components
59
 
 
188
 
189
  return components
190
 
191
+ def create_anima_controlnet_lllite_ui(prefix: str, max_units=MAX_CONTROLNETS):
192
+ components = {}
193
+ key = lambda name: f"{name}_{prefix}"
194
+
195
+ with gr.Accordion("Anima ControlNet Lllite Settings", open=False, visible=('anima_controlnet_lllite' in default_enabled_chains)) as accordion:
196
+ components[key('anima_controlnet_lllite_accordion')] = accordion
197
+ gr.Markdown("💡 **Tip:** Processed using the [kohya-ss/ComfyUI-Anima-LLLite](https://github.com/kohya-ss/ComfyUI-Anima-LLLite) node.")
198
+
199
+ cn_rows, images, series, types, strengths, filepaths, start_percents, end_percents = [], [], [], [], [], [], [], []
200
+ components.update({
201
+ key('anima_controlnet_lllite_rows'): cn_rows,
202
+ key('anima_controlnet_lllite_images'): images,
203
+ key('anima_controlnet_lllite_series'): series,
204
+ key('anima_controlnet_lllite_types'): types,
205
+ key('anima_controlnet_lllite_strengths'): strengths,
206
+ key('anima_controlnet_lllite_filepaths'): filepaths,
207
+ key('anima_controlnet_lllite_start_percents'): start_percents,
208
+ key('anima_controlnet_lllite_end_percents'): end_percents
209
+ })
210
+
211
+ for i in range(max_units):
212
+ with gr.Row(visible=(i < 1)) as row:
213
+ with gr.Column(scale=1):
214
+ images.append(gr.Image(label=f"Control Image {i+1}", type="pil", sources=["upload"], height=256))
215
+ with gr.Column(scale=2):
216
+ types.append(gr.Dropdown(label="Type", choices=[], interactive=True, allow_custom_value=True))
217
+ series.append(gr.Dropdown(label="Series", choices=[], interactive=True, allow_custom_value=True))
218
+ strengths.append(gr.Slider(label="Strength", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True))
219
+ with gr.Row(visible=False):
220
+ start_percents.append(gr.State(0.0))
221
+ end_percents.append(gr.State(1.0))
222
+ filepaths.append(gr.State(None))
223
+ cn_rows.append(row)
224
+
225
+ with gr.Row():
226
+ components[key('add_anima_controlnet_lllite_button')] = gr.Button("✚ Add Lllite")
227
+ components[key('delete_anima_controlnet_lllite_button')] = gr.Button("➖ Delete Lllite", visible=False)
228
+ components[key('anima_controlnet_lllite_count_state')] = gr.State(1)
229
+
230
+ all_cn_components_flat = []
231
+ for i in range(max_units):
232
+ all_cn_components_flat.extend([
233
+ images[i], types[i], series[i], strengths[i], filepaths[i], start_percents[i], end_percents[i]
234
+ ])
235
+ components[key('all_anima_controlnet_lllite_components_flat')] = all_cn_components_flat
236
+
237
+ return components
238
+
239
  def create_diffsynth_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):
240
  components = {}
241
  key = lambda name: f"{name}_{prefix}"
 
287
 
288
  with gr.Accordion("IPAdapter Settings", open=False, visible=('ipadapter' in default_enabled_chains)) as accordion:
289
  components[key('ipadapter_accordion')] = accordion
290
+ gr.Markdown("💡 **Tip:** Processed using the [cubiq/ComfyUI_IPAdapter_plus](https://github.com/cubiq/ComfyUI_IPAdapter_plus) node.")
291
 
292
  with gr.Row():
293
  components[key('ipadapter_final_preset')] = gr.Dropdown(
 
356
 
357
  with gr.Accordion("IPAdapter Settings (FLUX.1)", open=False, visible=('flux1_ipadapter' in default_enabled_chains)) as accordion:
358
  components[key('flux1_ipadapter_accordion')] = accordion
359
+ gr.Markdown("💡 **Tip:** Processed using the [Shakker-Labs/ComfyUI-IPAdapter-Flux](https://github.com/Shakker-Labs/ComfyUI-IPAdapter-Flux) node.")
360
 
361
  ipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []
362
  components.update({
 
394
 
395
  with gr.Accordion("IPAdapter Settings (SD3)", open=False, visible=('sd3_ipadapter' in default_enabled_chains)) as accordion:
396
  components[key('sd3_ipadapter_accordion')] = accordion
397
+ gr.Markdown("💡 **Tip:** Processed using the [Slickytail/ComfyUI-InstantX-IPAdapter-SD3](https://github.com/Slickytail/ComfyUI-InstantX-IPAdapter-SD3) node.")
398
 
399
  ipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []
400
  components.update({
 
535
  components[key('all_conditioning_components_flat')] = all_cond_components_flat
536
 
537
  return components
538
+
539
+ def on_vae_upload(file_obj):
540
+ if not file_obj:
541
+ return gr.update(), gr.update(), None
542
 
543
+ hashed_filename = save_uploaded_file_with_hash(file_obj, VAE_DIR)
544
+ return hashed_filename, "File", file_obj
545
+
546
  def create_vae_override_ui(prefix: str):
547
  components = {}
548
  key = lambda name: f"{name}_{prefix}"
 
574
  components[key('vae_upload_button')] = upload_btn
575
  components[key('vae_file')] = gr.State(None)
576
 
577
+ upload_btn.upload(
578
+ fn=on_vae_upload,
579
+ inputs=[upload_btn],
580
+ outputs=[components[key('vae_id')], components[key('vae_source')], components[key('vae_file')]]
581
+ )
582
+
583
  return components
584
 
585
  def create_reference_latent_ui(prefix: str, max_units=10):
 
588
 
589
  with gr.Accordion("Reference Edit Settings", open=False, visible=('reference_latent' in default_enabled_chains)) as ref_accordion:
590
  components[key('reference_latent_accordion')] = ref_accordion
591
+ gr.Markdown("💡 **Tip:** For multimodal models, this feature enables powerful editing and combining capabilities. In txt2img mode, adding a single reference image performs an **Image Edit**, while adding multiple images performs an **Image Combine**.")
592
 
593
  ref_image_groups = []
594
  ref_image_inputs = []
 
609
 
610
  components[key('all_reference_latent_components_flat')] = ref_image_inputs
611
 
612
+ return components
613
+
614
+ def create_hidream_o1_reference_ui(prefix: str, max_units=10):
615
+ components = {}
616
+ key = lambda name: f"{name}_{prefix}"
617
+
618
+ with gr.Accordion("HiDream-O1 Reference Edit Settings", open=False, visible=('hidream_o1_reference' in default_enabled_chains)) as ref_accordion:
619
+ components[key('hidream_o1_reference_accordion')] = ref_accordion
620
+ gr.Markdown("💡 **Tip:** Please use **HiDream-O1-Image-Dev** (HiDream-O1-Image will time out), and set the resolution to **4.0MP** (e.g., 2048x2048). In txt2img mode, adding a single reference image performs an **Image Edit**, while adding multiple images performs an **Image Combine**.")
621
+
622
+ ref_image_groups = []
623
+ ref_image_inputs = []
624
+ with gr.Row():
625
+ for i in range(max_units):
626
+ with gr.Column(visible=(i < 1), min_width=160) as img_col:
627
+ img_comp = gr.Image(type="pil", label=f"Ref. {i+1}", sources=["upload"], height=150)
628
+ ref_image_groups.append(img_col)
629
+ ref_image_inputs.append(img_comp)
630
+
631
+ components[key('hidream_o1_reference_rows')] = ref_image_groups
632
+ components[key('hidream_o1_reference_images')] = ref_image_inputs
633
+
634
+ with gr.Row():
635
+ components[key('add_hidream_o1_reference_button')] = gr.Button("✚ Add Reference Image")
636
+ components[key('delete_hidream_o1_reference_button')] = gr.Button("➖ Delete Reference Image", visible=False)
637
+ components[key('hidream_o1_reference_count_state')] = gr.State(1)
638
+
639
+ components[key('all_hidream_o1_reference_components_flat')] = ref_image_inputs
640
+
641
  return components
utils/app_utils.py CHANGED
@@ -15,7 +15,6 @@ import yaml
15
 
16
  from core.settings import *
17
 
18
- DISK_LIMIT_GB = 120
19
  MODELS_ROOT_DIR = "ComfyUI/models"
20
 
21
  IPADAPTER_PRESETS = None
@@ -89,54 +88,6 @@ def get_directory_size(path: str) -> int:
89
  print(f"Warning: Could not access {path} to calculate size: {e}")
90
  return total_size
91
 
92
- def enforce_disk_limit():
93
- disk_limit_bytes = DISK_LIMIT_GB * (1024 ** 3)
94
- cache_dir = hf_constants.HF_HUB_CACHE
95
-
96
- if not os.path.exists(cache_dir):
97
- return
98
-
99
- print(f"--- [Storage Manager] Checking disk usage in '{cache_dir}' (Limit: {DISK_LIMIT_GB} GB) ---")
100
-
101
- try:
102
- all_files = []
103
- current_size_bytes = 0
104
- for dirpath, _, filenames in os.walk(cache_dir):
105
- for f in filenames:
106
- if f.endswith(".incomplete") or f.endswith(".lock"):
107
- continue
108
- file_path = os.path.join(dirpath, f)
109
- if os.path.isfile(file_path) and not os.path.islink(file_path):
110
- try:
111
- file_size = os.path.getsize(file_path)
112
- creation_time = os.path.getctime(file_path)
113
- all_files.append((creation_time, file_path, file_size))
114
- current_size_bytes += file_size
115
- except OSError:
116
- continue
117
-
118
- print(f"--- [Storage Manager] Current usage: {bytes_to_gb(current_size_bytes)} GB ---")
119
-
120
- if current_size_bytes > disk_limit_bytes:
121
- print(f"--- [Storage Manager] Usage exceeds limit. Starting cleanup... ---")
122
- all_files.sort(key=lambda x: x[0])
123
-
124
- while current_size_bytes > disk_limit_bytes and all_files:
125
- oldest_file_time, oldest_file_path, oldest_file_size = all_files.pop(0)
126
- try:
127
- os.remove(oldest_file_path)
128
- current_size_bytes -= oldest_file_size
129
- print(f"--- [Storage Manager] Deleted oldest file: {os.path.basename(oldest_file_path)} ({bytes_to_gb(oldest_file_size)} GB freed) ---")
130
- except OSError as e:
131
- print(f"--- [Storage Manager] Error deleting file {oldest_file_path}: {e} ---")
132
-
133
- print(f"--- [Storage Manager] Cleanup finished. New usage: {bytes_to_gb(current_size_bytes)} GB ---")
134
- else:
135
- print("--- [Storage Manager] Disk usage is within the limit. No action needed. ---")
136
-
137
- except Exception as e:
138
- print(f"--- [Storage Manager] An unexpected error occurred: {e} ---")
139
-
140
  def get_value_at_index(obj: Union[Sequence, Mapping], index: int) -> Any:
141
  try:
142
  return obj[index]
@@ -188,8 +139,6 @@ def get_civitai_file_info(version_id: str) -> dict | None:
188
  return None
189
 
190
  def download_file(url: str, save_path: str, api_key: str = None, progress=None, desc: str = "") -> str:
191
- enforce_disk_limit()
192
-
193
  if os.path.exists(save_path):
194
  return f"File already exists: {os.path.basename(save_path)}"
195
 
@@ -526,24 +475,6 @@ def ensure_sd3_ipadapter_models_downloaded(progress):
526
  print(f"Warning: Failed to load or download sd3 ipadapter models: {e}")
527
 
528
 
529
- def print_welcome_message():
530
- author_name = "RioShiina"
531
- project_url = "https://huggingface.co/RioShiina"
532
- border = "=" * 72
533
-
534
- message = (
535
- f"\n{border}\n\n"
536
- f" Thank you for using this project!\n\n"
537
- f" **Author:** {author_name}\n"
538
- f" **Find more from the author:** {project_url}\n\n"
539
- f" This project is open-source under the GNU General Public License v3.0 (GPL-3.0).\n"
540
- f" As it's built upon GPL-3.0 components (like ComfyUI), any modifications you\n"
541
- f" distribute must also be open-sourced under the same license.\n\n"
542
- f" Your respect for the principles of free software is greatly appreciated!\n\n"
543
- f"{border}\n"
544
- )
545
-
546
- print(message)
547
 
548
  def get_model_generation_defaults(model_display_name: str, model_type: str, defaults_config: dict):
549
  final_defaults = {
 
15
 
16
  from core.settings import *
17
 
 
18
  MODELS_ROOT_DIR = "ComfyUI/models"
19
 
20
  IPADAPTER_PRESETS = None
 
88
  print(f"Warning: Could not access {path} to calculate size: {e}")
89
  return total_size
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  def get_value_at_index(obj: Union[Sequence, Mapping], index: int) -> Any:
92
  try:
93
  return obj[index]
 
139
  return None
140
 
141
  def download_file(url: str, save_path: str, api_key: str = None, progress=None, desc: str = "") -> str:
 
 
142
  if os.path.exists(save_path):
143
  return f"File already exists: {os.path.basename(save_path)}"
144
 
 
475
  print(f"Warning: Failed to load or download sd3 ipadapter models: {e}")
476
 
477
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478
 
479
  def get_model_generation_defaults(model_display_name: str, model_type: str, defaults_config: dict):
480
  final_defaults = {
yaml/anima_controlnet_lllite_models.yaml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Anima_ControlNet_Lllite:
2
+ - Filepath: "anima-lllite-lineart-1.safetensors"
3
+ Series: "kohya-ss"
4
+ Type: ["Lineart"]
5
+ - Filepath: "anima-lllite-depth-1.safetensors"
6
+ Series: "kohya-ss"
7
+ Type: ["Depth"]
8
+ - Filepath: "anima-lllite-pose-1.safetensors"
9
+ Series: "kohya-ss"
10
+ Type: ["Pose"]
11
+ - Filepath: "anima-lllite-scribble-1.safetensors"
12
+ Series: "kohya-ss"
13
+ Type: ["Scribble"]
yaml/constants.yaml CHANGED
@@ -95,7 +95,15 @@ RESOLUTION_MAP:
95
  "3:4 (Classic Portrait)": [896, 1152]
96
  "3:2 (Photography)": [1216, 832]
97
  "2:3 (Photography Portrait)": [832, 1216]
98
- hidream:
 
 
 
 
 
 
 
 
99
  "1:1 (Square)": [1024, 1024]
100
  "16:9 (Landscape)": [1344, 768]
101
  "9:16 (Portrait)": [768, 1344]
 
95
  "3:4 (Classic Portrait)": [896, 1152]
96
  "3:2 (Photography)": [1216, 832]
97
  "2:3 (Photography Portrait)": [832, 1216]
98
+ hidream-o1:
99
+ "1:1 (Square)": [1024, 1024]
100
+ "16:9 (Landscape)": [1344, 768]
101
+ "9:16 (Portrait)": [768, 1344]
102
+ "4:3 (Classic)": [1152, 896]
103
+ "3:4 (Classic Portrait)": [896, 1152]
104
+ "3:2 (Photography)": [1216, 832]
105
+ "2:3 (Photography Portrait)": [832, 1216]
106
+ hidream-i1:
107
  "1:1 (Square)": [1024, 1024]
108
  "16:9 (Landscape)": [1344, 768]
109
  "9:16 (Portrait)": [768, 1344]
yaml/file_list.yaml CHANGED
@@ -1,5 +1,14 @@
1
  file:
2
  checkpoints:
 
 
 
 
 
 
 
 
 
3
  # Lumina
4
  - filename: "lumina_2.safetensors"
5
  source: "hf"
@@ -48,17 +57,14 @@ file:
48
  source: hf
49
  repo_id: "bluepen5805/illustrious_pencil-XL"
50
  repository_file_path: "illustrious_pencil-XL-v5.0.0.safetensors"
51
- - filename: "hassakuXLIllustrious_v34.safetensors"
52
  source: hf
53
- repo_id: "oldhag88/hassakuXLIllustrious_v34.safetensors"
54
- repository_file_path: "hassakuXLIllustrious_v34.safetensors"
55
  - filename: "novaAnimeXL_ilV160.safetensors"
56
  source: hf
57
  repo_id: "Yevrey921/novaAnimeXL_ilV160"
58
  repository_file_path: "novaAnimeXL_ilV160.safetensors"
59
- - filename: "Illustrious-XL-v2.0.safetensors"
60
- source: hf
61
- repo_id: "OnomaAIResearch/Illustrious-XL-v2.0"
62
  - filename: "Illustrious-XL-v2.0.safetensors"
63
  source: hf
64
  repo_id: "OnomaAIResearch/Illustrious-XL-v2.0"
@@ -105,10 +111,10 @@ file:
105
  source: hf
106
  repo_id: "bluepen5805/pony_pencil-XL"
107
  repository_file_path: "pony_pencil-XL-v2.0.0.safetensors"
108
- - filename: "CyberRealisticPony_V14.0.safetensors"
109
  source: hf
110
  repo_id: "cyberdelia/CyberRealisticPony"
111
- repository_file_path: "CyberRealisticPony_V14.0.safetensors"
112
  # SDXL-Base
113
  - filename: "sd_xl_base_1.0.safetensors"
114
  source: "hf"
@@ -140,6 +146,23 @@ file:
140
  repo_id: "Comfy-Org/sigclip_vision_384"
141
  repository_file_path: "sigclip_vision_patch14_384.safetensors"
142
  controlnet:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  # SD3.5
144
  - filename: "sd3.5_large_controlnet_blur.safetensors"
145
  source: "hf"
@@ -208,6 +231,116 @@ file:
208
  source: "hf"
209
  repo_id: "xinsir/anime-painter"
210
  repository_file_path: "diffusion_pytorch_model.safetensors"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  # SD1.5
212
  - filename: "control_v11e_sd15_ip2p_fp16.safetensors"
213
  source: "hf"
@@ -270,25 +403,23 @@ file:
270
  repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
271
  repository_file_path: "control_v11u_sd15_tile_fp16.safetensors"
272
  diffusion_models:
273
- # FLUX.2-klein-9B
274
- - filename: "flux-2-klein-9b-fp8.safetensors"
275
- source: "hf"
276
- repo_id: "black-forest-labs/FLUX.2-klein-9b-fp8"
277
- repository_file_path: "flux-2-klein-9b-fp8.safetensors"
278
- # FLUX.2-klein-base-9B
279
- - filename: "flux-2-klein-base-9b-fp8.safetensors"
280
- source: "hf"
281
- repo_id: "black-forest-labs/FLUX.2-klein-base-9b-fp8"
282
- repository_file_path: "flux-2-klein-base-9b-fp8.safetensors"
283
  # Anima
284
- - filename: "anima-preview3-base.safetensors"
 
 
 
 
285
  source: "hf"
286
  repo_id: "circlestone-labs/Anima"
287
- repository_file_path: "split_files/diffusion_models/anima-preview3-base.safetensors"
288
- - filename: "AnimaYume_tuned_v04.safetensors"
289
  source: "hf"
290
  repo_id: "duongve/AnimaYume"
291
- repository_file_path: "split_files/diffusion_models/AnimaYume_tuned_v04.safetensors"
 
 
 
 
292
  # NewBie-Image
293
  - filename: "NewBie-Image-Exp0.1-bf16.safetensors"
294
  source: "hf"
@@ -378,7 +509,7 @@ file:
378
  source: "hf"
379
  repo_id: "Comfy-Org/FLUX.1-Krea-dev_ComfyUI"
380
  repository_file_path: "split_files/diffusion_models/flux1-krea-dev_fp8_scaled.safetensors"
381
- # HiDream
382
  - filename: "hidream_i1_dev_fp8.safetensors"
383
  source: "hf"
384
  repo_id: "Comfy-Org/HiDream-I1_ComfyUI"
@@ -399,10 +530,6 @@ file:
399
  source: "hf"
400
  repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"
401
  repository_file_path: "split_files/diffusion_models/hunyuanimage2.1_distilled_fp8_e4m3fn.safetensors"
402
- - filename: "hunyuanimage2.1_refiner_fp8_e4m3fn.safetensors"
403
- source: "hf"
404
- repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"
405
- repository_file_path: "split_files/diffusion_models/hunyuanimage2.1_refiner_fp8_e4m3fn.safetensors"
406
  # Chroma1-Radiance
407
  - filename: "Chroma1-Radiance-x0-fp8mixed_fullmm-20260104.safetensors"
408
  source: "hf"
 
1
  file:
2
  checkpoints:
3
+ # HiDream-O1
4
+ - filename: "hidream_o1_image_dev_fp8_scaled.safetensors"
5
+ source: "hf"
6
+ repo_id: "Comfy-Org/HiDream-O1-Image"
7
+ repository_file_path: "checkpoints/hidream_o1_image_dev_fp8_scaled.safetensors"
8
+ - filename: "hidream_o1_image_fp8_scaled.safetensors"
9
+ source: "hf"
10
+ repo_id: "Comfy-Org/HiDream-O1-Image"
11
+ repository_file_path: "checkpoints/hidream_o1_image_fp8_scaled.safetensors"
12
  # Lumina
13
  - filename: "lumina_2.safetensors"
14
  source: "hf"
 
57
  source: hf
58
  repo_id: "bluepen5805/illustrious_pencil-XL"
59
  repository_file_path: "illustrious_pencil-XL-v5.0.0.safetensors"
60
+ - filename: "hassakuXLIllustrious_v30.safetensors"
61
  source: hf
62
+ repo_id: "misri/hassakuXLIllustrious_v30"
63
+ repository_file_path: "hassakuXLIllustrious_v30.safetensors"
64
  - filename: "novaAnimeXL_ilV160.safetensors"
65
  source: hf
66
  repo_id: "Yevrey921/novaAnimeXL_ilV160"
67
  repository_file_path: "novaAnimeXL_ilV160.safetensors"
 
 
 
68
  - filename: "Illustrious-XL-v2.0.safetensors"
69
  source: hf
70
  repo_id: "OnomaAIResearch/Illustrious-XL-v2.0"
 
111
  source: hf
112
  repo_id: "bluepen5805/pony_pencil-XL"
113
  repository_file_path: "pony_pencil-XL-v2.0.0.safetensors"
114
+ - filename: "CyberRealisticPony_V17.0_FP16.safetensors"
115
  source: hf
116
  repo_id: "cyberdelia/CyberRealisticPony"
117
+ repository_file_path: "CyberRealisticPony_V17.0_FP16.safetensors"
118
  # SDXL-Base
119
  - filename: "sd_xl_base_1.0.safetensors"
120
  source: "hf"
 
146
  repo_id: "Comfy-Org/sigclip_vision_384"
147
  repository_file_path: "sigclip_vision_patch14_384.safetensors"
148
  controlnet:
149
+ # Anima
150
+ - filename: "anima-lllite-lineart-1.safetensors"
151
+ source: "hf"
152
+ repo_id: "kohya-ss/Anima-LLLite"
153
+ repository_file_path: "anima-lllite-lineart-1.safetensors"
154
+ - filename: "anima-lllite-depth-1.safetensors"
155
+ source: "hf"
156
+ repo_id: "kohya-ss/Anima-LLLite"
157
+ repository_file_path: "anima-lllite-depth-1.safetensors"
158
+ - filename: "anima-lllite-pose-1.safetensors"
159
+ source: "hf"
160
+ repo_id: "kohya-ss/Anima-LLLite"
161
+ repository_file_path: "anima-lllite-pose-1.safetensors"
162
+ - filename: "anima-lllite-scribble-1.safetensors"
163
+ source: "hf"
164
+ repo_id: "kohya-ss/Anima-LLLite"
165
+ repository_file_path: "anima-lllite-scribble-1.safetensors"
166
  # SD3.5
167
  - filename: "sd3.5_large_controlnet_blur.safetensors"
168
  source: "hf"
 
231
  source: "hf"
232
  repo_id: "xinsir/anime-painter"
233
  repository_file_path: "diffusion_pytorch_model.safetensors"
234
+ # SDXL - NoobAI
235
+ - filename: "noob_sdxl_controlnet_canny.fp16.safetensors"
236
+ source: "hf"
237
+ repo_id: "Eugeoter/noob-sdxl-controlnet-canny"
238
+ repository_file_path: "noob_sdxl_controlnet_canny.fp16.safetensors"
239
+ - filename: "noob_sdxl_controlnet_depth.fp16.safetensors"
240
+ source: "hf"
241
+ repo_id: "Eugeoter/noob-sdxl-controlnet-depth"
242
+ repository_file_path: "diffusion_pytorch_model.fp16.safetensors"
243
+ - filename: "noob-sdxl-controlnet-lineart_anime.fp16.safetensors"
244
+ source: "hf"
245
+ repo_id: "Eugeoter/noob-sdxl-controlnet-lineart_anime"
246
+ repository_file_path: "diffusion_pytorch_model.fp16.safetensors"
247
+ - filename: "noob-sdxl-controlnet-lineart_realistic.fp16.safetensors"
248
+ source: "hf"
249
+ repo_id: "Eugeoter/noob-sdxl-controlnet-lineart_realistic"
250
+ repository_file_path: "diffusion_pytorch_model.fp16.safetensors"
251
+ - filename: "noob-sdxl-controlnet-manga_line.fp16.safetensors"
252
+ source: "hf"
253
+ repo_id: "Eugeoter/noob-sdxl-controlnet-manga_line"
254
+ repository_file_path: "diffusion_pytorch_model.fp16.safetensors"
255
+ - filename: "noob-sdxl-controlnet-normal.fp16.safetensors"
256
+ source: "hf"
257
+ repo_id: "Eugeoter/noob-sdxl-controlnet-normal"
258
+ repository_file_path: "diffusion_pytorch_model.fp16.safetensors"
259
+ - filename: "noob-sdxl-controlnet-softedge_hed.fp16.safetensors"
260
+ source: "hf"
261
+ repo_id: "Eugeoter/noob-sdxl-controlnet-softedge_hed"
262
+ repository_file_path: "diffusion_pytorch_model.fp16.safetensors"
263
+ - filename: "noob-sdxl-controlnet-tile.fp16.safetensors"
264
+ source: "hf"
265
+ repo_id: "Eugeoter/noob-sdxl-controlnet-tile"
266
+ repository_file_path: "diffusion_pytorch_model.fp16.safetensors"
267
+ - filename: "NoobAI_Inpainting_ControlNet.safetensors"
268
+ source: "hf"
269
+ repo_id: "Wenaka/NoobAI_XL_Inpainting_ControlNet_Full"
270
+ repository_file_path: "NoobAI_Inpainting_ControlNet.safetensors"
271
+ - filename: "noob_openpose_pre.safetensors"
272
+ source: "hf"
273
+ repo_id: "Laxhar/noob_openpose"
274
+ repository_file_path: "openpose_pre.safetensors"
275
+ - filename: "noobaiXLControlnet_epsBlur.safetensors"
276
+ source: "civitai"
277
+ model_version_id: "1731092"
278
+ - filename: "noobaiXLControlnet_epsDepthMidasV11.safetensors"
279
+ source: "hf"
280
+ repo_id: "licyk/sd_control_collection"
281
+ repository_file_path: "noobaiXLControlnet_epsDepthMidasV11.safetensors"
282
+ - filename: "noobaiXLControlnet_epsNormalMidas.safetensors"
283
+ source: "hf"
284
+ repo_id: "licyk/sd_control_collection"
285
+ repository_file_path: "noobaiXLControlnet_epsNormalMidas.safetensors"
286
+ - filename: "noobaiXLControlnet_epsScribbleHed.safetensors"
287
+ source: "hf"
288
+ repo_id: "licyk/sd_control_collection"
289
+ repository_file_path: "noobaiXLControlnet_epsScribbleHed.safetensors"
290
+ - filename: "noobaiXLControlnet_epsScribblePidinet.safetensors"
291
+ source: "hf"
292
+ repo_id: "licyk/sd_control_collection"
293
+ repository_file_path: "noobaiXLControlnet_epsScribblePidinet.safetensors"
294
+ - filename: "noobaiXLControlnet_epsDepthMidas.safetensors"
295
+ source: "hf"
296
+ repo_id: "licyk/sd_control_collection"
297
+ repository_file_path: "noobaiXLControlnet_epsDepthMidas.safetensors"
298
+ - filename: "noobaiXLControlnet_openposeModel.safetensors"
299
+ source: "hf"
300
+ repo_id: "licyk/sd_control_collection"
301
+ repository_file_path: "noobaiXLControlnet_openposeModel.safetensors"
302
+ # SDXL - Illustrious-XL-v0.1
303
+ - filename: "illustriousXLv0.1_Canny_fp16.safetensors"
304
+ source: "hf"
305
+ repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"
306
+ repository_file_path: "illustriousXLv0.1_Canny_fp16.safetensors"
307
+ - filename: "illustriousXLv0.1_Lineart_fp16.safetensors"
308
+ source: "hf"
309
+ repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"
310
+ repository_file_path: "illustriousXLv0.1_Lineart_fp16.safetensors"
311
+ - filename: "illustriousXLv0.1_Softedge_fp16.safetensors"
312
+ source: "hf"
313
+ repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"
314
+ repository_file_path: "illustriousXLv0.1_Softedge_fp16.safetensors"
315
+ - filename: "illustriousXLv0.1_Tile_fp16.safetensors"
316
+ source: "hf"
317
+ repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"
318
+ repository_file_path: "illustriousXLv0.1_Tile_fp16.safetensors"
319
+ - filename: "illustriousXLv0.1_depth_midas_fp16.safetensors"
320
+ source: "hf"
321
+ repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"
322
+ repository_file_path: "illustriousXLv0.1_depth_midas_fp16.safetensors"
323
+ - filename: "illustriousXLv0.1_inpainting_fp16.safetensors"
324
+ source: "hf"
325
+ repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"
326
+ repository_file_path: "illustriousXLv0.1_inpainting_fp16.safetensors"
327
+ # SDXL - Illustrious-XL-v1.1
328
+ - filename: "illustriousXLv1.1_canny_fp16.safetensors"
329
+ source: "hf"
330
+ repo_id: "MIC-Lab/illustriousXLv1.1_controlnet"
331
+ repository_file_path: "illustriousXLv1.1_canny_fp16.safetensors"
332
+ - filename: "illustriousXLv1.1_depth_midas_fp16.safetensors"
333
+ source: "hf"
334
+ repo_id: "MIC-Lab/illustriousXLv1.1_controlnet"
335
+ repository_file_path: "illustriousXLv1.1_depth_midas_fp16.safetensors"
336
+ - filename: "illustriousXLv1.1_inpainting_fp16.safetensors"
337
+ source: "hf"
338
+ repo_id: "MIC-Lab/illustriousXLv1.1_controlnet"
339
+ repository_file_path: "illustriousXLv1.1_inpainting_fp16.safetensors"
340
+ - filename: "illustriousXLv1.1_tile_fp16.safetensors"
341
+ source: "hf"
342
+ repo_id: "MIC-Lab/illustriousXLv1.1_controlnet"
343
+ repository_file_path: "illustriousXLv1.1_tile_fp16.safetensors"
344
  # SD1.5
345
  - filename: "control_v11e_sd15_ip2p_fp16.safetensors"
346
  source: "hf"
 
403
  repo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"
404
  repository_file_path: "control_v11u_sd15_tile_fp16.safetensors"
405
  diffusion_models:
 
 
 
 
 
 
 
 
 
 
406
  # Anima
407
+ - filename: "waiANIMA_v10.safetensors"
408
+ source: "hf"
409
+ repo_id: "diffusionmodels1254ani/waiANIMA"
410
+ repository_file_path: "waiANIMA_v10.safetensors"
411
+ - filename: "anima-base-v1.0.safetensors"
412
  source: "hf"
413
  repo_id: "circlestone-labs/Anima"
414
+ repository_file_path: "split_files/diffusion_models/anima-base-v1.0.safetensors"
415
+ - filename: "AnimaYume_tuned_v05.safetensors"
416
  source: "hf"
417
  repo_id: "duongve/AnimaYume"
418
+ repository_file_path: "split_files/diffusion_models/AnimaYume_tuned_v05.safetensors"
419
+ - filename: "anima_pencil-v1.0.0.safetensors"
420
+ source: "hf"
421
+ repo_id: "bluepen5805/anima-models"
422
+ repository_file_path: "anima_pencil-v1.0.0.safetensors"
423
  # NewBie-Image
424
  - filename: "NewBie-Image-Exp0.1-bf16.safetensors"
425
  source: "hf"
 
509
  source: "hf"
510
  repo_id: "Comfy-Org/FLUX.1-Krea-dev_ComfyUI"
511
  repository_file_path: "split_files/diffusion_models/flux1-krea-dev_fp8_scaled.safetensors"
512
+ # HiDream-I1
513
  - filename: "hidream_i1_dev_fp8.safetensors"
514
  source: "hf"
515
  repo_id: "Comfy-Org/HiDream-I1_ComfyUI"
 
530
  source: "hf"
531
  repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"
532
  repository_file_path: "split_files/diffusion_models/hunyuanimage2.1_distilled_fp8_e4m3fn.safetensors"
 
 
 
 
533
  # Chroma1-Radiance
534
  - filename: "Chroma1-Radiance-x0-fp8mixed_fullmm-20260104.safetensors"
535
  source: "hf"
yaml/image_gen_features.yaml CHANGED
@@ -44,6 +44,7 @@ longcat-image:
44
  anima:
45
  enabled_chains:
46
  - lora
 
47
  - conditioning
48
 
49
  newbie-image:
@@ -99,10 +100,16 @@ flux1:
99
  - conditioning
100
  - flux1_ipadapter
101
 
102
- hidream:
103
  enabled_chains:
104
- - lora
105
- - conditioning
 
 
 
 
 
 
106
 
107
  chroma1:
108
  enabled_chains:
 
44
  anima:
45
  enabled_chains:
46
  - lora
47
+ - anima_controlnet_lllite
48
  - conditioning
49
 
50
  newbie-image:
 
100
  - conditioning
101
  - flux1_ipadapter
102
 
103
+ hidream-o1:
104
  enabled_chains:
105
+ - lora
106
+ - conditioning
107
+ - hidream_o1_reference
108
+
109
+ hidream-i1:
110
+ enabled_chains:
111
+ - lora
112
+ - conditioning
113
 
114
  chroma1:
115
  enabled_chains:
yaml/injectors.yaml CHANGED
@@ -7,6 +7,8 @@ injector_definitions:
7
  module: "chain_injectors.newbie_lora_injector"
8
  dynamic_controlnet_chains:
9
  module: "chain_injectors.controlnet_injector"
 
 
10
  dynamic_diffsynth_controlnet_chains:
11
  module: "chain_injectors.diffsynth_controlnet_injector"
12
  dynamic_ipadapter_chains:
@@ -15,12 +17,16 @@ injector_definitions:
15
  module: "chain_injectors.flux1_ipadapter_injector"
16
  dynamic_sd3_ipadapter_chains:
17
  module: "chain_injectors.sd3_ipadapter_injector"
18
- dynamic_style_chains:
19
- module: "chain_injectors.style_injector"
20
- dynamic_conditioning_chains:
21
- module: "chain_injectors.conditioning_injector"
22
  dynamic_reference_latent_chains:
23
  module: "chain_injectors.reference_latent_injector"
 
 
 
 
 
 
 
 
24
 
25
  injector_order:
26
  - dynamic_vae_chains
@@ -30,7 +36,10 @@ injector_order:
30
  - dynamic_ipadapter_chains
31
  - dynamic_flux1_ipadapter_chains
32
  - dynamic_sd3_ipadapter_chains
33
- - dynamic_style_chains
34
- - dynamic_conditioning_chains
35
  - dynamic_reference_latent_chains
36
- - dynamic_controlnet_chains
 
 
 
 
 
 
7
  module: "chain_injectors.newbie_lora_injector"
8
  dynamic_controlnet_chains:
9
  module: "chain_injectors.controlnet_injector"
10
+ dynamic_anima_controlnet_lllite_chains:
11
+ module: "chain_injectors.anima_controlnet_lllite_injector"
12
  dynamic_diffsynth_controlnet_chains:
13
  module: "chain_injectors.diffsynth_controlnet_injector"
14
  dynamic_ipadapter_chains:
 
17
  module: "chain_injectors.flux1_ipadapter_injector"
18
  dynamic_sd3_ipadapter_chains:
19
  module: "chain_injectors.sd3_ipadapter_injector"
 
 
 
 
20
  dynamic_reference_latent_chains:
21
  module: "chain_injectors.reference_latent_injector"
22
+ dynamic_conditioning_chains:
23
+ module: "chain_injectors.conditioning_injector"
24
+ dynamic_style_chains:
25
+ module: "chain_injectors.style_injector"
26
+ dynamic_hidream_o1_smoothing_chains:
27
+ module: "chain_injectors.hidream_o1_smoothing_injector"
28
+ dynamic_hidream_o1_reference_chains:
29
+ module: "chain_injectors.hidream_o1_reference_injector"
30
 
31
  injector_order:
32
  - dynamic_vae_chains
 
36
  - dynamic_ipadapter_chains
37
  - dynamic_flux1_ipadapter_chains
38
  - dynamic_sd3_ipadapter_chains
 
 
39
  - dynamic_reference_latent_chains
40
+ - dynamic_conditioning_chains
41
+ - dynamic_style_chains
42
+ - dynamic_controlnet_chains
43
+ - dynamic_anima_controlnet_lllite_chains
44
+ - dynamic_hidream_o1_smoothing_chains
45
+ - dynamic_hidream_o1_reference_chains
yaml/model_architectures.yaml CHANGED
@@ -13,7 +13,8 @@ architecture_order:
13
  - "Chroma1"
14
  - "OmniGen2"
15
  - "Lumina"
16
- - "HiDream"
 
17
  - "FLUX.1"
18
  - "SD3.5"
19
  - "SDXL"
@@ -71,9 +72,12 @@ architectures:
71
  "SD3.5":
72
  model_type: "sd35"
73
  controlnet_key: "SD3.5"
74
- "HiDream":
75
- model_type: "hidream"
76
- controlnet_key: "HiDream"
 
 
 
77
  "SD1.5":
78
  model_type: "sd15"
79
  controlnet_key: "SD1.5"
 
13
  - "Chroma1"
14
  - "OmniGen2"
15
  - "Lumina"
16
+ - "HiDream-O1"
17
+ - "HiDream-I1"
18
  - "FLUX.1"
19
  - "SD3.5"
20
  - "SDXL"
 
72
  "SD3.5":
73
  model_type: "sd35"
74
  controlnet_key: "SD3.5"
75
+ "HiDream-O1":
76
+ model_type: "hidream-o1"
77
+ controlnet_key: "HiDream-O1"
78
+ "HiDream-I1":
79
+ model_type: "hidream-i1"
80
+ controlnet_key: "HiDream-I1"
81
  "SD1.5":
82
  model_type: "sd15"
83
  controlnet_key: "SD1.5"
yaml/model_defaults.yaml CHANGED
@@ -3,7 +3,6 @@ Default:
3
  cfg: 7.0
4
  sampler_name: "euler"
5
  scheduler: "simple"
6
- total_pixels: 1048576
7
  positive_prompt: ""
8
  negative_prompt: ""
9
 
@@ -13,13 +12,11 @@ ERNIE-Image:
13
  cfg: 4.0
14
  sampler_name: "euler"
15
  scheduler: "simple"
16
- total_pixels: 1048576
17
  "baidu/ERNIE-Image-Turbo":
18
  steps: 8
19
  cfg: 1.0
20
  sampler_name: "euler"
21
  scheduler: "simple"
22
- total_pixels: 1048576
23
 
24
  FLUX.2:
25
  _defaults:
@@ -27,7 +24,6 @@ FLUX.2:
27
  cfg: 4.0
28
  sampler_name: "euler"
29
  scheduler: "simple"
30
- total_pixels: 1048576
31
  "black-forest-labs/FLUX.2-klein-4B":
32
  steps: 4
33
  cfg: 1.0
@@ -41,7 +37,6 @@ FLUX.2-KV:
41
  cfg: 4.0
42
  sampler_name: "euler"
43
  scheduler: "simple"
44
- total_pixels: 1048576
45
  "black-forest-labs/FLUX.2-klein-9B-KV":
46
  steps: 4
47
  cfg: 1.0
@@ -52,13 +47,11 @@ Z-Image:
52
  cfg: 4.0
53
  sampler_name: "euler"
54
  scheduler: "simple"
55
- total_pixels: 1048576
56
  "Tongyi-MAI/Z Image Turbo":
57
  steps: 9
58
  cfg: 1.0
59
  sampler_name: "euler"
60
  scheduler: "simple"
61
- total_pixels: 1048576
62
 
63
  Qwen-Image:
64
  _defaults:
@@ -66,7 +59,6 @@ Qwen-Image:
66
  cfg: 1.0
67
  sampler_name: "euler"
68
  scheduler: "simple"
69
- total_pixels: 1763584
70
 
71
  LongCat-Image:
72
  _defaults:
@@ -75,7 +67,6 @@ LongCat-Image:
75
  guidance: 4.0
76
  sampler_name: "euler"
77
  scheduler: "simple"
78
- total_pixels: 1048576
79
 
80
  Anima:
81
  _defaults:
@@ -83,7 +74,6 @@ Anima:
83
  cfg: 4.0
84
  sampler_name: "er_sde"
85
  scheduler: "simple"
86
- total_pixels: 1048576
87
  positive_prompt: "masterpiece, best quality, score_7, safe. "
88
  negative_prompt: "worst quality, low quality, score_1, score_2, score_3, blurry, jpeg artifacts, sepia"
89
 
@@ -102,7 +92,6 @@ Ovis-Image:
102
  cfg: 5.0
103
  sampler_name: "euler"
104
  scheduler: "simple"
105
- total_pixels: 1048576
106
 
107
  OmniGen2:
108
  _defaults:
@@ -110,7 +99,6 @@ OmniGen2:
110
  cfg: 5.0
111
  sampler_name: "euler"
112
  scheduler: "simple"
113
- total_pixels: 1048576
114
  positive_prompt: ""
115
  negative_prompt: ""
116
 
@@ -120,7 +108,6 @@ Chroma1:
120
  cfg: 4.0
121
  sampler_name: "euler"
122
  scheduler: "simple"
123
- total_pixels: 1048576
124
  negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs"
125
  "lodestones/Chroma1-HD-Flash":
126
  steps: 8
@@ -133,7 +120,6 @@ Chroma1-Radiance:
133
  cfg: 4.0
134
  sampler_name: "euler"
135
  scheduler: "simple"
136
- total_pixels: 1048576
137
  negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs, hands, fingers"
138
 
139
  SD3.5:
@@ -142,7 +128,6 @@ SD3.5:
142
  cfg: 4.0
143
  sampler_name: "euler"
144
  scheduler: "sgm_uniform"
145
- total_pixels: 1048576
146
 
147
  SDXL:
148
  _defaults:
@@ -150,7 +135,6 @@ SDXL:
150
  cfg: 7.0
151
  sampler_name: "euler"
152
  scheduler: "simple"
153
- total_pixels: 1048576
154
  positive_prompt: ""
155
  negative_prompt: ""
156
 
@@ -160,7 +144,6 @@ SD1.5:
160
  cfg: 7.0
161
  sampler_name: "euler_ancestral"
162
  scheduler: "simple"
163
- total_pixels: 393216
164
 
165
  FLUX.1:
166
  _defaults:
@@ -168,20 +151,30 @@ FLUX.1:
168
  cfg: 1.0
169
  sampler_name: "euler"
170
  scheduler: "simple"
171
- total_pixels: 1048576
172
  "flux1-schnell":
173
  steps: 4
174
  cfg: 1.0
175
  sampler_name: "euler"
176
  scheduler: "simple"
177
 
178
- HiDream:
 
 
 
 
 
 
 
 
 
 
 
 
179
  _defaults:
180
  steps: 50
181
  cfg: 3.0
182
  sampler_name: "uni_pc"
183
  scheduler: "simple"
184
- total_pixels: 1048576
185
  negative_prompt: "bad ugly jpeg artifacts"
186
  "HiDream_i1_Dev":
187
  steps: 28
@@ -200,7 +193,6 @@ HunyuanImage:
200
  cfg: 3.5
201
  sampler_name: "euler"
202
  scheduler: "simple"
203
- total_pixels: 4194304
204
  "HunyuanImage-2.1-Distilled":
205
  steps: 8
206
  cfg: 1.0
 
3
  cfg: 7.0
4
  sampler_name: "euler"
5
  scheduler: "simple"
 
6
  positive_prompt: ""
7
  negative_prompt: ""
8
 
 
12
  cfg: 4.0
13
  sampler_name: "euler"
14
  scheduler: "simple"
 
15
  "baidu/ERNIE-Image-Turbo":
16
  steps: 8
17
  cfg: 1.0
18
  sampler_name: "euler"
19
  scheduler: "simple"
 
20
 
21
  FLUX.2:
22
  _defaults:
 
24
  cfg: 4.0
25
  sampler_name: "euler"
26
  scheduler: "simple"
 
27
  "black-forest-labs/FLUX.2-klein-4B":
28
  steps: 4
29
  cfg: 1.0
 
37
  cfg: 4.0
38
  sampler_name: "euler"
39
  scheduler: "simple"
 
40
  "black-forest-labs/FLUX.2-klein-9B-KV":
41
  steps: 4
42
  cfg: 1.0
 
47
  cfg: 4.0
48
  sampler_name: "euler"
49
  scheduler: "simple"
 
50
  "Tongyi-MAI/Z Image Turbo":
51
  steps: 9
52
  cfg: 1.0
53
  sampler_name: "euler"
54
  scheduler: "simple"
 
55
 
56
  Qwen-Image:
57
  _defaults:
 
59
  cfg: 1.0
60
  sampler_name: "euler"
61
  scheduler: "simple"
 
62
 
63
  LongCat-Image:
64
  _defaults:
 
67
  guidance: 4.0
68
  sampler_name: "euler"
69
  scheduler: "simple"
 
70
 
71
  Anima:
72
  _defaults:
 
74
  cfg: 4.0
75
  sampler_name: "er_sde"
76
  scheduler: "simple"
 
77
  positive_prompt: "masterpiece, best quality, score_7, safe. "
78
  negative_prompt: "worst quality, low quality, score_1, score_2, score_3, blurry, jpeg artifacts, sepia"
79
 
 
92
  cfg: 5.0
93
  sampler_name: "euler"
94
  scheduler: "simple"
 
95
 
96
  OmniGen2:
97
  _defaults:
 
99
  cfg: 5.0
100
  sampler_name: "euler"
101
  scheduler: "simple"
 
102
  positive_prompt: ""
103
  negative_prompt: ""
104
 
 
108
  cfg: 4.0
109
  sampler_name: "euler"
110
  scheduler: "simple"
 
111
  negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs"
112
  "lodestones/Chroma1-HD-Flash":
113
  steps: 8
 
120
  cfg: 4.0
121
  sampler_name: "euler"
122
  scheduler: "simple"
 
123
  negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs, hands, fingers"
124
 
125
  SD3.5:
 
128
  cfg: 4.0
129
  sampler_name: "euler"
130
  scheduler: "sgm_uniform"
 
131
 
132
  SDXL:
133
  _defaults:
 
135
  cfg: 7.0
136
  sampler_name: "euler"
137
  scheduler: "simple"
 
138
  positive_prompt: ""
139
  negative_prompt: ""
140
 
 
144
  cfg: 7.0
145
  sampler_name: "euler_ancestral"
146
  scheduler: "simple"
 
147
 
148
  FLUX.1:
149
  _defaults:
 
151
  cfg: 1.0
152
  sampler_name: "euler"
153
  scheduler: "simple"
 
154
  "flux1-schnell":
155
  steps: 4
156
  cfg: 1.0
157
  sampler_name: "euler"
158
  scheduler: "simple"
159
 
160
+ HiDream-O1:
161
+ _defaults:
162
+ steps: 40
163
+ cfg: 5.0
164
+ sampler_name: "dpmpp_2m_sde_gpu"
165
+ scheduler: "normal"
166
+ "HiDream-O1-Image-Dev":
167
+ steps: 28
168
+ cfg: 1.0
169
+ sampler_name: "lcm"
170
+ scheduler: "normal"
171
+
172
+ HiDream-I1:
173
  _defaults:
174
  steps: 50
175
  cfg: 3.0
176
  sampler_name: "uni_pc"
177
  scheduler: "simple"
 
178
  negative_prompt: "bad ugly jpeg artifacts"
179
  "HiDream_i1_Dev":
180
  steps: 28
 
193
  cfg: 3.5
194
  sampler_name: "euler"
195
  scheduler: "simple"
 
196
  "HunyuanImage-2.1-Distilled":
197
  steps: 8
198
  cfg: 1.0
yaml/model_list.yaml CHANGED
@@ -6,4 +6,314 @@ Checkpoint:
6
  components:
7
  unet: "flux-2-klein-9b-kv-fp8.safetensors"
8
  clip: "qwen_3_8b_fp8mixed.safetensors"
9
- vae: "flux2-vae.safetensors"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  components:
7
  unet: "flux-2-klein-9b-kv-fp8.safetensors"
8
  clip: "qwen_3_8b_fp8mixed.safetensors"
9
+ vae: "flux2-vae.safetensors"
10
+ FLUX.2:
11
+ latent_type: flux2_latent
12
+ models:
13
+ - display_name: "black-forest-labs/FLUX.2-klein-4B"
14
+ components:
15
+ unet: "flux-2-klein-4b-fp8.safetensors"
16
+ clip: "qwen_3_4b.safetensors"
17
+ vae: "flux2-vae.safetensors"
18
+ - display_name: "black-forest-labs/FLUX.2-klein-9B"
19
+ components:
20
+ unet: "flux-2-klein-9b-fp8.safetensors"
21
+ clip: "qwen_3_8b_fp8mixed.safetensors"
22
+ vae: "flux2-vae.safetensors"
23
+ - display_name: "black-forest-labs/FLUX.2-klein-base-4B"
24
+ components:
25
+ unet: "flux-2-klein-base-4b-fp8.safetensors"
26
+ clip: "qwen_3_4b.safetensors"
27
+ vae: "flux2-vae.safetensors"
28
+ - display_name: "black-forest-labs/FLUX.2-klein-base-9B"
29
+ components:
30
+ unet: "flux-2-klein-base-9b-fp8.safetensors"
31
+ clip: "qwen_3_8b_fp8mixed.safetensors"
32
+ vae: "flux2-vae.safetensors"
33
+ - display_name: "black-forest-labs/FLUX.2-dev (Need to set ZeroGPU Duration to 120)"
34
+ components:
35
+ unet: "flux2_dev_fp8mixed.safetensors"
36
+ clip: "mistral_3_small_flux2_fp8.safetensors"
37
+ vae: "flux2-vae.safetensors"
38
+ ERNIE-Image:
39
+ latent_type: flux2_latent
40
+ models:
41
+ - display_name: "baidu/ERNIE-Image"
42
+ components:
43
+ unet: "ernie-image.safetensors"
44
+ vae: "flux2-vae.safetensors"
45
+ clip: "ministral-3-3b.safetensors"
46
+ - display_name: "baidu/ERNIE-Image-Turbo"
47
+ components:
48
+ unet: "ernie-image-turbo.safetensors"
49
+ vae: "flux2-vae.safetensors"
50
+ clip: "ministral-3-3b.safetensors"
51
+ Z-Image:
52
+ latent_type: sd3_latent
53
+ models:
54
+ - display_name: "Tongyi-MAI/Z Image Turbo"
55
+ components:
56
+ unet: "z_image_turbo_bf16.safetensors"
57
+ vae: "ae.safetensors"
58
+ clip: "qwen_3_4b_fp8_mixed.safetensors"
59
+ - display_name: "Tongyi-MAI/Z Image"
60
+ components:
61
+ unet: "z_image_bf16.safetensors"
62
+ vae: "ae.safetensors"
63
+ clip: "qwen_3_4b_fp8_mixed.safetensors"
64
+ Qwen-Image:
65
+ latent_type: sd3_latent
66
+ models:
67
+ - display_name: "Qwen/Qwen-Image-2512 + Lightning-4steps-V1.0 LoRA"
68
+ components:
69
+ unet: "qwen_image_2512_fp8_e4m3fn.safetensors"
70
+ vae: "qwen_image_vae.safetensors"
71
+ clip: "qwen_2.5_vl_7b_fp8_scaled.safetensors"
72
+ lora: "Qwen-Image-2512-Lightning-4steps-V1.0-bf16.safetensors"
73
+ - display_name: "Qwen/Qwen-Image + Lightning-4steps-V1.0 LoRA"
74
+ components:
75
+ unet: "qwen_image_fp8_e4m3fn.safetensors"
76
+ vae: "qwen_image_vae.safetensors"
77
+ clip: "qwen_2.5_vl_7b_fp8_scaled.safetensors"
78
+ lora: "Qwen-Image-fp8-e4m3fn-Lightning-4steps-V1.0-bf16.safetensors"
79
+ LongCat-Image:
80
+ latent_type: sd3_latent
81
+ models:
82
+ - display_name: "meituan-longcat/LongCat-Image"
83
+ components:
84
+ unet: "longcat_image_bf16.safetensors"
85
+ vae: "ae.safetensors"
86
+ clip: "qwen_2.5_vl_7b_fp8_scaled.safetensors"
87
+ Anima:
88
+ latent_type: latent
89
+ models:
90
+ - display_name: "WAI0731/waiANIMA-v1.0"
91
+ components:
92
+ unet: "waiANIMA_v10.safetensors"
93
+ vae: "qwen_image_vae.safetensors"
94
+ clip: "qwen_3_06b_base.safetensors"
95
+ - display_name: "duongve/AnimaYume-v0.5"
96
+ components:
97
+ unet: "AnimaYume_tuned_v05.safetensors"
98
+ vae: "qwen_image_vae.safetensors"
99
+ clip: "qwen_3_06b_base.safetensors"
100
+ - display_name: "bluepen5805/Anima-pencil-v1.0"
101
+ components:
102
+ unet: "anima_pencil-v1.0.0.safetensors"
103
+ vae: "qwen_image_vae.safetensors"
104
+ clip: "qwen_3_06b_base.safetensors"
105
+ - display_name: "circlestone-labs/Anima-base-v1.0"
106
+ components:
107
+ unet: "anima-base-v1.0.safetensors"
108
+ vae: "qwen_image_vae.safetensors"
109
+ clip: "qwen_3_06b_base.safetensors"
110
+ NewBie-Image:
111
+ latent_type: sd3_latent
112
+ models:
113
+ - display_name: "NewBie-AI/NewBie-image-Exp0.1"
114
+ components:
115
+ unet: "NewBie-Image-Exp0.1-bf16.safetensors"
116
+ vae: "ae.safetensors"
117
+ clip1: "gemma_3_4b_it_bf16.safetensors"
118
+ clip2: "jina_clip_v2_bf16.safetensors"
119
+ Ovis-Image:
120
+ latent_type: sd3_latent
121
+ models:
122
+ - display_name: "AIDC-AI/Ovis-Image"
123
+ components:
124
+ unet: "ovis_image_bf16.safetensors"
125
+ vae: "ae.safetensors"
126
+ clip: "ovis_2.5.safetensors"
127
+ HunyuanImage:
128
+ latent_type: hunyuan_latent
129
+ models:
130
+ - display_name: "HunyuanImage-2.1"
131
+ components:
132
+ unet: "hunyuanimage2.1_fp8_e4m3fn.safetensors"
133
+ vae: "hunyuan_image_2.1_vae_fp16.safetensors"
134
+ clip1: "qwen_2.5_vl_7b_fp8_scaled.safetensors"
135
+ clip2: "byt5_small_glyphxl_fp16.safetensors"
136
+ - display_name: "HunyuanImage-2.1-Distilled"
137
+ components:
138
+ unet: "hunyuanimage2.1_distilled_fp8_e4m3fn.safetensors"
139
+ vae: "hunyuan_image_2.1_vae_fp16.safetensors"
140
+ clip1: "qwen_2.5_vl_7b_fp8_scaled.safetensors"
141
+ clip2: "byt5_small_glyphxl_fp16.safetensors"
142
+ Chroma1-Radiance:
143
+ latent_type: chroma_radiance_latent
144
+ models:
145
+ - display_name: "lodestones/Chroma1-Radiance-x0"
146
+ components:
147
+ unet: "Chroma1-Radiance-x0-fp8mixed_fullmm-20260104.safetensors"
148
+ vae: "pixel_space"
149
+ clip: "t5xxl_fp8_e4m3fn_scaled.safetensors"
150
+ Chroma1:
151
+ latent_type: sd3_latent
152
+ models:
153
+ - display_name: "lodestones/Chroma1-HD"
154
+ components:
155
+ unet: "Chroma1-HD_float8_e4m3fn_scaled_learned_topk8_svd.safetensors"
156
+ vae: "ae.safetensors"
157
+ clip: "t5xxl_fp8_e4m3fn_scaled.safetensors"
158
+ - display_name: "lodestones/Chroma1-HD-Flash"
159
+ components:
160
+ unet: "Chroma1-HD-Flash_float8_e4m3fn_scaled_learned_topk8_svd.safetensors"
161
+ vae: "ae.safetensors"
162
+ clip: "t5xxl_fp8_e4m3fn_scaled.safetensors"
163
+ OmniGen2:
164
+ latent_type: sd3_latent
165
+ models:
166
+ - display_name: "OmniGen2"
167
+ components:
168
+ unet: "omnigen2_fp16.safetensors"
169
+ vae: "ae.safetensors"
170
+ clip: "qwen_2.5_vl_fp16.safetensors"
171
+ Lumina:
172
+ latent_type: sd3_latent
173
+ models:
174
+ - display_name: "Alpha-VLLM/Lumina-Image-2.0"
175
+ path: "lumina_2.safetensors"
176
+ HiDream-O1:
177
+ latent_type: hidream_o1_latent
178
+ models:
179
+ - display_name: "HiDream-O1-Image-Dev"
180
+ path: "hidream_o1_image_dev_fp8_scaled.safetensors"
181
+ - display_name: "HiDream-O1-Image"
182
+ path: "hidream_o1_image_fp8_scaled.safetensors"
183
+ HiDream-I1:
184
+ latent_type: sd3_latent
185
+ models:
186
+ - display_name: "HiDream_i1_Dev"
187
+ components:
188
+ unet: "hidream_i1_dev_fp8.safetensors"
189
+ vae: "ae.safetensors"
190
+ clip1: "clip_l_hidream.safetensors"
191
+ clip2: "clip_g_hidream.safetensors"
192
+ clip3: "t5xxl_fp8_e4m3fn_scaled.safetensors"
193
+ clip4: "llama_3.1_8b_instruct_fp8_scaled.safetensors"
194
+ - display_name: "HiDream_i1_Full"
195
+ components:
196
+ unet: "hidream_i1_full_fp8.safetensors"
197
+ vae: "ae.safetensors"
198
+ clip1: "clip_l_hidream.safetensors"
199
+ clip2: "clip_g_hidream.safetensors"
200
+ clip3: "t5xxl_fp8_e4m3fn_scaled.safetensors"
201
+ clip4: "llama_3.1_8b_instruct_fp8_scaled.safetensors"
202
+ - display_name: "HiDream_i1_Fast"
203
+ components:
204
+ unet: "hidream_i1_fast_fp8.safetensors"
205
+ vae: "ae.safetensors"
206
+ clip1: "clip_l_hidream.safetensors"
207
+ clip2: "clip_g_hidream.safetensors"
208
+ clip3: "t5xxl_fp8_e4m3fn_scaled.safetensors"
209
+ clip4: "llama_3.1_8b_instruct_fp8_scaled.safetensors"
210
+ FLUX.1:
211
+ latent_type: sd3_latent
212
+ models:
213
+ - display_name: "flux1-dev"
214
+ components:
215
+ unet: "flux1-dev-fp8-e4m3fn.safetensors"
216
+ vae: "ae.safetensors"
217
+ clip1: "clip_l.safetensors"
218
+ clip2: "t5xxl_fp8_e4m3fn_scaled.safetensors"
219
+ - display_name: "flux1-schnell"
220
+ components:
221
+ unet: "flux1-schnell-fp8-e4m3fn.safetensors"
222
+ vae: "ae.safetensors"
223
+ clip1: "clip_l.safetensors"
224
+ clip2: "t5xxl_fp8_e4m3fn_scaled.safetensors"
225
+ - display_name: "flux1-krea-dev"
226
+ components:
227
+ unet: "flux1-krea-dev_fp8_scaled.safetensors"
228
+ vae: "ae.safetensors"
229
+ clip1: "clip_l.safetensors"
230
+ clip2: "t5xxl_fp8_e4m3fn_scaled.safetensors"
231
+ SD3.5:
232
+ latent_type: sd3_latent
233
+ models:
234
+ - display_name: "StabilityAI/SD3.5-Large"
235
+ path: "sd3.5_large_fp8_scaled.safetensors"
236
+ - display_name: "StabilityAI/SD3.5-Medium"
237
+ path: "sd3.5_medium_incl_clips_t5xxlfp8scaled.safetensors"
238
+ SDXL:
239
+ latent_type: latent
240
+ models:
241
+ # NoobAI
242
+ - display_name: "Laxhar/noobai-XL-Vpred-1.0"
243
+ path: "NoobAI-XL-Vpred-v1.0.safetensors"
244
+ category: "NoobAI"
245
+ - display_name: "Laxhar/noobai-XL-1.1"
246
+ path: "NoobAI-XL-v1.1.safetensors"
247
+ category: "NoobAI"
248
+ - display_name: "bluepen5805/noob_v_pencil-XL-3.0.0"
249
+ path: "noob_v_pencil-XL-v3.0.0.safetensors"
250
+ category: "NoobAI"
251
+ - display_name: "RedRayz/hikari_noob_v-pred_1.2.4"
252
+ path: "Hikari_Noob_v-pred_1.2.4.safetensors"
253
+ category: "NoobAI"
254
+ - display_name: "ChenkinNoob/ChenkinNoob-XL-V0.5"
255
+ path: "ChenkinNoob-XL-V0.5.safetensors"
256
+ category: "NoobAI"
257
+ # Illustrious
258
+ - display_name: "WAI0731/wai-illustrious-sdxl-v170"
259
+ path: "waiIllustriousSDXL_v170.safetensors"
260
+ category: "Illustrious"
261
+ - display_name: "blue_pen5805/mellow_pencil-XL-v1.0.0"
262
+ path: "mellow_pencil-XL-v1.0.0.safetensors"
263
+ category: "Illustrious"
264
+ - display_name: "blue_pen5805/illustrious_pencil-XL-v5.0.0"
265
+ path: "illustrious_pencil-XL-v5.0.0.safetensors"
266
+ category: "Illustrious"
267
+ - display_name: "Ikena/hassaku-xl-illustrious-v3.0"
268
+ path: "hassakuXLIllustrious_v30.safetensors"
269
+ category: "Illustrious"
270
+ - display_name: "Crody/Nova-Anime-XL-v16.0"
271
+ path: "novaAnimeXL_ilV160.safetensors"
272
+ category: "Illustrious"
273
+ - display_name: "OnomaAIResearch/Illustrious-XL-v2.0"
274
+ path: "Illustrious-XL-v2.0.safetensors"
275
+ category: "Illustrious"
276
+ - display_name: "OnomaAIResearch/Illustrious-XL-v1.1"
277
+ path: "Illustrious-XL-v1.1.safetensors"
278
+ category: "Illustrious"
279
+ - display_name: "OnomaAIResearch/Illustrious-XL-v1.0"
280
+ path: "Illustrious-XL-v1.0.safetensors"
281
+ category: "Illustrious"
282
+ - display_name: "aria1th261/Illustrious-XL-v0.1"
283
+ path: "illustriousXL_v01.safetensors"
284
+ category: "Illustrious"
285
+ # SDXL-Animate
286
+ - display_name: "CagliostroLab/Animagine XL 4.0"
287
+ path: "animagine-xl-4.0.safetensors"
288
+ category: "Animate"
289
+ - display_name: "CagliostroLab/Animagine XL 3.1"
290
+ path: "animagine-xl-3.1.safetensors"
291
+ category: "Animate"
292
+ - display_name: "blue_pen5805/4nima_pencil-XL v1.0.1"
293
+ path: "4nima_pencil-XL-v1.0.1.safetensors"
294
+ category: "Animate"
295
+ - display_name: "blue_pen5805/anima_pencil-XL v5.0.0"
296
+ path: "anima_pencil-XL-v5.0.0.safetensors"
297
+ category: "Animate"
298
+ - display_name: "blue_pen5805/blue_pencil-XL v7.0.0"
299
+ path: "blue_pencil-XL-v7.0.0.safetensors"
300
+ category: "Animate"
301
+ # SDXL-Pony
302
+ - display_name: "PurpleSmartAI/Pony Diffusion V6 XL"
303
+ path: "ponyDiffusionV6XL_v6StartWithThisOne.safetensors"
304
+ category: "Pony"
305
+ - display_name: "blue_pen5805/pony_pencil-XL v2.0.0"
306
+ path: "pony_pencil-XL-v2.0.0.safetensors"
307
+ category: "Pony"
308
+ - display_name: "Cyberdelia/CyberRealistic Pony v17.0"
309
+ path: "CyberRealisticPony_V17.0_FP16.safetensors"
310
+ category: "Pony"
311
+ # SDXL-Base
312
+ - display_name: "stabilityai/stable-diffusion-xl-base-1.0"
313
+ path: "sd_xl_base_1.0.safetensors"
314
+ category: "Base"
315
+ SD1.5:
316
+ latent_type: latent
317
+ models:
318
+ - display_name: "stable-diffusion-v1-5/stable-diffusion-v1-5"
319
+ path: "v1-5-pruned-emaonly.safetensors"