Refactor UI event handlers into subpackage
Browse filesFiles changed (38)
- LICENSEAdded+674
- README.md+92
- app.py+1-13
- chain_injectors/anima_controlnet_lllite_injector.pyAdded+48
- chain_injectors/hidream_o1_reference_injector.pyAdded+54
- chain_injectors/hidream_o1_smoothing_injector.pyAdded+39
- comfy_integration/setup.py+8
- core/pipelines/sd_image_pipeline.py+67-21
- core/pipelines/workflow_recipes/_partials/conditioning/anima.yaml+4
- core/pipelines/workflow_recipes/_partials/conditioning/hidream.yaml → core/pipelines/workflow_recipes/_partials/conditioning/hidream-i1.yamlRenamed+3-3
- core/pipelines/workflow_recipes/_partials/conditioning/hidream-o1.yamlAdded+68
- core/pipelines/workflow_recipes/_partials/input/txt2img_hidream_o1_latent.yamlAdded+11
- requirements.txt+12-28
- scripts/__init__.pyDeleted
- scripts/build_sage_attention.pyDeleted-99
- ui/events.pyDeleted-1258
- ui/events/__init__.pyAdded+10
- ui/events/chain_handlers.pyAdded+680
- ui/events/change_handlers.pyAdded+333
- ui/events/config_loaders.pyAdded+131
- ui/events/main.pyAdded+240
- ui/events/run_handlers.pyAdded+100
- ui/layout.py+9-6
- ui/shared/hires_fix_ui.py+4-2
- ui/shared/img2img_ui.py+4-2
- ui/shared/inpaint_ui.py+4-2
- ui/shared/outpaint_ui.py+4-2
- ui/shared/txt2img_ui.py+4-2
- ui/shared/ui_components.py+98-4
- utils/app_utils.py-69
- yaml/anima_controlnet_lllite_models.yamlAdded+13
- yaml/constants.yaml+9-1
- yaml/file_list.yaml+154-27
- yaml/image_gen_features.yaml+10-3
- yaml/injectors.yaml+16-7
- yaml/model_architectures.yaml+8-4
- yaml/model_defaults.yaml+13-21
- yaml/model_list.yaml+311-1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.8 unmodified lines91011128 unmodified linespython_version: 3.12short_description: Multi-task image generator with dynamic, chainable workflowspinned: true---8 unmodified lines91011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031048 unmodified linespython_version: 3.12short_description: Multi-task image generator with dynamic, chainable workflowspinned: truemodels:- AiAF/Illustrious-XL-v0.1.safetensors- alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union-2.1- black-forest-labs/FLUX.1-Redux-dev- black-forest-labs/FLUX.2-klein-4b-fp8- black-forest-labs/FLUX.2-klein-9b-fp8- black-forest-labs/FLUX.2-klein-9b-kv-fp8- black-forest-labs/FLUX.2-klein-base-4b-fp8- black-forest-labs/FLUX.2-klein-base-9b-fp8- bluepen5805/4nima_pencil-XL- bluepen5805/anima-models- bluepen5805/anima_pencil-XL- bluepen5805/blue_pencil-XL- bluepen5805/illustrious_pencil-XL- bluepen5805/mellow_pencil-XL- bluepen5805/noob_v_pencil-XL- bluepen5805/pony_pencil-XL- cagliostrolab/animagine-xl-3.1- cagliostrolab/animagine-xl-4.0- ChenkinNoob/ChenkinNoob-XL-V0.5- circlestone-labs/Anima- Clybius/Chroma-fp8-scaled- comfyanonymous/ControlNet-v1-1_fp16_safetensors- comfyanonymous/flux_text_encoders- Comfy-Org/ERNIE-Image- Comfy-Org/FLUX.1-Krea-dev_ComfyUI- Comfy-Org/flux1-kontext-dev_ComfyUI- Comfy-Org/flux2-dev- Comfy-Org/HiDream-I1_ComfyUI- Comfy-Org/HiDream-O1-Image- Comfy-Org/HunyuanImage_2.1_ComfyUI- Comfy-Org/LongCat-Image- Comfy-Org/Lumina_Image_2.0_Repackaged- Comfy-Org/NewBie-image-Exp0.1_repackaged- Comfy-Org/Omnigen2_ComfyUI_repackaged- Comfy-Org/Ovis-Image- Comfy-Org/Qwen-Image_ComfyUI- Comfy-Org/sigclip_vision_384- Comfy-Org/stable-diffusion-3.5-fp8- Comfy-Org/vae-text-encorder-for-flux-klein-4b- Comfy-Org/vae-text-encorder-for-flux-klein-9b- Comfy-Org/z_image- Comfy-Org/z_image_turbo- cyberdelia/CyberRealisticPony- diffusionmodels1254ani/waiANIMA- duongve/AnimaYume- Eugeoter/noob-sdxl-controlnet-canny- Eugeoter/noob-sdxl-controlnet-depth- Eugeoter/noob-sdxl-controlnet-lineart_anime- Eugeoter/noob-sdxl-controlnet-lineart_realistic- Eugeoter/noob-sdxl-controlnet-manga_line- Eugeoter/noob-sdxl-controlnet-normal- Eugeoter/noob-sdxl-controlnet-softedge_hed- Eugeoter/noob-sdxl-controlnet-tile- h94/IP-Adapter- h94/IP-Adapter-FaceID- InstantX/FLUX.1-dev-IP-Adapter- InstantX/Qwen-Image-ControlNet-Inpainting- InstantX/Qwen-Image-ControlNet-Union- InstantX/SD3.5-Large-IP-Adapter- Kijai/flux-fp8- kohya-ss/Anima-LLLite- Laxhar/noob_openpose- Laxhar/noobai-XL-1.1- Laxhar/noobai-XL-Vpred-1.0- licyk/sd_control_collection- lightx2v/Qwen-Image-2512-Lightning- lightx2v/Qwen-Image-Lightning- LyliaEngine/Pony_Diffusion_V6_XL- MIC-Lab/illustriousXLv0.1_controlnet- MIC-Lab/illustriousXLv1.1_controlnet- misri/hassakuXLIllustrious_v30- OnomaAIResearch/Illustrious-XL-v1.0- OnomaAIResearch/Illustrious-XL-v1.1- OnomaAIResearch/Illustrious-XL-v2.0- RedRayz/hikari_noob_v-pred_1.2.4- Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0- silveroxides/Chroma1-Radiance-fp8-scaled- stabilityai/stable-diffusion-3.5-controlnets- stabilityai/stable-diffusion-xl-base-1.0- stable-diffusion-v1-5/stable-diffusion-v1-5- Wenaka/NoobAI_XL_Inpainting_ControlNet_Full- xinsir/anime-painter- xinsir/controlnet-canny-sdxl-1.0- xinsir/controlnet-depth-sdxl-1.0- xinsir/controlnet-openpose-sdxl-1.0- xinsir/controlnet-scribble-sdxl-1.0- xinsir/controlnet-tile-sdxl-1.0- xinsir/controlnet-union-sdxl-1.0- XLabs-AI/flux-controlnet-collections- Yevrey921/novaAnimeXL_ilV160- zhenshipo/waiIllustriousSDXL_v170---
45 unmodified lines4647484950515253545556575859606162636410 unmodified lines757677787980818245 unmodified linesdef main():from utils.app_utils import print_welcome_messagefrom scripts import build_sage_attentionfrom comfy_integration import setup as setup_comfyuiprint_welcome_message()print("--- [Setup] Attempting to build and install SageAttention... ---")try:build_sage_attention.install_sage_attention()print("--- [Setup] ✅ SageAttention installation process finished. ---")except Exception as e:print(f"--- [Setup] ❌ SageAttention installation failed: {e}. Continuing with default attention. ---")print("--- [Setup] Starting ComfyUI initialization ---")setup_comfyui.initialize_comfyui()10 unmodified linesexcept Exception as e:print(f"--- [GPU Startup] ⚠️ Warning: Startup check failed: {e} ---")from utils.app_utils import load_ipadapter_presetsprint("--- Starting Application Setup ---")print("--- Loading IPAdapter presets ---")45 unmodified lines46474849505152535410 unmodified lines65666768697045 unmodified linesdef main():from comfy_integration import setup as setup_comfyuifrom utils.app_utils import load_ipadapter_presetsprint("--- [Setup] Starting ComfyUI initialization ---")setup_comfyui.initialize_comfyui()10 unmodified linesexcept Exception as e:print(f"--- [GPU Startup] ⚠️ Warning: Startup check failed: {e} ---")print("--- Starting Application Setup ---")print("--- Loading IPAdapter presets ---")
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748def inject(assembler, chain_definition, chain_items):
if not chain_items:
return
ksampler_name = chain_definition.get('ksampler_node', 'ksampler')
if ksampler_name not in assembler.node_map:
print(f"Warning: KSampler node '{ksampler_name}' not found for Anima LLLite chain. Skipping.")
return
ksampler_id = assembler.node_map[ksampler_name]
if 'model' not in assembler.workflow[ksampler_id]['inputs']:
print(f"Warning: KSampler node '{ksampler_name}' is missing 'model' input. Skipping.")
return
current_model_connection = assembler.workflow[ksampler_id]['inputs']['model']
for item_data in chain_items:
image_loader_id = assembler._get_unique_id()
image_loader_node = assembler._get_node_template("LoadImage")
image_loader_node['inputs']['image'] = item_data['image']
assembler.workflow[image_loader_id] = image_loader_node
image_scaler_id = assembler._get_unique_id()
image_scaler_node = assembler._get_node_template("ImageScaleToTotalPixels")
image_scaler_node['inputs']['image'] = [image_loader_id, 0]
image_scaler_node['inputs']['upscale_method'] = 'nearest-exact'
image_scaler_node['inputs']['megapixels'] = 1.0
assembler.workflow[image_scaler_id] = image_scaler_node
apply_cn_id = assembler._get_unique_id()
apply_cn_node = assembler._get_node_template("AnimaLLLiteApply")
apply_cn_node['inputs']['lllite_name'] = item_data['control_net_name']
apply_cn_node['inputs']['strength'] = item_data['strength']
apply_cn_node['inputs']['start_percent'] = item_data.get('start_percent', 0.0)
apply_cn_node['inputs']['end_percent'] = item_data.get('end_percent', 1.0)
apply_cn_node['inputs']['model'] = current_model_connection
apply_cn_node['inputs']['image'] = [image_scaler_id, 0]
assembler.workflow[apply_cn_id] = apply_cn_node
current_model_connection = [apply_cn_id, 0]
assembler.workflow[ksampler_id]['inputs']['model'] = current_model_connection
print(f"Anima LLLite injector applied. KSampler model input re-routed through {len(chain_items)} LLLite(s).")123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354def inject(assembler, chain_definition, chain_items):
if not chain_items:
return
ksampler_name = chain_definition.get('ksampler_node', 'ksampler')
if ksampler_name not in assembler.node_map:
print(f"Warning: KSampler node '{ksampler_name}' not found for HiDream-O1 Reference chain. Skipping.")
return
ksampler_id = assembler.node_map[ksampler_name]
if 'positive' not in assembler.workflow[ksampler_id]['inputs'] or 'negative' not in assembler.workflow[ksampler_id]['inputs']:
print(f"Warning: KSampler node '{ksampler_name}' missing positive/negative inputs. Skipping.")
return
current_pos_conditioning = assembler.workflow[ksampler_id]['inputs']['positive']
current_neg_conditioning = assembler.workflow[ksampler_id]['inputs']['negative']
ref_images_id = assembler._get_unique_id()
ref_images_node = assembler._get_node_template("HiDreamO1ReferenceImages")
if 'images' in ref_images_node['inputs']:
del ref_images_node['inputs']['images']
ref_images_node['inputs']['positive'] = current_pos_conditioning
ref_images_node['inputs']['negative'] = current_neg_conditioning
for i, img_filename in enumerate(chain_items):
if i >= 10:
break
load_id = assembler._get_unique_id()
load_node = assembler._get_node_template("LoadImage")
load_node['inputs']['image'] = img_filename
load_node['_meta']['title'] = f"Load Reference Image {i+1}"
assembler.workflow[load_id] = load_node
scale_id = assembler._get_unique_id()
scale_node = assembler._get_node_template("ImageScaleToTotalPixels")
scale_node['inputs']['megapixels'] = 1.0
scale_node['inputs']['upscale_method'] = "lanczos"
scale_node['inputs']['image'] = [load_id, 0]
scale_node['_meta']['title'] = f"Scale Reference {i+1}"
assembler.workflow[scale_id] = scale_node
ref_images_node['inputs'][f'images.image_{i+1}'] = [scale_id, 0]
assembler.workflow[ref_images_id] = ref_images_node
assembler.workflow[ksampler_id]['inputs']['positive'] = [ref_images_id, 0]
assembler.workflow[ksampler_id]['inputs']['negative'] = [ref_images_id, 1]
print(f"HiDream-O1 Reference injector applied. Re-routed inputs through {min(len(chain_items), 10)} reference images.")123456789101112131415161718192021222324252627282930313233343536373839from copy import deepcopy
def inject(assembler, chain_definition, chain_items):
if not chain_items:
return
target_node_name = chain_definition.get('target_node')
if not target_node_name or target_node_name not in assembler.node_map:
print(f"Warning: Target node '{target_node_name}' not found for HiDream-O1 Smoothing. Skipping.")
return
target_node_id = assembler.node_map[target_node_name]
if 'model' not in assembler.workflow[target_node_id]['inputs']:
print(f"Warning: Target node '{target_node_name}' has no 'model' input. Skipping.")
return
current_model_connection = assembler.workflow[target_node_id]['inputs']['model']
for _ in chain_items:
template = assembler._get_node_template("HiDreamO1PatchSeamSmoothing")
node_data = deepcopy(template)
node_data['inputs']['start_percent'] = 0.8
node_data['inputs']['end_percent'] = 1.0
node_data['inputs']['pattern'] = "single_shift"
node_data['inputs']['passes'] = "ramp_2_4"
node_data['inputs']['blend'] = "median"
node_data['inputs']['strength'] = 1.0
node_data['inputs']['model'] = current_model_connection
new_node_id = assembler._get_unique_id()
assembler.workflow[new_node_id] = node_data
current_model_connection = [new_node_id, 0]
assembler.workflow[target_node_id]['inputs']['model'] = current_model_connection
print("HiDream-O1 Patch Seam Smoothing injector applied.")73 unmodified lines74757677787973 unmodified lineselse:print("✅ ComfyUI-Newbie-Nodes extension already exists.")print(f"✅ Current working directory is: {os.getcwd()}")import comfy.model_management73 unmodified lines747576777879808182838485868773 unmodified lineselse:print("✅ ComfyUI-Newbie-Nodes extension already exists.")# 5. ComfyUI-Anima-LLLiteanima_controlnet_lllite_nodes_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-Anima-LLLite")if not os.path.exists(anima_controlnet_lllite_nodes_path):os.system(f"git clone https://github.com/kohya-ss/ComfyUI-Anima-LLLite.git {anima_controlnet_lllite_nodes_path}")print("✅ ComfyUI-Anima-LLLite extension cloned.")else:print("✅ ComfyUI-Anima-LLLite extension already exists.")print(f"✅ Current working directory is: {os.getcwd()}")import comfy.model_management
95 unmodified lines9697989910010110210310493 unmodified lines19819920020120220320420520620720820921020 unmodified lines23123223323423523623723823924024124224324424524624724824925025125234 unmodified lines287288289290291292293122 unmodified lines41641741841942042149 unmodified lines4714724734744754765 unmodified lines4824834844854864874881 unmodified line49049149249349449549695 unmodified linesraise RuntimeError(f"Workflow integrity error: Output of node {source_node_id} needed for {node_id} but not yet computed.")source_output_tuple = computed_outputs[source_node_id]kwargs[param_name] = get_value_at_index(source_output_tuple, output_index)else:kwargs[param_name] = param_valuefunction_name = getattr(node_class, 'FUNCTION')execution_method = getattr(node_instance, function_name)93 unmodified linesif task_type == 'img2img':input_image_pil = ui_inputs.get('img2img_image')if input_image_pil:temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")input_image_pil.save(temp_file_path, "PNG")ui_inputs['input_image'] = os.path.basename(temp_file_path)temp_files_to_clean.append(temp_file_path)ui_inputs['width'] = input_image_pil.widthui_inputs['height'] = input_image_pil.heightelif task_type == 'inpaint':inpaint_dict = ui_inputs.get('inpaint_image_dict')20 unmodified lineselif task_type == 'outpaint':input_image_pil = ui_inputs.get('outpaint_image')if input_image_pil:temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")input_image_pil.save(temp_file_path, "PNG")ui_inputs['input_image'] = os.path.basename(temp_file_path)temp_files_to_clean.append(temp_file_path)ui_inputs['megapixels'] = 0.25ui_inputs['grow_mask_by'] = ui_inputs.get('feathering', 10)elif task_type == 'hires_fix':input_image_pil = ui_inputs.get('hires_image')if input_image_pil:temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")input_image_pil.save(temp_file_path, "PNG")ui_inputs['input_image'] = os.path.basename(temp_file_path)temp_files_to_clean.append(temp_file_path)embedding_data = ui_inputs.get('embedding_data', [])embedding_filenames = []34 unmodified lines"image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],"start_percent": 0.0, "end_percent": 1.0, "control_net_name": cn_filepaths[i]})diffsynth_controlnet_data = ui_inputs.get('diffsynth_controlnet_data', [])active_diffsynth_controlnets = []if diffsynth_controlnet_data:122 unmodified linesimg.save(temp_path, "PNG")temp_files_to_clean.append(temp_path)active_reference_latents.append(os.path.basename(temp_path))from utils.app_utils import get_vae_pathvae_source = ui_inputs.get('vae_source')49 unmodified linesrecipe_path = os.path.join(os.path.dirname(__file__), "workflow_recipes", "sd_unified_recipe.yaml")assembler = WorkflowAssembler(recipe_path, dynamic_values=dynamic_values)workflow_inputs = {**ui_inputs,"positive_prompt": ui_inputs['positive_prompt'], "negative_prompt": ui_inputs['negative_prompt'],5 unmodified lines"vae_name": ui_inputs.get('vae_name'),"guidance": ui_inputs.get('guidance', 3.5),"lora_chain": active_loras_for_gpu,"controlnet_chain": active_controlnets,"diffsynth_controlnet_chain": active_diffsynth_controlnets,"ipadapter_chain": active_ipadapters,"flux1_ipadapter_chain": active_flux1_ipadapters,1 unmodified line"style_chain": active_styles,"conditioning_chain": active_conditioning,"reference_latent_chain": active_reference_latents,"vae_chain": [ui_inputs.get('vae_name')] if ui_inputs.get('vae_name') else [],}if isinstance(path_or_components, dict):95 unmodified lines9697989910010110210310410510610710810911011111293 unmodified lines20620720820921021121221321421521621721821920 unmodified lines24024124224324424524624724824925025125225325425525625725825926026126226334 unmodified lines298299300301302303304305306307308309310311312313314315316317318319320321122 unmodified lines44444544644744844945045145245345445545645745845946049 unmodified lines5105115125135145155165175185195 unmodified lines5255265275285295305315321 unmodified line53453553653753853954054154295 unmodified linesraise RuntimeError(f"Workflow integrity error: Output of node {source_node_id} needed for {node_id} but not yet computed.")source_output_tuple = computed_outputs[source_node_id]actual_value = get_value_at_index(source_output_tuple, output_index)else:actual_value = param_valueif '.' in param_name:parent_key, child_key = param_name.split('.', 1)if parent_key not in kwargs or not isinstance(kwargs[parent_key], dict):kwargs[parent_key] = {}kwargs[parent_key][child_key] = actual_valueelse:kwargs[param_name] = actual_valuefunction_name = getattr(node_class, 'FUNCTION')execution_method = getattr(node_instance, function_name)93 unmodified linesif task_type == 'img2img':input_image_pil = ui_inputs.get('img2img_image')if not input_image_pil:raise gr.Error("Please upload an image for Image-to-Image.")temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")input_image_pil.save(temp_file_path, "PNG")ui_inputs['input_image'] = os.path.basename(temp_file_path)temp_files_to_clean.append(temp_file_path)ui_inputs['width'] = input_image_pil.widthui_inputs['height'] = input_image_pil.heightelif task_type == 'inpaint':inpaint_dict = ui_inputs.get('inpaint_image_dict')20 unmodified lineselif task_type == 'outpaint':input_image_pil = ui_inputs.get('outpaint_image')if not input_image_pil:raise gr.Error("Please upload an image for Outpainting.")temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")input_image_pil.save(temp_file_path, "PNG")ui_inputs['input_image'] = os.path.basename(temp_file_path)temp_files_to_clean.append(temp_file_path)ui_inputs['megapixels'] = 0.25ui_inputs['grow_mask_by'] = ui_inputs.get('feathering', 10)elif task_type == 'hires_fix':input_image_pil = ui_inputs.get('hires_image')if not input_image_pil:raise gr.Error("Please upload an image for Hires Fix.")temp_file_path = os.path.join(INPUT_DIR, f"temp_input_{random.randint(1000, 9999)}.png")input_image_pil.save(temp_file_path, "PNG")ui_inputs['input_image'] = os.path.basename(temp_file_path)temp_files_to_clean.append(temp_file_path)embedding_data = ui_inputs.get('embedding_data', [])embedding_filenames = []34 unmodified lines"image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],"start_percent": 0.0, "end_percent": 1.0, "control_net_name": cn_filepaths[i]})anima_controlnet_lllite_data = ui_inputs.get('anima_controlnet_lllite_data', [])active_anima_controlnets = []if anima_controlnet_lllite_data:(cn_images, _, _, cn_strengths, cn_filepaths, cn_starts, cn_ends) = [anima_controlnet_lllite_data[i::7] for i in range(7)]for i in range(len(cn_images)):if cn_images[i] and cn_strengths[i] > 0 and cn_filepaths[i] and cn_filepaths[i] != "None":from utils.app_utils import _ensure_model_downloaded_ensure_model_downloaded(cn_filepaths[i], progress)if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)cn_temp_path = os.path.join(INPUT_DIR, f"temp_anima_cn_{i}_{random.randint(1000, 9999)}.png")cn_images[i].save(cn_temp_path, "PNG")temp_files_to_clean.append(cn_temp_path)active_anima_controlnets.append({"image": os.path.basename(cn_temp_path), "strength": cn_strengths[i],"start_percent": cn_starts[i], "end_percent": cn_ends[i], "control_net_name": cn_filepaths[i]})diffsynth_controlnet_data = ui_inputs.get('diffsynth_controlnet_data', [])active_diffsynth_controlnets = []if diffsynth_controlnet_data:122 unmodified linesimg.save(temp_path, "PNG")temp_files_to_clean.append(temp_path)active_reference_latents.append(os.path.basename(temp_path))hidream_o1_reference_data = ui_inputs.get('hidream_o1_reference_data', [])active_hidream_o1_reference = []if hidream_o1_reference_data:for img in hidream_o1_reference_data:if img:if not os.path.exists(INPUT_DIR): os.makedirs(INPUT_DIR)temp_path = os.path.join(INPUT_DIR, f"temp_ho1_ref_{random.randint(1000, 9999)}.png")img.save(temp_path, "PNG")temp_files_to_clean.append(temp_path)active_hidream_o1_reference.append(os.path.basename(temp_path))from utils.app_utils import get_vae_pathvae_source = ui_inputs.get('vae_source')49 unmodified linesrecipe_path = os.path.join(os.path.dirname(__file__), "workflow_recipes", "sd_unified_recipe.yaml")assembler = WorkflowAssembler(recipe_path, dynamic_values=dynamic_values)hidream_o1_smoothing_data = []if workflow_model_type == 'hidream-o1' and model_display_name == "HiDream-O1-Image":hidream_o1_smoothing_data.append({})workflow_inputs = {**ui_inputs,"positive_prompt": ui_inputs['positive_prompt'], "negative_prompt": ui_inputs['negative_prompt'],5 unmodified lines"vae_name": ui_inputs.get('vae_name'),"guidance": ui_inputs.get('guidance', 3.5),"lora_chain": active_loras_for_gpu,"controlnet_chain": active_controlnets if not active_anima_controlnets else [],"anima_controlnet_lllite_chain": active_anima_controlnets,"diffsynth_controlnet_chain": active_diffsynth_controlnets,"ipadapter_chain": active_ipadapters,"flux1_ipadapter_chain": active_flux1_ipadapters,1 unmodified line"style_chain": active_styles,"conditioning_chain": active_conditioning,"reference_latent_chain": active_reference_latents,"hidream_o1_reference_chain": active_hidream_o1_reference,"vae_chain": [ui_inputs.get('vae_name')] if ui_inputs.get('vae_name') else [],"hidream_o1_smoothing_chain": hidream_o1_smoothing_data,}if isinstance(path_or_components, dict):
42 unmodified lines43444546474842 unmodified lines"model": ["ksampler:model"]"clip": ["pos_prompt:clip", "neg_prompt:clip"]dynamic_conditioning_chains:conditioning_chain:ksampler_node: "ksampler"42 unmodified lines4344454647484950515242 unmodified lines"model": ["ksampler:model"]"clip": ["pos_prompt:clip", "neg_prompt:clip"]dynamic_anima_controlnet_lllite_chains:anima_controlnet_lllite_chain:ksampler_node: "ksampler"dynamic_conditioning_chains:conditioning_chain:ksampler_node: "ksampler"
123456789101112131415nodes:unet_loader:class_type: UNETLoadertitle: "Load HiDream UNET"params:weight_dtype: "default"vae_loader:class_type: VAELoadertitle: "Load HiDream VAE"clip_loader:class_type: QuadrupleCLIPLoadertitle: "Load HiDream Quadruple CLIP"model_sampler:class_type: ModelSamplingSD3123456789101112131415nodes:unet_loader:class_type: UNETLoadertitle: "Load HiDream-I1 UNET"params:weight_dtype: "default"vae_loader:class_type: VAELoadertitle: "Load HiDream-I1 VAE"clip_loader:class_type: QuadrupleCLIPLoadertitle: "Load HiDream-I1 Quadruple CLIP"model_sampler:class_type: ModelSamplingSD3
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768nodes: ckpt_loader: class_type: CheckpointLoaderSimple title: "Load Checkpoint" model_noise_scale: class_type: ModelNoiseScale title: "ModelNoiseScale" params: noise_scale: 8
connections: - from: "ckpt_loader:0" to: "model_noise_scale:model" - from: "model_noise_scale:0" to: "ksampler:model"
- from: "ckpt_loader:1" to: "pos_prompt:clip" - from: "ckpt_loader:1" to: "neg_prompt:clip"
- from: "pos_prompt:0" to: "ksampler:positive" - from: "neg_prompt:0" to: "ksampler:negative" - from: "ckpt_loader:2" to: "vae_decode:vae" - from: "ckpt_loader:2" to: "vae_encode:vae"
dynamic_vae_chains: vae_chain: targets: - "vae_decode:vae" - "vae_encode:vae"
dynamic_lora_chains: lora_chain: template: "LoraLoader" start: "ckpt_loader" output_map: "0": "model" "1": "clip" input_map: "model": "model" "clip": "clip" end_input_map: "model": ["model_noise_scale:model"] "clip": ["pos_prompt:clip", "neg_prompt:clip"]
dynamic_hidream_o1_smoothing_chains: hidream_o1_smoothing_chain: target_node: "ksampler"
dynamic_conditioning_chains: conditioning_chain: ksampler_node: "ksampler" clip_source: "ckpt_loader:1"
dynamic_hidream_o1_reference_chains: hidream_o1_reference_chain: ksampler_node: "ksampler"
ui_map: model_name: "ckpt_loader:ckpt_name"1234567891011nodes: latent_source: class_type: "EmptyHiDreamO1LatentImage" title: "Empty HiDream-O1 Latent Image"
connections: []
ui_map: width: "latent_source:width" height: "latent_source:height" batch_size: "latent_source:batch_size"1234567891012 unmodified lines232425262728297 unmodified lines3738394041424344454647484950515253545556575859606162comfyui-frontend-package==1.42.15comfyui-workflow-templates==0.9.66comfyui-embedded-docs==0.4.4torch==2.10.0torchsdetorchvision==0.25.0torchaudio==2.10.0numpy>=1.25.0einopstransformers>=4.50.312 unmodified linesfilelockav>=14.2.0comfy-kitchen>=0.2.8comfy-aimdo==0.3.0requestssimpleeval>=1.0.0blake37 unmodified linesglfwaddictalbumentationsftfyfvcorehuggingface-hubimageio[ffmpeg]importlib_metadatamatplotlibmediapipeninjaomegaconfopencv-python>=4.7.0.72python-dateutilscikit-imagescikit-learnsoundfilespacessvglibtrimesh[easy]yacsyapfonnxruntime-gpudiffusers1234567891012 unmodified lines232425262728297 unmodified lines37383940414243444546comfyui-frontend-package==1.44.19comfyui-workflow-templates==0.9.82comfyui-embedded-docs==0.5.1torchtorchsdetorchvisiontorchaudionumpy>=1.25.0einopstransformers>=4.50.312 unmodified linesfilelockav>=14.2.0comfy-kitchen>=0.2.8comfy-aimdo==0.4.5requestssimpleeval>=1.0.0blake37 unmodified linesglfwdiffusersprotobufhuggingface-hubimageiospacessageattention @ https://huggingface.co/RioShiina/Sage-Attention-ZeroGPU-Space-Build/resolve/main/sageattention-2.2.0-cp312-cp312-linux_x86_64.whl
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899import os
import subprocess
import sys
import textwrap
REPO_URL = "https://github.com/thu-ml/SageAttention.git"
REPO_DIR = "SageAttention"
def run_command(command, cwd=None, env=None):
print(f"🚀 Running command: {' '.join(command)}")
result = subprocess.run(
command,
cwd=cwd,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True
)
if result.returncode != 0:
print(result.stdout)
raise subprocess.CalledProcessError(result.returncode, command)
def patch_setup_py(setup_py_path):
print(f"--- [SageAttention Build] Applying patches to {setup_py_path} ---")
with open(setup_py_path, 'r', encoding='utf-8') as f:
content = f.read()
original_cxx_flags = 'CXX_FLAGS = ["-g", "-O3", "-fopenmp", "-lgomp", "-std=c++17", "-DENABLE_BF16"]'
modified_cxx_flags = 'CXX_FLAGS = ["-g", "-O3", "-std=c++17", "-DENABLE_BF16"]'
if original_cxx_flags in content:
content = content.replace(original_cxx_flags, modified_cxx_flags)
print("🔧 Patch 1/1: Removed '-fopenmp' and '-lgomp' from CXX_FLAGS.")
else:
print("⚠️ Patch 1/1: CXX_FLAGS line not found as expected. It might have been changed upstream. Skipping.")
with open(setup_py_path, 'w', encoding='utf-8') as f:
f.write(content)
print("✅ Patches applied successfully.")
def install_sage_attention():
print("--- [SageAttention Build] Checking environment ---")
if os.path.isdir(REPO_DIR):
print(f"✅ Directory '{REPO_DIR}' already exists, assuming SageAttention is installed. Skipping build.")
return
print(f"⏳ Directory '{REPO_DIR}' not found. Starting a fresh installation of SageAttention.")
try:
print(f"--- [SageAttention Build] Step 1/3: Cloning repository ---")
run_command(["git", "clone", REPO_URL])
print("✅ Repository cloned successfully.")
print(f"--- [SageAttention Build] Step 2/3: Patching setup.py ---")
setup_py_path = os.path.join(REPO_DIR, "setup.py")
patch_setup_py(setup_py_path)
print(f"--- [SageAttention Build] Step 3/3: Compiling and installing ---")
build_env = os.environ.copy()
build_env.update({
"TORCH_CUDA_ARCH_LIST": "9.0",
"EXT_PARALLEL": "4",
"NVCC_APPEND_FLAGS": "--threads 8",
"MAX_JOBS": "32"
})
print("🔧 Setting build environment variables:")
print(f" - TORCH_CUDA_ARCH_LIST='{build_env['TORCH_CUDA_ARCH_LIST']}'")
print(f" - EXT_PARALLEL={build_env['EXT_PARALLEL']}")
print(f" - NVCC_APPEND_FLAGS='{build_env['NVCC_APPEND_FLAGS']}'")
print(f" - MAX_JOBS={build_env['MAX_JOBS']}")
install_command = [sys.executable, "setup.py", "install"]
run_command(install_command, cwd=REPO_DIR, env=build_env)
print("🎉 SageAttention compiled and installed successfully! ---")
except FileNotFoundError:
print("❌ ERROR: 'git' command not found. Please ensure Git is installed in your environment.")
sys.exit(1)
except subprocess.CalledProcessError as e:
print(f"❌ Command failed with return code: {e.returncode}")
print(f"❌ Command: {' '.join(e.cmd)}")
print("❌ SageAttention installation failed. Please check the logs above for details.")
sys.exit(1)
except Exception as e:
print(f"❌ An unknown error occurred: {e}")
sys.exit(1)
if __name__ == "__main__":
if os.path.isdir(REPO_DIR):
print(f"Note: To force a rebuild, please delete the '{REPO_DIR}' directory first.")
install_sage_attention()1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258import gradio as gr
import yaml
import os
import shutil
from functools import lru_cache
from core.settings import *
from utils.app_utils import *
from core.generation_logic import *
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
from utils.app_utils import save_uploaded_file_with_hash
from ui.shared.ui_components import RESOLUTION_MAP, MAX_CONTROLNETS, MAX_IPADAPTERS, MAX_EMBEDDINGS, MAX_CONDITIONINGS, MAX_LORAS
@lru_cache(maxsize=1)
def load_controlnet_config():
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'controlnet_models.yaml')
try:
print("--- Loading controlnet_models.yaml ---")
with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
print("--- ✅ controlnet_models.yaml loaded successfully ---")
return config.get("ControlNet", {})
except Exception as e:
print(f"Error loading controlnet_models.yaml: {e}")
return {}
def get_cn_defaults(arch_val):
cn_full_config = load_controlnet_config()
cn_config = cn_full_config.get(arch_val, [])
if not cn_config:
return [], None, [], None, "None"
all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", []))))
default_type = all_types[0] if all_types else None
series_choices = []
if default_type:
series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", []))))
default_series = series_choices[0] if series_choices else None
filepath = "None"
if default_series and default_type:
for model in cn_config:
if model.get("Series") == default_series and default_type in model.get("Type", []):
filepath = model.get("Filepath")
break
return all_types, default_type, series_choices, default_series, filepath
@lru_cache(maxsize=1)
def load_diffsynth_controlnet_config():
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'diffsynth_controlnet_models.yaml')
try:
print("--- Loading diffsynth_controlnet_models.yaml ---")
with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
print("--- ✅ diffsynth_controlnet_models.yaml loaded successfully ---")
return config.get("DiffSynth_ControlNet", {})
except Exception as e:
print(f"Error loading diffsynth_controlnet_models.yaml: {e}")
return {}
def get_diffsynth_cn_defaults(arch_val):
cn_full_config = load_diffsynth_controlnet_config()
cn_config = cn_full_config.get(arch_val, [])
if not cn_config:
return [], None, [], None, "None"
all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", []))))
default_type = all_types[0] if all_types else None
series_choices = []
if default_type:
series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", []))))
default_series = series_choices[0] if series_choices else None
filepath = "None"
if default_series and default_type:
for model in cn_config:
if model.get("Series") == default_series and default_type in model.get("Type", []):
filepath = model.get("Filepath")
break
return all_types, default_type, series_choices, default_series, filepath
@lru_cache(maxsize=1)
def load_ipadapter_config():
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_IPA_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'ipadapter.yaml')
try:
print("--- Loading ipadapter.yaml ---")
with open(_IPA_MODEL_LIST_PATH, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
print("--- ✅ ipadapter.yaml loaded successfully ---")
return config
except Exception as e:
print(f"Error loading ipadapter.yaml: {e}")
return {}
def apply_data_to_ui(data, prefix, ui_components):
final_sampler = data.get('sampler') if data.get('sampler') in SAMPLER_CHOICES else SAMPLER_CHOICES[0]
default_scheduler = 'normal' if 'normal' in SCHEDULER_CHOICES else SCHEDULER_CHOICES[0]
final_scheduler = data.get('scheduler') if data.get('scheduler') in SCHEDULER_CHOICES else default_scheduler
updates = {}
base_model_name = data.get('base_model')
model_map = MODEL_MAP_CHECKPOINT
if f'base_model_{prefix}' in ui_components:
model_dropdown_component = ui_components[f'base_model_{prefix}']
if base_model_name and base_model_name in model_map:
updates[model_dropdown_component] = base_model_name
if f'model_arch_{prefix}' in ui_components:
m_type = MODEL_TYPE_MAP.get(base_model_name, "SDXL")
updates[ui_components[f'model_arch_{prefix}']] = m_type
if f'model_cat_{prefix}' in ui_components:
m_info = model_map.get(base_model_name)
m_cat = m_info[4] if m_info and len(m_info) > 4 else None
updates[ui_components[f'model_cat_{prefix}']] = m_cat if m_cat else "ALL"
else:
updates[model_dropdown_component] = gr.update()
common_params = {
f'prompt_{prefix}': data.get('prompt', ''),
f'neg_prompt_{prefix}': data.get('negative_prompt', ''),
f'seed_{prefix}': data.get('seed', -1),
f'cfg_{prefix}': data.get('cfg_scale', 7.5),
f'steps_{prefix}': data.get('steps', 28),
f'sampler_{prefix}': final_sampler,
f'scheduler_{prefix}': final_scheduler,
}
for comp_name, value in common_params.items():
if comp_name in ui_components:
updates[ui_components[comp_name]] = value
if prefix == 'txt2img':
if f'width_{prefix}' in ui_components:
updates[ui_components[f'width_{prefix}']] = data.get('width', 1024)
if f'height_{prefix}' in ui_components:
updates[ui_components[f'height_{prefix}']] = data.get('height', 1024)
tab_indices = {"txt2img": 0, "img2img": 1, "inpaint": 2, "outpaint": 3, "hires_fix": 4}
tab_index = tab_indices.get(prefix, 0)
updates[ui_components['tabs']] = gr.Tabs(selected=tab_index)
return updates
def send_info_to_tab(image, prefix, ui_components):
if not image or not image.info.get('parameters', ''):
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])]
return {comp: gr.update() for comp in all_comps}
data = parse_parameters(image.info['parameters'])
image_input_map = {
"img2img": 'input_image_img2img',
"inpaint": 'input_image_dict_inpaint',
"outpaint": 'input_image_outpaint',
"hires_fix": 'input_image_hires_fix'
}
updates = apply_data_to_ui(data, prefix, ui_components)
if prefix in image_input_map and image_input_map[prefix] in ui_components:
component_key = image_input_map[prefix]
updates[ui_components[component_key]] = gr.update(value=image)
return updates
def send_info_by_hash(image, ui_components):
if not image or not image.info.get('parameters', ''):
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])]
return {comp: gr.update() for comp in all_comps}
data = parse_parameters(image.info['parameters'])
return apply_data_to_ui(data, "txt2img", ui_components)
def attach_event_handlers(ui_components, demo):
def create_lora_event_handlers(prefix):
lora_rows = ui_components.get(f'lora_rows_{prefix}')
if not lora_rows: return
lora_ids = ui_components[f'lora_ids_{prefix}']
lora_scales = ui_components[f'lora_scales_{prefix}']
lora_uploads = ui_components[f'lora_uploads_{prefix}']
count_state = ui_components[f'lora_count_state_{prefix}']
add_button = ui_components[f'add_lora_button_{prefix}']
del_button = ui_components[f'delete_lora_button_{prefix}']
def add_lora_row(c):
updates = {}
if c < MAX_LORAS:
c += 1
updates[lora_rows[c - 1]] = gr.update(visible=True)
updates[count_state] = c
updates[add_button] = gr.update(visible=c < MAX_LORAS)
updates[del_button] = gr.update(visible=c > 1)
return updates
def del_lora_row(c):
updates = {}
if c > 1:
updates[lora_rows[c - 1]] = gr.update(visible=False)
updates[lora_ids[c - 1]] = ""
updates[lora_scales[c - 1]] = 0.0
updates[lora_uploads[c - 1]] = None
c -= 1
updates[count_state] = c
updates[add_button] = gr.update(visible=True)
updates[del_button] = gr.update(visible=c > 1)
return updates
add_outputs = [count_state, add_button, del_button] + lora_rows
del_outputs = [count_state, add_button, del_button] + lora_rows + lora_ids + lora_scales + lora_uploads
add_button.click(add_lora_row, [count_state], add_outputs, show_progress=False)
del_button.click(del_lora_row, [count_state], del_outputs, show_progress=False)
def create_controlnet_event_handlers(prefix):
cn_rows = ui_components.get(f'controlnet_rows_{prefix}')
if not cn_rows: return
cn_types = ui_components[f'controlnet_types_{prefix}']
cn_series = ui_components[f'controlnet_series_{prefix}']
cn_filepaths = ui_components[f'controlnet_filepaths_{prefix}']
cn_images = ui_components[f'controlnet_images_{prefix}']
cn_strengths = ui_components[f'controlnet_strengths_{prefix}']
count_state = ui_components[f'controlnet_count_state_{prefix}']
add_button = ui_components[f'add_controlnet_button_{prefix}']
del_button = ui_components[f'delete_controlnet_button_{prefix}']
accordion = ui_components[f'controlnet_accordion_{prefix}']
arch_comp = ui_components.get(f'model_arch_{prefix}')
actual_arch_comp = arch_comp if arch_comp else gr.State("SDXL")
def add_cn_row(c):
c += 1
updates = {
count_state: c,
cn_rows[c-1]: gr.update(visible=True),
add_button: gr.update(visible=c < MAX_CONTROLNETS),
del_button: gr.update(visible=True)
}
return updates
def del_cn_row(c):
c -= 1
updates = {
count_state: c,
cn_rows[c]: gr.update(visible=False),
cn_images[c]: None,
cn_strengths[c]: 1.0,
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0)
}
return updates
add_outputs = [count_state, add_button, del_button] + cn_rows
del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths
add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def on_cn_type_change(selected_type, arch_val):
cn_full_config = load_controlnet_config()
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
cn_config = cn_full_config.get(controlnet_key, [])
series_choices = []
if selected_type:
series_choices = sorted(list(set(
model.get("Series", "Default") for model in cn_config
if selected_type in model.get("Type", [])
)))
default_series = series_choices[0] if series_choices else None
filepath = "None"
if default_series:
for model in cn_config:
if model.get("Series") == default_series and selected_type in model.get("Type", []):
filepath = model.get("Filepath")
break
return gr.update(choices=series_choices, value=default_series), filepath
def on_cn_series_change(selected_series, selected_type, arch_val):
cn_full_config = load_controlnet_config()
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
cn_config = cn_full_config.get(controlnet_key, [])
filepath = "None"
if selected_series and selected_type:
for model in cn_config:
if model.get("Series") == selected_series and selected_type in model.get("Type", []):
filepath = model.get("Filepath")
break
return filepath
for i in range(MAX_CONTROLNETS):
cn_types[i].change(
fn=on_cn_type_change,
inputs=[cn_types[i], actual_arch_comp],
outputs=[cn_series[i], cn_filepaths[i]],
show_progress=False
)
cn_series[i].change(
fn=on_cn_series_change,
inputs=[cn_series[i], cn_types[i], actual_arch_comp],
outputs=[cn_filepaths[i]],
show_progress=False
)
def on_accordion_expand(*images):
return [gr.update() for _ in images]
accordion.expand(
fn=on_accordion_expand,
inputs=cn_images,
outputs=cn_images,
show_progress=False
)
def create_diffsynth_controlnet_event_handlers(prefix):
cn_rows = ui_components.get(f'diffsynth_controlnet_rows_{prefix}')
if not cn_rows: return
cn_types = ui_components[f'diffsynth_controlnet_types_{prefix}']
cn_series = ui_components[f'diffsynth_controlnet_series_{prefix}']
cn_filepaths = ui_components[f'diffsynth_controlnet_filepaths_{prefix}']
cn_images = ui_components[f'diffsynth_controlnet_images_{prefix}']
cn_strengths = ui_components[f'diffsynth_controlnet_strengths_{prefix}']
count_state = ui_components[f'diffsynth_controlnet_count_state_{prefix}']
add_button = ui_components[f'add_diffsynth_controlnet_button_{prefix}']
del_button = ui_components[f'delete_diffsynth_controlnet_button_{prefix}']
accordion = ui_components[f'diffsynth_controlnet_accordion_{prefix}']
arch_comp = ui_components.get(f'model_arch_{prefix}')
actual_arch_comp = arch_comp if arch_comp else gr.State("Z-Image")
def add_cn_row(c):
c += 1
updates = {
count_state: c,
cn_rows[c-1]: gr.update(visible=True),
add_button: gr.update(visible=c < MAX_CONTROLNETS),
del_button: gr.update(visible=True)
}
return updates
def del_cn_row(c):
c -= 1
updates = {
count_state: c,
cn_rows[c]: gr.update(visible=False),
cn_images[c]: None,
cn_strengths[c]: 1.0,
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0)
}
return updates
add_outputs = [count_state, add_button, del_button] + cn_rows
del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths
add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def on_cn_type_change(selected_type, arch_val):
cn_full_config = load_diffsynth_controlnet_config()
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
cn_config = cn_full_config.get(controlnet_key, [])
series_choices = []
if selected_type:
series_choices = sorted(list(set(
model.get("Series", "Default") for model in cn_config
if selected_type in model.get("Type", [])
)))
default_series = series_choices[0] if series_choices else None
filepath = "None"
if default_series:
for model in cn_config:
if model.get("Series") == default_series and selected_type in model.get("Type", []):
filepath = model.get("Filepath")
break
return gr.update(choices=series_choices, value=default_series), filepath
def on_cn_series_change(selected_series, selected_type, arch_val):
cn_full_config = load_diffsynth_controlnet_config()
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
controlnet_key = architectures_dict.get(arch_val, {}).get("controlnet_key", arch_val)
cn_config = cn_full_config.get(controlnet_key, [])
filepath = "None"
if selected_series and selected_type:
for model in cn_config:
if model.get("Series") == selected_series and selected_type in model.get("Type", []):
filepath = model.get("Filepath")
break
return filepath
for i in range(MAX_CONTROLNETS):
cn_types[i].change(
fn=on_cn_type_change,
inputs=[cn_types[i], actual_arch_comp],
outputs=[cn_series[i], cn_filepaths[i]],
show_progress=False
)
cn_series[i].change(
fn=on_cn_series_change,
inputs=[cn_series[i], cn_types[i], actual_arch_comp],
outputs=[cn_filepaths[i]],
show_progress=False
)
def on_accordion_expand(*images):
return [gr.update() for _ in images]
accordion.expand(
fn=on_accordion_expand,
inputs=cn_images,
outputs=cn_images,
show_progress=False
)
def create_flux1_ipadapter_event_handlers(prefix):
fipa_rows = ui_components.get(f'flux1_ipadapter_rows_{prefix}')
if not fipa_rows: return
count_state = ui_components[f'flux1_ipadapter_count_state_{prefix}']
add_button = ui_components[f'add_flux1_ipadapter_button_{prefix}']
del_button = ui_components[f'delete_flux1_ipadapter_button_{prefix}']
def add_fipa_row(c):
c += 1
return {
count_state: c,
fipa_rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < MAX_IPADAPTERS),
del_button: gr.update(visible=True),
}
def del_fipa_row(c):
c -= 1
return {
count_state: c,
fipa_rows[c]: gr.update(visible=False),
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0),
}
add_outputs = [count_state, add_button, del_button] + fipa_rows
del_outputs = [count_state, add_button, del_button] + fipa_rows
add_button.click(fn=add_fipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_fipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_style_event_handlers(prefix):
style_rows = ui_components.get(f'style_rows_{prefix}')
if not style_rows: return
count_state = ui_components[f'style_count_state_{prefix}']
add_button = ui_components[f'add_style_button_{prefix}']
del_button = ui_components[f'delete_style_button_{prefix}']
def add_style_row(c):
c += 1
return {
count_state: c,
style_rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < 5),
del_button: gr.update(visible=True),
}
def del_style_row(c):
c -= 1
return {
count_state: c,
style_rows[c]: gr.update(visible=False),
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0),
}
add_outputs = [count_state, add_button, del_button] + style_rows
del_outputs = [count_state, add_button, del_button] + style_rows
add_button.click(fn=add_style_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_style_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_ipadapter_event_handlers(prefix):
ipa_rows = ui_components.get(f'ipadapter_rows_{prefix}')
if not ipa_rows: return
ipa_lora_strengths = ui_components[f'ipadapter_lora_strengths_{prefix}']
ipa_final_preset = ui_components[f'ipadapter_final_preset_{prefix}']
ipa_final_lora_strength = ui_components[f'ipadapter_final_lora_strength_{prefix}']
count_state = ui_components[f'ipadapter_count_state_{prefix}']
add_button = ui_components[f'add_ipadapter_button_{prefix}']
del_button = ui_components[f'delete_ipadapter_button_{prefix}']
accordion = ui_components[f'ipadapter_accordion_{prefix}']
def add_ipa_row(c):
c += 1
return {
count_state: c,
ipa_rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < MAX_IPADAPTERS),
del_button: gr.update(visible=True),
}
def del_ipa_row(c):
c -= 1
return {
count_state: c,
ipa_rows[c]: gr.update(visible=False),
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0),
}
add_outputs = [count_state, add_button, del_button] + ipa_rows
del_outputs = [count_state, add_button, del_button] + ipa_rows
add_button.click(fn=add_ipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_ipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def on_preset_change(preset_value):
config = load_ipadapter_config()
faceid_presets = []
if config:
faceid_presets.extend(config.get("IPAdapter_FaceID_presets", {}).get("SDXL", []))
faceid_presets.extend(config.get("IPAdapter_FaceID_presets", {}).get("SD1.5", []))
is_visible = preset_value in faceid_presets
updates = [gr.update(visible=is_visible)] * (MAX_IPADAPTERS + 1)
return updates
all_lora_strength_sliders = [ipa_final_lora_strength] + ipa_lora_strengths
ipa_final_preset.change(fn=on_preset_change, inputs=[ipa_final_preset], outputs=all_lora_strength_sliders, show_progress=False)
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)
def create_reference_latent_event_handlers(prefix):
ref_rows = ui_components.get(f'reference_latent_rows_{prefix}')
if not ref_rows: return
count_state = ui_components[f'reference_latent_count_state_{prefix}']
add_button = ui_components[f'add_reference_latent_button_{prefix}']
del_button = ui_components[f'delete_reference_latent_button_{prefix}']
images = ui_components[f'reference_latent_images_{prefix}']
def add_ref_row(c):
c += 1
return {
count_state: c,
ref_rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < 10),
del_button: gr.update(visible=True),
}
def del_ref_row(c):
c -= 1
return {
count_state: c,
ref_rows[c]: gr.update(visible=False),
images[c]: None,
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0),
}
add_outputs = [count_state, add_button, del_button] + ref_rows
del_outputs = [count_state, add_button, del_button] + ref_rows + images
add_button.click(fn=add_ref_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_embedding_event_handlers(prefix):
rows = ui_components.get(f'embedding_rows_{prefix}')
if not rows: return
ids = ui_components[f'embeddings_ids_{prefix}']
files = ui_components[f'embeddings_files_{prefix}']
count_state = ui_components[f'embedding_count_state_{prefix}']
add_button = ui_components[f'add_embedding_button_{prefix}']
del_button = ui_components[f'delete_embedding_button_{prefix}']
def add_row(c):
c += 1
return {
count_state: c,
rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < MAX_EMBEDDINGS),
del_button: gr.update(visible=True)
}
def del_row(c):
c -= 1
return {
count_state: c,
rows[c]: gr.update(visible=False),
ids[c]: "",
files[c]: None,
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0)
}
add_outputs = [count_state, add_button, del_button] + rows
del_outputs = [count_state, add_button, del_button] + rows + ids + files
add_button.click(fn=add_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_conditioning_event_handlers(prefix):
rows = ui_components.get(f'conditioning_rows_{prefix}')
if not rows: return
prompts = ui_components[f'conditioning_prompts_{prefix}']
count_state = ui_components[f'conditioning_count_state_{prefix}']
add_button = ui_components[f'add_conditioning_button_{prefix}']
del_button = ui_components[f'delete_conditioning_button_{prefix}']
def add_row(c):
c += 1
return {
count_state: c,
rows[c - 1]: gr.update(visible=True),
add_button: gr.update(visible=c < MAX_CONDITIONINGS),
del_button: gr.update(visible=True),
}
def del_row(c):
c -= 1
return {
count_state: c,
rows[c]: gr.update(visible=False),
prompts[c]: "",
add_button: gr.update(visible=True),
del_button: gr.update(visible=c > 0),
}
add_outputs = [count_state, add_button, del_button] + rows
del_outputs = [count_state, add_button, del_button] + rows + prompts
add_button.click(fn=add_row, inputs=[count_state], outputs=add_outputs, show_progress=False)
del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def on_vae_upload(file_obj):
if not file_obj:
return gr.update(), gr.update(), None
hashed_filename = save_uploaded_file_with_hash(file_obj, VAE_DIR)
return hashed_filename, "File", file_obj
def on_lora_upload(file_obj):
if not file_obj:
return gr.update(), gr.update()
hashed_filename = save_uploaded_file_with_hash(file_obj, LORA_DIR)
return hashed_filename, "File"
def on_embedding_upload(file_obj):
if not file_obj:
return gr.update(), gr.update(), None
hashed_filename = save_uploaded_file_with_hash(file_obj, EMBEDDING_DIR)
return hashed_filename, "File", file_obj
def create_run_event(prefix: str, task_type: str):
run_inputs_map = {
'model_display_name': ui_components[f'base_model_{prefix}'],
'positive_prompt': ui_components.get(f'prompt_{prefix}') or ui_components.get(f'{prefix}_positive_prompt'),
'negative_prompt': ui_components.get(f'neg_prompt_{prefix}') or ui_components.get(f'{prefix}_negative_prompt'),
'seed': ui_components.get(f'seed_{prefix}') or ui_components.get(f'{prefix}_seed'),
'batch_size': ui_components.get(f'batch_size_{prefix}') or ui_components.get(f'{prefix}_batch_size'),
'guidance_scale': ui_components.get(f'cfg_{prefix}') or ui_components.get(f'{prefix}_cfg'),
'num_inference_steps': ui_components.get(f'steps_{prefix}') or ui_components.get(f'{prefix}_steps'),
'sampler': ui_components.get(f'sampler_{prefix}') or ui_components.get(f'{prefix}_sampler_name'),
'scheduler': ui_components.get(f'scheduler_{prefix}') or ui_components.get(f'{prefix}_scheduler'),
'zero_gpu_duration': ui_components.get(f'zero_gpu_{prefix}'),
'clip_skip': ui_components.get(f'clip_skip_{prefix}'),
'guidance': ui_components.get(f'guidance_{prefix}'),
'task_type': gr.State(task_type)
}
if task_type not in ['img2img', 'inpaint']:
run_inputs_map.update({
'width': ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width'),
'height': ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
})
task_specific_map = {
'img2img': {'img2img_image': f'input_image_{prefix}', 'img2img_denoise': f'denoise_{prefix}'},
'inpaint': {'inpaint_image_dict': f'input_image_dict_{prefix}', 'grow_mask_by': f'grow_mask_by_{prefix}'},
'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}'},
'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}'}
}
if task_type in task_specific_map:
for key, comp_name in task_specific_map[task_type].items():
if comp_name in ui_components:
run_inputs_map[key] = ui_components[comp_name]
lora_data_components = ui_components.get(f'all_lora_components_flat_{prefix}', [])
controlnet_data_components = ui_components.get(f'all_controlnet_components_flat_{prefix}', [])
diffsynth_controlnet_data_components = ui_components.get(f'all_diffsynth_controlnet_components_flat_{prefix}', [])
ipadapter_data_components = ui_components.get(f'all_ipadapter_components_flat_{prefix}', [])
sd3_ipadapter_data_components = ui_components.get(f'all_sd3_ipadapter_components_flat_{prefix}', [])
flux1_ipadapter_data_components = ui_components.get(f'all_flux1_ipadapter_components_flat_{prefix}', [])
style_data_components = ui_components.get(f'all_style_components_flat_{prefix}', [])
embedding_data_components = ui_components.get(f'all_embedding_components_flat_{prefix}', [])
conditioning_data_components = ui_components.get(f'all_conditioning_components_flat_{prefix}', [])
reference_latent_data_components = ui_components.get(f'all_reference_latent_components_flat_{prefix}', [])
run_inputs_map['vae_source'] = ui_components.get(f'vae_source_{prefix}')
run_inputs_map['vae_id'] = ui_components.get(f'vae_id_{prefix}')
run_inputs_map['vae_file'] = ui_components.get(f'vae_file_{prefix}')
input_keys = list(run_inputs_map.keys())
input_list_flat = [v for v in run_inputs_map.values() if v is not None]
all_chains = [
lora_data_components, controlnet_data_components, diffsynth_controlnet_data_components, ipadapter_data_components,
sd3_ipadapter_data_components, flux1_ipadapter_data_components, style_data_components,
embedding_data_components, conditioning_data_components, reference_latent_data_components
]
for chain in all_chains:
if chain:
input_list_flat.extend(chain)
def create_ui_inputs_dict(*args):
valid_keys = [k for k in input_keys if run_inputs_map[k] is not None]
ui_dict = dict(zip(valid_keys, args[:len(valid_keys)]))
arg_idx = len(valid_keys)
def assign_chain_data(chain_key, components_list):
nonlocal arg_idx
if components_list:
ui_dict[chain_key] = list(args[arg_idx : arg_idx + len(components_list)])
arg_idx += len(components_list)
assign_chain_data('lora_data', lora_data_components)
assign_chain_data('controlnet_data', controlnet_data_components)
assign_chain_data('diffsynth_controlnet_data', diffsynth_controlnet_data_components)
assign_chain_data('ipadapter_data', ipadapter_data_components)
assign_chain_data('sd3_ipadapter_chain', sd3_ipadapter_data_components)
assign_chain_data('flux1_ipadapter_data', flux1_ipadapter_data_components)
assign_chain_data('style_data', style_data_components)
assign_chain_data('embedding_data', embedding_data_components)
assign_chain_data('conditioning_data', conditioning_data_components)
assign_chain_data('reference_latent_data', reference_latent_data_components)
return ui_dict
run_btn = ui_components.get(f'run_{prefix}') or ui_components.get(f'{prefix}_run_button')
res_gal = ui_components.get(f'result_{prefix}') or ui_components.get(f'{prefix}_output_gallery')
if run_btn and res_gal:
run_btn.click(
fn=lambda *args, progress=gr.Progress(track_tqdm=True): generate_image_wrapper(create_ui_inputs_dict(*args), progress),
inputs=input_list_flat,
outputs=[res_gal]
)
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):
def update_fn(*args):
arch = args[0]
category = args[1]
current_ar = args[2] if len(args) > 2 else None
from core.settings import MODEL_TYPE_MAP, MODEL_MAP_CHECKPOINT, FEATURES_CONFIG, ARCHITECTURES_CONFIG, MODEL_DEFAULTS_CONFIG, ARCH_CATEGORIES_MAP
from utils.app_utils import get_model_generation_defaults
if arch == "ALL":
valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
else:
valid_cats = ARCH_CATEGORIES_MAP.get(arch, [])
cat_choices = ["ALL"] + sorted(valid_cats)
new_category = category if category in cat_choices else "ALL"
choices = []
for name, info in MODEL_MAP_CHECKPOINT.items():
m_arch = info[2]
m_cat = info[4] if len(info) > 4 else None
arch_match = (arch == "ALL" or m_arch == arch)
cat_match = (new_category == "ALL" or m_cat == new_category)
if arch_match and cat_match:
choices.append(name)
val = choices[0] if choices else None
updates = {
m_comp: gr.update(choices=choices, value=val),
cat_comp: gr.update(choices=cat_choices, value=new_category)
}
m_type = MODEL_TYPE_MAP.get(val, "SDXL") if val else "SDXL"
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {}))
enabled_chains = arch_features.get('enabled_chains', [])
if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains))
if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains))
if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains))
if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains))
if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains))
if cs_comp:
updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15"))
if guidance_comp:
updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1"))
if ar_comp:
res_key = arch_model_type
if res_key not in RESOLUTION_MAP:
res_key = 'sdxl'
res_map = RESOLUTION_MAP.get(res_key, {})
target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)")
updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar)
if width_comp and height_comp and target_ar in res_map:
updates[width_comp] = gr.update(value=res_map[target_ar][0])
updates[height_comp] = gr.update(value=res_map[target_ar][1])
controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
for t_comp in cn_types:
updates[t_comp] = gr.update(choices=all_types, value=default_type)
for s_comp in cn_series:
updates[s_comp] = gr.update(choices=series_choices, value=default_series)
for f_comp in cn_filepaths:
updates[f_comp] = filepath
diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
for t_comp in diffsynth_cn_types:
updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
for s_comp in diffsynth_cn_series:
updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
for f_comp in diffsynth_cn_filepaths:
updates[f_comp] = diffsynth_filepath
if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
config = load_ipadapter_config()
ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
all_ipa_presets = std_presets + face_presets
default_ipa = all_ipa_presets[0] if all_ipa_presets else None
updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa)
defaults = get_model_generation_defaults(val, arch_model_type, MODEL_DEFAULTS_CONFIG)
if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps'))
if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg'))
if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name'))
if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler'))
if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt'))
if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt'))
return updates
return update_fn
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):
def change_fn(*args):
model_name = args[0]
idx = 1
current_arch = args[idx] if arch_comp_ref and idx < len(args) else None
if arch_comp_ref: idx += 1
current_cat = args[idx] if cat_comp_ref and idx < len(args) else None
if cat_comp_ref: idx += 1
current_ar = args[idx] if idx < len(args) else None
from core.settings import MODEL_TYPE_MAP, FEATURES_CONFIG, ARCHITECTURES_CONFIG, MODEL_DEFAULTS_CONFIG, ARCH_CATEGORIES_MAP, MODEL_MAP_CHECKPOINT
from utils.app_utils import get_model_generation_defaults
m_type = MODEL_TYPE_MAP.get(model_name, "SDXL")
m_info = MODEL_MAP_CHECKPOINT.get(model_name)
m_cat = m_info[4] if m_info and len(m_info) > 4 else None
if not m_cat: m_cat = "ALL"
updates = {}
target_arch = m_type
if arch_comp_ref:
if current_arch == "ALL":
updates[arch_comp_ref] = gr.update()
target_arch = "ALL"
else:
updates[arch_comp_ref] = m_type
if cat_comp_ref:
if target_arch == "ALL":
valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats))
else:
valid_cats = ARCH_CATEGORIES_MAP.get(target_arch, [])
cat_choices = ["ALL"] + sorted(valid_cats)
if current_cat == "ALL":
updates[cat_comp_ref] = gr.update(choices=cat_choices)
else:
updates[cat_comp_ref] = gr.update(choices=cat_choices, value=m_cat)
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {}))
enabled_chains = arch_features.get('enabled_chains', [])
if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains))
if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains))
if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains))
if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains))
if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains))
if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains))
if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains))
if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains))
if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains))
if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains))
if cs_comp:
updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15"))
if guidance_comp:
updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1"))
if ar_comp:
res_key = arch_model_type
if res_key not in RESOLUTION_MAP:
res_key = 'sdxl'
res_map = RESOLUTION_MAP.get(res_key, {})
target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)")
updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar)
if width_comp and height_comp and target_ar in res_map:
updates[width_comp] = gr.update(value=res_map[target_ar][0])
updates[height_comp] = gr.update(value=res_map[target_ar][1])
controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
for t_comp in cn_types:
updates[t_comp] = gr.update(choices=all_types, value=default_type)
for s_comp in cn_series:
updates[s_comp] = gr.update(choices=series_choices, value=default_series)
for f_comp in cn_filepaths:
updates[f_comp] = filepath
diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
for t_comp in diffsynth_cn_types:
updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
for s_comp in diffsynth_cn_series:
updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
for f_comp in diffsynth_cn_filepaths:
updates[f_comp] = diffsynth_filepath
if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]):
config = load_ipadapter_config()
ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
all_ipa_presets = std_presets + face_presets
default_ipa = all_ipa_presets[0] if all_ipa_presets else None
updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa)
defaults = get_model_generation_defaults(model_name, arch_model_type, MODEL_DEFAULTS_CONFIG)
if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps'))
if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg'))
if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name'))
if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler'))
if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt'))
if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt'))
return updates
return change_fn
for prefix, task_type in [
("txt2img", "txt2img"), ("img2img", "img2img"), ("inpaint", "inpaint"),
("outpaint", "outpaint"), ("hires_fix", "hires_fix"),
]:
arch_comp = ui_components.get(f'model_arch_{prefix}')
cat_comp = ui_components.get(f'model_cat_{prefix}')
model_comp = ui_components.get(f'base_model_{prefix}')
clip_skip_comp = ui_components.get(f'clip_skip_{prefix}') or ui_components.get(f'{prefix}_clip_skip')
guidance_comp = ui_components.get(f'guidance_{prefix}') or ui_components.get(f'{prefix}_guidance')
aspect_ratio_comp = ui_components.get(f'aspect_ratio_{prefix}') or ui_components.get(f'{prefix}_aspect_ratio_dropdown')
width_comp = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
height_comp = ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
cn_types_list = ui_components.get(f'controlnet_types_{prefix}', [])
cn_series_list = ui_components.get(f'controlnet_series_{prefix}', [])
cn_filepaths_list = ui_components.get(f'controlnet_filepaths_{prefix}', [])
diffsynth_cn_types_list = ui_components.get(f'diffsynth_controlnet_types_{prefix}', [])
diffsynth_cn_series_list = ui_components.get(f'diffsynth_controlnet_series_{prefix}', [])
diffsynth_cn_filepaths_list = ui_components.get(f'diffsynth_controlnet_filepaths_{prefix}', [])
lora_accordion = ui_components.get(f'lora_accordion_{prefix}')
cn_accordion = ui_components.get(f'controlnet_accordion_{prefix}')
diffsynth_cn_accordion = ui_components.get(f'diffsynth_controlnet_accordion_{prefix}')
ipa_accordion = ui_components.get(f'ipadapter_accordion_{prefix}')
sd3_ipa_accordion = ui_components.get(f'sd3_ipadapter_accordion_{prefix}')
flux1_ipa_accordion = ui_components.get(f'flux1_ipadapter_accordion_{prefix}')
style_accordion = ui_components.get(f'style_accordion_{prefix}')
embedding_accordion = ui_components.get(f'embedding_accordion_{prefix}')
conditioning_accordion = ui_components.get(f'conditioning_accordion_{prefix}')
ref_latent_accordion = ui_components.get(f'reference_latent_accordion_{prefix}')
ipa_preset_list = ui_components.get(f'ipadapter_final_preset_{prefix}')
prompt_comp = ui_components.get(f'prompt_{prefix}') or ui_components.get(f'{prefix}_positive_prompt')
neg_prompt_comp = ui_components.get(f'neg_prompt_{prefix}') or ui_components.get(f'{prefix}_negative_prompt')
steps_comp = ui_components.get(f'steps_{prefix}') or ui_components.get(f'{prefix}_steps')
cfg_comp = ui_components.get(f'cfg_{prefix}') or ui_components.get(f'{prefix}_cfg')
sampler_comp = ui_components.get(f'sampler_{prefix}') or ui_components.get(f'{prefix}_sampler_name')
scheduler_comp = ui_components.get(f'scheduler_{prefix}') or ui_components.get(f'{prefix}_scheduler')
extra_comps = [prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, width_comp, height_comp]
valid_extra_comps = [c for c in extra_comps if c is not None]
if arch_comp and cat_comp and model_comp:
outputs = [model_comp, cat_comp]
if clip_skip_comp: outputs.append(clip_skip_comp)
if guidance_comp: outputs.append(guidance_comp)
if aspect_ratio_comp: outputs.append(aspect_ratio_comp)
outputs.extend(cn_types_list + cn_series_list + cn_filepaths_list)
outputs.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
if lora_accordion: outputs.append(lora_accordion)
if cn_accordion: outputs.append(cn_accordion)
if diffsynth_cn_accordion: outputs.append(diffsynth_cn_accordion)
if ipa_accordion: outputs.append(ipa_accordion)
if sd3_ipa_accordion: outputs.append(sd3_ipa_accordion)
if flux1_ipa_accordion: outputs.append(flux1_ipa_accordion)
if style_accordion: outputs.append(style_accordion)
if embedding_accordion: outputs.append(embedding_accordion)
if conditioning_accordion: outputs.append(conditioning_accordion)
if ref_latent_accordion: outputs.append(ref_latent_accordion)
if ipa_preset_list: outputs.append(ipa_preset_list)
outputs.extend(valid_extra_comps)
update_fn = make_update_fn(
model_comp, cat_comp, clip_skip_comp, aspect_ratio_comp, width_comp, height_comp,
cn_types_list, cn_series_list, cn_filepaths_list,
diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
ipa_preset_list, lora_accordion, cn_accordion, diffsynth_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
ref_latent_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp
)
inputs = [arch_comp, cat_comp]
if aspect_ratio_comp:
inputs.append(aspect_ratio_comp)
arch_comp.change(fn=update_fn, inputs=inputs, outputs=outputs)
cat_comp.change(fn=update_fn, inputs=inputs, outputs=outputs)
if model_comp:
outputs2 = []
if arch_comp: outputs2.append(arch_comp)
if cat_comp: outputs2.append(cat_comp)
if clip_skip_comp: outputs2.append(clip_skip_comp)
if guidance_comp: outputs2.append(guidance_comp)
if aspect_ratio_comp: outputs2.append(aspect_ratio_comp)
outputs2.extend(cn_types_list + cn_series_list + cn_filepaths_list)
outputs2.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list)
if lora_accordion: outputs2.append(lora_accordion)
if cn_accordion: outputs2.append(cn_accordion)
if diffsynth_cn_accordion: outputs2.append(diffsynth_cn_accordion)
if ipa_accordion: outputs2.append(ipa_accordion)
if sd3_ipa_accordion: outputs2.append(sd3_ipa_accordion)
if flux1_ipa_accordion: outputs2.append(flux1_ipa_accordion)
if style_accordion: outputs2.append(style_accordion)
if embedding_accordion: outputs2.append(embedding_accordion)
if conditioning_accordion: outputs2.append(conditioning_accordion)
if ref_latent_accordion: outputs2.append(ref_latent_accordion)
if ipa_preset_list: outputs2.append(ipa_preset_list)
outputs2.extend(valid_extra_comps)
if outputs2:
inputs2 = [model_comp]
if arch_comp: inputs2.append(arch_comp)
if cat_comp: inputs2.append(cat_comp)
if aspect_ratio_comp: inputs2.append(aspect_ratio_comp)
change_fn = make_model_change_fn(
cat_comp, clip_skip_comp, aspect_ratio_comp, width_comp, height_comp,
cn_types_list, cn_series_list, cn_filepaths_list,
diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list,
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,
ref_latent_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp
)
model_comp.change(fn=change_fn, inputs=inputs2, outputs=outputs2)
create_lora_event_handlers(prefix)
create_controlnet_event_handlers(prefix)
create_diffsynth_controlnet_event_handlers(prefix)
create_ipadapter_event_handlers(prefix)
create_embedding_event_handlers(prefix)
create_conditioning_event_handlers(prefix)
create_flux1_ipadapter_event_handlers(prefix)
create_style_event_handlers(prefix)
create_reference_latent_event_handlers(prefix)
create_run_event(prefix, task_type)
if 'view_mode_inpaint' in ui_components:
def toggle_inpaint_fullscreen_view(view_mode):
is_fullscreen = (view_mode == "Fullscreen View")
other_elements_visible = not is_fullscreen
editor_height = 800 if is_fullscreen else 272
updates = {
ui_components['prompts_column_inpaint']: gr.update(visible=other_elements_visible),
ui_components['params_and_gallery_row_inpaint']: gr.update(visible=other_elements_visible),
ui_components['accordion_wrapper_inpaint']: gr.update(visible=other_elements_visible),
ui_components['input_image_dict_inpaint']: gr.update(height=editor_height),
}
model_and_run_rows = ui_components.get('model_and_run_row_inpaint', [])
for row in model_and_run_rows:
updates[row] = gr.update(visible=other_elements_visible)
return updates
output_components = []
model_and_run_rows = ui_components.get('model_and_run_row_inpaint', [])
if isinstance(model_and_run_rows, list):
output_components.extend(model_and_run_rows)
else:
output_components.append(model_and_run_rows)
output_components.extend([
ui_components['prompts_column_inpaint'],
ui_components['params_and_gallery_row_inpaint'],
ui_components['accordion_wrapper_inpaint'],
ui_components['input_image_dict_inpaint']
])
ui_components['view_mode_inpaint'].change(
fn=toggle_inpaint_fullscreen_view,
inputs=[ui_components['view_mode_inpaint']],
outputs=output_components,
show_progress=False
)
def initialize_all_cn_dropdowns():
from core.settings import MODEL_TYPE_MAP, MODEL_MAP_CHECKPOINT, ARCHITECTURES_CONFIG
default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
controlnet_key = architectures_dict.get(default_m_type, {}).get("controlnet_key", default_m_type)
all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key)
diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key)
updates = {}
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
if f'controlnet_types_{prefix}' in ui_components:
for type_dd in ui_components[f'controlnet_types_{prefix}']:
updates[type_dd] = gr.update(choices=all_types, value=default_type)
for series_dd in ui_components[f'controlnet_series_{prefix}']:
updates[series_dd] = gr.update(choices=series_choices, value=default_series)
for filepath_state in ui_components[f'controlnet_filepaths_{prefix}']:
updates[filepath_state] = filepath
if f'diffsynth_controlnet_types_{prefix}' in ui_components:
for type_dd in ui_components[f'diffsynth_controlnet_types_{prefix}']:
updates[type_dd] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type)
for series_dd in ui_components[f'diffsynth_controlnet_series_{prefix}']:
updates[series_dd] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series)
for filepath_state in ui_components[f'diffsynth_controlnet_filepaths_{prefix}']:
updates[filepath_state] = diffsynth_filepath
return updates
def initialize_all_ipa_dropdowns():
config = load_ipadapter_config()
if not config: return {}
from core.settings import MODEL_TYPE_MAP, MODEL_MAP_CHECKPOINT, ARCHITECTURES_CONFIG
default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None
default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(default_m_type, {}).get("model_type", default_m_type.lower().replace(" ", "").replace(".", ""))
ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
unified_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, [])
faceid_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, [])
all_presets = unified_presets + faceid_presets
default_preset = all_presets[0] if all_presets else None
is_faceid_default = default_preset in faceid_presets
lora_strength_update = gr.update(visible=is_faceid_default)
updates = {}
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
if f'ipadapter_final_preset_{prefix}' in ui_components:
for lora_strength_slider in ui_components[f'ipadapter_lora_strengths_{prefix}']:
updates[lora_strength_slider] = lora_strength_update
updates[ui_components[f'ipadapter_final_preset_{prefix}']] = gr.update(choices=all_presets, value=default_preset)
updates[ui_components[f'ipadapter_final_lora_strength_{prefix}']] = lora_strength_update
return updates
def run_on_load():
cn_updates = initialize_all_cn_dropdowns()
ipa_updates = initialize_all_ipa_dropdowns()
all_updates = {**cn_updates, **ipa_updates}
return all_updates
all_load_outputs = []
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
if f'controlnet_types_{prefix}' in ui_components:
all_load_outputs.extend(ui_components[f'controlnet_types_{prefix}'])
all_load_outputs.extend(ui_components[f'controlnet_series_{prefix}'])
all_load_outputs.extend(ui_components[f'controlnet_filepaths_{prefix}'])
if f'diffsynth_controlnet_types_{prefix}' in ui_components:
all_load_outputs.extend(ui_components[f'diffsynth_controlnet_types_{prefix}'])
all_load_outputs.extend(ui_components[f'diffsynth_controlnet_series_{prefix}'])
all_load_outputs.extend(ui_components[f'diffsynth_controlnet_filepaths_{prefix}'])
if f'ipadapter_final_preset_{prefix}' in ui_components:
all_load_outputs.extend(ui_components[f'ipadapter_lora_strengths_{prefix}'])
all_load_outputs.append(ui_components[f'ipadapter_final_preset_{prefix}'])
all_load_outputs.append(ui_components[f'ipadapter_final_lora_strength_{prefix}'])
if all_load_outputs:
demo.load(
fn=run_on_load,
outputs=all_load_outputs
)
def on_aspect_ratio_change(ratio_key, model_display_name):
from core.settings import MODEL_TYPE_MAP, ARCHITECTURES_CONFIG
m_type = MODEL_TYPE_MAP.get(model_display_name, 'SDXL')
architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {})
arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
res_map = RESOLUTION_MAP.get(arch_model_type, RESOLUTION_MAP.get("sdxl", {}))
w, h = res_map.get(ratio_key, (1024, 1024))
return w, h
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]:
aspect_ratio_dropdown = ui_components.get(f'aspect_ratio_{prefix}') or ui_components.get(f'{prefix}_aspect_ratio_dropdown')
width_component = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
height_component = ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height')
model_dropdown = ui_components.get(f'base_model_{prefix}')
if aspect_ratio_dropdown and width_component and height_component and model_dropdown:
aspect_ratio_dropdown.change(fn=on_aspect_ratio_change, inputs=[aspect_ratio_dropdown, model_dropdown], outputs=[width_component, height_component], show_progress=False)12345678910from .main import attach_event_handlersfrom .config_loaders import ( load_controlnet_config, get_cn_defaults, load_anima_controlnet_lllite_config, get_anima_cn_defaults, load_diffsynth_controlnet_config, get_diffsynth_cn_defaults, load_ipadapter_config)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680import gradio as grfrom core.settings import VAE_DIR, LORA_DIR, EMBEDDING_DIR, ARCHITECTURES_CONFIGfrom utils.app_utils import save_uploaded_file_with_hashfrom ui.shared.ui_components import ( MAX_CONTROLNETS, MAX_IPADAPTERS, MAX_EMBEDDINGS, MAX_CONDITIONINGS, MAX_LORAS)from .config_loaders import ( load_controlnet_config, load_anima_controlnet_lllite_config, load_diffsynth_controlnet_config, load_ipadapter_config)
def on_vae_upload(file_obj): if not file_obj: return gr.update(), gr.update(), None hashed_filename = save_uploaded_file_with_hash(file_obj, VAE_DIR) return hashed_filename, "File", file_obj
def on_lora_upload(file_obj): if not file_obj: return gr.update(), gr.update() hashed_filename = save_uploaded_file_with_hash(file_obj, LORA_DIR) return hashed_filename, "File"
def on_embedding_upload(file_obj): if not file_obj: return gr.update(), gr.update(), None hashed_filename = save_uploaded_file_with_hash(file_obj, EMBEDDING_DIR) return hashed_filename, "File", file_obj
def create_lora_event_handlers(prefix, ui_components): lora_rows = ui_components.get(f'lora_rows_{prefix}') if not lora_rows: return lora_ids = ui_components[f'lora_ids_{prefix}'] lora_scales = ui_components[f'lora_scales_{prefix}'] lora_uploads = ui_components[f'lora_uploads_{prefix}'] count_state = ui_components[f'lora_count_state_{prefix}'] add_button = ui_components[f'add_lora_button_{prefix}'] del_button = ui_components[f'delete_lora_button_{prefix}']
def add_lora_row(c): updates = {} if c < MAX_LORAS: c += 1 updates[lora_rows[c - 1]] = gr.update(visible=True) updates[count_state] = c updates[add_button] = gr.update(visible=c < MAX_LORAS) updates[del_button] = gr.update(visible=c > 1) return updates
def del_lora_row(c): updates = {} if c > 1: updates[lora_rows[c - 1]] = gr.update(visible=False) updates[lora_ids[c - 1]] = "" updates[lora_scales[c - 1]] = 0.0 updates[lora_uploads[c - 1]] = None c -= 1
updates[count_state] = c updates[add_button] = gr.update(visible=True) updates[del_button] = gr.update(visible=c > 1) return updates add_outputs = [count_state, add_button, del_button] + lora_rows del_outputs = [count_state, add_button, del_button] + lora_rows + lora_ids + lora_scales + lora_uploads
add_button.click(add_lora_row, [count_state], add_outputs, show_progress=False) del_button.click(del_lora_row, [count_state], del_outputs, show_progress=False)
def create_controlnet_event_handlers(prefix, ui_components): cn_rows = ui_components.get(f'controlnet_rows_{prefix}') if not cn_rows: return cn_types = ui_components[f'controlnet_types_{prefix}'] cn_series = ui_components[f'controlnet_series_{prefix}'] cn_filepaths = ui_components[f'controlnet_filepaths_{prefix}'] cn_images = ui_components[f'controlnet_images_{prefix}'] cn_strengths = ui_components[f'controlnet_strengths_{prefix}'] count_state = ui_components[f'controlnet_count_state_{prefix}'] add_button = ui_components[f'add_controlnet_button_{prefix}'] del_button = ui_components[f'delete_controlnet_button_{prefix}'] accordion = ui_components[f'controlnet_accordion_{prefix}']
base_model_comp = ui_components.get(f'base_model_{prefix}') actual_arch_comp = base_model_comp if base_model_comp else gr.State("SDXL")
def add_cn_row(c): c += 1 updates = { count_state: c, cn_rows[c-1]: gr.update(visible=True), add_button: gr.update(visible=c < MAX_CONTROLNETS), del_button: gr.update(visible=True) } return updates
def del_cn_row(c): c -= 1 updates = { count_state: c, cn_rows[c]: gr.update(visible=False), cn_images[c]: None, cn_strengths[c]: 1.0, add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0) } return updates add_outputs = [count_state, add_button, del_button] + cn_rows del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False) def on_cn_type_change(selected_type, model_name): from core.settings import MODEL_TYPE_MAP m_type = MODEL_TYPE_MAP.get(model_name, "SDXL") if model_name else "SDXL" cn_full_config = load_controlnet_config() architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
cn_config = cn_full_config.get(controlnet_key, []) series_choices = [] if selected_type: series_choices = sorted(list(set( model.get("Series", "Default") for model in cn_config if selected_type in model.get("Type", []) ))) default_series = series_choices[0] if series_choices else None filepath = "None" if default_series: for model in cn_config: if model.get("Series") == default_series and selected_type in model.get("Type", []): filepath = model.get("Filepath") break return gr.update(choices=series_choices, value=default_series), filepath
def on_cn_series_change(selected_series, selected_type, model_name): from core.settings import MODEL_TYPE_MAP m_type = MODEL_TYPE_MAP.get(model_name, "SDXL") if model_name else "SDXL" cn_full_config = load_controlnet_config() architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
cn_config = cn_full_config.get(controlnet_key, []) filepath = "None" if selected_series and selected_type: for model in cn_config: if model.get("Series") == selected_series and selected_type in model.get("Type", []): filepath = model.get("Filepath") break return filepath for i in range(MAX_CONTROLNETS): cn_types[i].change( fn=on_cn_type_change, inputs=[cn_types[i], actual_arch_comp], outputs=[cn_series[i], cn_filepaths[i]], show_progress=False ) cn_series[i].change( fn=on_cn_series_change, inputs=[cn_series[i], cn_types[i], actual_arch_comp], outputs=[cn_filepaths[i]], show_progress=False )
def on_accordion_expand(*images): return [gr.update() for _ in images] accordion.expand( fn=on_accordion_expand, inputs=cn_images, outputs=cn_images, show_progress=False )
def create_anima_controlnet_lllite_event_handlers(prefix, ui_components): cn_rows = ui_components.get(f'anima_controlnet_lllite_rows_{prefix}') if not cn_rows: return cn_types = ui_components[f'anima_controlnet_lllite_types_{prefix}'] cn_series = ui_components[f'anima_controlnet_lllite_series_{prefix}'] cn_filepaths = ui_components[f'anima_controlnet_lllite_filepaths_{prefix}'] cn_images = ui_components[f'anima_controlnet_lllite_images_{prefix}'] cn_strengths = ui_components[f'anima_controlnet_lllite_strengths_{prefix}'] count_state = ui_components[f'anima_controlnet_lllite_count_state_{prefix}'] add_button = ui_components[f'add_anima_controlnet_lllite_button_{prefix}'] del_button = ui_components[f'delete_anima_controlnet_lllite_button_{prefix}'] accordion = ui_components[f'anima_controlnet_lllite_accordion_{prefix}']
def add_cn_row(c): c += 1 updates = { count_state: c, cn_rows[c-1]: gr.update(visible=True), add_button: gr.update(visible=c < MAX_CONTROLNETS), del_button: gr.update(visible=True) } return updates
def del_cn_row(c): c -= 1 updates = { count_state: c, cn_rows[c]: gr.update(visible=False), cn_images[c]: None, cn_strengths[c]: 1.0, add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0) } return updates add_outputs = [count_state, add_button, del_button] + cn_rows del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False) def on_cn_type_change(selected_type): cn_config = load_anima_controlnet_lllite_config() series_choices = [] if selected_type: series_choices = sorted(list(set( model.get("Series", "Default") for model in cn_config if selected_type in model.get("Type", []) ))) default_series = series_choices[0] if series_choices else None filepath = "None" if default_series: for model in cn_config: if model.get("Series") == default_series and selected_type in model.get("Type", []): filepath = model.get("Filepath") break return gr.update(choices=series_choices, value=default_series), filepath
def on_cn_series_change(selected_series, selected_type): cn_config = load_anima_controlnet_lllite_config() filepath = "None" if selected_series and selected_type: for model in cn_config: if model.get("Series") == selected_series and selected_type in model.get("Type", []): filepath = model.get("Filepath") break return filepath for i in range(MAX_CONTROLNETS): cn_types[i].change( fn=on_cn_type_change, inputs=[cn_types[i]], outputs=[cn_series[i], cn_filepaths[i]], show_progress=False ) cn_series[i].change( fn=on_cn_series_change, inputs=[cn_series[i], cn_types[i]], outputs=[cn_filepaths[i]], show_progress=False )
def on_accordion_expand(*images): return [gr.update() for _ in images] accordion.expand( fn=on_accordion_expand, inputs=cn_images, outputs=cn_images, show_progress=False )
def create_diffsynth_controlnet_event_handlers(prefix, ui_components): cn_rows = ui_components.get(f'diffsynth_controlnet_rows_{prefix}') if not cn_rows: return cn_types = ui_components[f'diffsynth_controlnet_types_{prefix}'] cn_series = ui_components[f'diffsynth_controlnet_series_{prefix}'] cn_filepaths = ui_components[f'diffsynth_controlnet_filepaths_{prefix}'] cn_images = ui_components[f'diffsynth_controlnet_images_{prefix}'] cn_strengths = ui_components[f'diffsynth_controlnet_strengths_{prefix}'] count_state = ui_components[f'diffsynth_controlnet_count_state_{prefix}'] add_button = ui_components[f'add_diffsynth_controlnet_button_{prefix}'] del_button = ui_components[f'delete_diffsynth_controlnet_button_{prefix}'] accordion = ui_components[f'diffsynth_controlnet_accordion_{prefix}']
base_model_comp = ui_components.get(f'base_model_{prefix}') actual_arch_comp = base_model_comp if base_model_comp else gr.State("SDXL")
def add_cn_row(c): c += 1 updates = { count_state: c, cn_rows[c-1]: gr.update(visible=True), add_button: gr.update(visible=c < MAX_CONTROLNETS), del_button: gr.update(visible=True) } return updates
def del_cn_row(c): c -= 1 updates = { count_state: c, cn_rows[c]: gr.update(visible=False), cn_images[c]: None, cn_strengths[c]: 1.0, add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0) } return updates add_outputs = [count_state, add_button, del_button] + cn_rows del_outputs = [count_state, add_button, del_button] + cn_rows + cn_images + cn_strengths add_button.click(fn=add_cn_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_cn_row, inputs=[count_state], outputs=del_outputs, show_progress=False) def on_cn_type_change(selected_type, model_name): from core.settings import MODEL_TYPE_MAP m_type = MODEL_TYPE_MAP.get(model_name, "SDXL") if model_name else "SDXL" cn_full_config = load_diffsynth_controlnet_config() architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
cn_config = cn_full_config.get(controlnet_key, []) series_choices = [] if selected_type: series_choices = sorted(list(set( model.get("Series", "Default") for model in cn_config if selected_type in model.get("Type", []) ))) default_series = series_choices[0] if series_choices else None filepath = "None" if default_series: for model in cn_config: if model.get("Series") == default_series and selected_type in model.get("Type", []): filepath = model.get("Filepath") break return gr.update(choices=series_choices, value=default_series), filepath
def on_cn_series_change(selected_series, selected_type, model_name): from core.settings import MODEL_TYPE_MAP m_type = MODEL_TYPE_MAP.get(model_name, "SDXL") if model_name else "SDXL" cn_full_config = load_diffsynth_controlnet_config() architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type)
cn_config = cn_full_config.get(controlnet_key, []) filepath = "None" if selected_series and selected_type: for model in cn_config: if model.get("Series") == selected_series and selected_type in model.get("Type", []): filepath = model.get("Filepath") break return filepath for i in range(MAX_CONTROLNETS): cn_types[i].change( fn=on_cn_type_change, inputs=[cn_types[i], actual_arch_comp], outputs=[cn_series[i], cn_filepaths[i]], show_progress=False ) cn_series[i].change( fn=on_cn_series_change, inputs=[cn_series[i], cn_types[i], actual_arch_comp], outputs=[cn_filepaths[i]], show_progress=False )
def on_accordion_expand(*images): return [gr.update() for _ in images] accordion.expand( fn=on_accordion_expand, inputs=cn_images, outputs=cn_images, show_progress=False )
def create_flux1_ipadapter_event_handlers(prefix, ui_components): fipa_rows = ui_components.get(f'flux1_ipadapter_rows_{prefix}') if not fipa_rows: return count_state = ui_components[f'flux1_ipadapter_count_state_{prefix}'] add_button = ui_components[f'add_flux1_ipadapter_button_{prefix}'] del_button = ui_components[f'delete_flux1_ipadapter_button_{prefix}']
def add_fipa_row(c): c += 1 return { count_state: c, fipa_rows[c - 1]: gr.update(visible=True), add_button: gr.update(visible=c < MAX_IPADAPTERS), del_button: gr.update(visible=True), }
def del_fipa_row(c): c -= 1 return { count_state: c, fipa_rows[c]: gr.update(visible=False), add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0), }
add_outputs = [count_state, add_button, del_button] + fipa_rows del_outputs = [count_state, add_button, del_button] + fipa_rows add_button.click(fn=add_fipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_fipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_sd3_ipadapter_event_handlers(prefix, ui_components): ipa_rows = ui_components.get(f'sd3_ipadapter_rows_{prefix}') if not ipa_rows: return count_state = ui_components[f'sd3_ipadapter_count_state_{prefix}'] add_button = ui_components[f'add_sd3_ipadapter_button_{prefix}'] del_button = ui_components[f'delete_sd3_ipadapter_button_{prefix}'] images = ui_components[f'sd3_ipadapter_images_{prefix}'] weights = ui_components[f'sd3_ipadapter_weights_{prefix}'] start_percents = ui_components[f'sd3_ipadapter_start_percents_{prefix}'] end_percents = ui_components[f'sd3_ipadapter_end_percents_{prefix}']
def add_ipa_row(c): c += 1 return { count_state: c, ipa_rows[c - 1]: gr.update(visible=True), add_button: gr.update(visible=c < MAX_IPADAPTERS), del_button: gr.update(visible=True), }
def del_ipa_row(c): c -= 1 return { count_state: c, ipa_rows[c]: gr.update(visible=False), images[c]: None, weights[c]: 0.5, start_percents[c]: 0.0, end_percents[c]: 1.0, add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0), }
add_outputs = [count_state, add_button, del_button] + ipa_rows del_outputs = [count_state, add_button, del_button] + ipa_rows + images + weights + start_percents + end_percents add_button.click(fn=add_ipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_ipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_style_event_handlers(prefix, ui_components): style_rows = ui_components.get(f'style_rows_{prefix}') if not style_rows: return count_state = ui_components[f'style_count_state_{prefix}'] add_button = ui_components[f'add_style_button_{prefix}'] del_button = ui_components[f'delete_style_button_{prefix}']
def add_style_row(c): c += 1 return { count_state: c, style_rows[c - 1]: gr.update(visible=True), add_button: gr.update(visible=c < 5), del_button: gr.update(visible=True), }
def del_style_row(c): c -= 1 return { count_state: c, style_rows[c]: gr.update(visible=False), add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0), }
add_outputs = [count_state, add_button, del_button] + style_rows del_outputs = [count_state, add_button, del_button] + style_rows add_button.click(fn=add_style_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_style_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_ipadapter_event_handlers(prefix, ui_components): ipa_rows = ui_components.get(f'ipadapter_rows_{prefix}') if not ipa_rows: return ipa_lora_strengths = ui_components[f'ipadapter_lora_strengths_{prefix}'] ipa_final_preset = ui_components[f'ipadapter_final_preset_{prefix}'] ipa_final_lora_strength = ui_components[f'ipadapter_final_lora_strength_{prefix}'] count_state = ui_components[f'ipadapter_count_state_{prefix}'] add_button = ui_components[f'add_ipadapter_button_{prefix}'] del_button = ui_components[f'delete_ipadapter_button_{prefix}'] accordion = ui_components[f'ipadapter_accordion_{prefix}']
def add_ipa_row(c): c += 1 return { count_state: c, ipa_rows[c - 1]: gr.update(visible=True), add_button: gr.update(visible=c < MAX_IPADAPTERS), del_button: gr.update(visible=True), }
def del_ipa_row(c): c -= 1 return { count_state: c, ipa_rows[c]: gr.update(visible=False), add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0), }
add_outputs = [count_state, add_button, del_button] + ipa_rows del_outputs = [count_state, add_button, del_button] + ipa_rows add_button.click(fn=add_ipa_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_ipa_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def on_preset_change(preset_value): config = load_ipadapter_config() faceid_presets = [] if config: faceid_presets.extend(config.get("IPAdapter_FaceID_presets", {}).get("SDXL", [])) faceid_presets.extend(config.get("IPAdapter_FaceID_presets", {}).get("SD1.5", []))
is_visible = preset_value in faceid_presets updates = [gr.update(visible=is_visible)] * (MAX_IPADAPTERS + 1) return updates
all_lora_strength_sliders = [ipa_final_lora_strength] + ipa_lora_strengths ipa_final_preset.change(fn=on_preset_change, inputs=[ipa_final_preset], outputs=all_lora_strength_sliders, show_progress=False) 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)
def create_reference_latent_event_handlers(prefix, ui_components): ref_rows = ui_components.get(f'reference_latent_rows_{prefix}') if not ref_rows: return count_state = ui_components[f'reference_latent_count_state_{prefix}'] add_button = ui_components[f'add_reference_latent_button_{prefix}'] del_button = ui_components[f'delete_reference_latent_button_{prefix}'] images = ui_components[f'reference_latent_images_{prefix}']
def add_ref_row(c): c += 1 return { count_state: c, ref_rows[c - 1]: gr.update(visible=True), add_button: gr.update(visible=c < 10), del_button: gr.update(visible=True), }
def del_ref_row(c): c -= 1 return { count_state: c, ref_rows[c]: gr.update(visible=False), images[c]: None, add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0), }
add_outputs = [count_state, add_button, del_button] + ref_rows del_outputs = [count_state, add_button, del_button] + ref_rows + images add_button.click(fn=add_ref_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_hidream_o1_reference_event_handlers(prefix, ui_components): ref_rows = ui_components.get(f'hidream_o1_reference_rows_{prefix}') if not ref_rows: return count_state = ui_components[f'hidream_o1_reference_count_state_{prefix}'] add_button = ui_components[f'add_hidream_o1_reference_button_{prefix}'] del_button = ui_components[f'delete_hidream_o1_reference_button_{prefix}'] images = ui_components[f'hidream_o1_reference_images_{prefix}']
def add_ref_row(c): c += 1 return { count_state: c, ref_rows[c - 1]: gr.update(visible=True), add_button: gr.update(visible=c < 10), del_button: gr.update(visible=True), }
def del_ref_row(c): c -= 1 return { count_state: c, ref_rows[c]: gr.update(visible=False), images[c]: None, add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0), }
add_outputs = [count_state, add_button, del_button] + ref_rows del_outputs = [count_state, add_button, del_button] + ref_rows + images add_button.click(fn=add_ref_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_ref_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_embedding_event_handlers(prefix, ui_components): rows = ui_components.get(f'embedding_rows_{prefix}') if not rows: return ids = ui_components[f'embeddings_ids_{prefix}'] files = ui_components[f'embeddings_files_{prefix}'] count_state = ui_components[f'embedding_count_state_{prefix}'] add_button = ui_components[f'add_embedding_button_{prefix}'] del_button = ui_components[f'delete_embedding_button_{prefix}']
def add_row(c): c += 1 return { count_state: c, rows[c - 1]: gr.update(visible=True), add_button: gr.update(visible=c < MAX_EMBEDDINGS), del_button: gr.update(visible=True) }
def del_row(c): c -= 1 return { count_state: c, rows[c]: gr.update(visible=False), ids[c]: "", files[c]: None, add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0) } add_outputs = [count_state, add_button, del_button] + rows del_outputs = [count_state, add_button, del_button] + rows + ids + files add_button.click(fn=add_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)
def create_conditioning_event_handlers(prefix, ui_components): rows = ui_components.get(f'conditioning_rows_{prefix}') if not rows: return prompts = ui_components[f'conditioning_prompts_{prefix}'] count_state = ui_components[f'conditioning_count_state_{prefix}'] add_button = ui_components[f'add_conditioning_button_{prefix}'] del_button = ui_components[f'delete_conditioning_button_{prefix}'] def add_row(c): c += 1 return { count_state: c, rows[c - 1]: gr.update(visible=True), add_button: gr.update(visible=c < MAX_CONDITIONINGS), del_button: gr.update(visible=True), }
def del_row(c): c -= 1 return { count_state: c, rows[c]: gr.update(visible=False), prompts[c]: "", add_button: gr.update(visible=True), del_button: gr.update(visible=c > 0), }
add_outputs = [count_state, add_button, del_button] + rows del_outputs = [count_state, add_button, del_button] + rows + prompts add_button.click(fn=add_row, inputs=[count_state], outputs=add_outputs, show_progress=False) del_button.click(fn=del_row, inputs=[count_state], outputs=del_outputs, show_progress=False)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333import gradio as grfrom core.settings import ( MODEL_TYPE_MAP, MODEL_MAP_CHECKPOINT, FEATURES_CONFIG, ARCHITECTURES_CONFIG, MODEL_DEFAULTS_CONFIG, ARCH_CATEGORIES_MAP)from utils.app_utils import get_model_generation_defaultsfrom ui.shared.ui_components import RESOLUTION_MAPfrom .config_loaders import ( get_cn_defaults, get_anima_cn_defaults, get_diffsynth_cn_defaults, load_ipadapter_config)
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): def update_fn(*args): arch = args[0] category = args[1] current_ar = args[2] if len(args) > 2 else None if arch == "ALL": valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats)) else: valid_cats = ARCH_CATEGORIES_MAP.get(arch, []) cat_choices = ["ALL"] + sorted(valid_cats) new_category = category if category in cat_choices else "ALL"
choices = [] for name, info in MODEL_MAP_CHECKPOINT.items(): m_arch = info[2] m_cat = info[4] if len(info) > 4 else None arch_match = (arch == "ALL" or m_arch == arch) cat_match = (new_category == "ALL" or m_cat == new_category) if arch_match and cat_match: choices.append(name) val = choices[0] if choices else None updates = { m_comp: gr.update(choices=choices, value=val), cat_comp: gr.update(choices=cat_choices, value=new_category) }
m_type = MODEL_TYPE_MAP.get(val, "SDXL") if val else "SDXL" architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {})) enabled_chains = arch_features.get('enabled_chains', [])
if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains)) if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains)) if anima_cn_acc: updates[anima_cn_acc] = gr.update(visible=('anima_controlnet_lllite' in enabled_chains)) if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains)) if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains)) if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains)) if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains)) if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains)) if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains)) if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains)) if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains)) if hidream_o1_ref_acc: updates[hidream_o1_ref_acc] = gr.update(visible=('hidream_o1_reference' in enabled_chains))
if cs_comp: updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15")) if guidance_comp: updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1")) if ar_comp: res_key = arch_model_type if res_key not in RESOLUTION_MAP: res_key = 'sdxl' res_map = RESOLUTION_MAP.get(res_key, {}) target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)") updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar) if width_comp and height_comp and target_ar in res_map: updates[width_comp] = gr.update(value=res_map[target_ar][0]) updates[height_comp] = gr.update(value=res_map[target_ar][1]) controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type) all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key) for t_comp in cn_types: updates[t_comp] = gr.update(choices=all_types, value=default_type) for s_comp in cn_series: updates[s_comp] = gr.update(choices=series_choices, value=default_series) for f_comp in cn_filepaths: updates[f_comp] = filepath
anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults() for t_comp in anima_cn_types: updates[t_comp] = gr.update(choices=anima_all_types, value=anima_default_type) for s_comp in anima_cn_series: updates[s_comp] = gr.update(choices=anima_series_choices, value=anima_default_series) for f_comp in anima_cn_filepaths: updates[f_comp] = anima_filepath diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key) for t_comp in diffsynth_cn_types: updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type) for s_comp in diffsynth_cn_series: updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series) for f_comp in diffsynth_cn_filepaths: updates[f_comp] = diffsynth_filepath if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]): config = load_ipadapter_config() ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5" std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, []) face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, []) all_ipa_presets = std_presets + face_presets default_ipa = all_ipa_presets[0] if all_ipa_presets else None updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa) defaults = get_model_generation_defaults(val, arch_model_type, MODEL_DEFAULTS_CONFIG) if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps')) if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg')) if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name')) if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler')) if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt')) if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt')) return updates return update_fn
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): def change_fn(*args): model_name = args[0] idx = 1 current_arch = args[idx] if arch_comp_ref and idx < len(args) else None if arch_comp_ref: idx += 1 current_cat = args[idx] if cat_comp_ref and idx < len(args) else None if cat_comp_ref: idx += 1 current_ar = args[idx] if idx < len(args) else None m_type = MODEL_TYPE_MAP.get(model_name, "SDXL") m_info = MODEL_MAP_CHECKPOINT.get(model_name) m_cat = m_info[4] if m_info and len(m_info) > 4 else None if not m_cat: m_cat = "ALL" updates = {} target_arch = m_type if arch_comp_ref: if current_arch == "ALL": updates[arch_comp_ref] = gr.update() target_arch = "ALL" else: updates[arch_comp_ref] = m_type if cat_comp_ref: if target_arch == "ALL": valid_cats = list(set(cat for cats in ARCH_CATEGORIES_MAP.values() for cat in cats)) else: valid_cats = ARCH_CATEGORIES_MAP.get(target_arch, []) cat_choices = ["ALL"] + sorted(valid_cats) if current_cat == "ALL": updates[cat_comp_ref] = gr.update(choices=cat_choices) else: updates[cat_comp_ref] = gr.update(choices=cat_choices, value=m_cat) architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", ""))
arch_features = FEATURES_CONFIG.get(arch_model_type, FEATURES_CONFIG.get('default', {})) enabled_chains = arch_features.get('enabled_chains', [])
if lora_acc: updates[lora_acc] = gr.update(visible=('lora' in enabled_chains)) if cn_acc: updates[cn_acc] = gr.update(visible=('controlnet' in enabled_chains)) if anima_cn_acc: updates[anima_cn_acc] = gr.update(visible=('anima_controlnet_lllite' in enabled_chains)) if diffsynth_cn_acc: updates[diffsynth_cn_acc] = gr.update(visible=('controlnet_model_patch' in enabled_chains)) if ipa_acc: updates[ipa_acc] = gr.update(visible=('ipadapter' in enabled_chains)) if flux1_ipa_acc: updates[flux1_ipa_acc] = gr.update(visible=('flux1_ipadapter' in enabled_chains)) if sd3_ipa_acc: updates[sd3_ipa_acc] = gr.update(visible=('sd3_ipadapter' in enabled_chains)) if style_acc: updates[style_acc] = gr.update(visible=('style' in enabled_chains)) if embed_acc: updates[embed_acc] = gr.update(visible=('embedding' in enabled_chains)) if cond_acc: updates[cond_acc] = gr.update(visible=('conditioning' in enabled_chains)) if ref_latent_acc: updates[ref_latent_acc] = gr.update(visible=('reference_latent' in enabled_chains)) if hidream_o1_ref_acc: updates[hidream_o1_ref_acc] = gr.update(visible=('hidream_o1_reference' in enabled_chains))
if cs_comp: updates[cs_comp] = gr.update(visible=(arch_model_type == "sd15")) if guidance_comp: updates[guidance_comp] = gr.update(visible=(arch_model_type == "flux1")) if ar_comp: res_key = arch_model_type if res_key not in RESOLUTION_MAP: res_key = 'sdxl' res_map = RESOLUTION_MAP.get(res_key, {}) target_ar = current_ar if current_ar in res_map else (list(res_map.keys())[0] if res_map else "1:1 (Square)") updates[ar_comp] = gr.update(choices=list(res_map.keys()), value=target_ar) if width_comp and height_comp and target_ar in res_map: updates[width_comp] = gr.update(value=res_map[target_ar][0]) updates[height_comp] = gr.update(value=res_map[target_ar][1]) controlnet_key = architectures_dict.get(m_type, {}).get("controlnet_key", m_type) all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key) for t_comp in cn_types: updates[t_comp] = gr.update(choices=all_types, value=default_type) for s_comp in cn_series: updates[s_comp] = gr.update(choices=series_choices, value=default_series) for f_comp in cn_filepaths: updates[f_comp] = filepath
anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults() for t_comp in anima_cn_types: updates[t_comp] = gr.update(choices=anima_all_types, value=anima_default_type) for s_comp in anima_cn_series: updates[s_comp] = gr.update(choices=anima_series_choices, value=anima_default_series) for f_comp in anima_cn_filepaths: updates[f_comp] = anima_filepath diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key) for t_comp in diffsynth_cn_types: updates[t_comp] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type) for s_comp in diffsynth_cn_series: updates[s_comp] = gr.update(choices=diffsynth_series_choices, value=diffsynth_default_series) for f_comp in diffsynth_cn_filepaths: updates[f_comp] = diffsynth_filepath if ipa_preset and (arch_model_type in ["sdxl", "sd15", "sd35"]): config = load_ipadapter_config() ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5" std_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, []) face_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, []) all_ipa_presets = std_presets + face_presets default_ipa = all_ipa_presets[0] if all_ipa_presets else None updates[ipa_preset] = gr.update(choices=all_ipa_presets, value=default_ipa) defaults = get_model_generation_defaults(model_name, arch_model_type, MODEL_DEFAULTS_CONFIG) if steps_comp: updates[steps_comp] = gr.update(value=defaults.get('steps')) if cfg_comp: updates[cfg_comp] = gr.update(value=defaults.get('cfg')) if sampler_comp: updates[sampler_comp] = gr.update(value=defaults.get('sampler_name')) if scheduler_comp: updates[scheduler_comp] = gr.update(value=defaults.get('scheduler')) if prompt_comp: updates[prompt_comp] = gr.update(value=defaults.get('positive_prompt')) if neg_prompt_comp: updates[neg_prompt_comp] = gr.update(value=defaults.get('negative_prompt')) return updates return change_fn
def initialize_all_cn_dropdowns(ui_components): default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL" architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) controlnet_key = architectures_dict.get(default_m_type, {}).get("controlnet_key", default_m_type) all_types, default_type, series_choices, default_series, filepath = get_cn_defaults(controlnet_key) anima_all_types, anima_default_type, anima_series_choices, anima_default_series, anima_filepath = get_anima_cn_defaults() diffsynth_all_types, diffsynth_default_type, diffsynth_series_choices, diffsynth_default_series, diffsynth_filepath = get_diffsynth_cn_defaults(controlnet_key) updates = {} for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]: if f'controlnet_types_{prefix}' in ui_components: for type_dd in ui_components[f'controlnet_types_{prefix}']: updates[type_dd] = gr.update(choices=all_types, value=default_type) for series_dd in ui_components[f'controlnet_series_{prefix}']: updates[series_dd] = gr.update(choices=series_choices, value=default_series) for filepath_state in ui_components[f'controlnet_filepaths_{prefix}']: updates[filepath_state] = filepath
if f'anima_controlnet_lllite_types_{prefix}' in ui_components: for type_dd in ui_components[f'anima_controlnet_lllite_types_{prefix}']: updates[type_dd] = gr.update(choices=anima_all_types, value=anima_default_type) for series_dd in ui_components[f'anima_controlnet_lllite_series_{prefix}']: updates[series_dd] = gr.update(choices=anima_series_choices, value=anima_default_series) for filepath_state in ui_components[f'anima_controlnet_lllite_filepaths_{prefix}']: updates[filepath_state] = anima_filepath if f'diffsynth_controlnet_types_{prefix}' in ui_components: for type_dd in ui_components[f'diffsynth_controlnet_types_{prefix}']: updates[type_dd] = gr.update(choices=diffsynth_all_types, value=diffsynth_default_type) for series_dd in ui_components[f'diffsynth_controlnet_series_{prefix}']: updates[series_dd] = gr.update(choices=diffsynth_series_choices, value=default_series) for filepath_state in ui_components[f'diffsynth_controlnet_filepaths_{prefix}']: updates[filepath_state] = diffsynth_filepath return updates
def initialize_all_ipa_dropdowns(ui_components): config = load_ipadapter_config() if not config: return {} default_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else None default_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL" architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) arch_model_type = architectures_dict.get(default_m_type, {}).get("model_type", default_m_type.lower().replace(" ", "").replace(".", "")) ipa_arch_key = "SDXL" if arch_model_type in ["sdxl", "sd35"] else "SD1.5"
unified_presets = config.get("IPAdapter_presets", {}).get(ipa_arch_key, []) faceid_presets = config.get("IPAdapter_FaceID_presets", {}).get(ipa_arch_key, []) all_presets = unified_presets + faceid_presets default_preset = all_presets[0] if all_presets else None is_faceid_default = default_preset in faceid_presets
lora_strength_update = gr.update(visible=is_faceid_default) updates = {} for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]: if f'ipadapter_final_preset_{prefix}' in ui_components: for lora_strength_slider in ui_components[f'ipadapter_lora_strengths_{prefix}']: updates[lora_strength_slider] = lora_strength_update updates[ui_components[f'ipadapter_final_preset_{prefix}']] = gr.update(choices=all_presets, value=default_preset) updates[ui_components[f'ipadapter_final_lora_strength_{prefix}']] = lora_strength_update return updates
def run_on_load(ui_components): cn_updates = initialize_all_cn_dropdowns(ui_components) ipa_updates = initialize_all_ipa_dropdowns(ui_components) return {**cn_updates, **ipa_updates}
def on_aspect_ratio_change(ratio_key, model_display_name): m_type = MODEL_TYPE_MAP.get(model_display_name, 'SDXL') architectures_dict = ARCHITECTURES_CONFIG.get('architectures', {}) arch_model_type = architectures_dict.get(m_type, {}).get("model_type", m_type.lower().replace(" ", "").replace(".", "")) res_map = RESOLUTION_MAP.get(arch_model_type, RESOLUTION_MAP.get("sdxl", {})) w, h = res_map.get(ratio_key, (1024, 1024)) return w, h123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131import osimport yamlfrom functools import lru_cache
@lru_cache(maxsize=1)def load_controlnet_config(): _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) _CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'controlnet_models.yaml') try: print("--- Loading controlnet_models.yaml ---") with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f: config = yaml.safe_load(f) print("--- ✅ controlnet_models.yaml loaded successfully ---") return config.get("ControlNet", {}) except Exception as e: print(f"Error loading controlnet_models.yaml: {e}") return {}
def get_cn_defaults(arch_val): cn_full_config = load_controlnet_config() cn_config = cn_full_config.get(arch_val, []) if not cn_config: return [], None, [], None, "None" all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", [])))) default_type = all_types[0] if all_types else None series_choices = [] if default_type: series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", [])))) default_series = series_choices[0] if series_choices else None filepath = "None" if default_series and default_type: for model in cn_config: if model.get("Series") == default_series and default_type in model.get("Type", []): filepath = model.get("Filepath") break return all_types, default_type, series_choices, default_series, filepath
@lru_cache(maxsize=1)def load_anima_controlnet_lllite_config(): _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) _CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'anima_controlnet_lllite_models.yaml') try: print("--- Loading anima_controlnet_lllite_models.yaml ---") with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f: config = yaml.safe_load(f) print("--- ✅ anima_controlnet_lllite_models.yaml loaded successfully ---") return config.get("Anima_ControlNet_Lllite", []) except Exception as e: print(f"Error loading anima_controlnet_lllite_models.yaml: {e}") return []
def get_anima_cn_defaults(): cn_config = load_anima_controlnet_lllite_config() if not cn_config: return [], None, [], None, "None" all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", [])))) default_type = all_types[0] if all_types else None series_choices = [] if default_type: series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", [])))) default_series = series_choices[0] if series_choices else None filepath = "None" if default_series and default_type: for model in cn_config: if model.get("Series") == default_series and default_type in model.get("Type", []): filepath = model.get("Filepath") break return all_types, default_type, series_choices, default_series, filepath
@lru_cache(maxsize=1)def load_diffsynth_controlnet_config(): _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) _CN_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'diffsynth_controlnet_models.yaml') try: print("--- Loading diffsynth_controlnet_models.yaml ---") with open(_CN_MODEL_LIST_PATH, 'r', encoding='utf-8') as f: config = yaml.safe_load(f) print("--- ✅ diffsynth_controlnet_models.yaml loaded successfully ---") return config.get("DiffSynth_ControlNet", {}) except Exception as e: print(f"Error loading diffsynth_controlnet_models.yaml: {e}") return {}
def get_diffsynth_cn_defaults(arch_val): cn_full_config = load_diffsynth_controlnet_config() cn_config = cn_full_config.get(arch_val, []) if not cn_config: return [], None, [], None, "None" all_types = sorted(list(set(t for model in cn_config for t in model.get("Type", [])))) default_type = all_types[0] if all_types else None series_choices = [] if default_type: series_choices = sorted(list(set(model.get("Series", "Default") for model in cn_config if default_type in model.get("Type", [])))) default_series = series_choices[0] if series_choices else None filepath = "None" if default_series and default_type: for model in cn_config: if model.get("Series") == default_series and default_type in model.get("Type", []): filepath = model.get("Filepath") break return all_types, default_type, series_choices, default_series, filepath
@lru_cache(maxsize=1)def load_ipadapter_config(): _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) _IPA_MODEL_LIST_PATH = os.path.join(_PROJECT_ROOT, 'yaml', 'ipadapter.yaml') try: print("--- Loading ipadapter.yaml ---") with open(_IPA_MODEL_LIST_PATH, 'r', encoding='utf-8') as f: config = yaml.safe_load(f) print("--- ✅ ipadapter.yaml loaded successfully ---") return config except Exception as e: print(f"Error loading ipadapter.yaml: {e}") return {}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240import gradio as grfrom .chain_handlers import ( create_lora_event_handlers, create_controlnet_event_handlers, create_anima_controlnet_lllite_event_handlers, create_diffsynth_controlnet_event_handlers, create_ipadapter_event_handlers, create_embedding_event_handlers, create_conditioning_event_handlers, create_flux1_ipadapter_event_handlers, create_sd3_ipadapter_event_handlers, create_style_event_handlers, create_reference_latent_event_handlers, create_hidream_o1_reference_event_handlers)from .change_handlers import ( make_update_fn, make_model_change_fn, run_on_load, on_aspect_ratio_change)from .run_handlers import create_run_event
def attach_event_handlers(ui_components, demo): for prefix, task_type in [ ("txt2img", "txt2img"), ("img2img", "img2img"), ("inpaint", "inpaint"), ("outpaint", "outpaint"), ("hires_fix", "hires_fix"), ]:
arch_comp = ui_components.get(f'model_arch_{prefix}') cat_comp = ui_components.get(f'model_cat_{prefix}') model_comp = ui_components.get(f'base_model_{prefix}') clip_skip_comp = ui_components.get(f'clip_skip_{prefix}') or ui_components.get(f'{prefix}_clip_skip') guidance_comp = ui_components.get(f'guidance_{prefix}') or ui_components.get(f'{prefix}_guidance') aspect_ratio_comp = ui_components.get(f'aspect_ratio_{prefix}') or ui_components.get(f'{prefix}_aspect_ratio_dropdown') width_comp = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width') height_comp = ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height') cn_types_list = ui_components.get(f'controlnet_types_{prefix}', []) cn_series_list = ui_components.get(f'controlnet_series_{prefix}', []) cn_filepaths_list = ui_components.get(f'controlnet_filepaths_{prefix}', []) anima_cn_types_list = ui_components.get(f'anima_controlnet_lllite_types_{prefix}', []) anima_cn_series_list = ui_components.get(f'anima_controlnet_lllite_series_{prefix}', []) anima_cn_filepaths_list = ui_components.get(f'anima_controlnet_lllite_filepaths_{prefix}', [])
diffsynth_cn_types_list = ui_components.get(f'diffsynth_controlnet_types_{prefix}', []) diffsynth_cn_series_list = ui_components.get(f'diffsynth_controlnet_series_{prefix}', []) diffsynth_cn_filepaths_list = ui_components.get(f'diffsynth_controlnet_filepaths_{prefix}', []) lora_accordion = ui_components.get(f'lora_accordion_{prefix}') cn_accordion = ui_components.get(f'controlnet_accordion_{prefix}') anima_cn_accordion = ui_components.get(f'anima_controlnet_lllite_accordion_{prefix}') diffsynth_cn_accordion = ui_components.get(f'diffsynth_controlnet_accordion_{prefix}') ipa_accordion = ui_components.get(f'ipadapter_accordion_{prefix}') sd3_ipa_accordion = ui_components.get(f'sd3_ipadapter_accordion_{prefix}') flux1_ipa_accordion = ui_components.get(f'flux1_ipadapter_accordion_{prefix}') style_accordion = ui_components.get(f'style_accordion_{prefix}') embedding_accordion = ui_components.get(f'embedding_accordion_{prefix}') conditioning_accordion = ui_components.get(f'conditioning_accordion_{prefix}') ref_latent_accordion = ui_components.get(f'reference_latent_accordion_{prefix}') hidream_o1_ref_accordion = ui_components.get(f'hidream_o1_reference_accordion_{prefix}') ipa_preset_list = ui_components.get(f'ipadapter_final_preset_{prefix}') prompt_comp = ui_components.get(f'prompt_{prefix}') or ui_components.get(f'{prefix}_positive_prompt') neg_prompt_comp = ui_components.get(f'neg_prompt_{prefix}') or ui_components.get(f'{prefix}_negative_prompt') steps_comp = ui_components.get(f'steps_{prefix}') or ui_components.get(f'{prefix}_steps') cfg_comp = ui_components.get(f'cfg_{prefix}') or ui_components.get(f'{prefix}_cfg') sampler_comp = ui_components.get(f'sampler_{prefix}') or ui_components.get(f'{prefix}_sampler_name') scheduler_comp = ui_components.get(f'scheduler_{prefix}') or ui_components.get(f'{prefix}_scheduler') extra_comps = [prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, width_comp, height_comp] valid_extra_comps = [c for c in extra_comps if c is not None] if arch_comp and cat_comp and model_comp: outputs = [model_comp, cat_comp] if clip_skip_comp: outputs.append(clip_skip_comp) if guidance_comp: outputs.append(guidance_comp) if aspect_ratio_comp: outputs.append(aspect_ratio_comp) outputs.extend(cn_types_list + cn_series_list + cn_filepaths_list) outputs.extend(anima_cn_types_list + anima_cn_series_list + anima_cn_filepaths_list) outputs.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list) if lora_accordion: outputs.append(lora_accordion) if cn_accordion: outputs.append(cn_accordion) if anima_cn_accordion: outputs.append(anima_cn_accordion) if diffsynth_cn_accordion: outputs.append(diffsynth_cn_accordion) if ipa_accordion: outputs.append(ipa_accordion) if sd3_ipa_accordion: outputs.append(sd3_ipa_accordion) if flux1_ipa_accordion: outputs.append(flux1_ipa_accordion) if style_accordion: outputs.append(style_accordion) if embedding_accordion: outputs.append(embedding_accordion) if conditioning_accordion: outputs.append(conditioning_accordion) if ref_latent_accordion: outputs.append(ref_latent_accordion) if hidream_o1_ref_accordion: outputs.append(hidream_o1_ref_accordion) if ipa_preset_list: outputs.append(ipa_preset_list) outputs.extend(valid_extra_comps) update_fn = make_update_fn( model_comp, cat_comp, clip_skip_comp, aspect_ratio_comp, width_comp, height_comp, cn_types_list, cn_series_list, cn_filepaths_list, anima_cn_types_list, anima_cn_series_list, anima_cn_filepaths_list, diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list, 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, ref_latent_accordion, hidream_o1_ref_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp ) inputs = [arch_comp, cat_comp] if aspect_ratio_comp: inputs.append(aspect_ratio_comp) arch_comp.change(fn=update_fn, inputs=inputs, outputs=outputs) cat_comp.change(fn=update_fn, inputs=inputs, outputs=outputs)
if model_comp: outputs2 = [] if arch_comp: outputs2.append(arch_comp) if cat_comp: outputs2.append(cat_comp) if clip_skip_comp: outputs2.append(clip_skip_comp) if guidance_comp: outputs2.append(guidance_comp) if aspect_ratio_comp: outputs2.append(aspect_ratio_comp) outputs2.extend(cn_types_list + cn_series_list + cn_filepaths_list) outputs2.extend(anima_cn_types_list + anima_cn_series_list + anima_cn_filepaths_list) outputs2.extend(diffsynth_cn_types_list + diffsynth_cn_series_list + diffsynth_cn_filepaths_list) if lora_accordion: outputs2.append(lora_accordion) if cn_accordion: outputs2.append(cn_accordion) if anima_cn_accordion: outputs2.append(anima_cn_accordion) if diffsynth_cn_accordion: outputs2.append(diffsynth_cn_accordion) if ipa_accordion: outputs2.append(ipa_accordion) if sd3_ipa_accordion: outputs2.append(sd3_ipa_accordion) if flux1_ipa_accordion: outputs2.append(flux1_ipa_accordion) if style_accordion: outputs2.append(style_accordion) if embedding_accordion: outputs2.append(embedding_accordion) if conditioning_accordion: outputs2.append(conditioning_accordion) if ref_latent_accordion: outputs2.append(ref_latent_accordion) if hidream_o1_ref_accordion: outputs2.append(hidream_o1_ref_accordion) if ipa_preset_list: outputs2.append(ipa_preset_list) outputs2.extend(valid_extra_comps) if outputs2: inputs2 = [model_comp] if arch_comp: inputs2.append(arch_comp) if cat_comp: inputs2.append(cat_comp) if aspect_ratio_comp: inputs2.append(aspect_ratio_comp) change_fn = make_model_change_fn( cat_comp, clip_skip_comp, aspect_ratio_comp, width_comp, height_comp, cn_types_list, cn_series_list, cn_filepaths_list, anima_cn_types_list, anima_cn_series_list, anima_cn_filepaths_list, diffsynth_cn_types_list, diffsynth_cn_series_list, diffsynth_cn_filepaths_list, 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, ref_latent_accordion, hidream_o1_ref_accordion, guidance_comp, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp ) model_comp.change(fn=change_fn, inputs=inputs2, outputs=outputs2)
create_lora_event_handlers(prefix, ui_components) create_controlnet_event_handlers(prefix, ui_components) create_anima_controlnet_lllite_event_handlers(prefix, ui_components) create_diffsynth_controlnet_event_handlers(prefix, ui_components) create_ipadapter_event_handlers(prefix, ui_components) create_embedding_event_handlers(prefix, ui_components) create_conditioning_event_handlers(prefix, ui_components) create_flux1_ipadapter_event_handlers(prefix, ui_components) create_sd3_ipadapter_event_handlers(prefix, ui_components) create_style_event_handlers(prefix, ui_components) create_reference_latent_event_handlers(prefix, ui_components) create_hidream_o1_reference_event_handlers(prefix, ui_components) create_run_event(prefix, task_type, ui_components)
if 'view_mode_inpaint' in ui_components: def toggle_inpaint_fullscreen_view(view_mode): is_fullscreen = (view_mode == "Fullscreen View") other_elements_visible = not is_fullscreen editor_height = 800 if is_fullscreen else 272 updates = { ui_components['prompts_column_inpaint']: gr.update(visible=other_elements_visible), ui_components['params_and_gallery_row_inpaint']: gr.update(visible=other_elements_visible), ui_components['accordion_wrapper_inpaint']: gr.update(visible=other_elements_visible), ui_components['input_image_dict_inpaint']: gr.update(height=editor_height), } model_and_run_rows = ui_components.get('model_and_run_row_inpaint', []) for row in model_and_run_rows: updates[row] = gr.update(visible=other_elements_visible) return updates output_components = [] model_and_run_rows = ui_components.get('model_and_run_row_inpaint', []) if isinstance(model_and_run_rows, list): output_components.extend(model_and_run_rows) else: output_components.append(model_and_run_rows) output_components.extend([ ui_components['prompts_column_inpaint'], ui_components['params_and_gallery_row_inpaint'], ui_components['accordion_wrapper_inpaint'], ui_components['input_image_dict_inpaint'] ]) ui_components['view_mode_inpaint'].change( fn=toggle_inpaint_fullscreen_view, inputs=[ui_components['view_mode_inpaint']], outputs=output_components, show_progress=False )
all_load_outputs = [] for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]: if f'controlnet_types_{prefix}' in ui_components: all_load_outputs.extend(ui_components[f'controlnet_types_{prefix}']) all_load_outputs.extend(ui_components[f'controlnet_series_{prefix}']) all_load_outputs.extend(ui_components[f'controlnet_filepaths_{prefix}']) if f'anima_controlnet_lllite_types_{prefix}' in ui_components: all_load_outputs.extend(ui_components[f'anima_controlnet_lllite_types_{prefix}']) all_load_outputs.extend(ui_components[f'anima_controlnet_lllite_series_{prefix}']) all_load_outputs.extend(ui_components[f'anima_controlnet_lllite_filepaths_{prefix}']) if f'diffsynth_controlnet_types_{prefix}' in ui_components: all_load_outputs.extend(ui_components[f'diffsynth_controlnet_types_{prefix}']) all_load_outputs.extend(ui_components[f'diffsynth_controlnet_series_{prefix}']) all_load_outputs.extend(ui_components[f'diffsynth_controlnet_filepaths_{prefix}']) if f'ipadapter_final_preset_{prefix}' in ui_components: all_load_outputs.extend(ui_components[f'ipadapter_lora_strengths_{prefix}']) all_load_outputs.append(ui_components[f'ipadapter_final_preset_{prefix}']) all_load_outputs.append(ui_components[f'ipadapter_final_lora_strength_{prefix}'])
if all_load_outputs: demo.load( fn=lambda: run_on_load(ui_components), outputs=all_load_outputs )
for prefix in ["txt2img", "img2img", "inpaint", "outpaint", "hires_fix"]: aspect_ratio_dropdown = ui_components.get(f'aspect_ratio_{prefix}') or ui_components.get(f'{prefix}_aspect_ratio_dropdown') width_component = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width') height_component = ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height') model_dropdown = ui_components.get(f'base_model_{prefix}') if aspect_ratio_dropdown and width_component and height_component and model_dropdown: aspect_ratio_dropdown.change(fn=on_aspect_ratio_change, inputs=[aspect_ratio_dropdown, model_dropdown], outputs=[width_component, height_component], show_progress=False)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100import gradio as grfrom core.generation_logic import generate_image_wrapper
def create_run_event(prefix: str, task_type: str, ui_components: dict): run_inputs_map = { 'model_display_name': ui_components[f'base_model_{prefix}'], 'positive_prompt': ui_components.get(f'prompt_{prefix}') or ui_components.get(f'{prefix}_positive_prompt'), 'negative_prompt': ui_components.get(f'neg_prompt_{prefix}') or ui_components.get(f'{prefix}_negative_prompt'), 'seed': ui_components.get(f'seed_{prefix}') or ui_components.get(f'{prefix}_seed'), 'batch_size': ui_components.get(f'batch_size_{prefix}') or ui_components.get(f'{prefix}_batch_size'), 'guidance_scale': ui_components.get(f'cfg_{prefix}') or ui_components.get(f'{prefix}_cfg'), 'num_inference_steps': ui_components.get(f'steps_{prefix}') or ui_components.get(f'{prefix}_steps'), 'sampler': ui_components.get(f'sampler_{prefix}') or ui_components.get(f'{prefix}_sampler_name'), 'scheduler': ui_components.get(f'scheduler_{prefix}') or ui_components.get(f'{prefix}_scheduler'), 'zero_gpu_duration': ui_components.get(f'zero_gpu_{prefix}'),
'clip_skip': ui_components.get(f'clip_skip_{prefix}'), 'guidance': ui_components.get(f'guidance_{prefix}'), 'task_type': gr.State(task_type) } if task_type not in ['img2img', 'inpaint']: run_inputs_map.update({ 'width': ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width'), 'height': ui_components.get(f'height_{prefix}') or ui_components.get(f'{prefix}_height') }) task_specific_map = { 'img2img': {'img2img_image': f'input_image_{prefix}', 'img2img_denoise': f'denoise_{prefix}'}, 'inpaint': {'inpaint_image_dict': f'input_image_dict_{prefix}', 'grow_mask_by': f'grow_mask_by_{prefix}'}, '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}'}, '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}'} } if task_type in task_specific_map: for key, comp_name in task_specific_map[task_type].items(): if comp_name in ui_components: run_inputs_map[key] = ui_components[comp_name] lora_data_components = ui_components.get(f'all_lora_components_flat_{prefix}', []) controlnet_data_components = ui_components.get(f'all_controlnet_components_flat_{prefix}', []) anima_controlnet_lllite_data_components = ui_components.get(f'all_anima_controlnet_lllite_components_flat_{prefix}', []) diffsynth_controlnet_data_components = ui_components.get(f'all_diffsynth_controlnet_components_flat_{prefix}', []) ipadapter_data_components = ui_components.get(f'all_ipadapter_components_flat_{prefix}', []) sd3_ipadapter_data_components = ui_components.get(f'all_sd3_ipadapter_components_flat_{prefix}', []) flux1_ipadapter_data_components = ui_components.get(f'all_flux1_ipadapter_components_flat_{prefix}', []) style_data_components = ui_components.get(f'all_style_components_flat_{prefix}', []) embedding_data_components = ui_components.get(f'all_embedding_components_flat_{prefix}', []) conditioning_data_components = ui_components.get(f'all_conditioning_components_flat_{prefix}', []) reference_latent_data_components = ui_components.get(f'all_reference_latent_components_flat_{prefix}', []) hidream_o1_reference_data_components = ui_components.get(f'all_hidream_o1_reference_components_flat_{prefix}', []) run_inputs_map['vae_source'] = ui_components.get(f'vae_source_{prefix}') run_inputs_map['vae_id'] = ui_components.get(f'vae_id_{prefix}') run_inputs_map['vae_file'] = ui_components.get(f'vae_file_{prefix}')
input_keys = list(run_inputs_map.keys()) input_list_flat = [v for v in run_inputs_map.values() if v is not None] all_chains = [ lora_data_components, controlnet_data_components, anima_controlnet_lllite_data_components, diffsynth_controlnet_data_components, ipadapter_data_components, sd3_ipadapter_data_components, flux1_ipadapter_data_components, style_data_components, embedding_data_components, conditioning_data_components, reference_latent_data_components, hidream_o1_reference_data_components ] for chain in all_chains: if chain: input_list_flat.extend(chain)
def create_ui_inputs_dict(*args): valid_keys = [k for k in input_keys if run_inputs_map[k] is not None] ui_dict = dict(zip(valid_keys, args[:len(valid_keys)])) arg_idx = len(valid_keys)
def assign_chain_data(chain_key, components_list): nonlocal arg_idx if components_list: ui_dict[chain_key] = list(args[arg_idx : arg_idx + len(components_list)]) arg_idx += len(components_list)
assign_chain_data('lora_data', lora_data_components) assign_chain_data('controlnet_data', controlnet_data_components) assign_chain_data('anima_controlnet_lllite_data', anima_controlnet_lllite_data_components) assign_chain_data('diffsynth_controlnet_data', diffsynth_controlnet_data_components) assign_chain_data('ipadapter_data', ipadapter_data_components) assign_chain_data('sd3_ipadapter_chain', sd3_ipadapter_data_components) assign_chain_data('flux1_ipadapter_data', flux1_ipadapter_data_components) assign_chain_data('style_data', style_data_components) assign_chain_data('embedding_data', embedding_data_components) assign_chain_data('conditioning_data', conditioning_data_components) assign_chain_data('reference_latent_data', reference_latent_data_components) assign_chain_data('hidream_o1_reference_data', hidream_o1_reference_data_components)
return ui_dict
run_btn = ui_components.get(f'run_{prefix}') or ui_components.get(f'{prefix}_run_button') res_gal = ui_components.get(f'result_{prefix}') or ui_components.get(f'{prefix}_output_gallery') if run_btn and res_gal: run_btn.click( fn=lambda *args, progress=gr.Progress(track_tqdm=True): generate_image_wrapper(create_ui_inputs_dict(*args), progress), inputs=input_list_flat, outputs=[res_gal] )9 unmodified lines10111213141516171819202122239 unmodified linesui_components = {}with gr.Blocks() as demo:gr.Markdown("# ImageGen - FLUX.2-KV")gr.Markdown("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. ""Other versions are also available: ""[Anima](https://huggingface.co/spaces/RioShiina/ImageGen-Anima), ""[Illustrious](https://huggingface.co/spaces/RioShiina/ImageGen-Illustrious), ""[NoobAI](https://huggingface.co/spaces/RioShiina/ImageGen-NoobAI), ""[Pony](https://huggingface.co/spaces/RioShiina/ImageGen-Pony)")with gr.Tabs(elem_id="tabs_container") as tabs:with gr.TabItem("Txt2Img", id=0):9 unmodified lines10111213141516171819202122232425269 unmodified linesui_components = {}with gr.Blocks() as demo:gr.Markdown("# ImageGen")gr.Markdown("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. ""Other spaces: [ImageGen1](https://huggingface.co/spaces/RioShiina/ImageGen1), ""[ImageGen2](https://huggingface.co/spaces/RioShiina/ImageGen2), ""[ImageGen3](https://huggingface.co/spaces/RioShiina/ImageGen3), ""[ImageGen4](https://huggingface.co/spaces/RioShiina/ImageGen4), ""[ImageGen5](https://huggingface.co/spaces/RioShiina/ImageGen5), ""[ImageGen6](https://huggingface.co/spaces/RioShiina/ImageGen6), ""[ImageGen7](https://huggingface.co/spaces/RioShiina/ImageGen7), ""[ImageGen8](https://huggingface.co/spaces/RioShiina/ImageGen8)")with gr.Tabs(elem_id="tabs_container") as tabs:with gr.TabItem("Txt2Img", id=0):
2 unmodified lines34567891011121360 unmodified lines7475767778791 unmodified line8182838485862 unmodified linesfrom comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICESfrom .ui_components import (create_lora_settings_ui,create_controlnet_ui, create_ipadapter_ui, create_embedding_ui,create_conditioning_ui, create_vae_override_ui,create_model_architecture_filter_ui, create_category_filter_ui,create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,create_reference_latent_ui)def create_ui():60 unmodified linescomponents.update(create_lora_settings_ui(prefix))components.update(create_controlnet_ui(prefix))components.update(create_ipadapter_ui(prefix))components.update(create_flux1_ipadapter_ui(prefix))components.update(create_sd3_ipadapter_ui(prefix))1 unmodified linecomponents.update(create_embedding_ui(prefix))components.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_vae_override_ui(prefix))return components2 unmodified lines34567891011121360 unmodified lines747576777879801 unmodified line828384858687882 unmodified linesfrom comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICESfrom .ui_components import (create_lora_settings_ui,create_controlnet_ui, create_anima_controlnet_lllite_ui, create_ipadapter_ui, create_embedding_ui,create_conditioning_ui, create_vae_override_ui,create_model_architecture_filter_ui, create_category_filter_ui,create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,create_reference_latent_ui, create_hidream_o1_reference_ui)def create_ui():60 unmodified linescomponents.update(create_lora_settings_ui(prefix))components.update(create_controlnet_ui(prefix))components.update(create_anima_controlnet_lllite_ui(prefix))components.update(create_ipadapter_ui(prefix))components.update(create_flux1_ipadapter_ui(prefix))components.update(create_sd3_ipadapter_ui(prefix))1 unmodified linecomponents.update(create_embedding_ui(prefix))components.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_vae_override_ui(prefix))return components
2 unmodified lines34567891011121341 unmodified lines5556575859602 unmodified lines6364656667682 unmodified linesfrom comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICESfrom .ui_components import (create_lora_settings_ui,create_controlnet_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,create_conditioning_ui, create_vae_override_ui,create_model_architecture_filter_ui, create_category_filter_ui,create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,create_reference_latent_ui)def create_ui():41 unmodified linescomponents.update(create_lora_settings_ui(prefix))components.update(create_controlnet_ui(prefix))components.update(create_diffsynth_controlnet_ui(prefix))components.update(create_ipadapter_ui(prefix))components.update(create_flux1_ipadapter_ui(prefix))2 unmodified linescomponents.update(create_style_ui(prefix))components.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_vae_override_ui(prefix))return components2 unmodified lines34567891011121341 unmodified lines555657585960612 unmodified lines646566676869702 unmodified linesfrom comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICESfrom .ui_components import (create_lora_settings_ui,create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,create_conditioning_ui, create_vae_override_ui,create_model_architecture_filter_ui, create_category_filter_ui,create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,create_reference_latent_ui, create_hidream_o1_reference_ui)def create_ui():41 unmodified linescomponents.update(create_lora_settings_ui(prefix))components.update(create_controlnet_ui(prefix))components.update(create_anima_controlnet_lllite_ui(prefix))components.update(create_diffsynth_controlnet_ui(prefix))components.update(create_ipadapter_ui(prefix))components.update(create_flux1_ipadapter_ui(prefix))2 unmodified linescomponents.update(create_style_ui(prefix))components.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_vae_override_ui(prefix))return components
1 unmodified line2345678910111274 unmodified lines8788899091922 unmodified lines95969798991001 unmodified linefrom core.settings import MODEL_MAP_CHECKPOINTfrom .ui_components import (create_base_parameter_ui, create_lora_settings_ui,create_controlnet_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,create_conditioning_ui, create_vae_override_ui,create_model_architecture_filter_ui, create_category_filter_ui,create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,create_reference_latent_ui)def create_ui():74 unmodified linescomponents.update(create_lora_settings_ui(prefix))components.update(create_controlnet_ui(prefix))components.update(create_diffsynth_controlnet_ui(prefix))components.update(create_ipadapter_ui(prefix))components.update(create_flux1_ipadapter_ui(prefix))2 unmodified linescomponents.update(create_embedding_ui(prefix))components.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_vae_override_ui(prefix))components[f'accordion_wrapper_{prefix}'] = accordion_wrapper1 unmodified line2345678910111274 unmodified lines878889909192932 unmodified lines969798991001011021 unmodified linefrom core.settings import MODEL_MAP_CHECKPOINTfrom .ui_components import (create_base_parameter_ui, create_lora_settings_ui,create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,create_conditioning_ui, create_vae_override_ui,create_model_architecture_filter_ui, create_category_filter_ui,create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,create_reference_latent_ui, create_hidream_o1_reference_ui)def create_ui():74 unmodified linescomponents.update(create_lora_settings_ui(prefix))components.update(create_controlnet_ui(prefix))components.update(create_anima_controlnet_lllite_ui(prefix))components.update(create_diffsynth_controlnet_ui(prefix))components.update(create_ipadapter_ui(prefix))components.update(create_flux1_ipadapter_ui(prefix))2 unmodified linescomponents.update(create_embedding_ui(prefix))components.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_vae_override_ui(prefix))components[f'accordion_wrapper_{prefix}'] = accordion_wrapper
2 unmodified lines34567891011121356 unmodified lines7071727374752 unmodified lines7879808182832 unmodified linesfrom comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICESfrom .ui_components import (create_lora_settings_ui,create_controlnet_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,create_conditioning_ui, create_vae_override_ui,create_model_architecture_filter_ui, create_category_filter_ui,create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,create_reference_latent_ui)def create_ui():56 unmodified linescomponents.update(create_lora_settings_ui(prefix))components.update(create_controlnet_ui(prefix))components.update(create_diffsynth_controlnet_ui(prefix))components.update(create_ipadapter_ui(prefix))components.update(create_flux1_ipadapter_ui(prefix))2 unmodified linescomponents.update(create_embedding_ui(prefix))components.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_vae_override_ui(prefix))return components2 unmodified lines34567891011121356 unmodified lines707172737475762 unmodified lines798081828384852 unmodified linesfrom comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICESfrom .ui_components import (create_lora_settings_ui,create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,create_conditioning_ui, create_vae_override_ui,create_model_architecture_filter_ui, create_category_filter_ui,create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,create_reference_latent_ui, create_hidream_o1_reference_ui)def create_ui():56 unmodified linescomponents.update(create_lora_settings_ui(prefix))components.update(create_controlnet_ui(prefix))components.update(create_anima_controlnet_lllite_ui(prefix))components.update(create_diffsynth_controlnet_ui(prefix))components.update(create_ipadapter_ui(prefix))components.update(create_flux1_ipadapter_ui(prefix))2 unmodified linescomponents.update(create_embedding_ui(prefix))components.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_vae_override_ui(prefix))return components
1 unmodified line2345678910111229 unmodified lines4243444546472 unmodified lines5051525354551 unmodified linefrom core.settings import MODEL_MAP_CHECKPOINTfrom .ui_components import (create_base_parameter_ui, create_lora_settings_ui,create_controlnet_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,create_conditioning_ui, create_vae_override_ui,create_model_architecture_filter_ui, create_category_filter_ui,create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,create_reference_latent_ui)def create_ui():29 unmodified linescomponents.update(create_lora_settings_ui(prefix))components.update(create_controlnet_ui(prefix))components.update(create_diffsynth_controlnet_ui(prefix))components.update(create_ipadapter_ui(prefix))components.update(create_flux1_ipadapter_ui(prefix))2 unmodified linescomponents.update(create_style_ui(prefix))components.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_vae_override_ui(prefix))return components1 unmodified line2345678910111229 unmodified lines424344454647482 unmodified lines515253545556571 unmodified linefrom core.settings import MODEL_MAP_CHECKPOINTfrom .ui_components import (create_base_parameter_ui, create_lora_settings_ui,create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,create_conditioning_ui, create_vae_override_ui,create_model_architecture_filter_ui, create_category_filter_ui,create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,create_reference_latent_ui, create_hidream_o1_reference_ui)def create_ui():29 unmodified linescomponents.update(create_lora_settings_ui(prefix))components.update(create_controlnet_ui(prefix))components.update(create_anima_controlnet_lllite_ui(prefix))components.update(create_diffsynth_controlnet_ui(prefix))components.update(create_ipadapter_ui(prefix))components.update(create_flux1_ipadapter_ui(prefix))2 unmodified linescomponents.update(create_style_ui(prefix))components.update(create_conditioning_ui(prefix))components.update(create_reference_latent_ui(prefix))components.update(create_hidream_o1_reference_ui(prefix))components.update(create_vae_override_ui(prefix))return components
2 unmodified lines34567891011121337 unmodified lines51525354555657128 unmodified lines18618718818919019145 unmodified lines23723823924024124224362 unmodified lines30630730830931031131 unmodified lines343344345346347348134 unmodified lines48348448548648748848925 unmodified lines5155165175185195202 unmodified lines52352452552652752852914 unmodified lines5445455465472 unmodified linesfrom core.settings import (MAX_LORAS, LORA_SOURCE_CHOICES, MAX_EMBEDDINGS, MAX_CONDITIONINGS,MAX_CONTROLNETS, MAX_IPADAPTERS, RESOLUTION_MAP, ARCHITECTURES_CONFIG,MODEL_MAP_CHECKPOINT, MODEL_TYPE_MAP, FEATURES_CONFIG, ARCH_CATEGORIES_MAP)import yamlimport osfrom functools import lru_cachedefault_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else Nonedefault_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"37 unmodified lineschoices=choices,value="ALL",interactive=True,visible=False)return components128 unmodified linesreturn componentsdef create_diffsynth_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):components = {}key = lambda name: f"{name}_{prefix}"45 unmodified lineswith gr.Accordion("IPAdapter Settings", open=False, visible=('ipadapter' in default_enabled_chains)) as accordion:components[key('ipadapter_accordion')] = accordiongr.Markdown("Powered by [cubiq/ComfyUI_IPAdapter_plus](https://github.com/cubiq/ComfyUI_IPAdapter_plus).")with gr.Row():components[key('ipadapter_final_preset')] = gr.Dropdown(62 unmodified lineswith gr.Accordion("IPAdapter Settings (FLUX.1)", open=False, visible=('flux1_ipadapter' in default_enabled_chains)) as accordion:components[key('flux1_ipadapter_accordion')] = accordionipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []components.update({31 unmodified lineswith gr.Accordion("IPAdapter Settings (SD3)", open=False, visible=('sd3_ipadapter' in default_enabled_chains)) as accordion:components[key('sd3_ipadapter_accordion')] = accordionipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []components.update({134 unmodified linescomponents[key('all_conditioning_components_flat')] = all_cond_components_flatreturn componentsdef create_vae_override_ui(prefix: str):components = {}key = lambda name: f"{name}_{prefix}"25 unmodified linescomponents[key('vae_upload_button')] = upload_btncomponents[key('vae_file')] = gr.State(None)return componentsdef create_reference_latent_ui(prefix: str, max_units=10):2 unmodified lineswith gr.Accordion("Reference Edit Settings", open=False, visible=('reference_latent' in default_enabled_chains)) as ref_accordion:components[key('reference_latent_accordion')] = ref_accordiongr.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**.")ref_image_groups = []ref_image_inputs = []14 unmodified linescomponents[key('all_reference_latent_components_flat')] = ref_image_inputsreturn components2 unmodified lines345678910111213141537 unmodified lines53545556575859128 unmodified lines18818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024145 unmodified lines28728828929029129229362 unmodified lines35635735835936036136231 unmodified lines394395396397398399400134 unmodified lines53553653753853954054154254354454554654754825 unmodified lines5745755765775785795805815825835845852 unmodified lines58858959059159259359414 unmodified lines6096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406412 unmodified linesfrom core.settings import (MAX_LORAS, LORA_SOURCE_CHOICES, MAX_EMBEDDINGS, MAX_CONDITIONINGS,MAX_CONTROLNETS, MAX_IPADAPTERS, RESOLUTION_MAP, ARCHITECTURES_CONFIG,MODEL_MAP_CHECKPOINT, MODEL_TYPE_MAP, FEATURES_CONFIG, ARCH_CATEGORIES_MAP,VAE_DIR)import yamlimport osfrom functools import lru_cachefrom utils.app_utils import save_uploaded_file_with_hashdefault_model_name = list(MODEL_MAP_CHECKPOINT.keys())[0] if MODEL_MAP_CHECKPOINT else Nonedefault_m_type = MODEL_TYPE_MAP.get(default_model_name, "SDXL") if default_model_name else "SDXL"37 unmodified lineschoices=choices,value="ALL",interactive=True,visible=True)return components128 unmodified linesreturn componentsdef create_anima_controlnet_lllite_ui(prefix: str, max_units=MAX_CONTROLNETS):components = {}key = lambda name: f"{name}_{prefix}"with gr.Accordion("Anima ControlNet Lllite Settings", open=False, visible=('anima_controlnet_lllite' in default_enabled_chains)) as accordion:components[key('anima_controlnet_lllite_accordion')] = accordiongr.Markdown("💡 **Tip:** Processed using the [kohya-ss/ComfyUI-Anima-LLLite](https://github.com/kohya-ss/ComfyUI-Anima-LLLite) node.")cn_rows, images, series, types, strengths, filepaths, start_percents, end_percents = [], [], [], [], [], [], [], []components.update({key('anima_controlnet_lllite_rows'): cn_rows,key('anima_controlnet_lllite_images'): images,key('anima_controlnet_lllite_series'): series,key('anima_controlnet_lllite_types'): types,key('anima_controlnet_lllite_strengths'): strengths,key('anima_controlnet_lllite_filepaths'): filepaths,key('anima_controlnet_lllite_start_percents'): start_percents,key('anima_controlnet_lllite_end_percents'): end_percents})for i in range(max_units):with gr.Row(visible=(i < 1)) as row:with gr.Column(scale=1):images.append(gr.Image(label=f"Control Image {i+1}", type="pil", sources=["upload"], height=256))with gr.Column(scale=2):types.append(gr.Dropdown(label="Type", choices=[], interactive=True, allow_custom_value=True))series.append(gr.Dropdown(label="Series", choices=[], interactive=True, allow_custom_value=True))strengths.append(gr.Slider(label="Strength", minimum=0.0, maximum=2.0, step=0.05, value=1.0, interactive=True))with gr.Row(visible=False):start_percents.append(gr.State(0.0))end_percents.append(gr.State(1.0))filepaths.append(gr.State(None))cn_rows.append(row)with gr.Row():components[key('add_anima_controlnet_lllite_button')] = gr.Button("✚ Add Lllite")components[key('delete_anima_controlnet_lllite_button')] = gr.Button("➖ Delete Lllite", visible=False)components[key('anima_controlnet_lllite_count_state')] = gr.State(1)all_cn_components_flat = []for i in range(max_units):all_cn_components_flat.extend([images[i], types[i], series[i], strengths[i], filepaths[i], start_percents[i], end_percents[i]])components[key('all_anima_controlnet_lllite_components_flat')] = all_cn_components_flatreturn componentsdef create_diffsynth_controlnet_ui(prefix: str, max_units=MAX_CONTROLNETS):components = {}key = lambda name: f"{name}_{prefix}"45 unmodified lineswith gr.Accordion("IPAdapter Settings", open=False, visible=('ipadapter' in default_enabled_chains)) as accordion:components[key('ipadapter_accordion')] = accordiongr.Markdown("💡 **Tip:** Processed using the [cubiq/ComfyUI_IPAdapter_plus](https://github.com/cubiq/ComfyUI_IPAdapter_plus) node.")with gr.Row():components[key('ipadapter_final_preset')] = gr.Dropdown(62 unmodified lineswith gr.Accordion("IPAdapter Settings (FLUX.1)", open=False, visible=('flux1_ipadapter' in default_enabled_chains)) as accordion:components[key('flux1_ipadapter_accordion')] = accordiongr.Markdown("💡 **Tip:** Processed using the [Shakker-Labs/ComfyUI-IPAdapter-Flux](https://github.com/Shakker-Labs/ComfyUI-IPAdapter-Flux) node.")ipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []components.update({31 unmodified lineswith gr.Accordion("IPAdapter Settings (SD3)", open=False, visible=('sd3_ipadapter' in default_enabled_chains)) as accordion:components[key('sd3_ipadapter_accordion')] = accordiongr.Markdown("💡 **Tip:** Processed using the [Slickytail/ComfyUI-InstantX-IPAdapter-SD3](https://github.com/Slickytail/ComfyUI-InstantX-IPAdapter-SD3) node.")ipa_rows, images, weights, start_percents, end_percents = [], [], [], [], []components.update({134 unmodified linescomponents[key('all_conditioning_components_flat')] = all_cond_components_flatreturn componentsdef on_vae_upload(file_obj):if not file_obj:return gr.update(), gr.update(), Nonehashed_filename = save_uploaded_file_with_hash(file_obj, VAE_DIR)return hashed_filename, "File", file_objdef create_vae_override_ui(prefix: str):components = {}key = lambda name: f"{name}_{prefix}"25 unmodified linescomponents[key('vae_upload_button')] = upload_btncomponents[key('vae_file')] = gr.State(None)upload_btn.upload(fn=on_vae_upload,inputs=[upload_btn],outputs=[components[key('vae_id')], components[key('vae_source')], components[key('vae_file')]])return componentsdef create_reference_latent_ui(prefix: str, max_units=10):2 unmodified lineswith gr.Accordion("Reference Edit Settings", open=False, visible=('reference_latent' in default_enabled_chains)) as ref_accordion:components[key('reference_latent_accordion')] = ref_accordiongr.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**.")ref_image_groups = []ref_image_inputs = []14 unmodified linescomponents[key('all_reference_latent_components_flat')] = ref_image_inputsreturn componentsdef create_hidream_o1_reference_ui(prefix: str, max_units=10):components = {}key = lambda name: f"{name}_{prefix}"with gr.Accordion("HiDream-O1 Reference Edit Settings", open=False, visible=('hidream_o1_reference' in default_enabled_chains)) as ref_accordion:components[key('hidream_o1_reference_accordion')] = ref_accordiongr.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**.")ref_image_groups = []ref_image_inputs = []with gr.Row():for i in range(max_units):with gr.Column(visible=(i < 1), min_width=160) as img_col:img_comp = gr.Image(type="pil", label=f"Ref. {i+1}", sources=["upload"], height=150)ref_image_groups.append(img_col)ref_image_inputs.append(img_comp)components[key('hidream_o1_reference_rows')] = ref_image_groupscomponents[key('hidream_o1_reference_images')] = ref_image_inputswith gr.Row():components[key('add_hidream_o1_reference_button')] = gr.Button("✚ Add Reference Image")components[key('delete_hidream_o1_reference_button')] = gr.Button("➖ Delete Reference Image", visible=False)components[key('hidream_o1_reference_count_state')] = gr.State(1)components[key('all_hidream_o1_reference_components_flat')] = ref_image_inputsreturn components
14 unmodified lines1516171819202167 unmodified lines899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114245 unmodified lines188189190191192193194195330 unmodified lines52652752852953053153253353453553653753853954054154254354454554654754854914 unmodified linesfrom core.settings import *DISK_LIMIT_GB = 120MODELS_ROOT_DIR = "ComfyUI/models"IPADAPTER_PRESETS = None67 unmodified linesprint(f"Warning: Could not access {path} to calculate size: {e}")return total_sizedef enforce_disk_limit():disk_limit_bytes = DISK_LIMIT_GB * (1024 ** 3)cache_dir = hf_constants.HF_HUB_CACHEif not os.path.exists(cache_dir):returnprint(f"--- [Storage Manager] Checking disk usage in '{cache_dir}' (Limit: {DISK_LIMIT_GB} GB) ---")try:all_files = []current_size_bytes = 0for dirpath, _, filenames in os.walk(cache_dir):for f in filenames:if f.endswith(".incomplete") or f.endswith(".lock"):continuefile_path = os.path.join(dirpath, f)if os.path.isfile(file_path) and not os.path.islink(file_path):try:file_size = os.path.getsize(file_path)creation_time = os.path.getctime(file_path)all_files.append((creation_time, file_path, file_size))current_size_bytes += file_sizeexcept OSError:continueprint(f"--- [Storage Manager] Current usage: {bytes_to_gb(current_size_bytes)} GB ---")if current_size_bytes > disk_limit_bytes:print(f"--- [Storage Manager] Usage exceeds limit. Starting cleanup... ---")all_files.sort(key=lambda x: x[0])while current_size_bytes > disk_limit_bytes and all_files:oldest_file_time, oldest_file_path, oldest_file_size = all_files.pop(0)try:os.remove(oldest_file_path)current_size_bytes -= oldest_file_sizeprint(f"--- [Storage Manager] Deleted oldest file: {os.path.basename(oldest_file_path)} ({bytes_to_gb(oldest_file_size)} GB freed) ---")except OSError as e:print(f"--- [Storage Manager] Error deleting file {oldest_file_path}: {e} ---")print(f"--- [Storage Manager] Cleanup finished. New usage: {bytes_to_gb(current_size_bytes)} GB ---")else:print("--- [Storage Manager] Disk usage is within the limit. No action needed. ---")except Exception as e:print(f"--- [Storage Manager] An unexpected error occurred: {e} ---")def get_value_at_index(obj: Union[Sequence, Mapping], index: int) -> Any:try:return obj[index]45 unmodified linesreturn Nonedef download_file(url: str, save_path: str, api_key: str = None, progress=None, desc: str = "") -> str:enforce_disk_limit()if os.path.exists(save_path):return f"File already exists: {os.path.basename(save_path)}"330 unmodified linesprint(f"Warning: Failed to load or download sd3 ipadapter models: {e}")def print_welcome_message():author_name = "RioShiina"project_url = "https://huggingface.co/RioShiina"border = "=" * 72message = (f"\n{border}\n\n"f" Thank you for using this project!\n\n"f" **Author:** {author_name}\n"f" **Find more from the author:** {project_url}\n\n"f" This project is open-source under the GNU General Public License v3.0 (GPL-3.0).\n"f" As it's built upon GPL-3.0 components (like ComfyUI), any modifications you\n"f" distribute must also be open-sourced under the same license.\n\n"f" Your respect for the principles of free software is greatly appreciated!\n\n"f"{border}\n")print(message)def get_model_generation_defaults(model_display_name: str, model_type: str, defaults_config: dict):final_defaults = {14 unmodified lines15161718192067 unmodified lines88899091929345 unmodified lines139140141142143144330 unmodified lines47547647747847948014 unmodified linesfrom core.settings import *MODELS_ROOT_DIR = "ComfyUI/models"IPADAPTER_PRESETS = None67 unmodified linesprint(f"Warning: Could not access {path} to calculate size: {e}")return total_sizedef get_value_at_index(obj: Union[Sequence, Mapping], index: int) -> Any:try:return obj[index]45 unmodified linesreturn Nonedef download_file(url: str, save_path: str, api_key: str = None, progress=None, desc: str = "") -> str:if os.path.exists(save_path):return f"File already exists: {os.path.basename(save_path)}"330 unmodified linesprint(f"Warning: Failed to load or download sd3 ipadapter models: {e}")def get_model_generation_defaults(model_display_name: str, model_type: str, defaults_config: dict):final_defaults = {
12345678910111213Anima_ControlNet_Lllite:
- Filepath: "anima-lllite-lineart-1.safetensors"
Series: "kohya-ss"
Type: ["Lineart"]
- Filepath: "anima-lllite-depth-1.safetensors"
Series: "kohya-ss"
Type: ["Depth"]
- Filepath: "anima-lllite-pose-1.safetensors"
Series: "kohya-ss"
Type: ["Pose"]
- Filepath: "anima-lllite-scribble-1.safetensors"
Series: "kohya-ss"
Type: ["Scribble"]94 unmodified lines959697989910010194 unmodified lines"3:4 (Classic Portrait)": [896, 1152]"3:2 (Photography)": [1216, 832]"2:3 (Photography Portrait)": [832, 1216]hidream:"1:1 (Square)": [1024, 1024]"16:9 (Landscape)": [1344, 768]"9:16 (Portrait)": [768, 1344]94 unmodified lines959697989910010110210310410510610710810994 unmodified lines"3:4 (Classic Portrait)": [896, 1152]"3:2 (Photography)": [1216, 832]"2:3 (Photography Portrait)": [832, 1216]hidream-o1:"1:1 (Square)": [1024, 1024]"16:9 (Landscape)": [1344, 768]"9:16 (Portrait)": [768, 1344]"4:3 (Classic)": [1152, 896]"3:4 (Classic Portrait)": [896, 1152]"3:2 (Photography)": [1216, 832]"2:3 (Photography Portrait)": [832, 1216]hidream-i1:"1:1 (Square)": [1024, 1024]"16:9 (Landscape)": [1344, 768]"9:16 (Portrait)": [768, 1344]
1234542 unmodified lines484950515253545556575859606162636440 unmodified lines10510610710810911011111211311425 unmodified lines14014114214314414562 unmodified lines20820921021121221356 unmodified lines27027127227327427527627727827928028128228328428528628728828929029129229329483 unmodified lines37837938038138238338414 unmodified lines399400401402403404405406407408file:checkpoints:# Lumina- filename: "lumina_2.safetensors"source: "hf"42 unmodified linessource: hfrepo_id: "bluepen5805/illustrious_pencil-XL"repository_file_path: "illustrious_pencil-XL-v5.0.0.safetensors"- filename: "hassakuXLIllustrious_v34.safetensors"source: hfrepo_id: "oldhag88/hassakuXLIllustrious_v34.safetensors"repository_file_path: "hassakuXLIllustrious_v34.safetensors"- filename: "novaAnimeXL_ilV160.safetensors"source: hfrepo_id: "Yevrey921/novaAnimeXL_ilV160"repository_file_path: "novaAnimeXL_ilV160.safetensors"- filename: "Illustrious-XL-v2.0.safetensors"source: hfrepo_id: "OnomaAIResearch/Illustrious-XL-v2.0"- filename: "Illustrious-XL-v2.0.safetensors"source: hfrepo_id: "OnomaAIResearch/Illustrious-XL-v2.0"40 unmodified linessource: hfrepo_id: "bluepen5805/pony_pencil-XL"repository_file_path: "pony_pencil-XL-v2.0.0.safetensors"- filename: "CyberRealisticPony_V14.0.safetensors"source: hfrepo_id: "cyberdelia/CyberRealisticPony"repository_file_path: "CyberRealisticPony_V14.0.safetensors"# SDXL-Base- filename: "sd_xl_base_1.0.safetensors"source: "hf"25 unmodified linesrepo_id: "Comfy-Org/sigclip_vision_384"repository_file_path: "sigclip_vision_patch14_384.safetensors"controlnet:# SD3.5- filename: "sd3.5_large_controlnet_blur.safetensors"source: "hf"62 unmodified linessource: "hf"repo_id: "xinsir/anime-painter"repository_file_path: "diffusion_pytorch_model.safetensors"# SD1.5- filename: "control_v11e_sd15_ip2p_fp16.safetensors"source: "hf"56 unmodified linesrepo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"repository_file_path: "control_v11u_sd15_tile_fp16.safetensors"diffusion_models:# FLUX.2-klein-9B- filename: "flux-2-klein-9b-fp8.safetensors"source: "hf"repo_id: "black-forest-labs/FLUX.2-klein-9b-fp8"repository_file_path: "flux-2-klein-9b-fp8.safetensors"# FLUX.2-klein-base-9B- filename: "flux-2-klein-base-9b-fp8.safetensors"source: "hf"repo_id: "black-forest-labs/FLUX.2-klein-base-9b-fp8"repository_file_path: "flux-2-klein-base-9b-fp8.safetensors"# Anima- filename: "anima-preview3-base.safetensors"source: "hf"repo_id: "circlestone-labs/Anima"repository_file_path: "split_files/diffusion_models/anima-preview3-base.safetensors"- filename: "AnimaYume_tuned_v04.safetensors"source: "hf"repo_id: "duongve/AnimaYume"repository_file_path: "split_files/diffusion_models/AnimaYume_tuned_v04.safetensors"# NewBie-Image- filename: "NewBie-Image-Exp0.1-bf16.safetensors"source: "hf"83 unmodified linessource: "hf"repo_id: "Comfy-Org/FLUX.1-Krea-dev_ComfyUI"repository_file_path: "split_files/diffusion_models/flux1-krea-dev_fp8_scaled.safetensors"# HiDream- filename: "hidream_i1_dev_fp8.safetensors"source: "hf"repo_id: "Comfy-Org/HiDream-I1_ComfyUI"14 unmodified linessource: "hf"repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"repository_file_path: "split_files/diffusion_models/hunyuanimage2.1_distilled_fp8_e4m3fn.safetensors"- filename: "hunyuanimage2.1_refiner_fp8_e4m3fn.safetensors"source: "hf"repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"repository_file_path: "split_files/diffusion_models/hunyuanimage2.1_refiner_fp8_e4m3fn.safetensors"# Chroma1-Radiance- filename: "Chroma1-Radiance-x0-fp8mixed_fullmm-20260104.safetensors"source: "hf"123456789101112131442 unmodified lines575859606162636465666768697040 unmodified lines11111211311411511611711811912025 unmodified lines14614714814915015115215315415515615715815916016116216316416516616716862 unmodified lines23123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534656 unmodified lines40340440540640740840941041141241341441541641741841942042142242342442583 unmodified lines50951051151251351451514 unmodified lines530531532533534535file:checkpoints:# HiDream-O1- filename: "hidream_o1_image_dev_fp8_scaled.safetensors"source: "hf"repo_id: "Comfy-Org/HiDream-O1-Image"repository_file_path: "checkpoints/hidream_o1_image_dev_fp8_scaled.safetensors"- filename: "hidream_o1_image_fp8_scaled.safetensors"source: "hf"repo_id: "Comfy-Org/HiDream-O1-Image"repository_file_path: "checkpoints/hidream_o1_image_fp8_scaled.safetensors"# Lumina- filename: "lumina_2.safetensors"source: "hf"42 unmodified linessource: hfrepo_id: "bluepen5805/illustrious_pencil-XL"repository_file_path: "illustrious_pencil-XL-v5.0.0.safetensors"- filename: "hassakuXLIllustrious_v30.safetensors"source: hfrepo_id: "misri/hassakuXLIllustrious_v30"repository_file_path: "hassakuXLIllustrious_v30.safetensors"- filename: "novaAnimeXL_ilV160.safetensors"source: hfrepo_id: "Yevrey921/novaAnimeXL_ilV160"repository_file_path: "novaAnimeXL_ilV160.safetensors"- filename: "Illustrious-XL-v2.0.safetensors"source: hfrepo_id: "OnomaAIResearch/Illustrious-XL-v2.0"40 unmodified linessource: hfrepo_id: "bluepen5805/pony_pencil-XL"repository_file_path: "pony_pencil-XL-v2.0.0.safetensors"- filename: "CyberRealisticPony_V17.0_FP16.safetensors"source: hfrepo_id: "cyberdelia/CyberRealisticPony"repository_file_path: "CyberRealisticPony_V17.0_FP16.safetensors"# SDXL-Base- filename: "sd_xl_base_1.0.safetensors"source: "hf"25 unmodified linesrepo_id: "Comfy-Org/sigclip_vision_384"repository_file_path: "sigclip_vision_patch14_384.safetensors"controlnet:# Anima- filename: "anima-lllite-lineart-1.safetensors"source: "hf"repo_id: "kohya-ss/Anima-LLLite"repository_file_path: "anima-lllite-lineart-1.safetensors"- filename: "anima-lllite-depth-1.safetensors"source: "hf"repo_id: "kohya-ss/Anima-LLLite"repository_file_path: "anima-lllite-depth-1.safetensors"- filename: "anima-lllite-pose-1.safetensors"source: "hf"repo_id: "kohya-ss/Anima-LLLite"repository_file_path: "anima-lllite-pose-1.safetensors"- filename: "anima-lllite-scribble-1.safetensors"source: "hf"repo_id: "kohya-ss/Anima-LLLite"repository_file_path: "anima-lllite-scribble-1.safetensors"# SD3.5- filename: "sd3.5_large_controlnet_blur.safetensors"source: "hf"62 unmodified linessource: "hf"repo_id: "xinsir/anime-painter"repository_file_path: "diffusion_pytorch_model.safetensors"# SDXL - NoobAI- filename: "noob_sdxl_controlnet_canny.fp16.safetensors"source: "hf"repo_id: "Eugeoter/noob-sdxl-controlnet-canny"repository_file_path: "noob_sdxl_controlnet_canny.fp16.safetensors"- filename: "noob_sdxl_controlnet_depth.fp16.safetensors"source: "hf"repo_id: "Eugeoter/noob-sdxl-controlnet-depth"repository_file_path: "diffusion_pytorch_model.fp16.safetensors"- filename: "noob-sdxl-controlnet-lineart_anime.fp16.safetensors"source: "hf"repo_id: "Eugeoter/noob-sdxl-controlnet-lineart_anime"repository_file_path: "diffusion_pytorch_model.fp16.safetensors"- filename: "noob-sdxl-controlnet-lineart_realistic.fp16.safetensors"source: "hf"repo_id: "Eugeoter/noob-sdxl-controlnet-lineart_realistic"repository_file_path: "diffusion_pytorch_model.fp16.safetensors"- filename: "noob-sdxl-controlnet-manga_line.fp16.safetensors"source: "hf"repo_id: "Eugeoter/noob-sdxl-controlnet-manga_line"repository_file_path: "diffusion_pytorch_model.fp16.safetensors"- filename: "noob-sdxl-controlnet-normal.fp16.safetensors"source: "hf"repo_id: "Eugeoter/noob-sdxl-controlnet-normal"repository_file_path: "diffusion_pytorch_model.fp16.safetensors"- filename: "noob-sdxl-controlnet-softedge_hed.fp16.safetensors"source: "hf"repo_id: "Eugeoter/noob-sdxl-controlnet-softedge_hed"repository_file_path: "diffusion_pytorch_model.fp16.safetensors"- filename: "noob-sdxl-controlnet-tile.fp16.safetensors"source: "hf"repo_id: "Eugeoter/noob-sdxl-controlnet-tile"repository_file_path: "diffusion_pytorch_model.fp16.safetensors"- filename: "NoobAI_Inpainting_ControlNet.safetensors"source: "hf"repo_id: "Wenaka/NoobAI_XL_Inpainting_ControlNet_Full"repository_file_path: "NoobAI_Inpainting_ControlNet.safetensors"- filename: "noob_openpose_pre.safetensors"source: "hf"repo_id: "Laxhar/noob_openpose"repository_file_path: "openpose_pre.safetensors"- filename: "noobaiXLControlnet_epsBlur.safetensors"source: "civitai"model_version_id: "1731092"- filename: "noobaiXLControlnet_epsDepthMidasV11.safetensors"source: "hf"repo_id: "licyk/sd_control_collection"repository_file_path: "noobaiXLControlnet_epsDepthMidasV11.safetensors"- filename: "noobaiXLControlnet_epsNormalMidas.safetensors"source: "hf"repo_id: "licyk/sd_control_collection"repository_file_path: "noobaiXLControlnet_epsNormalMidas.safetensors"- filename: "noobaiXLControlnet_epsScribbleHed.safetensors"source: "hf"repo_id: "licyk/sd_control_collection"repository_file_path: "noobaiXLControlnet_epsScribbleHed.safetensors"- filename: "noobaiXLControlnet_epsScribblePidinet.safetensors"source: "hf"repo_id: "licyk/sd_control_collection"repository_file_path: "noobaiXLControlnet_epsScribblePidinet.safetensors"- filename: "noobaiXLControlnet_epsDepthMidas.safetensors"source: "hf"repo_id: "licyk/sd_control_collection"repository_file_path: "noobaiXLControlnet_epsDepthMidas.safetensors"- filename: "noobaiXLControlnet_openposeModel.safetensors"source: "hf"repo_id: "licyk/sd_control_collection"repository_file_path: "noobaiXLControlnet_openposeModel.safetensors"# SDXL - Illustrious-XL-v0.1- filename: "illustriousXLv0.1_Canny_fp16.safetensors"source: "hf"repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"repository_file_path: "illustriousXLv0.1_Canny_fp16.safetensors"- filename: "illustriousXLv0.1_Lineart_fp16.safetensors"source: "hf"repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"repository_file_path: "illustriousXLv0.1_Lineart_fp16.safetensors"- filename: "illustriousXLv0.1_Softedge_fp16.safetensors"source: "hf"repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"repository_file_path: "illustriousXLv0.1_Softedge_fp16.safetensors"- filename: "illustriousXLv0.1_Tile_fp16.safetensors"source: "hf"repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"repository_file_path: "illustriousXLv0.1_Tile_fp16.safetensors"- filename: "illustriousXLv0.1_depth_midas_fp16.safetensors"source: "hf"repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"repository_file_path: "illustriousXLv0.1_depth_midas_fp16.safetensors"- filename: "illustriousXLv0.1_inpainting_fp16.safetensors"source: "hf"repo_id: "MIC-Lab/illustriousXLv0.1_controlnet"repository_file_path: "illustriousXLv0.1_inpainting_fp16.safetensors"# SDXL - Illustrious-XL-v1.1- filename: "illustriousXLv1.1_canny_fp16.safetensors"source: "hf"repo_id: "MIC-Lab/illustriousXLv1.1_controlnet"repository_file_path: "illustriousXLv1.1_canny_fp16.safetensors"- filename: "illustriousXLv1.1_depth_midas_fp16.safetensors"source: "hf"repo_id: "MIC-Lab/illustriousXLv1.1_controlnet"repository_file_path: "illustriousXLv1.1_depth_midas_fp16.safetensors"- filename: "illustriousXLv1.1_inpainting_fp16.safetensors"source: "hf"repo_id: "MIC-Lab/illustriousXLv1.1_controlnet"repository_file_path: "illustriousXLv1.1_inpainting_fp16.safetensors"- filename: "illustriousXLv1.1_tile_fp16.safetensors"source: "hf"repo_id: "MIC-Lab/illustriousXLv1.1_controlnet"repository_file_path: "illustriousXLv1.1_tile_fp16.safetensors"# SD1.5- filename: "control_v11e_sd15_ip2p_fp16.safetensors"source: "hf"56 unmodified linesrepo_id: "comfyanonymous/ControlNet-v1-1_fp16_safetensors"repository_file_path: "control_v11u_sd15_tile_fp16.safetensors"diffusion_models:# Anima- filename: "waiANIMA_v10.safetensors"source: "hf"repo_id: "diffusionmodels1254ani/waiANIMA"repository_file_path: "waiANIMA_v10.safetensors"- filename: "anima-base-v1.0.safetensors"source: "hf"repo_id: "circlestone-labs/Anima"repository_file_path: "split_files/diffusion_models/anima-base-v1.0.safetensors"- filename: "AnimaYume_tuned_v05.safetensors"source: "hf"repo_id: "duongve/AnimaYume"repository_file_path: "split_files/diffusion_models/AnimaYume_tuned_v05.safetensors"- filename: "anima_pencil-v1.0.0.safetensors"source: "hf"repo_id: "bluepen5805/anima-models"repository_file_path: "anima_pencil-v1.0.0.safetensors"# NewBie-Image- filename: "NewBie-Image-Exp0.1-bf16.safetensors"source: "hf"83 unmodified linessource: "hf"repo_id: "Comfy-Org/FLUX.1-Krea-dev_ComfyUI"repository_file_path: "split_files/diffusion_models/flux1-krea-dev_fp8_scaled.safetensors"# HiDream-I1- filename: "hidream_i1_dev_fp8.safetensors"source: "hf"repo_id: "Comfy-Org/HiDream-I1_ComfyUI"14 unmodified linessource: "hf"repo_id: "Comfy-Org/HunyuanImage_2.1_ComfyUI"repository_file_path: "split_files/diffusion_models/hunyuanimage2.1_distilled_fp8_e4m3fn.safetensors"# Chroma1-Radiance- filename: "Chroma1-Radiance-x0-fp8mixed_fullmm-20260104.safetensors"source: "hf"
43 unmodified lines44454647484949 unmodified lines9910010110210310410510610710843 unmodified linesanima:enabled_chains:- lora- conditioningnewbie-image:49 unmodified lines- conditioning- flux1_ipadapterhidream:enabled_chains:- lora- conditioningchroma1:enabled_chains:43 unmodified lines4445464748495049 unmodified lines10010110210310410510610710810911011111211311411543 unmodified linesanima:enabled_chains:- lora- anima_controlnet_lllite- conditioningnewbie-image:49 unmodified lines- conditioning- flux1_ipadapterhidream-o1:enabled_chains:- lora- conditioning- hidream_o1_referencehidream-i1:enabled_chains:- lora- conditioningchroma1:enabled_chains:
6 unmodified lines7891011122 unmodified lines1516171819202122232425263 unmodified lines303132333435366 unmodified linesmodule: "chain_injectors.newbie_lora_injector"dynamic_controlnet_chains:module: "chain_injectors.controlnet_injector"dynamic_diffsynth_controlnet_chains:module: "chain_injectors.diffsynth_controlnet_injector"dynamic_ipadapter_chains:2 unmodified linesmodule: "chain_injectors.flux1_ipadapter_injector"dynamic_sd3_ipadapter_chains:module: "chain_injectors.sd3_ipadapter_injector"dynamic_style_chains:module: "chain_injectors.style_injector"dynamic_conditioning_chains:module: "chain_injectors.conditioning_injector"dynamic_reference_latent_chains:module: "chain_injectors.reference_latent_injector"injector_order:- dynamic_vae_chains3 unmodified lines- dynamic_ipadapter_chains- dynamic_flux1_ipadapter_chains- dynamic_sd3_ipadapter_chains- dynamic_style_chains- dynamic_conditioning_chains- dynamic_reference_latent_chains- dynamic_controlnet_chains6 unmodified lines78910111213142 unmodified lines171819202122232425262728293031323 unmodified lines363738394041424344456 unmodified linesmodule: "chain_injectors.newbie_lora_injector"dynamic_controlnet_chains:module: "chain_injectors.controlnet_injector"dynamic_anima_controlnet_lllite_chains:module: "chain_injectors.anima_controlnet_lllite_injector"dynamic_diffsynth_controlnet_chains:module: "chain_injectors.diffsynth_controlnet_injector"dynamic_ipadapter_chains:2 unmodified linesmodule: "chain_injectors.flux1_ipadapter_injector"dynamic_sd3_ipadapter_chains:module: "chain_injectors.sd3_ipadapter_injector"dynamic_reference_latent_chains:module: "chain_injectors.reference_latent_injector"dynamic_conditioning_chains:module: "chain_injectors.conditioning_injector"dynamic_style_chains:module: "chain_injectors.style_injector"dynamic_hidream_o1_smoothing_chains:module: "chain_injectors.hidream_o1_smoothing_injector"dynamic_hidream_o1_reference_chains:module: "chain_injectors.hidream_o1_reference_injector"injector_order:- dynamic_vae_chains3 unmodified lines- dynamic_ipadapter_chains- dynamic_flux1_ipadapter_chains- dynamic_sd3_ipadapter_chains- dynamic_reference_latent_chains- dynamic_conditioning_chains- dynamic_style_chains- dynamic_controlnet_chains- dynamic_anima_controlnet_lllite_chains- dynamic_hidream_o1_smoothing_chains- dynamic_hidream_o1_reference_chains
12 unmodified lines1314151617181951 unmodified lines71727374757677787912 unmodified lines- "Chroma1"- "OmniGen2"- "Lumina"- "HiDream"- "FLUX.1"- "SD3.5"- "SDXL"51 unmodified lines"SD3.5":model_type: "sd35"controlnet_key: "SD3.5""HiDream":model_type: "hidream"controlnet_key: "HiDream""SD1.5":model_type: "sd15"controlnet_key: "SD1.5"12 unmodified lines131415161718192051 unmodified lines72737475767778798081828312 unmodified lines- "Chroma1"- "OmniGen2"- "Lumina"- "HiDream-O1"- "HiDream-I1"- "FLUX.1"- "SD3.5"- "SDXL"51 unmodified lines"SD3.5":model_type: "sd35"controlnet_key: "SD3.5""HiDream-O1":model_type: "hidream-o1"controlnet_key: "HiDream-O1""HiDream-I1":model_type: "hidream-i1"controlnet_key: "HiDream-I1""SD1.5":model_type: "sd15"controlnet_key: "SD1.5"
2 unmodified lines34567893 unmodified lines131415161718192021222324251 unmodified line272829303132337 unmodified lines414243444546474 unmodified lines525354555657585960616263641 unmodified line666768697071722 unmodified lines757677787980811 unmodified line8384858687888912 unmodified lines1021031041051061071081 unmodified line1101111121131141151163 unmodified lines1201211221231241251266 unmodified lines1331341351361371381392 unmodified lines1421431441451461471481 unmodified line1501511521531541551563 unmodified lines1601611621631641651661 unmodified line16816917017117217317417517617717817918018118218318418518618712 unmodified lines2002012022032042052062 unmodified linescfg: 7.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576positive_prompt: ""negative_prompt: ""3 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576"baidu/ERNIE-Image-Turbo":steps: 8cfg: 1.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576FLUX.2:_defaults:1 unmodified linecfg: 4.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576"black-forest-labs/FLUX.2-klein-4B":steps: 4cfg: 1.07 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576"black-forest-labs/FLUX.2-klein-9B-KV":steps: 4cfg: 1.04 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576"Tongyi-MAI/Z Image Turbo":steps: 9cfg: 1.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576Qwen-Image:_defaults:1 unmodified linecfg: 1.0sampler_name: "euler"scheduler: "simple"total_pixels: 1763584LongCat-Image:_defaults:2 unmodified linesguidance: 4.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576Anima:_defaults:1 unmodified linecfg: 4.0sampler_name: "er_sde"scheduler: "simple"total_pixels: 1048576positive_prompt: "masterpiece, best quality, score_7, safe. "negative_prompt: "worst quality, low quality, score_1, score_2, score_3, blurry, jpeg artifacts, sepia"12 unmodified linescfg: 5.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576OmniGen2:_defaults:1 unmodified linecfg: 5.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576positive_prompt: ""negative_prompt: ""3 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs""lodestones/Chroma1-HD-Flash":steps: 86 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs, hands, fingers"SD3.5:2 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "sgm_uniform"total_pixels: 1048576SDXL:_defaults:1 unmodified linecfg: 7.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576positive_prompt: ""negative_prompt: ""3 unmodified linescfg: 7.0sampler_name: "euler_ancestral"scheduler: "simple"total_pixels: 393216FLUX.1:_defaults:1 unmodified linecfg: 1.0sampler_name: "euler"scheduler: "simple"total_pixels: 1048576"flux1-schnell":steps: 4cfg: 1.0sampler_name: "euler"scheduler: "simple"HiDream:_defaults:steps: 50cfg: 3.0sampler_name: "uni_pc"scheduler: "simple"total_pixels: 1048576negative_prompt: "bad ugly jpeg artifacts""HiDream_i1_Dev":steps: 2812 unmodified linescfg: 3.5sampler_name: "euler"scheduler: "simple"total_pixels: 4194304"HunyuanImage-2.1-Distilled":steps: 8cfg: 1.02 unmodified lines3456783 unmodified lines12131415161718192021221 unmodified line2425262728297 unmodified lines3738394041424 unmodified lines47484950515253545556571 unmodified line5960616263642 unmodified lines6768697071721 unmodified line74757677787912 unmodified lines9293949596971 unmodified line991001011021031043 unmodified lines1081091101111121136 unmodified lines1201211221231241252 unmodified lines1281291301311321331 unmodified line1351361371381391403 unmodified lines1441451461471481491 unmodified line15115215315415515615715815916016116216316416516616716816917017117217317417517617717817918012 unmodified lines1931941951961971982 unmodified linescfg: 7.0sampler_name: "euler"scheduler: "simple"positive_prompt: ""negative_prompt: ""3 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "simple""baidu/ERNIE-Image-Turbo":steps: 8cfg: 1.0sampler_name: "euler"scheduler: "simple"FLUX.2:_defaults:1 unmodified linecfg: 4.0sampler_name: "euler"scheduler: "simple""black-forest-labs/FLUX.2-klein-4B":steps: 4cfg: 1.07 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "simple""black-forest-labs/FLUX.2-klein-9B-KV":steps: 4cfg: 1.04 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "simple""Tongyi-MAI/Z Image Turbo":steps: 9cfg: 1.0sampler_name: "euler"scheduler: "simple"Qwen-Image:_defaults:1 unmodified linecfg: 1.0sampler_name: "euler"scheduler: "simple"LongCat-Image:_defaults:2 unmodified linesguidance: 4.0sampler_name: "euler"scheduler: "simple"Anima:_defaults:1 unmodified linecfg: 4.0sampler_name: "er_sde"scheduler: "simple"positive_prompt: "masterpiece, best quality, score_7, safe. "negative_prompt: "worst quality, low quality, score_1, score_2, score_3, blurry, jpeg artifacts, sepia"12 unmodified linescfg: 5.0sampler_name: "euler"scheduler: "simple"OmniGen2:_defaults:1 unmodified linecfg: 5.0sampler_name: "euler"scheduler: "simple"positive_prompt: ""negative_prompt: ""3 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "simple"negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs""lodestones/Chroma1-HD-Flash":steps: 86 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "simple"negative_prompt: "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs, hands, fingers"SD3.5:2 unmodified linescfg: 4.0sampler_name: "euler"scheduler: "sgm_uniform"SDXL:_defaults:1 unmodified linecfg: 7.0sampler_name: "euler"scheduler: "simple"positive_prompt: ""negative_prompt: ""3 unmodified linescfg: 7.0sampler_name: "euler_ancestral"scheduler: "simple"FLUX.1:_defaults:1 unmodified linecfg: 1.0sampler_name: "euler"scheduler: "simple""flux1-schnell":steps: 4cfg: 1.0sampler_name: "euler"scheduler: "simple"HiDream-O1:_defaults:steps: 40cfg: 5.0sampler_name: "dpmpp_2m_sde_gpu"scheduler: "normal""HiDream-O1-Image-Dev":steps: 28cfg: 1.0sampler_name: "lcm"scheduler: "normal"HiDream-I1:_defaults:steps: 50cfg: 3.0sampler_name: "uni_pc"scheduler: "simple"negative_prompt: "bad ugly jpeg artifacts""HiDream_i1_Dev":steps: 2812 unmodified linescfg: 3.5sampler_name: "euler"scheduler: "simple""HunyuanImage-2.1-Distilled":steps: 8cfg: 1.0
5 unmodified lines67895 unmodified linescomponents:unet: "flux-2-klein-9b-kv-fp8.safetensors"clip: "qwen_3_8b_fp8mixed.safetensors"vae: "flux2-vae.safetensors"5 unmodified lines67891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183195 unmodified linescomponents:unet: "flux-2-klein-9b-kv-fp8.safetensors"clip: "qwen_3_8b_fp8mixed.safetensors"vae: "flux2-vae.safetensors"FLUX.2:latent_type: flux2_latentmodels:- display_name: "black-forest-labs/FLUX.2-klein-4B"components:unet: "flux-2-klein-4b-fp8.safetensors"clip: "qwen_3_4b.safetensors"vae: "flux2-vae.safetensors"- display_name: "black-forest-labs/FLUX.2-klein-9B"components:unet: "flux-2-klein-9b-fp8.safetensors"clip: "qwen_3_8b_fp8mixed.safetensors"vae: "flux2-vae.safetensors"- display_name: "black-forest-labs/FLUX.2-klein-base-4B"components:unet: "flux-2-klein-base-4b-fp8.safetensors"clip: "qwen_3_4b.safetensors"vae: "flux2-vae.safetensors"- display_name: "black-forest-labs/FLUX.2-klein-base-9B"components:unet: "flux-2-klein-base-9b-fp8.safetensors"clip: "qwen_3_8b_fp8mixed.safetensors"vae: "flux2-vae.safetensors"- display_name: "black-forest-labs/FLUX.2-dev (Need to set ZeroGPU Duration to 120)"components:unet: "flux2_dev_fp8mixed.safetensors"clip: "mistral_3_small_flux2_fp8.safetensors"vae: "flux2-vae.safetensors"ERNIE-Image:latent_type: flux2_latentmodels:- display_name: "baidu/ERNIE-Image"components:unet: "ernie-image.safetensors"vae: "flux2-vae.safetensors"clip: "ministral-3-3b.safetensors"- display_name: "baidu/ERNIE-Image-Turbo"components:unet: "ernie-image-turbo.safetensors"vae: "flux2-vae.safetensors"clip: "ministral-3-3b.safetensors"Z-Image:latent_type: sd3_latentmodels:- display_name: "Tongyi-MAI/Z Image Turbo"components:unet: "z_image_turbo_bf16.safetensors"vae: "ae.safetensors"clip: "qwen_3_4b_fp8_mixed.safetensors"- display_name: "Tongyi-MAI/Z Image"components:unet: "z_image_bf16.safetensors"vae: "ae.safetensors"clip: "qwen_3_4b_fp8_mixed.safetensors"Qwen-Image:latent_type: sd3_latentmodels:- display_name: "Qwen/Qwen-Image-2512 + Lightning-4steps-V1.0 LoRA"components:unet: "qwen_image_2512_fp8_e4m3fn.safetensors"vae: "qwen_image_vae.safetensors"clip: "qwen_2.5_vl_7b_fp8_scaled.safetensors"lora: "Qwen-Image-2512-Lightning-4steps-V1.0-bf16.safetensors"- display_name: "Qwen/Qwen-Image + Lightning-4steps-V1.0 LoRA"components:unet: "qwen_image_fp8_e4m3fn.safetensors"vae: "qwen_image_vae.safetensors"clip: "qwen_2.5_vl_7b_fp8_scaled.safetensors"lora: "Qwen-Image-fp8-e4m3fn-Lightning-4steps-V1.0-bf16.safetensors"LongCat-Image:latent_type: sd3_latentmodels:- display_name: "meituan-longcat/LongCat-Image"components:unet: "longcat_image_bf16.safetensors"vae: "ae.safetensors"clip: "qwen_2.5_vl_7b_fp8_scaled.safetensors"Anima:latent_type: latentmodels:- display_name: "WAI0731/waiANIMA-v1.0"components:unet: "waiANIMA_v10.safetensors"vae: "qwen_image_vae.safetensors"clip: "qwen_3_06b_base.safetensors"- display_name: "duongve/AnimaYume-v0.5"components:unet: "AnimaYume_tuned_v05.safetensors"vae: "qwen_image_vae.safetensors"clip: "qwen_3_06b_base.safetensors"- display_name: "bluepen5805/Anima-pencil-v1.0"components:unet: "anima_pencil-v1.0.0.safetensors"vae: "qwen_image_vae.safetensors"clip: "qwen_3_06b_base.safetensors"- display_name: "circlestone-labs/Anima-base-v1.0"components:unet: "anima-base-v1.0.safetensors"vae: "qwen_image_vae.safetensors"clip: "qwen_3_06b_base.safetensors"NewBie-Image:latent_type: sd3_latentmodels:- display_name: "NewBie-AI/NewBie-image-Exp0.1"components:unet: "NewBie-Image-Exp0.1-bf16.safetensors"vae: "ae.safetensors"clip1: "gemma_3_4b_it_bf16.safetensors"clip2: "jina_clip_v2_bf16.safetensors"Ovis-Image:latent_type: sd3_latentmodels:- display_name: "AIDC-AI/Ovis-Image"components:unet: "ovis_image_bf16.safetensors"vae: "ae.safetensors"clip: "ovis_2.5.safetensors"HunyuanImage:latent_type: hunyuan_latentmodels:- display_name: "HunyuanImage-2.1"components:unet: "hunyuanimage2.1_fp8_e4m3fn.safetensors"vae: "hunyuan_image_2.1_vae_fp16.safetensors"clip1: "qwen_2.5_vl_7b_fp8_scaled.safetensors"clip2: "byt5_small_glyphxl_fp16.safetensors"- display_name: "HunyuanImage-2.1-Distilled"components:unet: "hunyuanimage2.1_distilled_fp8_e4m3fn.safetensors"vae: "hunyuan_image_2.1_vae_fp16.safetensors"clip1: "qwen_2.5_vl_7b_fp8_scaled.safetensors"clip2: "byt5_small_glyphxl_fp16.safetensors"Chroma1-Radiance:latent_type: chroma_radiance_latentmodels:- display_name: "lodestones/Chroma1-Radiance-x0"components:unet: "Chroma1-Radiance-x0-fp8mixed_fullmm-20260104.safetensors"vae: "pixel_space"clip: "t5xxl_fp8_e4m3fn_scaled.safetensors"Chroma1:latent_type: sd3_latentmodels:- display_name: "lodestones/Chroma1-HD"components:unet: "Chroma1-HD_float8_e4m3fn_scaled_learned_topk8_svd.safetensors"vae: "ae.safetensors"clip: "t5xxl_fp8_e4m3fn_scaled.safetensors"- display_name: "lodestones/Chroma1-HD-Flash"components:unet: "Chroma1-HD-Flash_float8_e4m3fn_scaled_learned_topk8_svd.safetensors"vae: "ae.safetensors"clip: "t5xxl_fp8_e4m3fn_scaled.safetensors"OmniGen2:latent_type: sd3_latentmodels:- display_name: "OmniGen2"components:unet: "omnigen2_fp16.safetensors"vae: "ae.safetensors"clip: "qwen_2.5_vl_fp16.safetensors"Lumina:latent_type: sd3_latentmodels:- display_name: "Alpha-VLLM/Lumina-Image-2.0"path: "lumina_2.safetensors"HiDream-O1:latent_type: hidream_o1_latentmodels:- display_name: "HiDream-O1-Image-Dev"path: "hidream_o1_image_dev_fp8_scaled.safetensors"- display_name: "HiDream-O1-Image"path: "hidream_o1_image_fp8_scaled.safetensors"HiDream-I1:latent_type: sd3_latentmodels:- display_name: "HiDream_i1_Dev"components:unet: "hidream_i1_dev_fp8.safetensors"vae: "ae.safetensors"clip1: "clip_l_hidream.safetensors"clip2: "clip_g_hidream.safetensors"clip3: "t5xxl_fp8_e4m3fn_scaled.safetensors"clip4: "llama_3.1_8b_instruct_fp8_scaled.safetensors"- display_name: "HiDream_i1_Full"components:unet: "hidream_i1_full_fp8.safetensors"vae: "ae.safetensors"clip1: "clip_l_hidream.safetensors"clip2: "clip_g_hidream.safetensors"clip3: "t5xxl_fp8_e4m3fn_scaled.safetensors"clip4: "llama_3.1_8b_instruct_fp8_scaled.safetensors"- display_name: "HiDream_i1_Fast"components:unet: "hidream_i1_fast_fp8.safetensors"vae: "ae.safetensors"clip1: "clip_l_hidream.safetensors"clip2: "clip_g_hidream.safetensors"clip3: "t5xxl_fp8_e4m3fn_scaled.safetensors"clip4: "llama_3.1_8b_instruct_fp8_scaled.safetensors"FLUX.1:latent_type: sd3_latentmodels:- display_name: "flux1-dev"components:unet: "flux1-dev-fp8-e4m3fn.safetensors"vae: "ae.safetensors"clip1: "clip_l.safetensors"clip2: "t5xxl_fp8_e4m3fn_scaled.safetensors"- display_name: "flux1-schnell"components:unet: "flux1-schnell-fp8-e4m3fn.safetensors"vae: "ae.safetensors"clip1: "clip_l.safetensors"clip2: "t5xxl_fp8_e4m3fn_scaled.safetensors"- display_name: "flux1-krea-dev"components:unet: "flux1-krea-dev_fp8_scaled.safetensors"vae: "ae.safetensors"clip1: "clip_l.safetensors"clip2: "t5xxl_fp8_e4m3fn_scaled.safetensors"SD3.5:latent_type: sd3_latentmodels:- display_name: "StabilityAI/SD3.5-Large"path: "sd3.5_large_fp8_scaled.safetensors"- display_name: "StabilityAI/SD3.5-Medium"path: "sd3.5_medium_incl_clips_t5xxlfp8scaled.safetensors"SDXL:latent_type: latentmodels:# NoobAI- display_name: "Laxhar/noobai-XL-Vpred-1.0"path: "NoobAI-XL-Vpred-v1.0.safetensors"category: "NoobAI"- display_name: "Laxhar/noobai-XL-1.1"path: "NoobAI-XL-v1.1.safetensors"category: "NoobAI"- display_name: "bluepen5805/noob_v_pencil-XL-3.0.0"path: "noob_v_pencil-XL-v3.0.0.safetensors"category: "NoobAI"- display_name: "RedRayz/hikari_noob_v-pred_1.2.4"path: "Hikari_Noob_v-pred_1.2.4.safetensors"category: "NoobAI"- display_name: "ChenkinNoob/ChenkinNoob-XL-V0.5"path: "ChenkinNoob-XL-V0.5.safetensors"category: "NoobAI"# Illustrious- display_name: "WAI0731/wai-illustrious-sdxl-v170"path: "waiIllustriousSDXL_v170.safetensors"category: "Illustrious"- display_name: "blue_pen5805/mellow_pencil-XL-v1.0.0"path: "mellow_pencil-XL-v1.0.0.safetensors"category: "Illustrious"- display_name: "blue_pen5805/illustrious_pencil-XL-v5.0.0"path: "illustrious_pencil-XL-v5.0.0.safetensors"category: "Illustrious"- display_name: "Ikena/hassaku-xl-illustrious-v3.0"path: "hassakuXLIllustrious_v30.safetensors"category: "Illustrious"- display_name: "Crody/Nova-Anime-XL-v16.0"path: "novaAnimeXL_ilV160.safetensors"category: "Illustrious"- display_name: "OnomaAIResearch/Illustrious-XL-v2.0"path: "Illustrious-XL-v2.0.safetensors"category: "Illustrious"- display_name: "OnomaAIResearch/Illustrious-XL-v1.1"path: "Illustrious-XL-v1.1.safetensors"category: "Illustrious"- display_name: "OnomaAIResearch/Illustrious-XL-v1.0"path: "Illustrious-XL-v1.0.safetensors"category: "Illustrious"- display_name: "aria1th261/Illustrious-XL-v0.1"path: "illustriousXL_v01.safetensors"category: "Illustrious"# SDXL-Animate- display_name: "CagliostroLab/Animagine XL 4.0"path: "animagine-xl-4.0.safetensors"category: "Animate"- display_name: "CagliostroLab/Animagine XL 3.1"path: "animagine-xl-3.1.safetensors"category: "Animate"- display_name: "blue_pen5805/4nima_pencil-XL v1.0.1"path: "4nima_pencil-XL-v1.0.1.safetensors"category: "Animate"- display_name: "blue_pen5805/anima_pencil-XL v5.0.0"path: "anima_pencil-XL-v5.0.0.safetensors"category: "Animate"- display_name: "blue_pen5805/blue_pencil-XL v7.0.0"path: "blue_pencil-XL-v7.0.0.safetensors"category: "Animate"# SDXL-Pony- display_name: "PurpleSmartAI/Pony Diffusion V6 XL"path: "ponyDiffusionV6XL_v6StartWithThisOne.safetensors"category: "Pony"- display_name: "blue_pen5805/pony_pencil-XL v2.0.0"path: "pony_pencil-XL-v2.0.0.safetensors"category: "Pony"- display_name: "Cyberdelia/CyberRealistic Pony v17.0"path: "CyberRealisticPony_V17.0_FP16.safetensors"category: "Pony"# SDXL-Base- display_name: "stabilityai/stable-diffusion-xl-base-1.0"path: "sd_xl_base_1.0.safetensors"category: "Base"SD1.5:latent_type: latentmodels:- display_name: "stable-diffusion-v1-5/stable-diffusion-v1-5"path: "v1-5-pruned-emaonly.safetensors"
LICENSEAdded+674
README.md+92
app.py+1-13
chain_injectors/anima_controlnet_lllite_injector.pyAdded+48
chain_injectors/hidream_o1_reference_injector.pyAdded+54
chain_injectors/hidream_o1_smoothing_injector.pyAdded+39
comfy_integration/setup.py+8
core/pipelines/sd_image_pipeline.py+67-21
core/pipelines/workflow_recipes/_partials/conditioning/anima.yaml+4
core/pipelines/workflow_recipes/_partials/conditioning/hidream.yaml → core/pipelines/workflow_recipes/_partials/conditioning/hidream-i1.yamlRenamed+3-3
core/pipelines/workflow_recipes/_partials/conditioning/hidream-o1.yamlAdded+68
core/pipelines/workflow_recipes/_partials/input/txt2img_hidream_o1_latent.yamlAdded+11
requirements.txt+12-28
scripts/__init__.pyDeleted
scripts/build_sage_attention.pyDeleted-99
ui/events.pyDeleted-1258
ui/events/__init__.pyAdded+10
ui/events/chain_handlers.pyAdded+680
ui/events/change_handlers.pyAdded+333
ui/events/config_loaders.pyAdded+131
ui/events/main.pyAdded+240
ui/events/run_handlers.pyAdded+100
ui/layout.py+9-6
ui/shared/hires_fix_ui.py+4-2
ui/shared/img2img_ui.py+4-2
ui/shared/inpaint_ui.py+4-2
ui/shared/outpaint_ui.py+4-2
ui/shared/txt2img_ui.py+4-2
ui/shared/ui_components.py+98-4
utils/app_utils.py-69
yaml/anima_controlnet_lllite_models.yamlAdded+13
yaml/constants.yaml+9-1
yaml/file_list.yaml+154-27
yaml/image_gen_features.yaml+10-3
yaml/injectors.yaml+16-7
yaml/model_architectures.yaml+8-4
yaml/model_defaults.yaml+13-21
yaml/model_list.yaml+311-1