mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-08-15 02:39:13 +02:00
Compare commits
282 Commits
v2.5.48-fi
...
diff-v26
Author | SHA1 | Date | |
---|---|---|---|
94f9e74d67 | |||
47432fe54e | |||
8660a79ccd | |||
547febafba | |||
85eaa305cc | |||
e77629c525 | |||
097780be26 | |||
398a0509d7 | |||
52cc99bf1f | |||
9bd4b3a6d0 | |||
8a98df4673 | |||
45a14a9be9 | |||
e419276e34 | |||
0a92b7b1d5 | |||
f110168366 | |||
ce24a05909 | |||
45facf64e5 | |||
e999832c26 | |||
4c8d5a7077 | |||
81643cb3af | |||
7a9bc883df | |||
6280a80129 | |||
a33908b6de | |||
0ea5620413 | |||
e23eb1fea8 | |||
41f2c82eaf | |||
91e3bfe58f | |||
83d5519a31 | |||
cc2666b9d6 | |||
954493fef5 | |||
967c3681cd | |||
87c9df5c0d | |||
62136768d2 | |||
b71b7804fc | |||
e8b7751374 | |||
54d4433141 | |||
14dbebbc35 | |||
d6a02a31a7 | |||
86e2ac40ae | |||
a12ed7533b | |||
9fb0ee2d1b | |||
6311b80474 | |||
c13d1093ee | |||
dd7deeba53 | |||
338aef3e95 | |||
134c98ccb5 | |||
d12877987f | |||
676316e5e4 | |||
52761ad88c | |||
f5e489ba87 | |||
982af1fff3 | |||
1cff398c20 | |||
a6271d2c4e | |||
60f8cc6883 | |||
ffb8feba6b | |||
4aca3c4639 | |||
120f9e567c | |||
c0492511df | |||
1075a5ed93 | |||
58d3507155 | |||
ae0c9b6a6b | |||
ad1374af1d | |||
8436e8a71e | |||
ea07483465 | |||
51f857c3f3 | |||
74c0ca0902 | |||
ad5641fa3e | |||
b0294f8cbd | |||
5d4498ff85 | |||
d52fb15746 | |||
ee6be74e72 | |||
4cbc86f945 | |||
3a5e0cb2d2 | |||
7916b8d26a | |||
a0842b4659 | |||
14ee87ca80 | |||
cec1d7d6c9 | |||
9aeae4d16e | |||
9c1b741d89 | |||
c71a74f857 | |||
524612cee5 | |||
11e47b3871 | |||
4a1b2be45c | |||
d641aa2f6e | |||
237c7a5348 | |||
19f37907d9 | |||
b8706da990 | |||
b458d57355 | |||
a5962dae33 | |||
670768e5b3 | |||
f02b915cd0 | |||
71bbbeb936 | |||
e084b78b53 | |||
013860e3c0 | |||
7a118eeb15 | |||
df408b25e5 | |||
536082c1a6 | |||
b986ca3059 | |||
4bf9e577b9 | |||
a7c12e61d8 | |||
847d27bffb | |||
781e812f22 | |||
e49b5e0e6b | |||
8f1c1b128e | |||
04cbb052d7 | |||
16f0950ebd | |||
e959a3d7ab | |||
fc9941abaa | |||
f177011395 | |||
80e47be5a5 | |||
9a9f6e3559 | |||
1a6e0234b3 | |||
56bea46e3a | |||
a09441b2c8 | |||
105994d96d | |||
d641647b1e | |||
672574d278 | |||
f1ded17399 | |||
d254e3e2fd | |||
ab5450bb27 | |||
a2e9e5eb57 | |||
8965f11ab4 | |||
1dd5644e7a | |||
37f813506e | |||
a5d5ed90e6 | |||
3792a1bc0d | |||
fbafa56ecb | |||
2f910c69b8 | |||
bf06cc48bb | |||
3ef67ebc73 | |||
0c4318fb31 | |||
c55ced93db | |||
4bd89ab2e1 | |||
807d940001 | |||
d4427b97ae | |||
4f336d9f25 | |||
1565530b0f | |||
a21b01a0cd | |||
1c7e90576d | |||
8c27fa136c | |||
c8de1cd49b | |||
5eb36e131d | |||
b5d1adaa19 | |||
b89d152540 | |||
e49772030d | |||
b1cb03962c | |||
a7b0858b22 | |||
ad227ca190 | |||
a8360484b2 | |||
80c4a50ca1 | |||
768b88a0ac | |||
82607573fa | |||
d07e00cd74 | |||
dfdd2b32e0 | |||
844edbc865 | |||
2bc66cc640 | |||
f9f9aba92d | |||
3f278cf2ad | |||
cb7ba96dad | |||
31edce4a60 | |||
1b6aae9678 | |||
9572ddf1c1 | |||
1f44cebd0e | |||
843ea58c15 | |||
1e13c4e808 | |||
c62161770d | |||
15b828b0f5 | |||
faa83a87df | |||
50da182e30 | |||
dba573bf1a | |||
6a0eef3fe4 | |||
98f58e8672 | |||
04274f5839 | |||
f387b9f464 | |||
b8f533d0ea | |||
5a49818a10 | |||
ad9d9e0b04 | |||
c92470ff7e | |||
1cd9c7fdac | |||
e607035c65 | |||
bde8113414 | |||
1fd011b1be | |||
061380742c | |||
8f9feb3ed9 | |||
0dc01cb974 | |||
55af328181 | |||
a8c0abfd5d | |||
4807744aa7 | |||
669d40a9d2 | |||
18049d529a | |||
f2b441d9fc | |||
d2078d4dde | |||
41d4ad2096 | |||
29ec8291ad | |||
b93a206a48 | |||
be83336cf7 | |||
19fdba7d73 | |||
2c2b3b75d5 | |||
47d5cb9e33 | |||
7b8e1bc919 | |||
77aa7a0148 | |||
bdd7d2599f | |||
ca8a96f956 | |||
8957250db8 | |||
1b6ec418a1 | |||
3759d77945 | |||
ab4d34e509 | |||
7f878f365b | |||
5efabfaea6 | |||
4cd8ae45e3 | |||
8999f9450f | |||
1d54943d71 | |||
767d8fc35d | |||
894f34678e | |||
1190bedafd | |||
e80db71d1c | |||
846bb2134e | |||
38b2eec4be | |||
8dafe486a2 | |||
c895a96a43 | |||
67cae9725e | |||
a2d06f87f6 | |||
8e4afc8374 | |||
afd879a692 | |||
83de2b8de7 | |||
4930f36a1a | |||
fa3f196add | |||
95004be0e9 | |||
281a849c8f | |||
5d82ce665c | |||
d632cfcde9 | |||
07f797a5e4 | |||
121107dd13 | |||
a2479b74be | |||
7ee1d3cd91 | |||
4b28ddd691 | |||
7270b5fe0c | |||
285792f692 | |||
23a0a48b81 | |||
2baad73bb9 | |||
097dc99e77 | |||
edd10bcfe7 | |||
ac1c65fba1 | |||
b4cc21ea89 | |||
3dfc3f5ff7 | |||
7c012df1d5 | |||
a1854d3734 | |||
074c566826 | |||
a2e7bfb30e | |||
01c1c77564 | |||
34de4fe8fe | |||
4975f8167e | |||
6777459e62 | |||
253d0dbd5e | |||
e98bd70871 | |||
6a216be5cb | |||
0adb7831e7 | |||
30ca98b597 | |||
e80001e8c8 | |||
b5490f7712 | |||
dc5748624f | |||
84c5a759d4 | |||
ec43aa2f18 | |||
8e7a6077e5 | |||
53a79c1a81 | |||
e9f54c8bae | |||
c978863e5f | |||
12fa08d7a7 | |||
50dea4cb52 | |||
20b06db359 | |||
b6e512e65f | |||
7d71c353b2 | |||
3216a68d63 | |||
df518f822c | |||
abdf0b6719 | |||
2d2a75f23c | |||
fcb59c68d4 | |||
d47816e7b9 | |||
21297d98f2 | |||
cc7452374d | |||
c0dcf1633c | |||
d8447ef1a9 |
1
.github/FUNDING.yml
vendored
1
.github/FUNDING.yml
vendored
@ -1,3 +1,4 @@
|
|||||||
# These are supported funding model platforms
|
# These are supported funding model platforms
|
||||||
|
|
||||||
ko_fi: easydiffusion
|
ko_fi: easydiffusion
|
||||||
|
patreon: easydiffusion
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@ installer.tar
|
|||||||
dist
|
dist
|
||||||
.idea/*
|
.idea/*
|
||||||
node_modules/*
|
node_modules/*
|
||||||
|
.tmp1
|
||||||
|
.tmp2
|
||||||
|
@ -712,3 +712,411 @@ FileSaver.js is licensed under the MIT license:
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|
||||||
[1]: http://eligrey.com
|
[1]: http://eligrey.com
|
||||||
|
|
||||||
|
croppr.js
|
||||||
|
=========
|
||||||
|
https://github.com/jamesssooi/Croppr.js
|
||||||
|
|
||||||
|
croppr.js is licensed under the MIT license:
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017 James Ooi
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
ExifReader
|
||||||
|
==========
|
||||||
|
https://github.com/mattiasw/ExifReader
|
||||||
|
|
||||||
|
ExifReader is licensed under the Mozilla Public License:
|
||||||
|
|
||||||
|
Mozilla Public License Version 2.0
|
||||||
|
==================================
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
--------------
|
||||||
|
|
||||||
|
1.1. "Contributor"
|
||||||
|
means each individual or legal entity that creates, contributes to
|
||||||
|
the creation of, or owns Covered Software.
|
||||||
|
|
||||||
|
1.2. "Contributor Version"
|
||||||
|
means the combination of the Contributions of others (if any) used
|
||||||
|
by a Contributor and that particular Contributor's Contribution.
|
||||||
|
|
||||||
|
1.3. "Contribution"
|
||||||
|
means Covered Software of a particular Contributor.
|
||||||
|
|
||||||
|
1.4. "Covered Software"
|
||||||
|
means Source Code Form to which the initial Contributor has attached
|
||||||
|
the notice in Exhibit A, the Executable Form of such Source Code
|
||||||
|
Form, and Modifications of such Source Code Form, in each case
|
||||||
|
including portions thereof.
|
||||||
|
|
||||||
|
1.5. "Incompatible With Secondary Licenses"
|
||||||
|
means
|
||||||
|
|
||||||
|
(a) that the initial Contributor has attached the notice described
|
||||||
|
in Exhibit B to the Covered Software; or
|
||||||
|
|
||||||
|
(b) that the Covered Software was made available under the terms of
|
||||||
|
version 1.1 or earlier of the License, but not also under the
|
||||||
|
terms of a Secondary License.
|
||||||
|
|
||||||
|
1.6. "Executable Form"
|
||||||
|
means any form of the work other than Source Code Form.
|
||||||
|
|
||||||
|
1.7. "Larger Work"
|
||||||
|
means a work that combines Covered Software with other material, in
|
||||||
|
a separate file or files, that is not Covered Software.
|
||||||
|
|
||||||
|
1.8. "License"
|
||||||
|
means this document.
|
||||||
|
|
||||||
|
1.9. "Licensable"
|
||||||
|
means having the right to grant, to the maximum extent possible,
|
||||||
|
whether at the time of the initial grant or subsequently, any and
|
||||||
|
all of the rights conveyed by this License.
|
||||||
|
|
||||||
|
1.10. "Modifications"
|
||||||
|
means any of the following:
|
||||||
|
|
||||||
|
(a) any file in Source Code Form that results from an addition to,
|
||||||
|
deletion from, or modification of the contents of Covered
|
||||||
|
Software; or
|
||||||
|
|
||||||
|
(b) any new file in Source Code Form that contains any Covered
|
||||||
|
Software.
|
||||||
|
|
||||||
|
1.11. "Patent Claims" of a Contributor
|
||||||
|
means any patent claim(s), including without limitation, method,
|
||||||
|
process, and apparatus claims, in any patent Licensable by such
|
||||||
|
Contributor that would be infringed, but for the grant of the
|
||||||
|
License, by the making, using, selling, offering for sale, having
|
||||||
|
made, import, or transfer of either its Contributions or its
|
||||||
|
Contributor Version.
|
||||||
|
|
||||||
|
1.12. "Secondary License"
|
||||||
|
means either the GNU General Public License, Version 2.0, the GNU
|
||||||
|
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||||
|
Public License, Version 3.0, or any later versions of those
|
||||||
|
licenses.
|
||||||
|
|
||||||
|
1.13. "Source Code Form"
|
||||||
|
means the form of the work preferred for making modifications.
|
||||||
|
|
||||||
|
1.14. "You" (or "Your")
|
||||||
|
means an individual or a legal entity exercising rights under this
|
||||||
|
License. For legal entities, "You" includes any entity that
|
||||||
|
controls, is controlled by, or is under common control with You. For
|
||||||
|
purposes of this definition, "control" means (a) the power, direct
|
||||||
|
or indirect, to cause the direction or management of such entity,
|
||||||
|
whether by contract or otherwise, or (b) ownership of more than
|
||||||
|
fifty percent (50%) of the outstanding shares or beneficial
|
||||||
|
ownership of such entity.
|
||||||
|
|
||||||
|
2. License Grants and Conditions
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
2.1. Grants
|
||||||
|
|
||||||
|
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||||
|
non-exclusive license:
|
||||||
|
|
||||||
|
(a) under intellectual property rights (other than patent or trademark)
|
||||||
|
Licensable by such Contributor to use, reproduce, make available,
|
||||||
|
modify, display, perform, distribute, and otherwise exploit its
|
||||||
|
Contributions, either on an unmodified basis, with Modifications, or
|
||||||
|
as part of a Larger Work; and
|
||||||
|
|
||||||
|
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||||
|
for sale, have made, import, and otherwise transfer either its
|
||||||
|
Contributions or its Contributor Version.
|
||||||
|
|
||||||
|
2.2. Effective Date
|
||||||
|
|
||||||
|
The licenses granted in Section 2.1 with respect to any Contribution
|
||||||
|
become effective for each Contribution on the date the Contributor first
|
||||||
|
distributes such Contribution.
|
||||||
|
|
||||||
|
2.3. Limitations on Grant Scope
|
||||||
|
|
||||||
|
The licenses granted in this Section 2 are the only rights granted under
|
||||||
|
this License. No additional rights or licenses will be implied from the
|
||||||
|
distribution or licensing of Covered Software under this License.
|
||||||
|
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||||
|
Contributor:
|
||||||
|
|
||||||
|
(a) for any code that a Contributor has removed from Covered Software;
|
||||||
|
or
|
||||||
|
|
||||||
|
(b) for infringements caused by: (i) Your and any other third party's
|
||||||
|
modifications of Covered Software, or (ii) the combination of its
|
||||||
|
Contributions with other software (except as part of its Contributor
|
||||||
|
Version); or
|
||||||
|
|
||||||
|
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||||
|
its Contributions.
|
||||||
|
|
||||||
|
This License does not grant any rights in the trademarks, service marks,
|
||||||
|
or logos of any Contributor (except as may be necessary to comply with
|
||||||
|
the notice requirements in Section 3.4).
|
||||||
|
|
||||||
|
2.4. Subsequent Licenses
|
||||||
|
|
||||||
|
No Contributor makes additional grants as a result of Your choice to
|
||||||
|
distribute the Covered Software under a subsequent version of this
|
||||||
|
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||||
|
permitted under the terms of Section 3.3).
|
||||||
|
|
||||||
|
2.5. Representation
|
||||||
|
|
||||||
|
Each Contributor represents that the Contributor believes its
|
||||||
|
Contributions are its original creation(s) or it has sufficient rights
|
||||||
|
to grant the rights to its Contributions conveyed by this License.
|
||||||
|
|
||||||
|
2.6. Fair Use
|
||||||
|
|
||||||
|
This License is not intended to limit any rights You have under
|
||||||
|
applicable copyright doctrines of fair use, fair dealing, or other
|
||||||
|
equivalents.
|
||||||
|
|
||||||
|
2.7. Conditions
|
||||||
|
|
||||||
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||||
|
in Section 2.1.
|
||||||
|
|
||||||
|
3. Responsibilities
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
3.1. Distribution of Source Form
|
||||||
|
|
||||||
|
All distribution of Covered Software in Source Code Form, including any
|
||||||
|
Modifications that You create or to which You contribute, must be under
|
||||||
|
the terms of this License. You must inform recipients that the Source
|
||||||
|
Code Form of the Covered Software is governed by the terms of this
|
||||||
|
License, and how they can obtain a copy of this License. You may not
|
||||||
|
attempt to alter or restrict the recipients' rights in the Source Code
|
||||||
|
Form.
|
||||||
|
|
||||||
|
3.2. Distribution of Executable Form
|
||||||
|
|
||||||
|
If You distribute Covered Software in Executable Form then:
|
||||||
|
|
||||||
|
(a) such Covered Software must also be made available in Source Code
|
||||||
|
Form, as described in Section 3.1, and You must inform recipients of
|
||||||
|
the Executable Form how they can obtain a copy of such Source Code
|
||||||
|
Form by reasonable means in a timely manner, at a charge no more
|
||||||
|
than the cost of distribution to the recipient; and
|
||||||
|
|
||||||
|
(b) You may distribute such Executable Form under the terms of this
|
||||||
|
License, or sublicense it under different terms, provided that the
|
||||||
|
license for the Executable Form does not attempt to limit or alter
|
||||||
|
the recipients' rights in the Source Code Form under this License.
|
||||||
|
|
||||||
|
3.3. Distribution of a Larger Work
|
||||||
|
|
||||||
|
You may create and distribute a Larger Work under terms of Your choice,
|
||||||
|
provided that You also comply with the requirements of this License for
|
||||||
|
the Covered Software. If the Larger Work is a combination of Covered
|
||||||
|
Software with a work governed by one or more Secondary Licenses, and the
|
||||||
|
Covered Software is not Incompatible With Secondary Licenses, this
|
||||||
|
License permits You to additionally distribute such Covered Software
|
||||||
|
under the terms of such Secondary License(s), so that the recipient of
|
||||||
|
the Larger Work may, at their option, further distribute the Covered
|
||||||
|
Software under the terms of either this License or such Secondary
|
||||||
|
License(s).
|
||||||
|
|
||||||
|
3.4. Notices
|
||||||
|
|
||||||
|
You may not remove or alter the substance of any license notices
|
||||||
|
(including copyright notices, patent notices, disclaimers of warranty,
|
||||||
|
or limitations of liability) contained within the Source Code Form of
|
||||||
|
the Covered Software, except that You may alter any license notices to
|
||||||
|
the extent required to remedy known factual inaccuracies.
|
||||||
|
|
||||||
|
3.5. Application of Additional Terms
|
||||||
|
|
||||||
|
You may choose to offer, and to charge a fee for, warranty, support,
|
||||||
|
indemnity or liability obligations to one or more recipients of Covered
|
||||||
|
Software. However, You may do so only on Your own behalf, and not on
|
||||||
|
behalf of any Contributor. You must make it absolutely clear that any
|
||||||
|
such warranty, support, indemnity, or liability obligation is offered by
|
||||||
|
You alone, and You hereby agree to indemnify every Contributor for any
|
||||||
|
liability incurred by such Contributor as a result of warranty, support,
|
||||||
|
indemnity or liability terms You offer. You may include additional
|
||||||
|
disclaimers of warranty and limitations of liability specific to any
|
||||||
|
jurisdiction.
|
||||||
|
|
||||||
|
4. Inability to Comply Due to Statute or Regulation
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this
|
||||||
|
License with respect to some or all of the Covered Software due to
|
||||||
|
statute, judicial order, or regulation then You must: (a) comply with
|
||||||
|
the terms of this License to the maximum extent possible; and (b)
|
||||||
|
describe the limitations and the code they affect. Such description must
|
||||||
|
be placed in a text file included with all distributions of the Covered
|
||||||
|
Software under this License. Except to the extent prohibited by statute
|
||||||
|
or regulation, such description must be sufficiently detailed for a
|
||||||
|
recipient of ordinary skill to be able to understand it.
|
||||||
|
|
||||||
|
5. Termination
|
||||||
|
--------------
|
||||||
|
|
||||||
|
5.1. The rights granted under this License will terminate automatically
|
||||||
|
if You fail to comply with any of its terms. However, if You become
|
||||||
|
compliant, then the rights granted under this License from a particular
|
||||||
|
Contributor are reinstated (a) provisionally, unless and until such
|
||||||
|
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||||
|
ongoing basis, if such Contributor fails to notify You of the
|
||||||
|
non-compliance by some reasonable means prior to 60 days after You have
|
||||||
|
come back into compliance. Moreover, Your grants from a particular
|
||||||
|
Contributor are reinstated on an ongoing basis if such Contributor
|
||||||
|
notifies You of the non-compliance by some reasonable means, this is the
|
||||||
|
first time You have received notice of non-compliance with this License
|
||||||
|
from such Contributor, and You become compliant prior to 30 days after
|
||||||
|
Your receipt of the notice.
|
||||||
|
|
||||||
|
5.2. If You initiate litigation against any entity by asserting a patent
|
||||||
|
infringement claim (excluding declaratory judgment actions,
|
||||||
|
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||||
|
directly or indirectly infringes any patent, then the rights granted to
|
||||||
|
You by any and all Contributors for the Covered Software under Section
|
||||||
|
2.1 of this License shall terminate.
|
||||||
|
|
||||||
|
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||||
|
end user license agreements (excluding distributors and resellers) which
|
||||||
|
have been validly granted by You or Your distributors under this License
|
||||||
|
prior to termination shall survive termination.
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 6. Disclaimer of Warranty *
|
||||||
|
* ------------------------- *
|
||||||
|
* *
|
||||||
|
* Covered Software is provided under this License on an "as is" *
|
||||||
|
* basis, without warranty of any kind, either expressed, implied, or *
|
||||||
|
* statutory, including, without limitation, warranties that the *
|
||||||
|
* Covered Software is free of defects, merchantable, fit for a *
|
||||||
|
* particular purpose or non-infringing. The entire risk as to the *
|
||||||
|
* quality and performance of the Covered Software is with You. *
|
||||||
|
* Should any Covered Software prove defective in any respect, You *
|
||||||
|
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||||
|
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||||
|
* essential part of this License. No use of any Covered Software is *
|
||||||
|
* authorized under this License except under this disclaimer. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 7. Limitation of Liability *
|
||||||
|
* -------------------------- *
|
||||||
|
* *
|
||||||
|
* Under no circumstances and under no legal theory, whether tort *
|
||||||
|
* (including negligence), contract, or otherwise, shall any *
|
||||||
|
* Contributor, or anyone who distributes Covered Software as *
|
||||||
|
* permitted above, be liable to You for any direct, indirect, *
|
||||||
|
* special, incidental, or consequential damages of any character *
|
||||||
|
* including, without limitation, damages for lost profits, loss of *
|
||||||
|
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||||
|
* and all other commercial damages or losses, even if such party *
|
||||||
|
* shall have been informed of the possibility of such damages. This *
|
||||||
|
* limitation of liability shall not apply to liability for death or *
|
||||||
|
* personal injury resulting from such party's negligence to the *
|
||||||
|
* extent applicable law prohibits such limitation. Some *
|
||||||
|
* jurisdictions do not allow the exclusion or limitation of *
|
||||||
|
* incidental or consequential damages, so this exclusion and *
|
||||||
|
* limitation may not apply to You. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
8. Litigation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Any litigation relating to this License may be brought only in the
|
||||||
|
courts of a jurisdiction where the defendant maintains its principal
|
||||||
|
place of business and such litigation shall be governed by laws of that
|
||||||
|
jurisdiction, without reference to its conflict-of-law provisions.
|
||||||
|
Nothing in this Section shall prevent a party's ability to bring
|
||||||
|
cross-claims or counter-claims.
|
||||||
|
|
||||||
|
9. Miscellaneous
|
||||||
|
----------------
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning the subject
|
||||||
|
matter hereof. If any provision of this License is held to be
|
||||||
|
unenforceable, such provision shall be reformed only to the extent
|
||||||
|
necessary to make it enforceable. Any law or regulation which provides
|
||||||
|
that the language of a contract shall be construed against the drafter
|
||||||
|
shall not be used to construe this License against a Contributor.
|
||||||
|
|
||||||
|
10. Versions of the License
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
10.1. New Versions
|
||||||
|
|
||||||
|
Mozilla Foundation is the license steward. Except as provided in Section
|
||||||
|
10.3, no one other than the license steward has the right to modify or
|
||||||
|
publish new versions of this License. Each version will be given a
|
||||||
|
distinguishing version number.
|
||||||
|
|
||||||
|
10.2. Effect of New Versions
|
||||||
|
|
||||||
|
You may distribute the Covered Software under the terms of the version
|
||||||
|
of the License under which You originally received the Covered Software,
|
||||||
|
or under the terms of any subsequent version published by the license
|
||||||
|
steward.
|
||||||
|
|
||||||
|
10.3. Modified Versions
|
||||||
|
|
||||||
|
If you create software not governed by this License, and you want to
|
||||||
|
create a new license for such software, you may create and use a
|
||||||
|
modified version of this License if you rename the license and remove
|
||||||
|
any references to the name of the license steward (except to note that
|
||||||
|
such modified license differs from this License).
|
||||||
|
|
||||||
|
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||||
|
Licenses
|
||||||
|
|
||||||
|
If You choose to distribute Source Code Form that is Incompatible With
|
||||||
|
Secondary Licenses under the terms of this version of the License, the
|
||||||
|
notice described in Exhibit B of this License must be attached.
|
||||||
|
|
||||||
|
Exhibit A - Source Code Form License Notice
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
If it is not possible or desirable to put the notice in a particular
|
||||||
|
file, then You may include the notice in a location (such as a LICENSE
|
||||||
|
file in a relevant directory) where a recipient would be likely to look
|
||||||
|
for such a notice.
|
||||||
|
|
||||||
|
You may add additional accurate notices of copyright ownership.
|
||||||
|
|
||||||
|
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||||
|
---------------------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
defined by the Mozilla Public License, v. 2.0.
|
||||||
|
52
CHANGES.md
52
CHANGES.md
@ -1,5 +1,57 @@
|
|||||||
# What's new?
|
# What's new?
|
||||||
|
|
||||||
|
## v3.0
|
||||||
|
### Major Changes
|
||||||
|
- **ControlNet** - Full support for ControlNet, with native integration of the common ControlNet models. Just select a control image, then choose the ControlNet filter/model and run. No additional configuration or download necessary. Supports custom ControlNets as well.
|
||||||
|
- **SDXL** - Full support for SDXL. No configuration necessary, just put the SDXL model in the `models/stable-diffusion` folder.
|
||||||
|
- **Multiple LoRAs** - Use multiple LoRAs, including SDXL and SD2-compatible LoRAs. Put them in the `models/lora` folder.
|
||||||
|
- **Embeddings** - Use textual inversion embeddings easily, by putting them in the `models/embeddings` folder and using their names in the prompt (or by clicking the `+ Embeddings` button to select embeddings visually). Thanks @JeLuf.
|
||||||
|
- **Seamless Tiling** - Generate repeating textures that can be useful for games and other art projects. Works best in 512x512 resolution. Thanks @JeLuf.
|
||||||
|
- **Inpainting Models** - Full support for inpainting models, including custom inpainting models. No configuration (or yaml files) necessary.
|
||||||
|
- **Faster than v2.5** - Nearly 40% faster than Easy Diffusion v2.5, and can be even faster if you enable xFormers.
|
||||||
|
- **Even less VRAM usage** - Less than 2 GB for 512x512 images on 'low' VRAM usage setting (SD 1.5). Can generate large images with SDXL.
|
||||||
|
- **WebP images** - Supports saving images in the lossless webp format.
|
||||||
|
- **Undo/Redo in the UI** - Remove tasks or images from the queue easily, and undo the action if you removed anything accidentally. Thanks @JeLuf.
|
||||||
|
- **Three new samplers, and latent upscaler** - Added `DEIS`, `DDPM` and `DPM++ 2m SDE` as additional samplers. Thanks @ogmaresca and @rbertus2000.
|
||||||
|
- **Significantly faster 'Upscale' and 'Fix Faces' buttons on the images**
|
||||||
|
- **Major rewrite of the code** - We've switched to using diffusers under-the-hood, which allows us to release new features faster, and focus on making the UI and installer even easier to use.
|
||||||
|
|
||||||
|
### Detailed changelog
|
||||||
|
* 3.0.8 - 13 Mar 2024 - Update diffusers version to v0.26.3.
|
||||||
|
* 3.0.7 - 11 Dec 2023 - Setting to enable/disable VAE tiling (in the Image Settings panel). Sometimes VAE tiling reduces the quality of the image, so this setting will help control that.
|
||||||
|
* 3.0.6 - 18 Sep 2023 - Add thumbnails to embeddings from the UI, using the new `Upload Thumbnail` button in the Embeddings popup. Thanks @JeLuf.
|
||||||
|
* 3.0.6 - 15 Sep 2023 - Fix broken embeddings dialog when LoRA information couldn't be fetched.
|
||||||
|
* 3.0.6 - 14 Sep 2023 - UI for adding notes to LoRA files (to help you remember which prompts to use). Also added a button to automatically fetch prompts from Civitai for a LoRA file, using the `Import from Civitai` button. Thanks @JeLuf.
|
||||||
|
* 3.0.5 - 2 Sep 2023 - Support SDXL ControlNets.
|
||||||
|
* 3.0.4 - 1 Sep 2023 - Fix incorrect metadata generated for embeddings, when the exact word doesn't match the case, or is part of a larger word.
|
||||||
|
* 3.0.4 - 1 Sep 2023 - Simplify the installation for AMD users on Linux. Thanks @JeLuf.
|
||||||
|
* 3.0.4 - 1 Sep 2023 - Allow using a different folder for models. This is useful if you want to share a models folder across different software, or on a different drive. You can change this path in the Settings tab.
|
||||||
|
* 3.0.3 - 31 Aug 2023 - Auto-save images to disk (if enabled by the user) when upscaling/fixing using the buttons on the image.
|
||||||
|
* 3.0.3 - 30 Aug 2023 - Allow loading NovelAI-based custom models.
|
||||||
|
* 3.0.3 - 30 Aug 2023 - Fix broken VAE tiling. This allows you to create larger images with lesser VRAM usage.
|
||||||
|
* 3.0.3 - 30 Aug 2023 - Allow blocking NSFW images using a server-side config. This prevents the browser from generating NSFW images or changing the config. Open `config.yaml` in a text editor (e.g. Notepad), and add `block_nsfw: true` at the end, and save the file.
|
||||||
|
* 3.0.2 - 29 Aug 2023 - Fixed incorrect matching of embeddings from prompts.
|
||||||
|
* 3.0.2 - 24 Aug 2023 - Fix broken seamless tiling.
|
||||||
|
* 3.0.2 - 23 Aug 2023 - Fix styling on mobile devices.
|
||||||
|
* 3.0.2 - 22 Aug 2023 - Full support for inpainting models, including custom models. Support SD 1.x and SD 2.x inpainting models. Does not require you to specify a yaml config file.
|
||||||
|
* 3.0.2 - 22 Aug 2023 - Reduce VRAM consumption of controlnet in 'low' VRAM mode, and allow accelerating controlnets using xformers.
|
||||||
|
* 3.0.2 - 22 Aug 2023 - Improve auto-detection of SD 2.0 and 2.1 models, removing the need for custom yaml files for SD 2.x models. Improve the model load time by speeding-up the black image test.
|
||||||
|
* 3.0.1 - 18 Aug 2023 - Rotate an image if EXIF rotation is present. For e.g. this is common in images taken with a smartphone.
|
||||||
|
* 3.0.1 - 18 Aug 2023 - Resize control images to the task dimensions, to avoid memory errors with high-res control images.
|
||||||
|
* 3.0.1 - 18 Aug 2023 - Show controlnet filter preview in the task entry.
|
||||||
|
* 3.0.1 - 18 Aug 2023 - Fix drag-and-drop and 'Use these Settings' for LoRA and ControlNet.
|
||||||
|
* 3.0.1 - 18 Aug 2023 - Auto-save LoRA models and strengths.
|
||||||
|
* 3.0.1 - 17 Aug 2023 - Automatically use the correct yaml config file for custom SDXL models, even if a yaml file isn't present in the folder.
|
||||||
|
* 3.0.1 - 17 Aug 2023 - Fix broken embeddings with SDXL.
|
||||||
|
* 3.0.1 - 16 Aug 2023 - Fix broken LoRA with SDXL.
|
||||||
|
* 3.0.1 - 15 Aug 2023 - Fix broken seamless tiling.
|
||||||
|
* 3.0.1 - 15 Aug 2023 - Fix textual inversion embeddings not working in `low` VRAM usage mode.
|
||||||
|
* 3.0.1 - 15 Aug 2023 - Fix for custom VAEs not working in `low` VRAM usage mode.
|
||||||
|
* 3.0.1 - 14 Aug 2023 - Slider to change the image dimensions proportionally (in Image Settings). Thanks @JeLuf.
|
||||||
|
* 3.0.1 - 14 Aug 2023 - Show an error to the user if an embedding isn't compatible with the model, instead of failing silently without informing the user. Thanks @JeLuf.
|
||||||
|
* 3.0.1 - 14 Aug 2023 - Disable watermarking for SDXL img2img. Thanks @AvidGameFan.
|
||||||
|
* 3.0.0 - 3 Aug 2023 - Enabled diffusers for everyone by default. The old v2 engine can be used by disabling the "Use v3 engine" option in the Settings tab.
|
||||||
|
|
||||||
## v2.5
|
## v2.5
|
||||||
### Major Changes
|
### Major Changes
|
||||||
- **Nearly twice as fast** - significantly faster speed of image generation. Code contributions are welcome to make our project even faster: https://github.com/easydiffusion/sdkit/#is-it-fast
|
- **Nearly twice as fast** - significantly faster speed of image generation. Code contributions are welcome to make our project even faster: https://github.com/easydiffusion/sdkit/#is-it-fast
|
||||||
|
@ -47,3 +47,5 @@ Build the Windows installer using Windows, and the Linux installer using Linux.
|
|||||||
|
|
||||||
1. Run `build.bat` or `./build.sh` depending on whether you're in Windows or Linux.
|
1. Run `build.bat` or `./build.sh` depending on whether you're in Windows or Linux.
|
||||||
2. Make a new GitHub release and upload the Windows and Linux installer builds created inside the `dist` folder.
|
2. Make a new GitHub release and upload the Windows and Linux installer builds created inside the `dist` folder.
|
||||||
|
|
||||||
|
For NSIS (on Windows), you need to have these plugins in the `nsis/Plugins` folder: `amd64-unicode`, `x86-ansi`, `x86-unicode`
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
Congrats on downloading Stable Diffusion UI, version 2!
|
Congrats on downloading Easy Diffusion, version 3!
|
||||||
|
|
||||||
If you haven't downloaded Stable Diffusion UI yet, please download from https://github.com/easydiffusion/easydiffusion#installation
|
If you haven't downloaded Easy Diffusion yet, please download from https://github.com/easydiffusion/easydiffusion#installation
|
||||||
|
|
||||||
After downloading, to install please follow these instructions:
|
After downloading, to install please follow these instructions:
|
||||||
|
|
||||||
For Windows:
|
For Windows:
|
||||||
- Please double-click the "Easy-Diffusion-Windows.exe" file and follow the instructions.
|
- Please double-click the "Easy-Diffusion-Windows.exe" file and follow the instructions.
|
||||||
|
|
||||||
For Linux:
|
For Linux and Mac:
|
||||||
- Please open a terminal, unzip the Easy-Diffusion-Linux.zip file and go to the "easy-diffusion" directory. Then run ./start.sh
|
- Please open a terminal, and go to the "easy-diffusion" directory. Then run ./start.sh
|
||||||
|
|
||||||
That file will automatically install everything. After that it will start the Stable Diffusion interface in a web browser.
|
That file will automatically install everything. After that it will start the Easy Diffusion interface in a web browser.
|
||||||
|
|
||||||
To start the UI in the future, please run the same command mentioned above.
|
To start Easy Diffusion in the future, please run the same command mentioned above.
|
||||||
|
|
||||||
|
|
||||||
If you have any problems, please:
|
If you have any problems, please:
|
||||||
|
BIN
NSIS/astro.bmp
BIN
NSIS/astro.bmp
Binary file not shown.
Before Width: | Height: | Size: 288 KiB |
@ -1 +0,0 @@
|
|||||||
!define EXISTING_INSTALLATION_DIR "D:\path\to\installed\easy-diffusion"
|
|
BIN
NSIS/sd.ico
BIN
NSIS/sd.ico
Binary file not shown.
Before Width: | Height: | Size: 200 KiB |
@ -7,9 +7,9 @@ RequestExecutionLevel user
|
|||||||
!AddPluginDir /amd64-unicode "."
|
!AddPluginDir /amd64-unicode "."
|
||||||
; HM NIS Edit Wizard helper defines
|
; HM NIS Edit Wizard helper defines
|
||||||
!define PRODUCT_NAME "Easy Diffusion"
|
!define PRODUCT_NAME "Easy Diffusion"
|
||||||
!define PRODUCT_VERSION "2.5"
|
!define PRODUCT_VERSION "3.0"
|
||||||
!define PRODUCT_PUBLISHER "cmdr2 and contributors"
|
!define PRODUCT_PUBLISHER "cmdr2 and contributors"
|
||||||
!define PRODUCT_WEB_SITE "https://stable-diffusion-ui.github.io"
|
!define PRODUCT_WEB_SITE "https://easydiffusion.github.io"
|
||||||
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Easy Diffusion\App Paths\installer.exe"
|
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Easy Diffusion\App Paths\installer.exe"
|
||||||
|
|
||||||
; MUI 1.67 compatible ------
|
; MUI 1.67 compatible ------
|
||||||
@ -165,9 +165,9 @@ FunctionEnd
|
|||||||
; MUI Settings
|
; MUI Settings
|
||||||
;---------------------------------------------------------------------------------------------------------
|
;---------------------------------------------------------------------------------------------------------
|
||||||
!define MUI_ABORTWARNING
|
!define MUI_ABORTWARNING
|
||||||
!define MUI_ICON "cyborg_flower_girl.ico"
|
!define MUI_ICON "${EXISTING_INSTALLATION_DIR}\installer_files\cyborg_flower_girl.ico"
|
||||||
|
|
||||||
!define MUI_WELCOMEFINISHPAGE_BITMAP "cyborg_flower_girl.bmp"
|
!define MUI_WELCOMEFINISHPAGE_BITMAP "${EXISTING_INSTALLATION_DIR}\installer_files\cyborg_flower_girl.bmp"
|
||||||
|
|
||||||
; Welcome page
|
; Welcome page
|
||||||
!define MUI_WELCOMEPAGE_TEXT "This installer will guide you through the installation of Easy Diffusion.$\n$\n\
|
!define MUI_WELCOMEPAGE_TEXT "This installer will guide you through the installation of Easy Diffusion.$\n$\n\
|
||||||
@ -176,8 +176,8 @@ Click Next to continue."
|
|||||||
Page custom MediaPackDialog
|
Page custom MediaPackDialog
|
||||||
|
|
||||||
; License page
|
; License page
|
||||||
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
|
!insertmacro MUI_PAGE_LICENSE "${EXISTING_INSTALLATION_DIR}\LICENSE"
|
||||||
!insertmacro MUI_PAGE_LICENSE "..\CreativeML Open RAIL-M License"
|
!insertmacro MUI_PAGE_LICENSE "${EXISTING_INSTALLATION_DIR}\CreativeML Open RAIL-M License"
|
||||||
; Directory page
|
; Directory page
|
||||||
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "DirectoryLeave"
|
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "DirectoryLeave"
|
||||||
!insertmacro MUI_PAGE_DIRECTORY
|
!insertmacro MUI_PAGE_DIRECTORY
|
||||||
@ -210,29 +210,33 @@ ShowInstDetails show
|
|||||||
; List of files to be installed
|
; List of files to be installed
|
||||||
Section "MainSection" SEC01
|
Section "MainSection" SEC01
|
||||||
SetOutPath "$INSTDIR"
|
SetOutPath "$INSTDIR"
|
||||||
File "..\CreativeML Open RAIL-M License"
|
File "${EXISTING_INSTALLATION_DIR}\CreativeML Open RAIL-M License"
|
||||||
File "..\How to install and run.txt"
|
File "${EXISTING_INSTALLATION_DIR}\How to install and run.txt"
|
||||||
File "..\LICENSE"
|
File "${EXISTING_INSTALLATION_DIR}\LICENSE"
|
||||||
File "..\scripts\Start Stable Diffusion UI.cmd"
|
File "${EXISTING_INSTALLATION_DIR}\Start Stable Diffusion UI.cmd"
|
||||||
File /r "${EXISTING_INSTALLATION_DIR}\installer_files"
|
File /r "${EXISTING_INSTALLATION_DIR}\installer_files"
|
||||||
File /r "${EXISTING_INSTALLATION_DIR}\profile"
|
|
||||||
File /r "${EXISTING_INSTALLATION_DIR}\sd-ui-files"
|
File /r "${EXISTING_INSTALLATION_DIR}\sd-ui-files"
|
||||||
SetOutPath "$INSTDIR\installer_files"
|
|
||||||
File "cyborg_flower_girl.ico"
|
|
||||||
SetOutPath "$INSTDIR\scripts"
|
SetOutPath "$INSTDIR\scripts"
|
||||||
File "${EXISTING_INSTALLATION_DIR}\scripts\install_status.txt"
|
File "${EXISTING_INSTALLATION_DIR}\scripts\install_status.txt"
|
||||||
File "..\scripts\on_env_start.bat"
|
File "${EXISTING_INSTALLATION_DIR}\scripts\on_env_start.bat"
|
||||||
File "C:\windows\system32\curl.exe"
|
File "C:\windows\system32\curl.exe"
|
||||||
CreateDirectory "$INSTDIR\models"
|
File "${EXISTING_INSTALLATION_DIR}\scripts\config.yaml.sample"
|
||||||
|
|
||||||
CreateDirectory "$INSTDIR\models\stable-diffusion"
|
CreateDirectory "$INSTDIR\models\stable-diffusion"
|
||||||
CreateDirectory "$INSTDIR\models\gfpgan"
|
CreateDirectory "$INSTDIR\models\gfpgan"
|
||||||
CreateDirectory "$INSTDIR\models\realesrgan"
|
CreateDirectory "$INSTDIR\models\realesrgan"
|
||||||
CreateDirectory "$INSTDIR\models\vae"
|
CreateDirectory "$INSTDIR\models\vae"
|
||||||
|
|
||||||
|
CreateDirectory "$INSTDIR\profile\.cache\huggingface\hub"
|
||||||
|
SetOutPath "$INSTDIR\profile\.cache\huggingface\hub"
|
||||||
|
File /r /x pytorch_model.bin "${EXISTING_INSTALLATION_DIR}\profile\.cache\huggingface\hub\models--openai--clip-vit-large-patch14"
|
||||||
|
|
||||||
CreateDirectory "$SMPROGRAMS\Easy Diffusion"
|
CreateDirectory "$SMPROGRAMS\Easy Diffusion"
|
||||||
CreateShortCut "$SMPROGRAMS\Easy Diffusion\Easy Diffusion.lnk" "$INSTDIR\Start Stable Diffusion UI.cmd" "" "$INSTDIR\installer_files\cyborg_flower_girl.ico"
|
CreateShortCut "$SMPROGRAMS\Easy Diffusion\Easy Diffusion.lnk" "$INSTDIR\Start Stable Diffusion UI.cmd" "" "$INSTDIR\installer_files\cyborg_flower_girl.ico"
|
||||||
|
|
||||||
DetailPrint 'Downloading the Stable Diffusion 1.4 model...'
|
DetailPrint 'Downloading the Stable Diffusion 1.5 model...'
|
||||||
NScurl::http get "https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt" "$INSTDIR\models\stable-diffusion\sd-v1-4.ckpt" /CANCEL /INSIST /END
|
NScurl::http get "https://github.com/easydiffusion/sdkit-test-data/releases/download/assets/sd-v1-5.safetensors" "$INSTDIR\models\stable-diffusion\sd-v1-5.safetensors" /CANCEL /INSIST /END
|
||||||
|
|
||||||
DetailPrint 'Downloading the GFPGAN model...'
|
DetailPrint 'Downloading the GFPGAN model...'
|
||||||
NScurl::http get "https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth" "$INSTDIR\models\gfpgan\GFPGANv1.4.pth" /CANCEL /INSIST /END
|
NScurl::http get "https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth" "$INSTDIR\models\gfpgan\GFPGANv1.4.pth" /CANCEL /INSIST /END
|
||||||
|
59
README.md
59
README.md
@ -1,19 +1,23 @@
|
|||||||
# Easy Diffusion 2.5
|
# Easy Diffusion 3.0
|
||||||
### The easiest way to install and use [Stable Diffusion](https://github.com/CompVis/stable-diffusion) on your computer.
|
### The easiest way to install and use [Stable Diffusion](https://github.com/CompVis/stable-diffusion) on your computer.
|
||||||
|
|
||||||
Does not require technical knowledge, does not require pre-installed software. 1-click install, powerful features, friendly community.
|
Does not require technical knowledge, does not require pre-installed software. 1-click install, powerful features, friendly community.
|
||||||
|
|
||||||
[Installation guide](#installation) | [Troubleshooting guide](https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting) | <sub>[](https://discord.com/invite/u9yhsFmEkB)</sub> <sup>(for support queries, and development discussions)</sup>
|
️🔥🎉 **New!** Support for SDXL, ControlNet, multiple LoRA files, embeddings (and a lot more) have been added!
|
||||||
|
|
||||||
|
[Installation guide](#installation) | [Troubleshooting guide](https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting) | [User guide](https://github.com/easydiffusion/easydiffusion/wiki) | <sub>[](https://discord.com/invite/u9yhsFmEkB)</sub> <sup>(for support queries, and development discussions)</sup>
|
||||||
|
|
||||||
|
---
|
||||||
|

|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
Click the download button for your operating system:
|
Click the download button for your operating system:
|
||||||
|
|
||||||
<p float="left">
|
<p float="left">
|
||||||
<a href="https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.5.41a/Easy-Diffusion-Windows.exe"><img src="https://github.com/cmdr2/stable-diffusion-ui/raw/main/media/download-win.png" width="200" /></a>
|
<a href="https://github.com/cmdr2/stable-diffusion-ui/releases/latest/download/Easy-Diffusion-Linux.zip"><img src="https://github.com/cmdr2/stable-diffusion-ui/raw/main/media/download-linux.png" width="200" /></a>
|
||||||
<a href="https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.5.41a/Easy-Diffusion-Linux.zip"><img src="https://github.com/cmdr2/stable-diffusion-ui/raw/main/media/download-linux.png" width="200" /></a>
|
<a href="https://github.com/cmdr2/stable-diffusion-ui/releases/latest/download/Easy-Diffusion-Mac.zip"><img src="https://github.com/cmdr2/stable-diffusion-ui/raw/main/media/download-mac.png" width="200" /></a>
|
||||||
<a href="https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.5.41a/Easy-Diffusion-Mac.zip"><img src="https://github.com/cmdr2/stable-diffusion-ui/raw/main/media/download-mac.png" width="200" /></a>
|
<a href="https://github.com/cmdr2/stable-diffusion-ui/releases/latest/download/Easy-Diffusion-Windows.exe"><img src="https://github.com/cmdr2/stable-diffusion-ui/raw/main/media/download-win.png" width="200" /></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
**Hardware requirements:**
|
**Hardware requirements:**
|
||||||
@ -62,17 +66,19 @@ Just delete the `EasyDiffusion` folder to uninstall all the downloaded packages.
|
|||||||
- **UI Themes**: Customize the program to your liking.
|
- **UI Themes**: Customize the program to your liking.
|
||||||
- **Searchable models dropdown**: organize your models into sub-folders, and search through them in the UI.
|
- **Searchable models dropdown**: organize your models into sub-folders, and search through them in the UI.
|
||||||
|
|
||||||
### Image generation
|
### Powerful image generation
|
||||||
- **Supports**: "*Text to Image*" and "*Image to Image*".
|
- **Supports**: "*Text to Image*", "*Image to Image*" and "*InPainting*"
|
||||||
- **21 Samplers**: `ddim`, `plms`, `heun`, `euler`, `euler_a`, `dpm2`, `dpm2_a`, `lms`, `dpm_solver_stability`, `dpmpp_2s_a`, `dpmpp_2m`, `dpmpp_sde`, `dpm_fast`, `dpm_adaptive`, `ddpm`, `deis`, `unipc_snr`, `unipc_tu`, `unipc_tq`, `unipc_snr_2`, `unipc_tu_2`.
|
- **ControlNet**: For advanced control over the image, e.g. by setting the pose or drawing the outline for the AI to fill in.
|
||||||
- **In-Painting**: Specify areas of your image to paint into.
|
- **16 Samplers**: `PLMS`, `DDIM`, `DEIS`, `Heun`, `Euler`, `Euler Ancestral`, `DPM2`, `DPM2 Ancestral`, `LMS`, `DPM Solver`, `DPM++ 2s Ancestral`, `DPM++ 2m`, `DPM++ 2m SDE`, `DPM++ SDE`, `DDPM`, `UniPC`.
|
||||||
|
- **Stable Diffusion XL and 2.1**: Generate higher-quality images using the latest Stable Diffusion XL models.
|
||||||
|
- **Textual Inversion Embeddings**: For guiding the AI strongly towards a particular concept.
|
||||||
- **Simple Drawing Tool**: Draw basic images to guide the AI, without needing an external drawing program.
|
- **Simple Drawing Tool**: Draw basic images to guide the AI, without needing an external drawing program.
|
||||||
- **Face Correction (GFPGAN)**
|
- **Face Correction (GFPGAN)**
|
||||||
- **Upscaling (RealESRGAN)**
|
- **Upscaling (RealESRGAN)**
|
||||||
- **Loopback**: Use the output image as the input image for the next img2img task.
|
- **Loopback**: Use the output image as the input image for the next image task.
|
||||||
- **Negative Prompt**: Specify aspects of the image to *remove*.
|
- **Negative Prompt**: Specify aspects of the image to *remove*.
|
||||||
- **Attention/Emphasis**: () in the prompt increases the model's attention to enclosed words, and [] decreases it.
|
- **Attention/Emphasis**: `+` in the prompt increases the model's attention to enclosed words, and `-` decreases it. E.g. `apple++ falling from a tree`.
|
||||||
- **Weighted Prompts**: Use weights for specific words in your prompt to change their importance, e.g. `red:2.4 dragon:1.2`.
|
- **Weighted Prompts**: Use weights for specific words in your prompt to change their importance, e.g. `(red)2.4 (dragon)1.2`.
|
||||||
- **Prompt Matrix**: Quickly create multiple variations of your prompt, e.g. `a photograph of an astronaut riding a horse | illustration | cinematic lighting`.
|
- **Prompt Matrix**: Quickly create multiple variations of your prompt, e.g. `a photograph of an astronaut riding a horse | illustration | cinematic lighting`.
|
||||||
- **Prompt Set**: Quickly create multiple variations of your prompt, e.g. `a photograph of an astronaut on the {moon,earth}`
|
- **Prompt Set**: Quickly create multiple variations of your prompt, e.g. `a photograph of an astronaut on the {moon,earth}`
|
||||||
- **1-click Upscale/Face Correction**: Upscale or correct an image after it has been generated.
|
- **1-click Upscale/Face Correction**: Upscale or correct an image after it has been generated.
|
||||||
@ -82,10 +88,11 @@ Just delete the `EasyDiffusion` folder to uninstall all the downloaded packages.
|
|||||||
|
|
||||||
### Advanced features
|
### Advanced features
|
||||||
- **Custom Models**: Use your own `.ckpt` or `.safetensors` file, by placing it inside the `models/stable-diffusion` folder!
|
- **Custom Models**: Use your own `.ckpt` or `.safetensors` file, by placing it inside the `models/stable-diffusion` folder!
|
||||||
- **Stable Diffusion 2.1 support**
|
- **Stable Diffusion XL and 2.1 support**
|
||||||
- **Merge Models**
|
- **Merge Models**
|
||||||
- **Use custom VAE models**
|
- **Use custom VAE models**
|
||||||
- **Use pre-trained Hypernetworks**
|
- **Textual Inversion Embeddings**
|
||||||
|
- **ControlNet**
|
||||||
- **Use custom GFPGAN models**
|
- **Use custom GFPGAN models**
|
||||||
- **UI Plugins**: Choose from a growing list of [community-generated UI plugins](https://github.com/easydiffusion/easydiffusion/wiki/UI-Plugins), or write your own plugin to add features to the project!
|
- **UI Plugins**: Choose from a growing list of [community-generated UI plugins](https://github.com/easydiffusion/easydiffusion/wiki/UI-Plugins), or write your own plugin to add features to the project!
|
||||||
|
|
||||||
@ -97,24 +104,14 @@ Just delete the `EasyDiffusion` folder to uninstall all the downloaded packages.
|
|||||||
- **Auto scan for malicious models**: Uses picklescan to prevent malicious models.
|
- **Auto scan for malicious models**: Uses picklescan to prevent malicious models.
|
||||||
- **Safetensors support**: Support loading models in the safetensor format, for improved safety.
|
- **Safetensors support**: Support loading models in the safetensor format, for improved safety.
|
||||||
- **Auto-updater**: Gets you the latest improvements and bug-fixes to a rapidly evolving project.
|
- **Auto-updater**: Gets you the latest improvements and bug-fixes to a rapidly evolving project.
|
||||||
- **Developer Console**: A developer-mode for those who want to modify their Stable Diffusion code, and edit the conda environment.
|
- **Developer Console**: A developer-mode for those who want to modify their Stable Diffusion code, modify packages, and edit the conda environment.
|
||||||
|
|
||||||
**(and a lot more)**
|
**(and a lot more)**
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
## Easy for new users:
|
## Easy for new users, powerful features for advanced users:
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
## Powerful features for advanced users:
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
## Live Preview
|
|
||||||
Useful for judging (and stopping) an image quickly, without waiting for it to finish rendering.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Task Queue
|
## Task Queue
|
||||||

|

|
||||||
@ -128,12 +125,6 @@ Please refer to our [guide](https://github.com/easydiffusion/easydiffusion/wiki/
|
|||||||
# Bugs reports and code contributions welcome
|
# Bugs reports and code contributions welcome
|
||||||
If there are any problems or suggestions, please feel free to ask on the [discord server](https://discord.com/invite/u9yhsFmEkB) or [file an issue](https://github.com/easydiffusion/easydiffusion/issues).
|
If there are any problems or suggestions, please feel free to ask on the [discord server](https://discord.com/invite/u9yhsFmEkB) or [file an issue](https://github.com/easydiffusion/easydiffusion/issues).
|
||||||
|
|
||||||
We could really use help on these aspects (click to view tasks that need your help):
|
|
||||||
* [User Interface](https://github.com/users/cmdr2/projects/1/views/1)
|
|
||||||
* [Engine](https://github.com/users/cmdr2/projects/3/views/1)
|
|
||||||
* [Installer](https://github.com/users/cmdr2/projects/4/views/1)
|
|
||||||
* [Documentation](https://github.com/users/cmdr2/projects/5/views/1)
|
|
||||||
|
|
||||||
If you have any code contributions in mind, please feel free to say Hi to us on the [discord server](https://discord.com/invite/u9yhsFmEkB). We use the Discord server for development-related discussions, and for helping users.
|
If you have any code contributions in mind, please feel free to say Hi to us on the [discord server](https://discord.com/invite/u9yhsFmEkB). We use the Discord server for development-related discussions, and for helping users.
|
||||||
|
|
||||||
# Credits
|
# Credits
|
||||||
|
94
build.bat
94
build.bat
@ -1,48 +1,78 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
@echo "Hi there, what you are running is meant for the developers of this project, not for users." & echo.
|
@echo "Hi there, what you are running is meant for the developers of this project, not for users." & echo.
|
||||||
@echo "If you only want to use the Stable Diffusion UI, you've downloaded the wrong file."
|
@echo "If you only want to use Easy Diffusion, you've downloaded the wrong file."
|
||||||
@echo "Please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation" & echo.
|
@echo "Please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation" & echo.
|
||||||
@echo "If you are actually a developer of this project, please type Y and press enter" & echo.
|
@echo "If you are actually a developer of this project, please type Y and press enter" & echo.
|
||||||
|
|
||||||
set /p answer=Are you a developer of this project (Y/N)?
|
set /p answer=Are you a developer of this project (Y/N)?
|
||||||
if /i "%answer:~,1%" NEQ "Y" exit /b
|
if /i "%answer:~,1%" NEQ "Y" exit /b
|
||||||
|
|
||||||
mkdir dist\win\stable-diffusion-ui\scripts
|
@rem verify dependencies
|
||||||
@REM mkdir dist\linux-mac\stable-diffusion-ui\scripts
|
call makensis /VERSION >.tmp1 2>.tmp2
|
||||||
|
if "!ERRORLEVEL!" NEQ "0" (
|
||||||
|
echo makensis.exe not found! Download it from https://sourceforge.net/projects/nsisbi/files/ and set it on the PATH variable.
|
||||||
|
pause
|
||||||
|
exit
|
||||||
|
)
|
||||||
|
|
||||||
@rem copy the installer files for Windows
|
set /p OUT_DIR=Output folder path (will create the installer files inside this, e.g. F:\EasyDiffusion):
|
||||||
|
|
||||||
copy scripts\on_env_start.bat dist\win\stable-diffusion-ui\scripts\
|
mkdir "%OUT_DIR%\scripts"
|
||||||
copy scripts\bootstrap.bat dist\win\stable-diffusion-ui\scripts\
|
mkdir "%OUT_DIR%\installer_files"
|
||||||
copy scripts\config.yaml.sample dist\win\stable-diffusion-ui\scripts\config.yaml
|
|
||||||
copy "scripts\Start Stable Diffusion UI.cmd" dist\win\stable-diffusion-ui\
|
|
||||||
copy LICENSE dist\win\stable-diffusion-ui\
|
|
||||||
copy "CreativeML Open RAIL-M License" dist\win\stable-diffusion-ui\
|
|
||||||
copy "How to install and run.txt" dist\win\stable-diffusion-ui\
|
|
||||||
echo. > dist\win\stable-diffusion-ui\scripts\install_status.txt
|
|
||||||
|
|
||||||
@rem copy the installer files for Linux and Mac
|
set BASE_DIR=%cd%
|
||||||
|
|
||||||
@REM copy scripts\on_env_start.sh dist\linux-mac\stable-diffusion-ui\scripts\
|
@rem STEP 1: copy the installer files for Windows
|
||||||
@REM copy scripts\bootstrap.sh dist\linux-mac\stable-diffusion-ui\scripts\
|
|
||||||
@REM copy scripts\start.sh dist\linux-mac\stable-diffusion-ui\
|
|
||||||
@REM copy LICENSE dist\linux-mac\stable-diffusion-ui\
|
|
||||||
@REM copy "CreativeML Open RAIL-M License" dist\linux-mac\stable-diffusion-ui\
|
|
||||||
@REM copy "How to install and run.txt" dist\linux-mac\stable-diffusion-ui\
|
|
||||||
@REM echo. > dist\linux-mac\stable-diffusion-ui\scripts\install_status.txt
|
|
||||||
|
|
||||||
@rem make the zip
|
copy "%BASE_DIR%\scripts\on_env_start.bat" "%OUT_DIR%\scripts\"
|
||||||
|
copy "%BASE_DIR%\scripts\config.yaml.sample" "%OUT_DIR%\scripts\config.yaml.sample"
|
||||||
cd dist\win
|
copy "%BASE_DIR%\scripts\Start Stable Diffusion UI.cmd" "%OUT_DIR%\"
|
||||||
call powershell Compress-Archive -Path stable-diffusion-ui -DestinationPath ..\stable-diffusion-ui-windows.zip
|
copy "%BASE_DIR%\LICENSE" "%OUT_DIR%\"
|
||||||
cd ..\..
|
copy "%BASE_DIR%\CreativeML Open RAIL-M License" "%OUT_DIR%\"
|
||||||
|
copy "%BASE_DIR%\How to install and run.txt" "%OUT_DIR%\"
|
||||||
@REM cd dist\linux-mac
|
copy "%BASE_DIR%\NSIS\cyborg_flower_girl.ico" "%OUT_DIR%\installer_files\"
|
||||||
@REM call powershell Compress-Archive -Path stable-diffusion-ui -DestinationPath ..\stable-diffusion-ui-linux.zip
|
copy "%BASE_DIR%\NSIS\cyborg_flower_girl.bmp" "%OUT_DIR%\installer_files\"
|
||||||
@REM call powershell Compress-Archive -Path stable-diffusion-ui -DestinationPath ..\stable-diffusion-ui-mac.zip
|
echo. > "%OUT_DIR%\scripts\install_status.txt"
|
||||||
@REM cd ..\..
|
|
||||||
|
|
||||||
echo "Build ready. Upload the zip files inside the 'dist' folder."
|
|
||||||
|
|
||||||
|
echo ----
|
||||||
|
echo Basic files ready. Verify the files in %OUT_DIR%, then press Enter to initialize the environment, or close to quit.
|
||||||
|
echo ----
|
||||||
|
pause
|
||||||
|
|
||||||
|
@rem STEP 2: Initialize the environment with git, python and conda
|
||||||
|
|
||||||
|
cd /d "%OUT_DIR%\"
|
||||||
|
call "%BASE_DIR%\scripts\bootstrap.bat"
|
||||||
|
|
||||||
|
echo ----
|
||||||
|
echo Environment ready. Verify the environment, then press Enter to download the necessary packages, or close to quit.
|
||||||
|
echo ----
|
||||||
|
pause
|
||||||
|
|
||||||
|
@rem STEP 3: Download the packages and create a working installation
|
||||||
|
|
||||||
|
cd /d "%OUT_DIR%\"
|
||||||
|
start "Install Easy Diffusion" /D "%OUT_DIR%" "Start Stable Diffusion UI.cmd"
|
||||||
|
|
||||||
|
echo ----
|
||||||
|
echo Installation in progress (in a new window). Once complete, verify the installation, then press Enter to create an installer from these files, or close to quit.
|
||||||
|
echo ----
|
||||||
|
pause
|
||||||
|
|
||||||
|
@rem STEP 4: Build the installer from a working installation
|
||||||
|
|
||||||
|
cd /d "%OUT_DIR%\"
|
||||||
|
|
||||||
|
echo ^^!define EXISTING_INSTALLATION_DIR "%OUT_DIR%" > nsisconf.nsh
|
||||||
|
call makensis /NOCD /V4 "%BASE_DIR%\NSIS\sdui.nsi"
|
||||||
|
|
||||||
|
echo ----
|
||||||
|
if "!ERRORLEVEL!" EQU "0" (
|
||||||
|
echo Installer built successfully at %OUT_DIR%
|
||||||
|
) else (
|
||||||
|
echo Installer failed to build at %OUT_DIR%
|
||||||
|
)
|
||||||
|
echo ----
|
||||||
pause
|
pause
|
46
build.sh
46
build.sh
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
printf "Hi there, what you are running is meant for the developers of this project, not for users.\n\n"
|
printf "Hi there, what you are running is meant for the developers of this project, not for users.\n\n"
|
||||||
printf "If you only want to use the Stable Diffusion UI, you've downloaded the wrong file.\n"
|
printf "If you only want to use Easy Diffusion, you've downloaded the wrong file.\n"
|
||||||
printf "Please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation \n\n"
|
printf "Please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation \n\n"
|
||||||
printf "If you are actually a developer of this project, please type Y and press enter\n\n"
|
printf "If you are actually a developer of this project, please type Y and press enter\n\n"
|
||||||
|
|
||||||
@ -11,40 +11,30 @@ case $yn in
|
|||||||
* ) exit;;
|
* ) exit;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# mkdir -p dist/win/stable-diffusion-ui/scripts
|
mkdir -p dist/linux-mac/easy-diffusion/scripts
|
||||||
mkdir -p dist/linux-mac/stable-diffusion-ui/scripts
|
|
||||||
|
|
||||||
# copy the installer files for Windows
|
|
||||||
|
|
||||||
# cp scripts/on_env_start.bat dist/win/stable-diffusion-ui/scripts/
|
|
||||||
# cp scripts/bootstrap.bat dist/win/stable-diffusion-ui/scripts/
|
|
||||||
# cp "scripts/Start Stable Diffusion UI.cmd" dist/win/stable-diffusion-ui/
|
|
||||||
# cp LICENSE dist/win/stable-diffusion-ui/
|
|
||||||
# cp "CreativeML Open RAIL-M License" dist/win/stable-diffusion-ui/
|
|
||||||
# cp "How to install and run.txt" dist/win/stable-diffusion-ui/
|
|
||||||
# echo "" > dist/win/stable-diffusion-ui/scripts/install_status.txt
|
|
||||||
|
|
||||||
# copy the installer files for Linux and Mac
|
# copy the installer files for Linux and Mac
|
||||||
|
|
||||||
cp scripts/on_env_start.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
cp scripts/on_env_start.sh dist/linux-mac/easy-diffusion/scripts/
|
||||||
cp scripts/bootstrap.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
cp scripts/bootstrap.sh dist/linux-mac/easy-diffusion/scripts/
|
||||||
cp scripts/functions.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
cp scripts/functions.sh dist/linux-mac/easy-diffusion/scripts/
|
||||||
cp scripts/config.yaml.sample dist/linux-mac/stable-diffusion-ui/scripts/config.yaml
|
cp scripts/config.yaml.sample dist/linux-mac/easy-diffusion/scripts/config.yaml.sample
|
||||||
cp scripts/start.sh dist/linux-mac/stable-diffusion-ui/
|
cp scripts/start.sh dist/linux-mac/easy-diffusion/
|
||||||
cp LICENSE dist/linux-mac/stable-diffusion-ui/
|
cp LICENSE dist/linux-mac/easy-diffusion/
|
||||||
cp "CreativeML Open RAIL-M License" dist/linux-mac/stable-diffusion-ui/
|
cp "CreativeML Open RAIL-M License" dist/linux-mac/easy-diffusion/
|
||||||
cp "How to install and run.txt" dist/linux-mac/stable-diffusion-ui/
|
cp "How to install and run.txt" dist/linux-mac/easy-diffusion/
|
||||||
echo "" > dist/linux-mac/stable-diffusion-ui/scripts/install_status.txt
|
echo "" > dist/linux-mac/easy-diffusion/scripts/install_status.txt
|
||||||
|
|
||||||
|
# set the permissions
|
||||||
|
chmod u+x dist/linux-mac/easy-diffusion/scripts/on_env_start.sh
|
||||||
|
chmod u+x dist/linux-mac/easy-diffusion/scripts/bootstrap.sh
|
||||||
|
chmod u+x dist/linux-mac/easy-diffusion/start.sh
|
||||||
|
|
||||||
# make the zip
|
# make the zip
|
||||||
|
|
||||||
# cd dist/win
|
|
||||||
# zip -r ../stable-diffusion-ui-windows.zip stable-diffusion-ui
|
|
||||||
# cd ../..
|
|
||||||
|
|
||||||
cd dist/linux-mac
|
cd dist/linux-mac
|
||||||
zip -r ../stable-diffusion-ui-linux.zip stable-diffusion-ui
|
zip -r ../Easy-Diffusion-Linux.zip easy-diffusion
|
||||||
zip -r ../stable-diffusion-ui-mac.zip stable-diffusion-ui
|
zip -r ../Easy-Diffusion-Mac.zip easy-diffusion
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
echo "Build ready. Upload the zip files inside the 'dist' folder."
|
echo "Build ready. Upload the zip files inside the 'dist' folder."
|
||||||
|
@ -4,6 +4,7 @@ cd /d %~dp0
|
|||||||
echo Install dir: %~dp0
|
echo Install dir: %~dp0
|
||||||
|
|
||||||
set PATH=C:\Windows\System32;%PATH%
|
set PATH=C:\Windows\System32;%PATH%
|
||||||
|
set PYTHONHOME=
|
||||||
|
|
||||||
if exist "on_sd_start.bat" (
|
if exist "on_sd_start.bat" (
|
||||||
echo ================================================================================
|
echo ================================================================================
|
||||||
@ -14,7 +15,7 @@ if exist "on_sd_start.bat" (
|
|||||||
echo download. This will not work.
|
echo download. This will not work.
|
||||||
echo.
|
echo.
|
||||||
echo Recommended: Please close this window and download the installer from
|
echo Recommended: Please close this window and download the installer from
|
||||||
echo https://stable-diffusion-ui.github.io/docs/installation/
|
echo https://easydiffusion.github.io/docs/installation/
|
||||||
echo.
|
echo.
|
||||||
echo ================================================================================
|
echo ================================================================================
|
||||||
echo.
|
echo.
|
||||||
@ -38,6 +39,7 @@ call where conda
|
|||||||
call conda --version
|
call conda --version
|
||||||
echo .
|
echo .
|
||||||
echo COMSPEC=%COMSPEC%
|
echo COMSPEC=%COMSPEC%
|
||||||
|
wmic path win32_VideoController get name,AdapterRAM,DriverDate,DriverVersion
|
||||||
|
|
||||||
@rem Download the rest of the installer and UI
|
@rem Download the rest of the installer and UI
|
||||||
call scripts\on_env_start.bat
|
call scripts\on_env_start.bat
|
||||||
|
@ -14,6 +14,8 @@ set LEGACY_INSTALL_ENV_DIR=%cd%\installer
|
|||||||
set MICROMAMBA_DOWNLOAD_URL=https://github.com/easydiffusion/easydiffusion/releases/download/v1.1/micromamba.exe
|
set MICROMAMBA_DOWNLOAD_URL=https://github.com/easydiffusion/easydiffusion/releases/download/v1.1/micromamba.exe
|
||||||
set umamba_exists=F
|
set umamba_exists=F
|
||||||
|
|
||||||
|
set PYTHONHOME=
|
||||||
|
|
||||||
set OLD_APPDATA=%APPDATA%
|
set OLD_APPDATA=%APPDATA%
|
||||||
set OLD_USERPROFILE=%USERPROFILE%
|
set OLD_USERPROFILE=%USERPROFILE%
|
||||||
set APPDATA=%cd%\installer_files\appdata
|
set APPDATA=%cd%\installer_files\appdata
|
||||||
@ -22,15 +24,12 @@ set USERPROFILE=%cd%\profile
|
|||||||
@rem figure out whether git and conda needs to be installed
|
@rem figure out whether git and conda needs to be installed
|
||||||
if exist "%INSTALL_ENV_DIR%" set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH%
|
if exist "%INSTALL_ENV_DIR%" set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH%
|
||||||
|
|
||||||
set PACKAGES_TO_INSTALL=
|
set PACKAGES_TO_INSTALL=git python=3.8.5
|
||||||
|
|
||||||
if not exist "%LEGACY_INSTALL_ENV_DIR%\etc\profile.d\conda.sh" (
|
if not exist "%LEGACY_INSTALL_ENV_DIR%\etc\profile.d\conda.sh" (
|
||||||
if not exist "%INSTALL_ENV_DIR%\etc\profile.d\conda.sh" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda python=3.8.5
|
if not exist "%INSTALL_ENV_DIR%\etc\profile.d\conda.sh" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda
|
||||||
)
|
)
|
||||||
|
|
||||||
call git --version >.tmp1 2>.tmp2
|
|
||||||
if "!ERRORLEVEL!" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git
|
|
||||||
|
|
||||||
call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version >.tmp1 2>.tmp2
|
call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version >.tmp1 2>.tmp2
|
||||||
if "!ERRORLEVEL!" EQU "0" set umamba_exists=T
|
if "!ERRORLEVEL!" EQU "0" set umamba_exists=T
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
@echo. & echo "Easy Diffusion - v2" & echo.
|
@echo. & echo "Easy Diffusion - v3" & echo.
|
||||||
|
|
||||||
set PATH=C:\Windows\System32;%PATH%
|
set PATH=C:\Windows\System32;%PATH%
|
||||||
|
|
||||||
@ -46,6 +46,8 @@ if "%update_branch%"=="" (
|
|||||||
|
|
||||||
@cd sd-ui-files
|
@cd sd-ui-files
|
||||||
|
|
||||||
|
@call git add -A .
|
||||||
|
@call git stash
|
||||||
@call git reset --hard
|
@call git reset --hard
|
||||||
@call git -c advice.detachedHead=false checkout "%update_branch%"
|
@call git -c advice.detachedHead=false checkout "%update_branch%"
|
||||||
@call git pull
|
@call git pull
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
source ./scripts/functions.sh
|
source ./scripts/functions.sh
|
||||||
|
|
||||||
printf "\n\nEasy Diffusion\n\n"
|
printf "\n\nEasy Diffusion - v3\n\n"
|
||||||
|
|
||||||
export PYTHONNOUSERSITE=y
|
export PYTHONNOUSERSITE=y
|
||||||
|
|
||||||
@ -29,6 +29,8 @@ if [ -f "scripts/install_status.txt" ] && [ `grep -c sd_ui_git_cloned scripts/in
|
|||||||
|
|
||||||
cd sd-ui-files
|
cd sd-ui-files
|
||||||
|
|
||||||
|
git add -A .
|
||||||
|
git stash
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git -c advice.detachedHead=false checkout "$update_branch"
|
git -c advice.detachedHead=false checkout "$update_branch"
|
||||||
git pull
|
git pull
|
||||||
|
@ -34,6 +34,7 @@ call conda activate
|
|||||||
|
|
||||||
@REM remove the old version of the dev console script, if it's still present
|
@REM remove the old version of the dev console script, if it's still present
|
||||||
if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
|
if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
|
||||||
|
if exist "ui\plugins\ui\merge.plugin.js" del "ui\plugins\ui\merge.plugin.js"
|
||||||
|
|
||||||
@rem create the stable-diffusion folder, to work with legacy installations
|
@rem create the stable-diffusion folder, to work with legacy installations
|
||||||
if not exist "stable-diffusion" mkdir stable-diffusion
|
if not exist "stable-diffusion" mkdir stable-diffusion
|
||||||
@ -52,73 +53,24 @@ if exist ldm rename ldm ldm-old
|
|||||||
if not exist "%INSTALL_ENV_DIR%\DLLs\libssl-1_1-x64.dll" copy "%INSTALL_ENV_DIR%\Library\bin\libssl-1_1-x64.dll" "%INSTALL_ENV_DIR%\DLLs\"
|
if not exist "%INSTALL_ENV_DIR%\DLLs\libssl-1_1-x64.dll" copy "%INSTALL_ENV_DIR%\Library\bin\libssl-1_1-x64.dll" "%INSTALL_ENV_DIR%\DLLs\"
|
||||||
if not exist "%INSTALL_ENV_DIR%\DLLs\libcrypto-1_1-x64.dll" copy "%INSTALL_ENV_DIR%\Library\bin\libcrypto-1_1-x64.dll" "%INSTALL_ENV_DIR%\DLLs\"
|
if not exist "%INSTALL_ENV_DIR%\DLLs\libcrypto-1_1-x64.dll" copy "%INSTALL_ENV_DIR%\Library\bin\libcrypto-1_1-x64.dll" "%INSTALL_ENV_DIR%\DLLs\"
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
@rem set any overrides
|
||||||
|
set HF_HUB_DISABLE_SYMLINKS_WARNING=true
|
||||||
|
|
||||||
@rem install or upgrade the required modules
|
@rem install or upgrade the required modules
|
||||||
set PATH=C:\Windows\System32;%PATH%
|
set PATH=C:\Windows\System32;%PATH%
|
||||||
|
|
||||||
@REM prevent from using packages from the user's home directory, to avoid conflicts
|
@REM prevent from using packages from the user's home directory, to avoid conflicts
|
||||||
set PYTHONNOUSERSITE=1
|
set PYTHONNOUSERSITE=1
|
||||||
set PYTHONPATH=%INSTALL_ENV_DIR%\lib\site-packages
|
|
||||||
|
|
||||||
@rem Download the required packages
|
|
||||||
call python ..\scripts\check_modules.py
|
|
||||||
if "%ERRORLEVEL%" NEQ "0" (
|
|
||||||
pause
|
|
||||||
exit /b
|
|
||||||
)
|
|
||||||
|
|
||||||
call WHERE uvicorn > .tmp
|
|
||||||
@>nul findstr /m "uvicorn" .tmp
|
|
||||||
@if "%ERRORLEVEL%" NEQ "0" (
|
|
||||||
@echo. & echo "UI packages not found! Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/easydiffusion/easydiffusion/issues" & echo "Thanks!" & echo.
|
|
||||||
pause
|
|
||||||
exit /b
|
|
||||||
)
|
|
||||||
|
|
||||||
@>nul findstr /m "conda_sd_ui_deps_installed" ..\scripts\install_status.txt
|
|
||||||
@if "%ERRORLEVEL%" NEQ "0" (
|
|
||||||
@echo conda_sd_ui_deps_installed >> ..\scripts\install_status.txt
|
|
||||||
)
|
|
||||||
|
|
||||||
@>nul findstr /m "sd_install_complete" ..\scripts\install_status.txt
|
|
||||||
@if "%ERRORLEVEL%" NEQ "0" (
|
|
||||||
@echo sd_weights_downloaded >> ..\scripts\install_status.txt
|
|
||||||
@echo sd_install_complete >> ..\scripts\install_status.txt
|
|
||||||
)
|
|
||||||
|
|
||||||
@echo. & echo "Easy Diffusion installation complete! Starting the server!" & echo.
|
|
||||||
|
|
||||||
@set SD_DIR=%cd%
|
|
||||||
|
|
||||||
set PYTHONPATH=%INSTALL_ENV_DIR%\lib\site-packages
|
set PYTHONPATH=%INSTALL_ENV_DIR%\lib\site-packages
|
||||||
echo PYTHONPATH=%PYTHONPATH%
|
echo PYTHONPATH=%PYTHONPATH%
|
||||||
|
|
||||||
|
@rem Download the required packages
|
||||||
call where python
|
call where python
|
||||||
call python --version
|
call python --version
|
||||||
|
|
||||||
@cd ..
|
call python scripts\check_modules.py --launch-uvicorn
|
||||||
@set SD_UI_PATH=%cd%\ui
|
pause
|
||||||
|
exit /b
|
||||||
|
|
||||||
@FOR /F "tokens=* USEBACKQ" %%F IN (`python scripts\get_config.py --default=9000 net listen_port`) DO (
|
|
||||||
@SET ED_BIND_PORT=%%F
|
|
||||||
)
|
|
||||||
|
|
||||||
@FOR /F "tokens=* USEBACKQ" %%F IN (`python scripts\get_config.py --default=False net listen_to_network`) DO (
|
|
||||||
if "%%F" EQU "True" (
|
|
||||||
@FOR /F "tokens=* USEBACKQ" %%G IN (`python scripts\get_config.py --default=0.0.0.0 net bind_ip`) DO (
|
|
||||||
@SET ED_BIND_IP=%%G
|
|
||||||
)
|
|
||||||
) else (
|
|
||||||
@SET ED_BIND_IP=127.0.0.1
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@cd stable-diffusion
|
|
||||||
|
|
||||||
@rem set any overrides
|
|
||||||
set HF_HUB_DISABLE_SYMLINKS_WARNING=true
|
|
||||||
|
|
||||||
@python -m uvicorn main:server_api --app-dir "%SD_UI_PATH%" --port %ED_BIND_PORT% --host %ED_BIND_IP% --log-level error
|
|
||||||
|
|
||||||
|
|
||||||
@pause
|
|
||||||
|
@ -7,6 +7,7 @@ cp sd-ui-files/scripts/check_modules.py scripts/
|
|||||||
cp sd-ui-files/scripts/get_config.py scripts/
|
cp sd-ui-files/scripts/get_config.py scripts/
|
||||||
cp sd-ui-files/scripts/config.yaml.sample scripts/
|
cp sd-ui-files/scripts/config.yaml.sample scripts/
|
||||||
|
|
||||||
|
|
||||||
source ./scripts/functions.sh
|
source ./scripts/functions.sh
|
||||||
|
|
||||||
# activate the installer env
|
# activate the installer env
|
||||||
@ -20,6 +21,10 @@ if [ -e "open_dev_console.sh" ]; then
|
|||||||
rm "open_dev_console.sh"
|
rm "open_dev_console.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -e "ui/plugins/ui/merge.plugin.js" ]; then
|
||||||
|
rm "ui/plugins/ui/merge.plugin.js"
|
||||||
|
fi
|
||||||
|
|
||||||
# set the correct installer path (current vs legacy)
|
# set the correct installer path (current vs legacy)
|
||||||
if [ -e "installer_files/env" ]; then
|
if [ -e "installer_files/env" ]; then
|
||||||
export INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
export INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
||||||
@ -41,45 +46,8 @@ fi
|
|||||||
if [ -e "src" ]; then mv src src-old; fi
|
if [ -e "src" ]; then mv src src-old; fi
|
||||||
if [ -e "ldm" ]; then mv ldm ldm-old; fi
|
if [ -e "ldm" ]; then mv ldm ldm-old; fi
|
||||||
|
|
||||||
# Download the required packages
|
|
||||||
if ! python ../scripts/check_modules.py; then
|
|
||||||
read -p "Press any key to continue"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v uvicorn &> /dev/null; then
|
|
||||||
fail "UI packages not found!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ `grep -c sd_install_complete ../scripts/install_status.txt` -gt "0" ]; then
|
|
||||||
echo sd_weights_downloaded >> ../scripts/install_status.txt
|
|
||||||
echo sd_install_complete >> ../scripts/install_status.txt
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "\n\nEasy Diffusion installation complete, starting the server!\n\n"
|
|
||||||
|
|
||||||
SD_PATH=`pwd`
|
|
||||||
|
|
||||||
export PYTORCH_ENABLE_MPS_FALLBACK=1
|
|
||||||
export PYTHONPATH="$INSTALL_ENV_DIR/lib/python3.8/site-packages"
|
|
||||||
echo "PYTHONPATH=$PYTHONPATH"
|
|
||||||
|
|
||||||
which python
|
|
||||||
python --version
|
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
export SD_UI_PATH=`pwd`/ui
|
# Download the required packages
|
||||||
export ED_BIND_PORT="$( python scripts/get_config.py --default=9000 net listen_port )"
|
python scripts/check_modules.py --launch-uvicorn
|
||||||
case "$( python scripts/get_config.py --default=False net listen_to_network )" in
|
|
||||||
"True")
|
|
||||||
export ED_BIND_IP=$( python scripts/get_config.py --default=0.0.0.0 net bind_ip)
|
|
||||||
;;
|
|
||||||
"False")
|
|
||||||
export ED_BIND_IP=127.0.0.1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
cd stable-diffusion
|
|
||||||
|
|
||||||
uvicorn main:server_api --app-dir "$SD_UI_PATH" --port "$ED_BIND_PORT" --host "$ED_BIND_IP" --log-level error
|
|
||||||
|
|
||||||
read -p "Press any key to continue"
|
read -p "Press any key to continue"
|
||||||
|
@ -11,7 +11,7 @@ if [ -f "on_sd_start.bat" ]; then
|
|||||||
echo download. This will not work.
|
echo download. This will not work.
|
||||||
echo
|
echo
|
||||||
echo Recommended: Please close this window and download the installer from
|
echo Recommended: Please close this window and download the installer from
|
||||||
echo https://stable-diffusion-ui.github.io/docs/installation/
|
echo https://easydiffusion.github.io/docs/installation/
|
||||||
echo
|
echo
|
||||||
echo ================================================================================
|
echo ================================================================================
|
||||||
echo
|
echo
|
||||||
@ -19,6 +19,7 @@ if [ -f "on_sd_start.bat" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
unset PYTHONHOME
|
||||||
|
|
||||||
# set legacy installer's PATH, if it exists
|
# set legacy installer's PATH, if it exists
|
||||||
if [ -e "installer" ]; then export PATH="$(pwd)/installer/bin:$PATH"; fi
|
if [ -e "installer" ]; then export PATH="$(pwd)/installer/bin:$PATH"; fi
|
||||||
|
@ -37,7 +37,7 @@ ROOT_DIR = os.path.abspath(os.path.join(SD_DIR, ".."))
|
|||||||
SD_UI_DIR = os.getenv("SD_UI_PATH", None)
|
SD_UI_DIR = os.getenv("SD_UI_PATH", None)
|
||||||
|
|
||||||
CONFIG_DIR = os.path.abspath(os.path.join(SD_UI_DIR, "..", "scripts"))
|
CONFIG_DIR = os.path.abspath(os.path.join(SD_UI_DIR, "..", "scripts"))
|
||||||
MODELS_DIR = os.path.abspath(os.path.join(SD_DIR, "..", "models"))
|
BUCKET_DIR = os.path.abspath(os.path.join(SD_DIR, "..", "bucket"))
|
||||||
|
|
||||||
USER_PLUGINS_DIR = os.path.abspath(os.path.join(SD_DIR, "..", "plugins"))
|
USER_PLUGINS_DIR = os.path.abspath(os.path.join(SD_DIR, "..", "plugins"))
|
||||||
CORE_PLUGINS_DIR = os.path.abspath(os.path.join(SD_UI_DIR, "plugins"))
|
CORE_PLUGINS_DIR = os.path.abspath(os.path.join(SD_UI_DIR, "plugins"))
|
||||||
@ -60,6 +60,7 @@ APP_CONFIG_DEFAULTS = {
|
|||||||
"ui": {
|
"ui": {
|
||||||
"open_browser_on_start": True,
|
"open_browser_on_start": True,
|
||||||
},
|
},
|
||||||
|
"use_v3_engine": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
IMAGE_EXTENSIONS = [
|
IMAGE_EXTENSIONS = [
|
||||||
@ -90,14 +91,23 @@ CUSTOM_MODIFIERS_LANDSCAPE_EXTENSIONS = [
|
|||||||
"-landscape",
|
"-landscape",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
MODELS_DIR = os.path.abspath(os.path.join(SD_DIR, "..", "models"))
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
|
global MODELS_DIR
|
||||||
|
|
||||||
os.makedirs(USER_UI_PLUGINS_DIR, exist_ok=True)
|
os.makedirs(USER_UI_PLUGINS_DIR, exist_ok=True)
|
||||||
os.makedirs(USER_SERVER_PLUGINS_DIR, exist_ok=True)
|
os.makedirs(USER_SERVER_PLUGINS_DIR, exist_ok=True)
|
||||||
|
|
||||||
# https://pytorch.org/docs/stable/storage.html
|
# https://pytorch.org/docs/stable/storage.html
|
||||||
warnings.filterwarnings("ignore", category=UserWarning, message="TypedStorage is deprecated")
|
warnings.filterwarnings("ignore", category=UserWarning, message="TypedStorage is deprecated")
|
||||||
|
|
||||||
|
config = getConfig()
|
||||||
|
config_models_dir = config.get("models_dir", None)
|
||||||
|
if (config_models_dir is not None and config_models_dir != ""):
|
||||||
|
MODELS_DIR = config_models_dir
|
||||||
|
|
||||||
|
|
||||||
def init_render_threads():
|
def init_render_threads():
|
||||||
load_server_plugins()
|
load_server_plugins()
|
||||||
@ -114,9 +124,9 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
|
|||||||
shutil.move(config_legacy_yaml, config_yaml_path)
|
shutil.move(config_legacy_yaml, config_yaml_path)
|
||||||
|
|
||||||
def set_config_on_startup(config: dict):
|
def set_config_on_startup(config: dict):
|
||||||
if getConfig.__test_diffusers_on_startup is None:
|
if getConfig.__use_v3_engine_on_startup is None:
|
||||||
getConfig.__test_diffusers_on_startup = config.get("test_diffusers", False)
|
getConfig.__use_v3_engine_on_startup = config.get("use_v3_engine", True)
|
||||||
config["config_on_startup"] = {"test_diffusers": getConfig.__test_diffusers_on_startup}
|
config["config_on_startup"] = {"use_v3_engine": getConfig.__use_v3_engine_on_startup}
|
||||||
|
|
||||||
if os.path.isfile(config_yaml_path):
|
if os.path.isfile(config_yaml_path):
|
||||||
try:
|
try:
|
||||||
@ -164,12 +174,15 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
|
|||||||
return default_val
|
return default_val
|
||||||
|
|
||||||
|
|
||||||
getConfig.__test_diffusers_on_startup = None
|
getConfig.__use_v3_engine_on_startup = None
|
||||||
|
|
||||||
|
|
||||||
def setConfig(config):
|
def setConfig(config):
|
||||||
|
global MODELS_DIR
|
||||||
|
|
||||||
try: # config.yaml
|
try: # config.yaml
|
||||||
config_yaml_path = os.path.join(CONFIG_DIR, "..", "config.yaml")
|
config_yaml_path = os.path.join(CONFIG_DIR, "..", "config.yaml")
|
||||||
|
config_yaml_path = os.path.abspath(config_yaml_path)
|
||||||
yaml = YAML()
|
yaml = YAML()
|
||||||
|
|
||||||
if not hasattr(config, "_yaml_comment"):
|
if not hasattr(config, "_yaml_comment"):
|
||||||
@ -203,6 +216,9 @@ def setConfig(config):
|
|||||||
except:
|
except:
|
||||||
log.error(traceback.format_exc())
|
log.error(traceback.format_exc())
|
||||||
|
|
||||||
|
if config.get("models_dir"):
|
||||||
|
MODELS_DIR = config["models_dir"]
|
||||||
|
|
||||||
|
|
||||||
def save_to_config(ckpt_model_name, vae_model_name, hypernetwork_model_name, vram_usage_level):
|
def save_to_config(ckpt_model_name, vae_model_name, hypernetwork_model_name, vram_usage_level):
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
107
ui/easydiffusion/bucket_manager.py
Normal file
107
ui/easydiffusion/bucket_manager.py
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
from typing import List
|
||||||
|
|
||||||
|
from fastapi import Depends, FastAPI, HTTPException, Response, File
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
from easydiffusion.easydb import crud, models, schemas
|
||||||
|
from easydiffusion.easydb.database import SessionLocal, engine
|
||||||
|
|
||||||
|
from requests.compat import urlparse
|
||||||
|
|
||||||
|
import base64, json
|
||||||
|
|
||||||
|
MIME_TYPES = {
|
||||||
|
"jpg": "image/jpeg",
|
||||||
|
"jpeg": "image/jpeg",
|
||||||
|
"gif": "image/gif",
|
||||||
|
"png": "image/png",
|
||||||
|
"webp": "image/webp",
|
||||||
|
"js": "text/javascript",
|
||||||
|
"htm": "text/html",
|
||||||
|
"html": "text/html",
|
||||||
|
"css": "text/css",
|
||||||
|
"json": "application/json",
|
||||||
|
"mjs": "application/json",
|
||||||
|
"yaml": "application/yaml",
|
||||||
|
"svg": "image/svg+xml",
|
||||||
|
"txt": "text/plain",
|
||||||
|
}
|
||||||
|
|
||||||
|
def init():
|
||||||
|
from easydiffusion.server import server_api
|
||||||
|
|
||||||
|
models.BucketBase.metadata.create_all(bind=engine)
|
||||||
|
|
||||||
|
|
||||||
|
# Dependency
|
||||||
|
def get_db():
|
||||||
|
db = SessionLocal()
|
||||||
|
try:
|
||||||
|
yield db
|
||||||
|
finally:
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
@server_api.get("/bucket/{obj_path:path}")
|
||||||
|
def bucket_get_object(obj_path: str, db: Session = Depends(get_db)):
|
||||||
|
filename = get_filename_from_url(obj_path)
|
||||||
|
path = get_path_from_url(obj_path)
|
||||||
|
|
||||||
|
if filename==None:
|
||||||
|
bucket = crud.get_bucket_by_path(db, path=path)
|
||||||
|
if bucket == None:
|
||||||
|
raise HTTPException(status_code=404, detail="Bucket not found")
|
||||||
|
bucketfiles = db.query(models.BucketFile).with_entities(models.BucketFile.filename).filter(models.BucketFile.bucket_id == bucket.id).all()
|
||||||
|
bucketfiles = [ x.filename for x in bucketfiles ]
|
||||||
|
return bucketfiles
|
||||||
|
|
||||||
|
else:
|
||||||
|
bucket = crud.get_bucket_by_path(db, path)
|
||||||
|
if bucket == None:
|
||||||
|
raise HTTPException(status_code=404, detail="Bucket not found")
|
||||||
|
bucket_id = bucket.id
|
||||||
|
bucketfile = db.query(models.BucketFile).filter(models.BucketFile.bucket_id == bucket_id, models.BucketFile.filename == filename).first()
|
||||||
|
if bucketfile == None:
|
||||||
|
raise HTTPException(status_code=404, detail="File not found")
|
||||||
|
|
||||||
|
suffix = get_suffix_from_filename(filename)
|
||||||
|
|
||||||
|
return Response(content=bucketfile.data, media_type=MIME_TYPES.get(suffix, "application/octet-stream"))
|
||||||
|
|
||||||
|
@server_api.post("/bucket/{obj_path:path}")
|
||||||
|
def bucket_post_object(obj_path: str, file: bytes = File(), db: Session = Depends(get_db)):
|
||||||
|
filename = get_filename_from_url(obj_path)
|
||||||
|
path = get_path_from_url(obj_path)
|
||||||
|
bucket = crud.get_bucket_by_path(db, path)
|
||||||
|
|
||||||
|
if bucket == None:
|
||||||
|
bucket = crud.create_bucket(db=db, bucket=schemas.BucketCreate(path=path))
|
||||||
|
bucket_id = bucket.id
|
||||||
|
|
||||||
|
bucketfile = schemas.BucketFileCreate(filename=filename, data=file)
|
||||||
|
result = crud.create_bucketfile(db=db, bucketfile=bucketfile, bucket_id=bucket_id)
|
||||||
|
result.data = base64.encodestring(result.data)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@server_api.post("/buckets/{bucket_id}/items/", response_model=schemas.BucketFile)
|
||||||
|
def create_bucketfile_in_bucket(
|
||||||
|
bucket_id: int, bucketfile: schemas.BucketFileCreate, db: Session = Depends(get_db)
|
||||||
|
):
|
||||||
|
bucketfile.data = base64.decodestring(bucketfile.data)
|
||||||
|
result = crud.create_bucketfile(db=db, bucketfile=bucketfile, bucket_id=bucket_id)
|
||||||
|
result.data = base64.encodestring(result.data)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def get_filename_from_url(url):
|
||||||
|
path = urlparse(url).path
|
||||||
|
name = path[path.rfind('/')+1:]
|
||||||
|
return name or None
|
||||||
|
|
||||||
|
def get_path_from_url(url):
|
||||||
|
path = urlparse(url).path
|
||||||
|
path = path[0:path.rfind('/')]
|
||||||
|
return path or None
|
||||||
|
|
||||||
|
def get_suffix_from_filename(filename):
|
||||||
|
return filename[filename.rfind('.')+1:]
|
24
ui/easydiffusion/easydb/crud.py
Normal file
24
ui/easydiffusion/easydb/crud.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
from easydiffusion.easydb import models, schemas
|
||||||
|
|
||||||
|
|
||||||
|
def get_bucket_by_path(db: Session, path: str):
|
||||||
|
return db.query(models.Bucket).filter(models.Bucket.path == path).first()
|
||||||
|
|
||||||
|
|
||||||
|
def create_bucket(db: Session, bucket: schemas.BucketCreate):
|
||||||
|
db_bucket = models.Bucket(path=bucket.path)
|
||||||
|
db.add(db_bucket)
|
||||||
|
db.commit()
|
||||||
|
db.refresh(db_bucket)
|
||||||
|
return db_bucket
|
||||||
|
|
||||||
|
|
||||||
|
def create_bucketfile(db: Session, bucketfile: schemas.BucketFileCreate, bucket_id: int):
|
||||||
|
db_bucketfile = models.BucketFile(**bucketfile.dict(), bucket_id=bucket_id)
|
||||||
|
db.merge(db_bucketfile)
|
||||||
|
db.commit()
|
||||||
|
db_bucketfile = db.query(models.BucketFile).filter(models.BucketFile.bucket_id==bucket_id, models.BucketFile.filename==bucketfile.filename).first()
|
||||||
|
return db_bucketfile
|
||||||
|
|
14
ui/easydiffusion/easydb/database.py
Normal file
14
ui/easydiffusion/easydb/database.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import os
|
||||||
|
from easydiffusion import app
|
||||||
|
|
||||||
|
from sqlalchemy import create_engine
|
||||||
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
os.makedirs(app.BUCKET_DIR, exist_ok=True)
|
||||||
|
SQLALCHEMY_DATABASE_URL = "sqlite:///"+os.path.join(app.BUCKET_DIR, "bucket.db")
|
||||||
|
|
||||||
|
engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False})
|
||||||
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||||
|
|
||||||
|
BucketBase = declarative_base()
|
25
ui/easydiffusion/easydb/models.py
Normal file
25
ui/easydiffusion/easydb/models.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, BLOB
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from easydiffusion.easydb.database import BucketBase
|
||||||
|
|
||||||
|
|
||||||
|
class Bucket(BucketBase):
|
||||||
|
__tablename__ = "bucket"
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
|
path = Column(String, unique=True, index=True)
|
||||||
|
|
||||||
|
bucketfiles = relationship("BucketFile", back_populates="bucket")
|
||||||
|
|
||||||
|
|
||||||
|
class BucketFile(BucketBase):
|
||||||
|
__tablename__ = "bucketfile"
|
||||||
|
|
||||||
|
filename = Column(String, index=True, primary_key=True)
|
||||||
|
bucket_id = Column(Integer, ForeignKey("bucket.id"), primary_key=True)
|
||||||
|
|
||||||
|
data = Column(BLOB, index=False)
|
||||||
|
|
||||||
|
bucket = relationship("Bucket", back_populates="bucketfiles")
|
||||||
|
|
36
ui/easydiffusion/easydb/schemas.py
Normal file
36
ui/easydiffusion/easydb/schemas.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
from typing import List, Union
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class BucketFileBase(BaseModel):
|
||||||
|
filename: str
|
||||||
|
data: bytes
|
||||||
|
|
||||||
|
|
||||||
|
class BucketFileCreate(BucketFileBase):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BucketFile(BucketFileBase):
|
||||||
|
bucket_id: int
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
|
|
||||||
|
|
||||||
|
class BucketBase(BaseModel):
|
||||||
|
path: str
|
||||||
|
|
||||||
|
|
||||||
|
class BucketCreate(BucketBase):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Bucket(BucketBase):
|
||||||
|
id: int
|
||||||
|
bucketfiles: List[BucketFile] = []
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
|
|
@ -11,6 +11,7 @@ from sdkit import Context
|
|||||||
from sdkit.models import load_model, scan_model, unload_model, download_model, get_model_info_from_db
|
from sdkit.models import load_model, scan_model, unload_model, download_model, get_model_info_from_db
|
||||||
from sdkit.models.model_loader.controlnet_filters import filters as cn_filters
|
from sdkit.models.model_loader.controlnet_filters import filters as cn_filters
|
||||||
from sdkit.utils import hash_file_quick
|
from sdkit.utils import hash_file_quick
|
||||||
|
from sdkit.models.model_loader.embeddings import get_embedding_token
|
||||||
|
|
||||||
KNOWN_MODEL_TYPES = [
|
KNOWN_MODEL_TYPES = [
|
||||||
"stable-diffusion",
|
"stable-diffusion",
|
||||||
@ -29,14 +30,14 @@ MODEL_EXTENSIONS = {
|
|||||||
"hypernetwork": [".pt", ".safetensors"],
|
"hypernetwork": [".pt", ".safetensors"],
|
||||||
"gfpgan": [".pth"],
|
"gfpgan": [".pth"],
|
||||||
"realesrgan": [".pth"],
|
"realesrgan": [".pth"],
|
||||||
"lora": [".ckpt", ".safetensors"],
|
"lora": [".ckpt", ".safetensors", ".pt"],
|
||||||
"codeformer": [".pth"],
|
"codeformer": [".pth"],
|
||||||
"embeddings": [".pt", ".bin", ".safetensors"],
|
"embeddings": [".pt", ".bin", ".safetensors"],
|
||||||
"controlnet": [".pth", ".safetensors"],
|
"controlnet": [".pth", ".safetensors"],
|
||||||
}
|
}
|
||||||
DEFAULT_MODELS = {
|
DEFAULT_MODELS = {
|
||||||
"stable-diffusion": [
|
"stable-diffusion": [
|
||||||
{"file_name": "sd-v1-4.ckpt", "model_id": "1.4"},
|
{"file_name": "sd-v1-5.safetensors", "model_id": "1.5-pruned-emaonly-fp16"},
|
||||||
],
|
],
|
||||||
"gfpgan": [
|
"gfpgan": [
|
||||||
{"file_name": "GFPGANv1.4.pth", "model_id": "1.4"},
|
{"file_name": "GFPGANv1.4.pth", "model_id": "1.4"},
|
||||||
@ -65,9 +66,6 @@ def load_default_models(context: Context):
|
|||||||
|
|
||||||
runtime.set_vram_optimizations(context)
|
runtime.set_vram_optimizations(context)
|
||||||
|
|
||||||
config = app.getConfig()
|
|
||||||
context.embeddings_path = os.path.join(app.MODELS_DIR, "embeddings")
|
|
||||||
|
|
||||||
# init default model paths
|
# init default model paths
|
||||||
for model_type in MODELS_TO_LOAD_ON_START:
|
for model_type in MODELS_TO_LOAD_ON_START:
|
||||||
context.model_paths[model_type] = resolve_model_to_use(model_type=model_type, fail_if_not_found=False)
|
context.model_paths[model_type] = resolve_model_to_use(model_type=model_type, fail_if_not_found=False)
|
||||||
@ -102,7 +100,16 @@ def unload_all(context: Context):
|
|||||||
|
|
||||||
def resolve_model_to_use(model_name: Union[str, list] = None, model_type: str = None, fail_if_not_found: bool = True):
|
def resolve_model_to_use(model_name: Union[str, list] = None, model_type: str = None, fail_if_not_found: bool = True):
|
||||||
model_names = model_name if isinstance(model_name, list) else [model_name]
|
model_names = model_name if isinstance(model_name, list) else [model_name]
|
||||||
model_paths = [resolve_model_to_use_single(m, model_type, fail_if_not_found) for m in model_names]
|
model_paths = []
|
||||||
|
for m in model_names:
|
||||||
|
if model_type == "embeddings":
|
||||||
|
try:
|
||||||
|
resolve_model_to_use_single(m, model_type)
|
||||||
|
except FileNotFoundError: # try with spaces
|
||||||
|
m = m.replace("_", " ")
|
||||||
|
|
||||||
|
path = resolve_model_to_use_single(m, model_type, fail_if_not_found)
|
||||||
|
model_paths.append(path)
|
||||||
|
|
||||||
return model_paths[0] if len(model_paths) == 1 else model_paths
|
return model_paths[0] if len(model_paths) == 1 else model_paths
|
||||||
|
|
||||||
@ -141,7 +148,9 @@ def resolve_model_to_use_single(model_name: str = None, model_type: str = None,
|
|||||||
return default_model_path
|
return default_model_path
|
||||||
|
|
||||||
if model_name and fail_if_not_found:
|
if model_name and fail_if_not_found:
|
||||||
raise Exception(f"Could not find the desired model {model_name}! Is it present in the {model_dir} folder?")
|
raise FileNotFoundError(
|
||||||
|
f"Could not find the desired model {model_name}! Is it present in the {model_dir} folder?"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def reload_models_if_necessary(context: Context, models_data: ModelsData, models_to_force_reload: list = []):
|
def reload_models_if_necessary(context: Context, models_data: ModelsData, models_to_force_reload: list = []):
|
||||||
@ -184,9 +193,9 @@ def resolve_model_paths(models_data: ModelsData):
|
|||||||
skip_models = cn_filters + ["latent_upscaler", "nsfw_checker"]
|
skip_models = cn_filters + ["latent_upscaler", "nsfw_checker"]
|
||||||
if model_type in skip_models: # doesn't use model paths
|
if model_type in skip_models: # doesn't use model paths
|
||||||
continue
|
continue
|
||||||
if model_type == "codeformer":
|
if model_type == "codeformer" and model_paths[model_type]:
|
||||||
download_if_necessary("codeformer", "codeformer.pth", "codeformer-0.1.0")
|
download_if_necessary("codeformer", "codeformer.pth", "codeformer-0.1.0")
|
||||||
elif model_type == "controlnet":
|
elif model_type == "controlnet" and model_paths[model_type]:
|
||||||
model_id = model_paths[model_type]
|
model_id = model_paths[model_type]
|
||||||
model_info = get_model_info_from_db(model_type=model_type, model_id=model_id)
|
model_info = get_model_info_from_db(model_type=model_type, model_id=model_id)
|
||||||
if model_info:
|
if model_info:
|
||||||
@ -252,7 +261,24 @@ def make_model_folders():
|
|||||||
for model_type in KNOWN_MODEL_TYPES:
|
for model_type in KNOWN_MODEL_TYPES:
|
||||||
model_dir_path = os.path.join(app.MODELS_DIR, model_type)
|
model_dir_path = os.path.join(app.MODELS_DIR, model_type)
|
||||||
|
|
||||||
|
try:
|
||||||
os.makedirs(model_dir_path, exist_ok=True)
|
os.makedirs(model_dir_path, exist_ok=True)
|
||||||
|
except Exception as e:
|
||||||
|
from rich.console import Console
|
||||||
|
from rich.panel import Panel
|
||||||
|
|
||||||
|
Console().print(
|
||||||
|
Panel(
|
||||||
|
"\n"
|
||||||
|
+ f"Error while creating the models directory: '{model_dir_path}'\n"
|
||||||
|
+ f"Error: {e}\n\n"
|
||||||
|
+ f"[white]Check the 'models_dir:' line in the file '{os.path.join(app.ROOT_DIR, 'config.yaml')}'.[/white]\n",
|
||||||
|
title="Fatal Error starting Easy Diffusion",
|
||||||
|
style="bold yellow on red",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
input("Press Enter to terminate...")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
help_file_name = f"Place your {model_type} model files here.txt"
|
help_file_name = f"Place your {model_type} model files here.txt"
|
||||||
help_file_contents = f'Supported extensions: {" or ".join(MODEL_EXTENSIONS.get(model_type))}'
|
help_file_contents = f'Supported extensions: {" or ".join(MODEL_EXTENSIONS.get(model_type))}'
|
||||||
@ -296,7 +322,7 @@ def is_malicious_model(file_path):
|
|||||||
def getModels(scan_for_malicious: bool = True):
|
def getModels(scan_for_malicious: bool = True):
|
||||||
models = {
|
models = {
|
||||||
"options": {
|
"options": {
|
||||||
"stable-diffusion": [{"sd-v1-4": "SD 1.4"}],
|
"stable-diffusion": [],
|
||||||
"vae": [],
|
"vae": [],
|
||||||
"hypernetwork": [],
|
"hypernetwork": [],
|
||||||
"lora": [],
|
"lora": [],
|
||||||
@ -315,6 +341,7 @@ def getModels(scan_for_malicious: bool = True):
|
|||||||
{"control_v11p_sd15_mlsd": "Straight Lines"},
|
{"control_v11p_sd15_mlsd": "Straight Lines"},
|
||||||
{"control_v11p_sd15_seg": "Segment"},
|
{"control_v11p_sd15_seg": "Segment"},
|
||||||
{"control_v11e_sd15_shuffle": "Shuffle"},
|
{"control_v11e_sd15_shuffle": "Shuffle"},
|
||||||
|
{"control_v11f1e_sd15_tile": "Tile"},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -324,9 +351,11 @@ def getModels(scan_for_malicious: bool = True):
|
|||||||
class MaliciousModelException(Exception):
|
class MaliciousModelException(Exception):
|
||||||
"Raised when picklescan reports a problem with a model"
|
"Raised when picklescan reports a problem with a model"
|
||||||
|
|
||||||
def scan_directory(directory, suffixes, directoriesFirst: bool = True, default_entries=[]):
|
def scan_directory(directory, suffixes, directoriesFirst: bool = True, default_entries=[], nameFilter=None):
|
||||||
tree = list(default_entries)
|
|
||||||
nonlocal models_scanned
|
nonlocal models_scanned
|
||||||
|
|
||||||
|
tree = list(default_entries)
|
||||||
|
|
||||||
for entry in sorted(
|
for entry in sorted(
|
||||||
os.scandir(directory),
|
os.scandir(directory),
|
||||||
key=lambda entry: (entry.is_file() == directoriesFirst, entry.name.lower()),
|
key=lambda entry: (entry.is_file() == directoriesFirst, entry.name.lower()),
|
||||||
@ -345,7 +374,11 @@ def getModels(scan_for_malicious: bool = True):
|
|||||||
raise MaliciousModelException(entry.path)
|
raise MaliciousModelException(entry.path)
|
||||||
if scan_for_malicious:
|
if scan_for_malicious:
|
||||||
known_models[entry.path] = mtime
|
known_models[entry.path] = mtime
|
||||||
|
|
||||||
model_id = entry.name[: -len(matching_suffix)]
|
model_id = entry.name[: -len(matching_suffix)]
|
||||||
|
if callable(nameFilter):
|
||||||
|
model_id = nameFilter(model_id)
|
||||||
|
|
||||||
model_exists = False
|
model_exists = False
|
||||||
for m in tree: # allows default "named" models, like CodeFormer and known ControlNet models
|
for m in tree: # allows default "named" models, like CodeFormer and known ControlNet models
|
||||||
if (isinstance(m, str) and model_id == m) or (isinstance(m, dict) and model_id in m):
|
if (isinstance(m, str) and model_id == m) or (isinstance(m, dict) and model_id in m):
|
||||||
@ -353,14 +386,15 @@ def getModels(scan_for_malicious: bool = True):
|
|||||||
break
|
break
|
||||||
if not model_exists:
|
if not model_exists:
|
||||||
tree.append(model_id)
|
tree.append(model_id)
|
||||||
|
|
||||||
elif entry.is_dir():
|
elif entry.is_dir():
|
||||||
scan = scan_directory(entry.path, suffixes, directoriesFirst=False)
|
scan = scan_directory(entry.path, suffixes, directoriesFirst=False, nameFilter=nameFilter)
|
||||||
|
|
||||||
if len(scan) != 0:
|
if len(scan) != 0:
|
||||||
tree.append((entry.name, scan))
|
tree.append((entry.name, scan))
|
||||||
return tree
|
return tree
|
||||||
|
|
||||||
def listModels(model_type):
|
def listModels(model_type, nameFilter=None):
|
||||||
nonlocal models_scanned
|
nonlocal models_scanned
|
||||||
|
|
||||||
model_extensions = MODEL_EXTENSIONS.get(model_type, [])
|
model_extensions = MODEL_EXTENSIONS.get(model_type, [])
|
||||||
@ -370,7 +404,9 @@ def getModels(scan_for_malicious: bool = True):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
default_tree = models["options"].get(model_type, [])
|
default_tree = models["options"].get(model_type, [])
|
||||||
models["options"][model_type] = scan_directory(models_dir, model_extensions, default_entries=default_tree)
|
models["options"][model_type] = scan_directory(
|
||||||
|
models_dir, model_extensions, default_entries=default_tree, nameFilter=nameFilter
|
||||||
|
)
|
||||||
except MaliciousModelException as e:
|
except MaliciousModelException as e:
|
||||||
models["scan-error"] = str(e)
|
models["scan-error"] = str(e)
|
||||||
|
|
||||||
@ -382,7 +418,7 @@ def getModels(scan_for_malicious: bool = True):
|
|||||||
listModels(model_type="hypernetwork")
|
listModels(model_type="hypernetwork")
|
||||||
listModels(model_type="gfpgan")
|
listModels(model_type="gfpgan")
|
||||||
listModels(model_type="lora")
|
listModels(model_type="lora")
|
||||||
listModels(model_type="embeddings")
|
listModels(model_type="embeddings", nameFilter=get_embedding_token)
|
||||||
listModels(model_type="controlnet")
|
listModels(model_type="controlnet")
|
||||||
|
|
||||||
if scan_for_malicious and models_scanned > 0:
|
if scan_for_malicious and models_scanned > 0:
|
||||||
|
@ -12,9 +12,9 @@ from easydiffusion import app
|
|||||||
manifest = {
|
manifest = {
|
||||||
"tensorrt": {
|
"tensorrt": {
|
||||||
"install": [
|
"install": [
|
||||||
"nvidia-cudnn --extra-index-url=https://pypi.ngc.nvidia.com --trusted-host pypi.ngc.nvidia.com",
|
"wheel",
|
||||||
"tensorrt-libs --extra-index-url=https://pypi.ngc.nvidia.com --trusted-host pypi.ngc.nvidia.com",
|
"nvidia-cudnn-cu11==8.9.4.25",
|
||||||
"tensorrt --extra-index-url=https://pypi.ngc.nvidia.com --trusted-host pypi.ngc.nvidia.com",
|
"tensorrt==9.0.0.post11.dev1 --pre --extra-index-url=https://pypi.nvidia.com --trusted-host pypi.nvidia.com",
|
||||||
],
|
],
|
||||||
"uninstall": ["tensorrt"],
|
"uninstall": ["tensorrt"],
|
||||||
# TODO also uninstall tensorrt-libs and nvidia-cudnn, but do it upon restarting (avoid 'file in use' error)
|
# TODO also uninstall tensorrt-libs and nvidia-cudnn, but do it upon restarting (avoid 'file in use' error)
|
||||||
@ -25,7 +25,7 @@ installing = []
|
|||||||
# remove this once TRT releases on pypi
|
# remove this once TRT releases on pypi
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
trt_dir = os.path.join(app.ROOT_DIR, "tensorrt")
|
trt_dir = os.path.join(app.ROOT_DIR, "tensorrt")
|
||||||
if os.path.exists(trt_dir):
|
if os.path.exists(trt_dir) and os.path.isdir(trt_dir) and len(os.listdir(trt_dir)) > 0:
|
||||||
files = os.listdir(trt_dir)
|
files = os.listdir(trt_dir)
|
||||||
|
|
||||||
packages = manifest["tensorrt"]["install"]
|
packages = manifest["tensorrt"]["install"]
|
||||||
@ -61,6 +61,10 @@ def install(module_name):
|
|||||||
raise RuntimeError(f"Can't install unknown package: {module_name}!")
|
raise RuntimeError(f"Can't install unknown package: {module_name}!")
|
||||||
|
|
||||||
commands = manifest[module_name]["install"]
|
commands = manifest[module_name]["install"]
|
||||||
|
if module_name == "tensorrt":
|
||||||
|
commands += [
|
||||||
|
"protobuf==3.20.3 polygraphy==0.47.1 onnx==1.14.0 --extra-index-url=https://pypi.ngc.nvidia.com --trusted-host pypi.ngc.nvidia.com"
|
||||||
|
]
|
||||||
commands = [f"python -m pip install --upgrade {cmd}" for cmd in commands]
|
commands = [f"python -m pip install --upgrade {cmd}" for cmd in commands]
|
||||||
|
|
||||||
installing.append(module_name)
|
installing.append(module_name)
|
||||||
|
@ -30,9 +30,7 @@ def init(device):
|
|||||||
from easydiffusion import app
|
from easydiffusion import app
|
||||||
|
|
||||||
app_config = app.getConfig()
|
app_config = app.getConfig()
|
||||||
context.test_diffusers = (
|
context.test_diffusers = app_config.get("use_v3_engine", True)
|
||||||
app_config.get("test_diffusers", False) and app_config.get("update_branch", "main") != "main"
|
|
||||||
)
|
|
||||||
|
|
||||||
log.info("Device usage during initialization:")
|
log.info("Device usage during initialization:")
|
||||||
get_device_usage(device, log_info=True, process_usage_only=False)
|
get_device_usage(device, log_info=True, process_usage_only=False)
|
||||||
|
@ -15,8 +15,10 @@ from easydiffusion.types import (
|
|||||||
FilterImageRequest,
|
FilterImageRequest,
|
||||||
MergeRequest,
|
MergeRequest,
|
||||||
TaskData,
|
TaskData,
|
||||||
|
RenderTaskData,
|
||||||
ModelsData,
|
ModelsData,
|
||||||
OutputFormatData,
|
OutputFormatData,
|
||||||
|
SaveToDiskData,
|
||||||
convert_legacy_render_req_to_new,
|
convert_legacy_render_req_to_new,
|
||||||
)
|
)
|
||||||
from easydiffusion.utils import log
|
from easydiffusion.utils import log
|
||||||
@ -36,6 +38,7 @@ NOCACHE_HEADERS = {
|
|||||||
"Pragma": "no-cache",
|
"Pragma": "no-cache",
|
||||||
"Expires": "0",
|
"Expires": "0",
|
||||||
}
|
}
|
||||||
|
PROTECTED_CONFIG_KEYS = ("block_nsfw",) # can't change these via the HTTP API
|
||||||
|
|
||||||
|
|
||||||
class NoCacheStaticFiles(StaticFiles):
|
class NoCacheStaticFiles(StaticFiles):
|
||||||
@ -63,7 +66,8 @@ class SetAppConfigRequest(BaseModel, extra=Extra.allow):
|
|||||||
ui_open_browser_on_start: bool = None
|
ui_open_browser_on_start: bool = None
|
||||||
listen_to_network: bool = None
|
listen_to_network: bool = None
|
||||||
listen_port: int = None
|
listen_port: int = None
|
||||||
test_diffusers: bool = False
|
use_v3_engine: bool = True
|
||||||
|
models_dir: str = None
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
@ -139,6 +143,10 @@ def init():
|
|||||||
def modify_package(package_name: str, req: dict):
|
def modify_package(package_name: str, req: dict):
|
||||||
return modify_package_internal(package_name, req)
|
return modify_package_internal(package_name, req)
|
||||||
|
|
||||||
|
@server_api.get("/sha256/{obj_path:path}")
|
||||||
|
def get_sha256(obj_path: str):
|
||||||
|
return get_sha256_internal(obj_path)
|
||||||
|
|
||||||
@server_api.get("/")
|
@server_api.get("/")
|
||||||
def read_root():
|
def read_root():
|
||||||
return FileResponse(os.path.join(app.SD_UI_DIR, "index.html"), headers=NOCACHE_HEADERS)
|
return FileResponse(os.path.join(app.SD_UI_DIR, "index.html"), headers=NOCACHE_HEADERS)
|
||||||
@ -168,10 +176,11 @@ def set_app_config_internal(req: SetAppConfigRequest):
|
|||||||
config["net"] = {}
|
config["net"] = {}
|
||||||
config["net"]["listen_port"] = int(req.listen_port)
|
config["net"]["listen_port"] = int(req.listen_port)
|
||||||
|
|
||||||
config["test_diffusers"] = req.test_diffusers
|
config["use_v3_engine"] = req.use_v3_engine
|
||||||
|
config["models_dir"] = req.models_dir
|
||||||
|
|
||||||
for property, property_value in req.dict().items():
|
for property, property_value in req.dict().items():
|
||||||
if property_value is not None and property not in req.__fields__:
|
if property_value is not None and property not in req.__fields__ and property not in PROTECTED_CONFIG_KEYS:
|
||||||
config[property] = property_value
|
config[property] = property_value
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -200,7 +209,12 @@ def read_web_data_internal(key: str = None, **kwargs):
|
|||||||
if not key: # /get without parameters, stable-diffusion easter egg.
|
if not key: # /get without parameters, stable-diffusion easter egg.
|
||||||
raise HTTPException(status_code=418, detail="StableDiffusion is drawing a teapot!") # HTTP418 I'm a teapot
|
raise HTTPException(status_code=418, detail="StableDiffusion is drawing a teapot!") # HTTP418 I'm a teapot
|
||||||
elif key == "app_config":
|
elif key == "app_config":
|
||||||
return JSONResponse(app.getConfig(), headers=NOCACHE_HEADERS)
|
config = app.getConfig()
|
||||||
|
|
||||||
|
if "models_dir" not in config:
|
||||||
|
config["models_dir"] = app.MODELS_DIR
|
||||||
|
|
||||||
|
return JSONResponse(config, headers=NOCACHE_HEADERS)
|
||||||
elif key == "system_info":
|
elif key == "system_info":
|
||||||
config = app.getConfig()
|
config = app.getConfig()
|
||||||
|
|
||||||
@ -211,6 +225,7 @@ def read_web_data_internal(key: str = None, **kwargs):
|
|||||||
"hosts": app.getIPConfig(),
|
"hosts": app.getIPConfig(),
|
||||||
"default_output_dir": output_dir,
|
"default_output_dir": output_dir,
|
||||||
"enforce_output_dir": ("force_save_path" in config),
|
"enforce_output_dir": ("force_save_path" in config),
|
||||||
|
"enforce_output_metadata": ("force_save_metadata" in config),
|
||||||
}
|
}
|
||||||
system_info["devices"]["config"] = config.get("render_devices", "auto")
|
system_info["devices"]["config"] = config.get("render_devices", "auto")
|
||||||
return JSONResponse(system_info, headers=NOCACHE_HEADERS)
|
return JSONResponse(system_info, headers=NOCACHE_HEADERS)
|
||||||
@ -257,14 +272,15 @@ def render_internal(req: dict):
|
|||||||
|
|
||||||
# separate out the request data into rendering and task-specific data
|
# separate out the request data into rendering and task-specific data
|
||||||
render_req: GenerateImageRequest = GenerateImageRequest.parse_obj(req)
|
render_req: GenerateImageRequest = GenerateImageRequest.parse_obj(req)
|
||||||
task_data: TaskData = TaskData.parse_obj(req)
|
task_data: RenderTaskData = RenderTaskData.parse_obj(req)
|
||||||
models_data: ModelsData = ModelsData.parse_obj(req)
|
models_data: ModelsData = ModelsData.parse_obj(req)
|
||||||
output_format: OutputFormatData = OutputFormatData.parse_obj(req)
|
output_format: OutputFormatData = OutputFormatData.parse_obj(req)
|
||||||
|
save_data: SaveToDiskData = SaveToDiskData.parse_obj(req)
|
||||||
|
|
||||||
# Overwrite user specified save path
|
# Overwrite user specified save path
|
||||||
config = app.getConfig()
|
config = app.getConfig()
|
||||||
if "force_save_path" in config:
|
if "force_save_path" in config:
|
||||||
task_data.save_to_disk_path = config["force_save_path"]
|
save_data.save_to_disk_path = config["force_save_path"]
|
||||||
|
|
||||||
render_req.init_image_mask = req.get("mask") # hack: will rename this in the HTTP API in a future revision
|
render_req.init_image_mask = req.get("mask") # hack: will rename this in the HTTP API in a future revision
|
||||||
|
|
||||||
@ -276,7 +292,7 @@ def render_internal(req: dict):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# enqueue the task
|
# enqueue the task
|
||||||
task = RenderTask(render_req, task_data, models_data, output_format)
|
task = RenderTask(render_req, task_data, models_data, output_format, save_data)
|
||||||
return enqueue_task(task)
|
return enqueue_task(task)
|
||||||
except HTTPException as e:
|
except HTTPException as e:
|
||||||
raise e
|
raise e
|
||||||
@ -287,13 +303,14 @@ def render_internal(req: dict):
|
|||||||
|
|
||||||
def filter_internal(req: dict):
|
def filter_internal(req: dict):
|
||||||
try:
|
try:
|
||||||
session_id = req.get("session_id", "session")
|
|
||||||
filter_req: FilterImageRequest = FilterImageRequest.parse_obj(req)
|
filter_req: FilterImageRequest = FilterImageRequest.parse_obj(req)
|
||||||
|
task_data: TaskData = TaskData.parse_obj(req)
|
||||||
models_data: ModelsData = ModelsData.parse_obj(req)
|
models_data: ModelsData = ModelsData.parse_obj(req)
|
||||||
output_format: OutputFormatData = OutputFormatData.parse_obj(req)
|
output_format: OutputFormatData = OutputFormatData.parse_obj(req)
|
||||||
|
save_data: SaveToDiskData = SaveToDiskData.parse_obj(req)
|
||||||
|
|
||||||
# enqueue the task
|
# enqueue the task
|
||||||
task = FilterTask(filter_req, session_id, models_data, output_format)
|
task = FilterTask(filter_req, task_data, models_data, output_format, save_data)
|
||||||
return enqueue_task(task)
|
return enqueue_task(task)
|
||||||
except HTTPException as e:
|
except HTTPException as e:
|
||||||
raise e
|
raise e
|
||||||
@ -451,3 +468,25 @@ def modify_package_internal(package_name: str, req: dict):
|
|||||||
log.error(str(e))
|
log.error(str(e))
|
||||||
log.error(traceback.format_exc())
|
log.error(traceback.format_exc())
|
||||||
return HTTPException(status_code=500, detail=str(e))
|
return HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
|
def get_sha256_internal(obj_path):
|
||||||
|
from easydiffusion.utils import sha256sum
|
||||||
|
|
||||||
|
path = obj_path.split("/")
|
||||||
|
type = path.pop(0)
|
||||||
|
|
||||||
|
try:
|
||||||
|
model_path = model_manager.resolve_model_to_use("/".join(path), type)
|
||||||
|
except Exception as e:
|
||||||
|
log.error(str(e))
|
||||||
|
log.error(traceback.format_exc())
|
||||||
|
|
||||||
|
return HTTPException(status_code=404)
|
||||||
|
try:
|
||||||
|
digest = sha256sum(model_path)
|
||||||
|
return {"digest": digest}
|
||||||
|
except Exception as e:
|
||||||
|
log.error(str(e))
|
||||||
|
log.error(traceback.format_exc())
|
||||||
|
return HTTPException(status_code=500, detail=str(e))
|
||||||
|
@ -1,12 +1,25 @@
|
|||||||
|
import os
|
||||||
import json
|
import json
|
||||||
import pprint
|
import pprint
|
||||||
|
import time
|
||||||
|
|
||||||
|
from numpy import base_repr
|
||||||
|
|
||||||
from sdkit.filter import apply_filters
|
from sdkit.filter import apply_filters
|
||||||
from sdkit.models import load_model
|
from sdkit.models import load_model
|
||||||
from sdkit.utils import img_to_base64_str, log
|
from sdkit.utils import img_to_base64_str, get_image, log, save_images
|
||||||
|
|
||||||
from easydiffusion import model_manager, runtime
|
from easydiffusion import model_manager, runtime
|
||||||
from easydiffusion.types import FilterImageRequest, FilterImageResponse, ModelsData, OutputFormatData
|
from easydiffusion.types import (
|
||||||
|
FilterImageRequest,
|
||||||
|
FilterImageResponse,
|
||||||
|
ModelsData,
|
||||||
|
OutputFormatData,
|
||||||
|
SaveToDiskData,
|
||||||
|
TaskData,
|
||||||
|
GenerateImageRequest,
|
||||||
|
)
|
||||||
|
from easydiffusion.utils.save_utils import format_folder_name
|
||||||
|
|
||||||
from .task import Task
|
from .task import Task
|
||||||
|
|
||||||
@ -15,13 +28,22 @@ class FilterTask(Task):
|
|||||||
"For applying filters to input images"
|
"For applying filters to input images"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, req: FilterImageRequest, session_id: str, models_data: ModelsData, output_format: OutputFormatData
|
self,
|
||||||
|
req: FilterImageRequest,
|
||||||
|
task_data: TaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
):
|
):
|
||||||
super().__init__(session_id)
|
super().__init__(task_data.session_id)
|
||||||
|
|
||||||
|
task_data.request_id = self.id
|
||||||
|
|
||||||
self.request = req
|
self.request = req
|
||||||
|
self.task_data = task_data
|
||||||
self.models_data = models_data
|
self.models_data = models_data
|
||||||
self.output_format = output_format
|
self.output_format = output_format
|
||||||
|
self.save_data = save_data
|
||||||
|
|
||||||
# convert to multi-filter format, if necessary
|
# convert to multi-filter format, if necessary
|
||||||
if isinstance(req.filter, str):
|
if isinstance(req.filter, str):
|
||||||
@ -34,17 +56,44 @@ class FilterTask(Task):
|
|||||||
def run(self):
|
def run(self):
|
||||||
"Runs the image filtering task on the assigned thread"
|
"Runs the image filtering task on the assigned thread"
|
||||||
|
|
||||||
|
from easydiffusion import app
|
||||||
|
|
||||||
context = runtime.context
|
context = runtime.context
|
||||||
|
|
||||||
model_manager.resolve_model_paths(self.models_data)
|
model_manager.resolve_model_paths(self.models_data)
|
||||||
model_manager.reload_models_if_necessary(context, self.models_data)
|
model_manager.reload_models_if_necessary(context, self.models_data)
|
||||||
model_manager.fail_if_models_did_not_load(context)
|
model_manager.fail_if_models_did_not_load(context)
|
||||||
|
|
||||||
print_task_info(self.request, self.models_data, self.output_format)
|
print_task_info(self.request, self.models_data, self.output_format, self.save_data)
|
||||||
|
|
||||||
images = filter_images(context, self.request.image, self.request.filter, self.request.filter_params)
|
if isinstance(self.request.image, list):
|
||||||
|
images = [get_image(img) for img in self.request.image]
|
||||||
|
else:
|
||||||
|
images = get_image(self.request.image)
|
||||||
|
|
||||||
|
images = filter_images(context, images, self.request.filter, self.request.filter_params)
|
||||||
|
|
||||||
output_format = self.output_format
|
output_format = self.output_format
|
||||||
|
|
||||||
|
if self.save_data.save_to_disk_path is not None:
|
||||||
|
app_config = app.getConfig()
|
||||||
|
folder_format = app_config.get("folder_format", "$id")
|
||||||
|
|
||||||
|
dummy_req = GenerateImageRequest()
|
||||||
|
img_id = base_repr(int(time.time() * 10000), 36)[-7:] # Base 36 conversion, 0-9, A-Z
|
||||||
|
|
||||||
|
save_dir_path = os.path.join(
|
||||||
|
self.save_data.save_to_disk_path, format_folder_name(folder_format, dummy_req, self.task_data)
|
||||||
|
)
|
||||||
|
save_images(
|
||||||
|
images,
|
||||||
|
save_dir_path,
|
||||||
|
file_name=img_id,
|
||||||
|
output_format=output_format.output_format,
|
||||||
|
output_quality=output_format.output_quality,
|
||||||
|
output_lossless=output_format.output_lossless,
|
||||||
|
)
|
||||||
|
|
||||||
images = [
|
images = [
|
||||||
img_to_base64_str(
|
img_to_base64_str(
|
||||||
img, output_format.output_format, output_format.output_quality, output_format.output_lossless
|
img, output_format.output_format, output_format.output_quality, output_format.output_lossless
|
||||||
@ -55,6 +104,7 @@ class FilterTask(Task):
|
|||||||
res = FilterImageResponse(self.request, self.models_data, images=images)
|
res = FilterImageResponse(self.request, self.models_data, images=images)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
self.buffer_queue.put(json.dumps(res))
|
self.buffer_queue.put(json.dumps(res))
|
||||||
|
|
||||||
log.info("Filter task completed")
|
log.info("Filter task completed")
|
||||||
|
|
||||||
self.response = res
|
self.response = res
|
||||||
@ -100,11 +150,15 @@ def after_filter(context, filter_name, filter_params, previous_state):
|
|||||||
load_model(context, "realesrgan")
|
load_model(context, "realesrgan")
|
||||||
|
|
||||||
|
|
||||||
def print_task_info(req: FilterImageRequest, models_data: ModelsData, output_format: OutputFormatData):
|
def print_task_info(
|
||||||
|
req: FilterImageRequest, models_data: ModelsData, output_format: OutputFormatData, save_data: SaveToDiskData
|
||||||
|
):
|
||||||
req_str = pprint.pformat({"filter": req.filter, "filter_params": req.filter_params}).replace("[", "\[")
|
req_str = pprint.pformat({"filter": req.filter, "filter_params": req.filter_params}).replace("[", "\[")
|
||||||
models_data = pprint.pformat(models_data.dict()).replace("[", "\[")
|
models_data = pprint.pformat(models_data.dict()).replace("[", "\[")
|
||||||
output_format = pprint.pformat(output_format.dict()).replace("[", "\[")
|
output_format = pprint.pformat(output_format.dict()).replace("[", "\[")
|
||||||
|
save_data = pprint.pformat(save_data.dict()).replace("[", "\[")
|
||||||
|
|
||||||
log.info(f"request: {req_str}")
|
log.info(f"request: {req_str}")
|
||||||
log.info(f"models data: {models_data}")
|
log.info(f"models data: {models_data}")
|
||||||
log.info(f"output format: {output_format}")
|
log.info(f"output format: {output_format}")
|
||||||
|
log.info(f"save data: {save_data}")
|
||||||
|
@ -4,9 +4,9 @@ import queue
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from easydiffusion import model_manager, runtime
|
from easydiffusion import model_manager, runtime
|
||||||
from easydiffusion.types import GenerateImageRequest, ModelsData, OutputFormatData
|
from easydiffusion.types import GenerateImageRequest, ModelsData, OutputFormatData, SaveToDiskData
|
||||||
from easydiffusion.types import Image as ResponseImage
|
from easydiffusion.types import Image as ResponseImage
|
||||||
from easydiffusion.types import GenerateImageResponse, TaskData, UserInitiatedStop
|
from easydiffusion.types import GenerateImageResponse, RenderTaskData, UserInitiatedStop
|
||||||
from easydiffusion.utils import get_printable_request, log, save_images_to_disk
|
from easydiffusion.utils import get_printable_request, log, save_images_to_disk
|
||||||
from sdkit.generate import generate_images
|
from sdkit.generate import generate_images
|
||||||
from sdkit.utils import (
|
from sdkit.utils import (
|
||||||
@ -15,6 +15,8 @@ from sdkit.utils import (
|
|||||||
img_to_base64_str,
|
img_to_base64_str,
|
||||||
img_to_buffer,
|
img_to_buffer,
|
||||||
latent_samples_to_images,
|
latent_samples_to_images,
|
||||||
|
resize_img,
|
||||||
|
get_image,
|
||||||
log,
|
log,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -26,23 +28,38 @@ class RenderTask(Task):
|
|||||||
"For image generation"
|
"For image generation"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, req: GenerateImageRequest, task_data: TaskData, models_data: ModelsData, output_format: OutputFormatData
|
self,
|
||||||
|
req: GenerateImageRequest,
|
||||||
|
task_data: RenderTaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
):
|
):
|
||||||
super().__init__(task_data.session_id)
|
super().__init__(task_data.session_id)
|
||||||
|
|
||||||
task_data.request_id = self.id
|
task_data.request_id = self.id
|
||||||
self.render_request: GenerateImageRequest = req # Initial Request
|
|
||||||
self.task_data: TaskData = task_data
|
self.render_request = req # Initial Request
|
||||||
|
self.task_data = task_data
|
||||||
self.models_data = models_data
|
self.models_data = models_data
|
||||||
self.output_format = output_format
|
self.output_format = output_format
|
||||||
|
self.save_data = save_data
|
||||||
|
|
||||||
self.temp_images: list = [None] * req.num_outputs * (1 if task_data.show_only_filtered_image else 2)
|
self.temp_images: list = [None] * req.num_outputs * (1 if task_data.show_only_filtered_image else 2)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"Runs the image generation task on the assigned thread"
|
"Runs the image generation task on the assigned thread"
|
||||||
|
|
||||||
from easydiffusion import task_manager
|
from easydiffusion import task_manager, app
|
||||||
|
|
||||||
context = runtime.context
|
context = runtime.context
|
||||||
|
config = app.getConfig()
|
||||||
|
|
||||||
|
if config.get("block_nsfw", False): # override if set on the server
|
||||||
|
self.task_data.block_nsfw = True
|
||||||
|
if "nsfw_checker" not in self.task_data.filters:
|
||||||
|
self.task_data.filters.append("nsfw_checker")
|
||||||
|
self.models_data.model_paths["nsfw_checker"] = "nsfw_checker"
|
||||||
|
|
||||||
def step_callback():
|
def step_callback():
|
||||||
task_manager.keep_task_alive(self)
|
task_manager.keep_task_alive(self)
|
||||||
@ -78,6 +95,7 @@ class RenderTask(Task):
|
|||||||
self.task_data,
|
self.task_data,
|
||||||
self.models_data,
|
self.models_data,
|
||||||
self.output_format,
|
self.output_format,
|
||||||
|
self.save_data,
|
||||||
self.buffer_queue,
|
self.buffer_queue,
|
||||||
self.temp_images,
|
self.temp_images,
|
||||||
step_callback,
|
step_callback,
|
||||||
@ -120,22 +138,23 @@ class RenderTask(Task):
|
|||||||
def make_images(
|
def make_images(
|
||||||
context,
|
context,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
models_data: ModelsData,
|
models_data: ModelsData,
|
||||||
output_format: OutputFormatData,
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
data_queue: queue.Queue,
|
data_queue: queue.Queue,
|
||||||
task_temp_images: list,
|
task_temp_images: list,
|
||||||
step_callback,
|
step_callback,
|
||||||
):
|
):
|
||||||
context.stop_processing = False
|
context.stop_processing = False
|
||||||
print_task_info(req, task_data, models_data, output_format)
|
print_task_info(req, task_data, models_data, output_format, save_data)
|
||||||
|
|
||||||
images, seeds = make_images_internal(
|
images, seeds = make_images_internal(
|
||||||
context, req, task_data, models_data, output_format, data_queue, task_temp_images, step_callback
|
context, req, task_data, models_data, output_format, save_data, data_queue, task_temp_images, step_callback
|
||||||
)
|
)
|
||||||
|
|
||||||
res = GenerateImageResponse(
|
res = GenerateImageResponse(
|
||||||
req, task_data, models_data, output_format, images=construct_response(images, seeds, output_format)
|
req, task_data, models_data, output_format, save_data, images=construct_response(images, seeds, output_format)
|
||||||
)
|
)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
data_queue.put(json.dumps(res))
|
data_queue.put(json.dumps(res))
|
||||||
@ -145,25 +164,32 @@ def make_images(
|
|||||||
|
|
||||||
|
|
||||||
def print_task_info(
|
def print_task_info(
|
||||||
req: GenerateImageRequest, task_data: TaskData, models_data: ModelsData, output_format: OutputFormatData
|
req: GenerateImageRequest,
|
||||||
|
task_data: RenderTaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
):
|
):
|
||||||
req_str = pprint.pformat(get_printable_request(req, task_data, output_format)).replace("[", "\[")
|
req_str = pprint.pformat(get_printable_request(req, task_data, models_data, output_format, save_data)).replace("[", "\[")
|
||||||
task_str = pprint.pformat(task_data.dict()).replace("[", "\[")
|
task_str = pprint.pformat(task_data.dict()).replace("[", "\[")
|
||||||
models_data = pprint.pformat(models_data.dict()).replace("[", "\[")
|
models_data = pprint.pformat(models_data.dict()).replace("[", "\[")
|
||||||
output_format = pprint.pformat(output_format.dict()).replace("[", "\[")
|
output_format = pprint.pformat(output_format.dict()).replace("[", "\[")
|
||||||
|
save_data = pprint.pformat(save_data.dict()).replace("[", "\[")
|
||||||
|
|
||||||
log.info(f"request: {req_str}")
|
log.info(f"request: {req_str}")
|
||||||
log.info(f"task data: {task_str}")
|
log.info(f"task data: {task_str}")
|
||||||
# log.info(f"models data: {models_data}")
|
# log.info(f"models data: {models_data}")
|
||||||
log.info(f"output format: {output_format}")
|
log.info(f"output format: {output_format}")
|
||||||
|
log.info(f"save data: {save_data}")
|
||||||
|
|
||||||
|
|
||||||
def make_images_internal(
|
def make_images_internal(
|
||||||
context,
|
context,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
models_data: ModelsData,
|
models_data: ModelsData,
|
||||||
output_format: OutputFormatData,
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
data_queue: queue.Queue,
|
data_queue: queue.Queue,
|
||||||
task_temp_images: list,
|
task_temp_images: list,
|
||||||
step_callback,
|
step_callback,
|
||||||
@ -185,8 +211,8 @@ def make_images_internal(
|
|||||||
filters, filter_params = task_data.filters, task_data.filter_params
|
filters, filter_params = task_data.filters, task_data.filter_params
|
||||||
filtered_images = filter_images(context, images, filters, filter_params) if not user_stopped else images
|
filtered_images = filter_images(context, images, filters, filter_params) if not user_stopped else images
|
||||||
|
|
||||||
if task_data.save_to_disk_path is not None:
|
if save_data.save_to_disk_path is not None:
|
||||||
save_images_to_disk(images, filtered_images, req, task_data, output_format)
|
save_images_to_disk(images, filtered_images, req, task_data, models_data, output_format, save_data)
|
||||||
|
|
||||||
seeds = [*range(req.seed, req.seed + len(images))]
|
seeds = [*range(req.seed, req.seed + len(images))]
|
||||||
if task_data.show_only_filtered_image or filtered_images is images:
|
if task_data.show_only_filtered_image or filtered_images is images:
|
||||||
@ -198,7 +224,7 @@ def make_images_internal(
|
|||||||
def generate_images_internal(
|
def generate_images_internal(
|
||||||
context,
|
context,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
models_data: ModelsData,
|
models_data: ModelsData,
|
||||||
data_queue: queue.Queue,
|
data_queue: queue.Queue,
|
||||||
task_temp_images: list,
|
task_temp_images: list,
|
||||||
@ -226,8 +252,13 @@ def generate_images_internal(
|
|||||||
req.width, req.height = map(lambda x: x - x % 8, (req.width, req.height)) # clamp to 8
|
req.width, req.height = map(lambda x: x - x % 8, (req.width, req.height)) # clamp to 8
|
||||||
|
|
||||||
if req.control_image and task_data.control_filter_to_apply:
|
if req.control_image and task_data.control_filter_to_apply:
|
||||||
|
req.control_image = get_image(req.control_image)
|
||||||
|
req.control_image = resize_img(req.control_image.convert("RGB"), req.width, req.height, clamp_to_8=True)
|
||||||
req.control_image = filter_images(context, req.control_image, task_data.control_filter_to_apply)[0]
|
req.control_image = filter_images(context, req.control_image, task_data.control_filter_to_apply)[0]
|
||||||
|
|
||||||
|
if req.init_image is not None and int(req.num_inference_steps * req.prompt_strength) == 0:
|
||||||
|
req.prompt_strength = 1 / req.num_inference_steps if req.num_inference_steps > 0 else 1
|
||||||
|
|
||||||
if context.test_diffusers:
|
if context.test_diffusers:
|
||||||
pipe = context.models["stable-diffusion"]["default"]
|
pipe = context.models["stable-diffusion"]["default"]
|
||||||
if hasattr(pipe.unet, "_allocate_trt_buffers_backup"):
|
if hasattr(pipe.unet, "_allocate_trt_buffers_backup"):
|
||||||
@ -247,6 +278,13 @@ def generate_images_internal(
|
|||||||
setattr(pipe.unet, "_allocate_trt_buffers_backup", pipe.unet._allocate_trt_buffers)
|
setattr(pipe.unet, "_allocate_trt_buffers_backup", pipe.unet._allocate_trt_buffers)
|
||||||
delattr(pipe.unet, "_allocate_trt_buffers")
|
delattr(pipe.unet, "_allocate_trt_buffers")
|
||||||
|
|
||||||
|
if task_data.enable_vae_tiling:
|
||||||
|
if hasattr(pipe, "enable_vae_tiling"):
|
||||||
|
pipe.enable_vae_tiling()
|
||||||
|
else:
|
||||||
|
if hasattr(pipe, "disable_vae_tiling"):
|
||||||
|
pipe.disable_vae_tiling()
|
||||||
|
|
||||||
images = generate_images(context, callback=callback, **req.dict())
|
images = generate_images(context, callback=callback, **req.dict())
|
||||||
user_stopped = False
|
user_stopped = False
|
||||||
except UserInitiatedStop:
|
except UserInitiatedStop:
|
||||||
@ -284,7 +322,7 @@ def construct_response(images: list, seeds: list, output_format: OutputFormatDat
|
|||||||
def make_step_callback(
|
def make_step_callback(
|
||||||
context,
|
context,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
data_queue: queue.Queue,
|
data_queue: queue.Queue,
|
||||||
task_temp_images: list,
|
task_temp_images: list,
|
||||||
step_callback,
|
step_callback,
|
||||||
|
@ -26,7 +26,7 @@ class GenerateImageRequest(BaseModel):
|
|||||||
sampler_name: str = None # "ddim", "plms", "heun", "euler", "euler_a", "dpm2", "dpm2_a", "lms"
|
sampler_name: str = None # "ddim", "plms", "heun", "euler", "euler_a", "dpm2", "dpm2_a", "lms"
|
||||||
hypernetwork_strength: float = 0
|
hypernetwork_strength: float = 0
|
||||||
lora_alpha: Union[float, List[float]] = 0
|
lora_alpha: Union[float, List[float]] = 0
|
||||||
tiling: str = "none" # "none", "x", "y", "xy"
|
tiling: str = None # None, "x", "y", "xy"
|
||||||
|
|
||||||
|
|
||||||
class FilterImageRequest(BaseModel):
|
class FilterImageRequest(BaseModel):
|
||||||
@ -58,10 +58,17 @@ class OutputFormatData(BaseModel):
|
|||||||
output_lossless: bool = False
|
output_lossless: bool = False
|
||||||
|
|
||||||
|
|
||||||
|
class SaveToDiskData(BaseModel):
|
||||||
|
save_to_disk_path: str = None
|
||||||
|
metadata_output_format: str = "txt" # or "json"
|
||||||
|
|
||||||
|
|
||||||
class TaskData(BaseModel):
|
class TaskData(BaseModel):
|
||||||
request_id: str = None
|
request_id: str = None
|
||||||
session_id: str = "session"
|
session_id: str = "session"
|
||||||
save_to_disk_path: str = None
|
|
||||||
|
|
||||||
|
class RenderTaskData(TaskData):
|
||||||
vram_usage_level: str = "balanced" # or "low" or "medium"
|
vram_usage_level: str = "balanced" # or "low" or "medium"
|
||||||
|
|
||||||
use_face_correction: Union[str, List[str]] = None # or "GFPGANv1.3"
|
use_face_correction: Union[str, List[str]] = None # or "GFPGANv1.3"
|
||||||
@ -73,13 +80,14 @@ class TaskData(BaseModel):
|
|||||||
use_hypernetwork_model: Union[str, List[str]] = None
|
use_hypernetwork_model: Union[str, List[str]] = None
|
||||||
use_lora_model: Union[str, List[str]] = None
|
use_lora_model: Union[str, List[str]] = None
|
||||||
use_controlnet_model: Union[str, List[str]] = None
|
use_controlnet_model: Union[str, List[str]] = None
|
||||||
|
use_embeddings_model: Union[str, List[str]] = None
|
||||||
filters: List[str] = []
|
filters: List[str] = []
|
||||||
filter_params: Dict[str, Dict[str, Any]] = {}
|
filter_params: Dict[str, Dict[str, Any]] = {}
|
||||||
control_filter_to_apply: Union[str, List[str]] = None
|
control_filter_to_apply: Union[str, List[str]] = None
|
||||||
|
enable_vae_tiling: bool = True
|
||||||
|
|
||||||
show_only_filtered_image: bool = False
|
show_only_filtered_image: bool = False
|
||||||
block_nsfw: bool = False
|
block_nsfw: bool = False
|
||||||
metadata_output_format: str = "txt" # or "json"
|
|
||||||
stream_image_progress: bool = False
|
stream_image_progress: bool = False
|
||||||
stream_image_progress_interval: int = 5
|
stream_image_progress_interval: int = 5
|
||||||
clip_skip: bool = False
|
clip_skip: bool = False
|
||||||
@ -125,12 +133,14 @@ class GenerateImageResponse:
|
|||||||
task_data: TaskData,
|
task_data: TaskData,
|
||||||
models_data: ModelsData,
|
models_data: ModelsData,
|
||||||
output_format: OutputFormatData,
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
images: list,
|
images: list,
|
||||||
):
|
):
|
||||||
self.render_request = render_request
|
self.render_request = render_request
|
||||||
self.task_data = task_data
|
self.task_data = task_data
|
||||||
self.models_data = models_data
|
self.models_data = models_data
|
||||||
self.output_format = output_format
|
self.output_format = output_format
|
||||||
|
self.save_data = save_data
|
||||||
self.images = images
|
self.images = images
|
||||||
|
|
||||||
def json(self):
|
def json(self):
|
||||||
@ -140,6 +150,7 @@ class GenerateImageResponse:
|
|||||||
|
|
||||||
task_data = self.task_data.dict()
|
task_data = self.task_data.dict()
|
||||||
task_data.update(self.output_format.dict())
|
task_data.update(self.output_format.dict())
|
||||||
|
task_data.update(self.save_data.dict())
|
||||||
|
|
||||||
res = {
|
res = {
|
||||||
"status": "succeeded",
|
"status": "succeeded",
|
||||||
@ -200,6 +211,7 @@ def convert_legacy_render_req_to_new(old_req: dict):
|
|||||||
model_paths["hypernetwork"] = old_req.get("use_hypernetwork_model")
|
model_paths["hypernetwork"] = old_req.get("use_hypernetwork_model")
|
||||||
model_paths["lora"] = old_req.get("use_lora_model")
|
model_paths["lora"] = old_req.get("use_lora_model")
|
||||||
model_paths["controlnet"] = old_req.get("use_controlnet_model")
|
model_paths["controlnet"] = old_req.get("use_controlnet_model")
|
||||||
|
model_paths["embeddings"] = old_req.get("use_embeddings_model")
|
||||||
|
|
||||||
model_paths["gfpgan"] = old_req.get("use_face_correction", "")
|
model_paths["gfpgan"] = old_req.get("use_face_correction", "")
|
||||||
model_paths["gfpgan"] = model_paths["gfpgan"] if "gfpgan" in model_paths["gfpgan"].lower() else None
|
model_paths["gfpgan"] = model_paths["gfpgan"] if "gfpgan" in model_paths["gfpgan"].lower() else None
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import hashlib
|
||||||
|
|
||||||
log = logging.getLogger("easydiffusion")
|
log = logging.getLogger("easydiffusion")
|
||||||
|
|
||||||
@ -6,3 +7,15 @@ from .save_utils import (
|
|||||||
save_images_to_disk,
|
save_images_to_disk,
|
||||||
get_printable_request,
|
get_printable_request,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def sha256sum(filename):
|
||||||
|
sha256 = hashlib.sha256()
|
||||||
|
with open(filename, "rb") as f:
|
||||||
|
while True:
|
||||||
|
data = f.read(8192) # Read in chunks of 8192 bytes
|
||||||
|
if not data:
|
||||||
|
break
|
||||||
|
sha256.update(data)
|
||||||
|
|
||||||
|
return sha256.hexdigest()
|
||||||
|
|
||||||
|
@ -7,9 +7,17 @@ from datetime import datetime
|
|||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
from easydiffusion import app
|
from easydiffusion import app
|
||||||
from easydiffusion.types import GenerateImageRequest, TaskData, OutputFormatData
|
from easydiffusion.types import (
|
||||||
|
GenerateImageRequest,
|
||||||
|
TaskData,
|
||||||
|
RenderTaskData,
|
||||||
|
OutputFormatData,
|
||||||
|
SaveToDiskData,
|
||||||
|
ModelsData,
|
||||||
|
)
|
||||||
from numpy import base_repr
|
from numpy import base_repr
|
||||||
from sdkit.utils import save_dicts, save_images
|
from sdkit.utils import save_dicts, save_images
|
||||||
|
from sdkit.models.model_loader.embeddings import get_embedding_token
|
||||||
|
|
||||||
filename_regex = re.compile("[^a-zA-Z0-9._-]")
|
filename_regex = re.compile("[^a-zA-Z0-9._-]")
|
||||||
img_number_regex = re.compile("([0-9]{5,})")
|
img_number_regex = re.compile("([0-9]{5,})")
|
||||||
@ -34,7 +42,7 @@ TASK_TEXT_MAPPING = {
|
|||||||
"lora_alpha": "LoRA Strength",
|
"lora_alpha": "LoRA Strength",
|
||||||
"use_hypernetwork_model": "Hypernetwork model",
|
"use_hypernetwork_model": "Hypernetwork model",
|
||||||
"hypernetwork_strength": "Hypernetwork Strength",
|
"hypernetwork_strength": "Hypernetwork Strength",
|
||||||
"use_embedding_models": "Embedding models",
|
"use_embeddings_model": "Embedding models",
|
||||||
"tiling": "Seamless Tiling",
|
"tiling": "Seamless Tiling",
|
||||||
"use_face_correction": "Use Face Correction",
|
"use_face_correction": "Use Face Correction",
|
||||||
"use_upscale": "Use Upscaling",
|
"use_upscale": "Use Upscaling",
|
||||||
@ -94,7 +102,7 @@ def format_folder_name(format: str, req: GenerateImageRequest, task_data: TaskDa
|
|||||||
def format_file_name(
|
def format_file_name(
|
||||||
format: str,
|
format: str,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
now: float,
|
now: float,
|
||||||
batch_file_number: int,
|
batch_file_number: int,
|
||||||
folder_img_number: ImageNumber,
|
folder_img_number: ImageNumber,
|
||||||
@ -117,13 +125,19 @@ def format_file_name(
|
|||||||
|
|
||||||
|
|
||||||
def save_images_to_disk(
|
def save_images_to_disk(
|
||||||
images: list, filtered_images: list, req: GenerateImageRequest, task_data: TaskData, output_format: OutputFormatData
|
images: list,
|
||||||
|
filtered_images: list,
|
||||||
|
req: GenerateImageRequest,
|
||||||
|
task_data: RenderTaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
):
|
):
|
||||||
now = time.time()
|
now = time.time()
|
||||||
app_config = app.getConfig()
|
app_config = app.getConfig()
|
||||||
folder_format = app_config.get("folder_format", "$id")
|
folder_format = app_config.get("folder_format", "$id")
|
||||||
save_dir_path = os.path.join(task_data.save_to_disk_path, format_folder_name(folder_format, req, task_data))
|
save_dir_path = os.path.join(save_data.save_to_disk_path, format_folder_name(folder_format, req, task_data))
|
||||||
metadata_entries = get_metadata_entries_for_request(req, task_data, output_format)
|
metadata_entries = get_metadata_entries_for_request(req, task_data, models_data, output_format, save_data)
|
||||||
file_number = calculate_img_number(save_dir_path, task_data)
|
file_number = calculate_img_number(save_dir_path, task_data)
|
||||||
make_filename = make_filename_callback(
|
make_filename = make_filename_callback(
|
||||||
app_config.get("filename_format", "$p_$tsb64"),
|
app_config.get("filename_format", "$p_$tsb64"),
|
||||||
@ -142,8 +156,8 @@ def save_images_to_disk(
|
|||||||
output_quality=output_format.output_quality,
|
output_quality=output_format.output_quality,
|
||||||
output_lossless=output_format.output_lossless,
|
output_lossless=output_format.output_lossless,
|
||||||
)
|
)
|
||||||
if task_data.metadata_output_format:
|
if save_data.metadata_output_format:
|
||||||
for metadata_output_format in task_data.metadata_output_format.split(","):
|
for metadata_output_format in save_data.metadata_output_format.split(","):
|
||||||
if metadata_output_format.lower() in ["json", "txt", "embed"]:
|
if metadata_output_format.lower() in ["json", "txt", "embed"]:
|
||||||
save_dicts(
|
save_dicts(
|
||||||
metadata_entries,
|
metadata_entries,
|
||||||
@ -178,8 +192,8 @@ def save_images_to_disk(
|
|||||||
output_quality=output_format.output_quality,
|
output_quality=output_format.output_quality,
|
||||||
output_lossless=output_format.output_lossless,
|
output_lossless=output_format.output_lossless,
|
||||||
)
|
)
|
||||||
if task_data.metadata_output_format:
|
if save_data.metadata_output_format:
|
||||||
for metadata_output_format in task_data.metadata_output_format.split(","):
|
for metadata_output_format in save_data.metadata_output_format.split(","):
|
||||||
if metadata_output_format.lower() in ["json", "txt", "embed"]:
|
if metadata_output_format.lower() in ["json", "txt", "embed"]:
|
||||||
save_dicts(
|
save_dicts(
|
||||||
metadata_entries,
|
metadata_entries,
|
||||||
@ -190,11 +204,17 @@ def save_images_to_disk(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskData, output_format: OutputFormatData):
|
def get_metadata_entries_for_request(
|
||||||
metadata = get_printable_request(req, task_data, output_format)
|
req: GenerateImageRequest,
|
||||||
|
task_data: RenderTaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
|
):
|
||||||
|
metadata = get_printable_request(req, task_data, models_data, output_format, save_data)
|
||||||
|
|
||||||
# if text, format it in the text format expected by the UI
|
# if text, format it in the text format expected by the UI
|
||||||
is_txt_format = task_data.metadata_output_format and "txt" in task_data.metadata_output_format.lower().split(",")
|
is_txt_format = save_data.metadata_output_format and "txt" in save_data.metadata_output_format.lower().split(",")
|
||||||
if is_txt_format:
|
if is_txt_format:
|
||||||
|
|
||||||
def format_value(value):
|
def format_value(value):
|
||||||
@ -213,13 +233,20 @@ def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskD
|
|||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
|
||||||
def get_printable_request(req: GenerateImageRequest, task_data: TaskData, output_format: OutputFormatData):
|
def get_printable_request(
|
||||||
|
req: GenerateImageRequest,
|
||||||
|
task_data: RenderTaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
|
):
|
||||||
req_metadata = req.dict()
|
req_metadata = req.dict()
|
||||||
task_data_metadata = task_data.dict()
|
task_data_metadata = task_data.dict()
|
||||||
task_data_metadata.update(output_format.dict())
|
task_data_metadata.update(output_format.dict())
|
||||||
|
task_data_metadata.update(save_data.dict())
|
||||||
|
|
||||||
app_config = app.getConfig()
|
app_config = app.getConfig()
|
||||||
using_diffusers = app_config.get("test_diffusers", False)
|
using_diffusers = app_config.get("use_v3_engine", True)
|
||||||
|
|
||||||
# Save the metadata in the order defined in TASK_TEXT_MAPPING
|
# Save the metadata in the order defined in TASK_TEXT_MAPPING
|
||||||
metadata = {}
|
metadata = {}
|
||||||
@ -228,28 +255,12 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData, output
|
|||||||
metadata[key] = req_metadata[key]
|
metadata[key] = req_metadata[key]
|
||||||
elif key in task_data_metadata:
|
elif key in task_data_metadata:
|
||||||
metadata[key] = task_data_metadata[key]
|
metadata[key] = task_data_metadata[key]
|
||||||
elif key == "use_embedding_models" and using_diffusers:
|
|
||||||
embeddings_extensions = {".pt", ".bin", ".safetensors"}
|
|
||||||
|
|
||||||
def scan_directory(directory_path: str):
|
if key == "use_embeddings_model" and task_data_metadata[key] and using_diffusers:
|
||||||
used_embeddings = []
|
embeddings_used = models_data.model_paths["embeddings"]
|
||||||
for entry in os.scandir(directory_path):
|
embeddings_used = embeddings_used if isinstance(embeddings_used, list) else [embeddings_used]
|
||||||
if entry.is_file():
|
|
||||||
entry_extension = os.path.splitext(entry.name)[1]
|
|
||||||
if entry_extension not in embeddings_extensions:
|
|
||||||
continue
|
|
||||||
|
|
||||||
embedding_name_regex = regex.compile(
|
metadata["use_embeddings_model"] = embeddings_used if len(embeddings_used) > 0 else None
|
||||||
r"(^|[\s,])" + regex.escape(os.path.splitext(entry.name)[0]) + r"([+-]*$|[\s,]|[+-]+[\s,])"
|
|
||||||
)
|
|
||||||
if embedding_name_regex.search(req.prompt) or embedding_name_regex.search(req.negative_prompt):
|
|
||||||
used_embeddings.append(entry.path)
|
|
||||||
elif entry.is_dir():
|
|
||||||
used_embeddings.extend(scan_directory(entry.path))
|
|
||||||
return used_embeddings
|
|
||||||
|
|
||||||
used_embeddings = scan_directory(os.path.join(app.MODELS_DIR, "embeddings"))
|
|
||||||
metadata["use_embedding_models"] = used_embeddings if len(used_embeddings) > 0 else None
|
|
||||||
|
|
||||||
# Clean up the metadata
|
# Clean up the metadata
|
||||||
if req.init_image is None and "prompt_strength" in metadata:
|
if req.init_image is None and "prompt_strength" in metadata:
|
||||||
@ -265,9 +276,22 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData, output
|
|||||||
if task_data.use_controlnet_model is None and "control_filter_to_apply" in metadata:
|
if task_data.use_controlnet_model is None and "control_filter_to_apply" in metadata:
|
||||||
del metadata["control_filter_to_apply"]
|
del metadata["control_filter_to_apply"]
|
||||||
|
|
||||||
if not using_diffusers:
|
if using_diffusers:
|
||||||
|
for key in (x for x in ["use_hypernetwork_model", "hypernetwork_strength"] if x in metadata):
|
||||||
|
del metadata[key]
|
||||||
|
else:
|
||||||
for key in (
|
for key in (
|
||||||
x for x in ["use_lora_model", "lora_alpha", "clip_skip", "tiling", "latent_upscaler_steps", "use_controlnet_model", "control_filter_to_apply"] if x in metadata
|
x
|
||||||
|
for x in [
|
||||||
|
"use_lora_model",
|
||||||
|
"lora_alpha",
|
||||||
|
"clip_skip",
|
||||||
|
"tiling",
|
||||||
|
"latent_upscaler_steps",
|
||||||
|
"use_controlnet_model",
|
||||||
|
"control_filter_to_apply",
|
||||||
|
]
|
||||||
|
if x in metadata
|
||||||
):
|
):
|
||||||
del metadata[key]
|
del metadata[key]
|
||||||
|
|
||||||
@ -277,7 +301,7 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData, output
|
|||||||
def make_filename_callback(
|
def make_filename_callback(
|
||||||
filename_format: str,
|
filename_format: str,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
folder_img_number: int,
|
folder_img_number: int,
|
||||||
suffix=None,
|
suffix=None,
|
||||||
now=None,
|
now=None,
|
||||||
@ -294,7 +318,7 @@ def make_filename_callback(
|
|||||||
return make_filename
|
return make_filename
|
||||||
|
|
||||||
|
|
||||||
def _calculate_img_number(save_dir_path: str, task_data: TaskData):
|
def _calculate_img_number(save_dir_path: str, task_data: RenderTaskData):
|
||||||
def get_highest_img_number(accumulator: int, file: os.DirEntry) -> int:
|
def get_highest_img_number(accumulator: int, file: os.DirEntry) -> int:
|
||||||
if not file.is_file:
|
if not file.is_file:
|
||||||
return accumulator
|
return accumulator
|
||||||
@ -338,5 +362,5 @@ def _calculate_img_number(save_dir_path: str, task_data: TaskData):
|
|||||||
_calculate_img_number.session_img_numbers = {}
|
_calculate_img_number.session_img_numbers = {}
|
||||||
|
|
||||||
|
|
||||||
def calculate_img_number(save_dir_path: str, task_data: TaskData):
|
def calculate_img_number(save_dir_path: str, task_data: RenderTaskData):
|
||||||
return ImageNumber(lambda: _calculate_img_number(save_dir_path, task_data))
|
return ImageNumber(lambda: _calculate_img_number(save_dir_path, task_data))
|
||||||
|
178
ui/index.html
178
ui/index.html
@ -18,12 +18,15 @@
|
|||||||
<link rel="stylesheet" href="/media/css/image-modal.css">
|
<link rel="stylesheet" href="/media/css/image-modal.css">
|
||||||
<link rel="stylesheet" href="/media/css/plugins.css">
|
<link rel="stylesheet" href="/media/css/plugins.css">
|
||||||
<link rel="stylesheet" href="/media/css/animations.css">
|
<link rel="stylesheet" href="/media/css/animations.css">
|
||||||
|
<link rel="stylesheet" href="/media/css/croppr.css" rel="stylesheet"/>
|
||||||
<link rel="manifest" href="/media/manifest.webmanifest">
|
<link rel="manifest" href="/media/manifest.webmanifest">
|
||||||
<script src="/media/js/jquery-3.6.1.min.js"></script>
|
<script src="/media/js/jquery-3.6.1.min.js"></script>
|
||||||
<script src="/media/js/jquery-confirm.min.js"></script>
|
<script src="/media/js/jquery-confirm.min.js"></script>
|
||||||
<script src="/media/js/jszip.min.js"></script>
|
<script src="/media/js/jszip.min.js"></script>
|
||||||
<script src="/media/js/FileSaver.min.js"></script>
|
<script src="/media/js/FileSaver.min.js"></script>
|
||||||
<script src="/media/js/marked.min.js"></script>
|
<script src="/media/js/marked.min.js"></script>
|
||||||
|
<script src="/media/js/croppr.js"></script>
|
||||||
|
<script src="/media/js/exif-reader.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
@ -32,7 +35,7 @@
|
|||||||
<h1>
|
<h1>
|
||||||
<img id="logo_img" src="/media/images/icon-512x512.png" >
|
<img id="logo_img" src="/media/images/icon-512x512.png" >
|
||||||
Easy Diffusion
|
Easy Diffusion
|
||||||
<small><span id="version">v2.5.48</span> <span id="updateBranchLabel"></span></small>
|
<small><span id="version">v3.0.8</span> <span id="updateBranchLabel"></span></small>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div id="server-status">
|
<div id="server-status">
|
||||||
@ -59,7 +62,14 @@
|
|||||||
<div id="editor-inputs-prompt" class="row">
|
<div id="editor-inputs-prompt" class="row">
|
||||||
<div id="prompt-toolbar" class="split-toolbar">
|
<div id="prompt-toolbar" class="split-toolbar">
|
||||||
<div id="prompt-toolbar-left" class="toolbar-left">
|
<div id="prompt-toolbar-left" class="toolbar-left">
|
||||||
<label for="prompt"><b>Enter Prompt</b></label> <small>or</small> <button id="promptsFromFileBtn" class="tertiaryButton smallButton">Load from a file</button>
|
<label for="prompt"><b>Enter Prompt</b>
|
||||||
|
<i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip right">
|
||||||
|
You can type your prompts in the below textbox or load them from a file. You can also
|
||||||
|
reload tasks from metadata embedded in PNG, WEBP and JPEG images (enable embedding from the Settings).
|
||||||
|
</span></i>
|
||||||
|
</label>
|
||||||
|
<small>or</small>
|
||||||
|
<button id="promptsFromFileBtn" class="tertiaryButton smallButton">Load from a file</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="prompt-toolbar-right" class="toolbar-right">
|
<div id="prompt-toolbar-right" class="toolbar-right">
|
||||||
<button id="image-modifier-dropdown" class="tertiaryButton smallButton">+ Image Modifiers</button>
|
<button id="image-modifier-dropdown" class="tertiaryButton smallButton">+ Image Modifiers</button>
|
||||||
@ -73,7 +83,7 @@
|
|||||||
<a href="https://github.com/easydiffusion/easydiffusion/wiki/Writing-prompts#negative-prompts" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top">Click to learn more about Negative Prompts</span></i></a>
|
<a href="https://github.com/easydiffusion/easydiffusion/wiki/Writing-prompts#negative-prompts" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top">Click to learn more about Negative Prompts</span></i></a>
|
||||||
<small>(optional)</small>
|
<small>(optional)</small>
|
||||||
</label>
|
</label>
|
||||||
<button id="negative-embeddings-button" class="tertiaryButton smallButton displayNone">+ Embedding</button>
|
<button id="negative-embeddings-button" class="tertiaryButton smallButton displayNone">+ Negative Embedding</button>
|
||||||
<div class="collapsible-content">
|
<div class="collapsible-content">
|
||||||
<textarea id="negative_prompt" name="negative_prompt" placeholder="list the things to remove from the image (e.g. fog, green)"></textarea>
|
<textarea id="negative_prompt" name="negative_prompt" placeholder="list the things to remove from the image (e.g. fog, green)"></textarea>
|
||||||
</div>
|
</div>
|
||||||
@ -81,6 +91,11 @@
|
|||||||
|
|
||||||
<div id="editor-inputs-init-image" class="row">
|
<div id="editor-inputs-init-image" class="row">
|
||||||
<label for="init_image">Initial Image (img2img) <small>(optional)</small> </label>
|
<label for="init_image">Initial Image (img2img) <small>(optional)</small> </label>
|
||||||
|
<i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top">
|
||||||
|
Add img2img source image using the Browse button, via drag & drop from external file or browser image (incl.
|
||||||
|
rendered image) or by pasting an image from the clipboard using Ctrl+V.<br /><br />
|
||||||
|
You may also reload the metadata embedded in a PNG, WEBP or JPEG image (enable embedding from the Settings).
|
||||||
|
</span></i>
|
||||||
|
|
||||||
<div id="init_image_preview_container" class="image_preview_container">
|
<div id="init_image_preview_container" class="image_preview_container">
|
||||||
<div id="init_image_wrapper" class="preview_image_wrapper">
|
<div id="init_image_wrapper" class="preview_image_wrapper">
|
||||||
@ -140,8 +155,13 @@
|
|||||||
<div id="editor-settings-entries" class="collapsible-content">
|
<div id="editor-settings-entries" class="collapsible-content">
|
||||||
<div><table>
|
<div><table>
|
||||||
<tr><b class="settings-subheader">Image Settings</b></tr>
|
<tr><b class="settings-subheader">Image Settings</b></tr>
|
||||||
<tr class="pl-5"><td><label for="seed">Seed:</label></td><td><input id="seed" name="seed" size="10" value="0" onkeypress="preventNonNumericalInput(event)"> <input id="random_seed" name="random_seed" type="checkbox" checked><label for="random_seed">Random</label></td></tr>
|
<tr class="pl-5"><td><label for="seed">Seed:</label></td><td><input id="seed" name="seed" size="10" value="0" onkeypress="preventNonNumericalInput(event)" inputmode="numeric"> <input id="random_seed" name="random_seed" type="checkbox" checked><label for="random_seed">Random</label></td></tr>
|
||||||
<tr class="pl-5"><td><label for="num_outputs_total">Number of Images:</label></td><td><input id="num_outputs_total" name="num_outputs_total" value="1" size="1" onkeypress="preventNonNumericalInput(event)"> <label><small>(total)</small></label> <input id="num_outputs_parallel" name="num_outputs_parallel" value="1" size="1" onkeypress="preventNonNumericalInput(event)"> <label id="num_outputs_parallel_label" for="num_outputs_parallel"><small>(in parallel)</small></label></td></tr>
|
<tr class="pl-5"><td><label for="num_outputs_total">Number of Images:</label></td>
|
||||||
|
<td><input id="num_outputs_total" name="num_outputs_total" value="1" type="number" value="1" min="1" step="1" onkeypres"="preventNonNumericalInput(event)" inputmode="numeric">
|
||||||
|
<label><small>(total)</small></label>
|
||||||
|
<input id="num_outputs_parallel" name="num_outputs_parallel" value="1" type="number" value="1" min="1" step="1" onkeypress="preventNonNumericalInput(event)" inputmode="numeric">
|
||||||
|
<label id="num_outputs_parallel_label" for="num_outputs_parallel"><small>(in parallel)</small></label></td>
|
||||||
|
</tr>
|
||||||
<tr class="pl-5"><td><label for="stable_diffusion_model">Model:</label></td><td class="model-input">
|
<tr class="pl-5"><td><label for="stable_diffusion_model">Model:</label></td><td class="model-input">
|
||||||
<input id="stable_diffusion_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
<input id="stable_diffusion_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
||||||
<button id="reload-models" class="secondaryButton reloadModels"><i class='fa-solid fa-rotate'></i></button>
|
<button id="reload-models" class="secondaryButton reloadModels"><i class='fa-solid fa-rotate'></i></button>
|
||||||
@ -270,8 +290,10 @@
|
|||||||
<option value="1792">1792</option>
|
<option value="1792">1792</option>
|
||||||
<option value="2048">2048</option>
|
<option value="2048">2048</option>
|
||||||
</select>
|
</select>
|
||||||
<label for="width"><small>(width)</small></label>
|
<label id="widthLabel" for="width"><small><span>(width)</span></small></label>
|
||||||
|
<div class="tooltip-container">
|
||||||
<span id="swap-width-height" class="clickable smallButton" style="margin-left: 2px; margin-right:2px;"><i class="fa-solid fa-right-left"><span class="simple-tooltip top-left"> Swap width and height </span></i></span>
|
<span id="swap-width-height" class="clickable smallButton" style="margin-left: 2px; margin-right:2px;"><i class="fa-solid fa-right-left"><span class="simple-tooltip top-left"> Swap width and height </span></i></span>
|
||||||
|
</div>
|
||||||
<select id="height" name="height" value="512">
|
<select id="height" name="height" value="512">
|
||||||
<option value="128">128</option>
|
<option value="128">128</option>
|
||||||
<option value="192">192</option>
|
<option value="192">192</option>
|
||||||
@ -293,43 +315,52 @@
|
|||||||
<option value="1792">1792</option>
|
<option value="1792">1792</option>
|
||||||
<option value="2048">2048</option>
|
<option value="2048">2048</option>
|
||||||
</select>
|
</select>
|
||||||
<label for="height"><small>(height)</small></label>
|
<label id="heightLabel" for="height"><small><span>(height)</span></small></label>
|
||||||
<div id="recent-resolutions-container">
|
<div id="recent-resolutions-container">
|
||||||
<span id="recent-resolutions-button" class="clickable"><i class="fa-solid fa-sliders"><span class="simple-tooltip top-left"> Advanced sizes </span></i></span>
|
<span id="recent-resolutions-button" class="clickable"><i class="fa-solid fa-sliders"><span class="simple-tooltip top-left"> Advanced sizes </span></i></span>
|
||||||
<div id="recent-resolutions-popup" class="displayNone">
|
<div id="recent-resolutions-popup" class="displayNone">
|
||||||
<small>Custom size:</small><br>
|
<small>Custom size:</small><br>
|
||||||
<input id="custom-width" name="custom-width" type="number" min="128" value="512" onkeypress="preventNonNumericalInput(event)">
|
<input id="custom-width" name="custom-width" type="number" min="128" value="512" onkeypress="preventNonNumericalInput(event)" inputmode="numeric">
|
||||||
×
|
×
|
||||||
<input id="custom-height" name="custom-height" type="number" min="128" value="512" onkeypress="preventNonNumericalInput(event)"><br>
|
<input id="custom-height" name="custom-height" type="number" min="128" value="512" onkeypress="preventNonNumericalInput(event)" inputmode="numeric"><br>
|
||||||
|
<small>Resize:</small><br>
|
||||||
<small>Enlarge:</small><br>
|
<input id="resize-slider" name="resize-slider" class="editor-slider" value="1" type="range" min="0.4" max="2" step="0.005" style="width:100%;"><br>
|
||||||
<div id="enlarge-buttons"><button id="enlarge15" class="tertiaryButton smallButton">×1.5</button> <button id="enlarge2" class="tertiaryButton smallButton">×2</button> <button id="enlarge3" class="tertiaryButton smallButton">×3</button></div>
|
<div id="enlarge-buttons"><button data-factor="0.5" class="tertiaryButton smallButton">×0.5</button> <button data-factor="1.2" class="tertiaryButton smallButton">×1.2</button> <button data-factor="1.5" class="tertiaryButton smallButton">×1.5</button> <button data-factor="2" class="tertiaryButton smallButton">×2</button> <button data-factor="3" class="tertiaryButton smallButton">×3</button></div>
|
||||||
|
|
||||||
|
<div class="two-column">
|
||||||
|
<div class="left-column">
|
||||||
<small>Recently used:</small><br>
|
<small>Recently used:</small><br>
|
||||||
<div id="recent-resolution-list">
|
<div id="recent-resolution-list">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="right-column">
|
||||||
|
<small>Common sizes:</small><br>
|
||||||
|
<div id="common-resolution-list">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="small_image_warning" class="displayNone">Small image sizes can cause bad image quality</div>
|
<div id="small_image_warning" class="displayNone">Small image sizes can cause bad image quality</div>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="pl-5"><td><label for="num_inference_steps">Inference Steps:</label></td><td> <input id="num_inference_steps" name="num_inference_steps" type="number" min="1" step="1" style="width: 42pt" value="25" onkeypress="preventNonNumericalInput(event)"></td></tr>
|
<tr class="pl-5"><td><label for="num_inference_steps">Inference Steps:</label></td><td> <input id="num_inference_steps" name="num_inference_steps" type="number" min="1" step="1" style="width: 42pt" value="25" onkeypress="preventNonNumericalInput(event)" inputmode="numeric"></td></tr>
|
||||||
<tr class="pl-5"><td><label for="guidance_scale_slider">Guidance Scale:</label></td><td> <input id="guidance_scale_slider" name="guidance_scale_slider" class="editor-slider" value="75" type="range" min="11" max="500"> <input id="guidance_scale" name="guidance_scale" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"></td></tr>
|
<tr class="pl-5"><td><label for="guidance_scale_slider">Guidance Scale:</label></td><td> <input id="guidance_scale_slider" name="guidance_scale_slider" class="editor-slider" value="75" type="range" min="11" max="500"> <input id="guidance_scale" name="guidance_scale" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal"></td></tr>
|
||||||
<tr id="prompt_strength_container" class="pl-5"><td><label for="prompt_strength_slider">Prompt Strength:</label></td><td> <input id="prompt_strength_slider" name="prompt_strength_slider" class="editor-slider" value="80" type="range" min="0" max="99"> <input id="prompt_strength" name="prompt_strength" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"><br/></td></tr>
|
<tr id="prompt_strength_container" class="pl-5"><td><label for="prompt_strength_slider">Prompt Strength:</label></td><td> <input id="prompt_strength_slider" name="prompt_strength_slider" class="editor-slider" value="80" type="range" min="0" max="99"> <input id="prompt_strength" name="prompt_strength" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal"><br/></td></tr>
|
||||||
<tr id="lora_model_container" class="pl-5">
|
<tr id="lora_model_container" class="pl-5">
|
||||||
<td>
|
<td>
|
||||||
<label for="lora_model">LoRA:</label>
|
<label for="lora_model">LoRA:</label>
|
||||||
</td>
|
</td>
|
||||||
<td class="diffusers-restart-needed">
|
<td class="diffusers-restart-needed">
|
||||||
<div class="model_entries"></div>
|
<div id="lora_model" data-path=""></div>
|
||||||
<button class="add_model_entry"><i class="fa-solid fa-plus"></i> add another LoRA</button>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="pl-5"><td><label for="hypernetwork_model">Hypernetwork:</label></td><td>
|
<tr id="hypernetwork_model_container" class="pl-5"><td><label for="hypernetwork_model">Hypernetwork:</label></td><td>
|
||||||
<input id="hypernetwork_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
<input id="hypernetwork_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr id="hypernetwork_strength_container" class="pl-5">
|
<tr id="hypernetwork_strength_container" class="pl-5">
|
||||||
<td><label for="hypernetwork_strength_slider">Hypernetwork Strength:</label></td>
|
<td><label for="hypernetwork_strength_slider">Hypernetwork Strength:</label></td>
|
||||||
<td> <input id="hypernetwork_strength_slider" name="hypernetwork_strength_slider" class="editor-slider" value="100" type="range" min="0" max="100"> <input id="hypernetwork_strength" name="hypernetwork_strength" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"><br/></td>
|
<td> <input id="hypernetwork_strength_slider" name="hypernetwork_strength_slider" class="editor-slider" value="100" type="range" min="0" max="100"> <input id="hypernetwork_strength" name="hypernetwork_strength" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal"><br/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr id="tiling_container" class="pl-5">
|
<tr id="tiling_container" class="pl-5">
|
||||||
<td><label for="tiling">Seamless Tiling:</label></td>
|
<td><label for="tiling">Seamless Tiling:</label></td>
|
||||||
@ -354,8 +385,15 @@
|
|||||||
</span>
|
</span>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="pl-5" id="output_quality_row"><td><label for="output_quality">Image Quality:</label></td><td>
|
<tr class="pl-5" id="output_quality_row"><td><label for="output_quality">Image Quality:</label></td><td>
|
||||||
<input id="output_quality_slider" name="output_quality" class="editor-slider" value="75" type="range" min="10" max="95"> <input id="output_quality" name="output_quality" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)">
|
<input id="output_quality_slider" name="output_quality" class="editor-slider" value="75" type="range" min="10" max="95"> <input id="output_quality" name="output_quality" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="numeric">
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
<tr class="pl-5">
|
||||||
|
<td><label for="tiling">Enable VAE Tiling:</label></td>
|
||||||
|
<td class="diffusers-restart-needed">
|
||||||
|
<input id="enable_vae_tiling" name="enable_vae_tiling" type="checkbox" checked>
|
||||||
|
<label><small>Optimizes memory for larger images</small></label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
|
|
||||||
<div><ul>
|
<div><ul>
|
||||||
@ -364,7 +402,7 @@
|
|||||||
<li class="pl-5" id="use_face_correction_container">
|
<li class="pl-5" id="use_face_correction_container">
|
||||||
<input id="use_face_correction" name="use_face_correction" type="checkbox"> <label for="use_face_correction">Fix incorrect faces and eyes</label> <div style="display:inline-block;"><input id="gfpgan_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" /></div>
|
<input id="use_face_correction" name="use_face_correction" type="checkbox"> <label for="use_face_correction">Fix incorrect faces and eyes</label> <div style="display:inline-block;"><input id="gfpgan_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" /></div>
|
||||||
<table id="codeformer_settings" class="displayNone sub-settings">
|
<table id="codeformer_settings" class="displayNone sub-settings">
|
||||||
<tr class="pl-5"><td><label for="codeformer_fidelity_slider">Strength:</label></td><td><input id="codeformer_fidelity_slider" name="codeformer_fidelity_slider" class="editor-slider" value="5" type="range" min="0" max="10"> <input id="codeformer_fidelity" name="codeformer_fidelity" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"></td></tr>
|
<tr class="pl-5"><td><label for="codeformer_fidelity_slider">Strength:</label></td><td><input id="codeformer_fidelity_slider" name="codeformer_fidelity_slider" class="editor-slider" value="5" type="range" min="0" max="10"> <input id="codeformer_fidelity" name="codeformer_fidelity" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal"></td></tr>
|
||||||
<tr class="pl-5"><td><label for="codeformer_upscale_faces">Upscale Faces:</label></td><td><input id="codeformer_upscale_faces" name="codeformer_upscale_faces" type="checkbox" checked> <label><small>(improves the resolution of faces)</small></label></td></tr>
|
<tr class="pl-5"><td><label for="codeformer_upscale_faces">Upscale Faces:</label></td><td><input id="codeformer_upscale_faces" name="codeformer_upscale_faces" type="checkbox" checked> <label><small>(improves the resolution of faces)</small></label></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</li>
|
</li>
|
||||||
@ -381,7 +419,7 @@
|
|||||||
<option value="latent_upscaler">Latent Upscaler 2x</option>
|
<option value="latent_upscaler">Latent Upscaler 2x</option>
|
||||||
</select>
|
</select>
|
||||||
<table id="latent_upscaler_settings" class="displayNone sub-settings">
|
<table id="latent_upscaler_settings" class="displayNone sub-settings">
|
||||||
<tr class="pl-5"><td><label for="latent_upscaler_steps_slider">Upscaling Steps:</label></td><td><input id="latent_upscaler_steps_slider" name="latent_upscaler_steps_slider" class="editor-slider" value="10" type="range" min="1" max="50"> <input id="latent_upscaler_steps" name="latent_upscaler_steps" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"></td></tr>
|
<tr class="pl-5"><td><label for="latent_upscaler_steps_slider">Upscaling Steps:</label></td><td><input id="latent_upscaler_steps_slider" name="latent_upscaler_steps_slider" class="editor-slider" value="10" type="range" min="1" max="50"> <input id="latent_upscaler_steps" name="latent_upscaler_steps" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="numeric"></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</li>
|
</li>
|
||||||
<li class="pl-5"><input id="show_only_filtered_image" name="show_only_filtered_image" type="checkbox" checked> <label for="show_only_filtered_image">Show only the corrected/upscaled image</label></li>
|
<li class="pl-5"><input id="show_only_filtered_image" name="show_only_filtered_image" type="checkbox" checked> <label for="show_only_filtered_image">Show only the corrected/upscaled image</label></li>
|
||||||
@ -389,7 +427,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label><small><b>Note:</b> The Image Modifiers section has moved to the <code>+ Image Modifiers</code> button at the top, just below the Prompt textbox.</small></label>
|
<label><small><b>Note:</b> The Image Modifiers section has moved to the <code>+ Image Modifiers</code> button at the top, just above the Prompt textbox.</small></label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="preview" class="col-free">
|
<div id="preview" class="col-free">
|
||||||
@ -403,7 +441,7 @@
|
|||||||
<div id="preview-content">
|
<div id="preview-content">
|
||||||
<div id="preview-tools" class="displayNone">
|
<div id="preview-tools" class="displayNone">
|
||||||
<button id="clear-all-previews" class="secondaryButton"><i class="fa-solid fa-trash-can icon"></i> Clear All</button>
|
<button id="clear-all-previews" class="secondaryButton"><i class="fa-solid fa-trash-can icon"></i> Clear All</button>
|
||||||
<button class="tertiaryButton" id="show-download-popup"><i class="fa-solid fa-download"></i> Download images</button>
|
<button class="tertiaryButton" id="show-download-popup"><i class="fa-solid fa-download"></i><span> Download images</span></button>
|
||||||
<div class="display-settings">
|
<div class="display-settings">
|
||||||
<button id="undo" class="displayNone primaryButton">
|
<button id="undo" class="displayNone primaryButton">
|
||||||
Undo <i class="fa-solid fa-rotate-left icon"></i>
|
Undo <i class="fa-solid fa-rotate-left icon"></i>
|
||||||
@ -426,12 +464,15 @@
|
|||||||
<div class="dropdown-content">
|
<div class="dropdown-content">
|
||||||
<div class="dropdown-item">
|
<div class="dropdown-item">
|
||||||
<input id="thumbnail_size" name="thumbnail_size" class="editor-slider" type="range" value="70" min="5" max="200" oninput="sliderUpdate(event)">
|
<input id="thumbnail_size" name="thumbnail_size" class="editor-slider" type="range" value="70" min="5" max="200" oninput="sliderUpdate(event)">
|
||||||
<input id="thumbnail_size-input" name="thumbnail_size-input" size="3" value="70" pattern="^[0-9.]+$" onkeypress="preventNonNumericalInput(event)" oninput="sliderUpdate(event)"> %
|
<input id="thumbnail_size-input" name="thumbnail_size-input" size="3" value="70" pattern="^[0-9.]+$" onkeypress="preventNonNumericalInput(event)" oninput="sliderUpdate(event)" inputmode="numeric"> %
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix" style="clear: both;"></div>
|
<div class="clearfix" style="clear: both;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="supportBanner" class="displayNone">
|
||||||
|
If you found this project useful and want to help keep it alive, please consider <a href="https://ko-fi.com/easydiffusion" target="_blank">buying me a coffee</a> to help cover the cost of development and maintenance! Thanks for your support!
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -476,29 +517,45 @@
|
|||||||
<div class="float-container">
|
<div class="float-container">
|
||||||
<div class="float-child">
|
<div class="float-child">
|
||||||
<h1>Help</h1>
|
<h1>Help</h1>
|
||||||
<ul id="help-links">
|
<div id="help-links">
|
||||||
<li><span class="help-section">Using the software</span>
|
<h4><span class="help-section"><b>Basics</b></span></h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/How-To-Use" target="_blank"><i class="fa-solid fa-book fa-fw"></i> How to use</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/How-To-Use" target="_blank">How to use</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/UI-Overview" target="_blank"><i class="fa-solid fa-list fa-fw"></i> UI Overview</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Writing-Prompts" target="_blank">Writing prompts</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Writing-Prompts" target="_blank"><i class="fa-solid fa-pen-to-square fa-fw"></i> Writing prompts</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Image-Modifiers" target="_blank">Image Modifiers</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Inpainting" target="_blank"><i class="fa-solid fa-paintbrush fa-fw"></i> Inpainting</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Inpainting" target="_blank">Inpainting</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Run-on-Multiple-GPUs" target="_blank"><i class="fa-solid fa-paintbrush fa-fw"></i> Run on Multiple GPUs</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Samplers" target="_blank">Samplers</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/UI-Overview" target="_blank">Summary of every UI option</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting" target="_blank">Common error messages (and solutions)</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<li><span class="help-section">Installation</span>
|
<h4><span class="help-section"><b>Intermediate</b></span></h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting" target="_blank"><i class="fa-solid fa-circle-question fa-fw"></i> Troubleshooting</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Custom-Models" target="_blank">Custom Models</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Prompt-Syntax" target="_blank">Prompt Syntax (weights, emphasis etc)</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/UI-Plugins" target="_blank">UI Plugins</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Embeddings" target="_blank">Embeddings</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/LoRA" target="_blank">LoRA</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/SDXL" target="_blank">SDXL</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/ControlNet" target="_blank">ControlNet</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Seamless-Tiling" target="_blank">Seamless Tiling</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/xFormers" target="_blank">xFormers</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/The-beta-channel" target="_blank">The beta channel</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<li><span class="help-section">Downloadable Content</span>
|
<h4><span class="help-section"><b>Advanced topics</b></span></h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Custom-Models" target="_blank"><i class="fa-solid fa-images fa-fw"></i> Custom Models</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Run-on-Multiple-GPUs" target="_blank">Run on Multiple GPUs</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/UI-Plugins" target="_blank"><i class="fa-solid fa-puzzle-piece fa-fw"></i> UI Plugins</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Model-Merging" target="_blank">Model Merging</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/VAE-Variational-Auto-Encoder" target="_blank"><i class="fa-solid fa-hand-sparkles fa-fw"></i> VAE Variational Auto Encoder</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Custom-Modifiers" target="_blank">Custom Modifiers</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<h4><span class="help-section"><b>Misc</b></span></h4>
|
||||||
|
<ul>
|
||||||
|
<li> <a href="https://theally.notion.site/The-Definitive-Stable-Diffusion-Glossary-1d1e6d15059c41e6a6b4306b4ecd9df9" target="_blank">Glossary of Stable Diffusion related terms</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="float-child">
|
<div class="float-child">
|
||||||
<h1>Community</h1>
|
<h1>Community</h1>
|
||||||
@ -669,6 +726,8 @@
|
|||||||
<span>
|
<span>
|
||||||
</div>
|
</div>
|
||||||
<div id="embeddings-dialog-header-right">
|
<div id="embeddings-dialog-header-right">
|
||||||
|
<button id="add-embeddings-thumb" class="tertiaryButton smallButton" style="background-color: var(--background-color4);"><i class="fa-solid fa-folder-plus"></i> Add thumbnail</button>
|
||||||
|
<input id="add-embeddings-thumb-input" name="add-embeddings-thumb-input" type="file" class="displayNone">
|
||||||
<i id="embeddings-dialog-close-button" class="fa-solid fa-xmark fa-lg"></i>
|
<i id="embeddings-dialog-close-button" class="fa-solid fa-xmark fa-lg"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -678,7 +737,16 @@
|
|||||||
<span class="embeddings-action-text">Expand Categories</span>
|
<span class="embeddings-action-text">Expand Categories</span>
|
||||||
</button>
|
</button>
|
||||||
<i class="fa-solid fa-magnifying-glass"></i>
|
<i class="fa-solid fa-magnifying-glass"></i>
|
||||||
<input id="embeddings-search-box" type="text" spellcheck="false" autocomplete="off" placeholder="Search...">
|
<input id="embeddings-search-box" type="text" spellcheck="false" autocomplete="off" placeholder="Search..." inputmode="search">
|
||||||
|
<label for="embedding-card-size-selector"><small>Thumbnail Size:</small></label>
|
||||||
|
<select id="embedding-card-size-selector" name="embedding-card-size-selector">
|
||||||
|
<option value="-2">0</option>
|
||||||
|
<option value="-1" selected>1</option>
|
||||||
|
<option value="0">2</option>
|
||||||
|
<option value="1">3</option>
|
||||||
|
<option value="2">4</option>
|
||||||
|
<option value="3">5</option>
|
||||||
|
</select>
|
||||||
<span style="float:right;"><label>Mode:</label> <select id="embeddings-mode"><option value="insert">Insert at cursor position</option><option value="append">Append at the end</option></select>
|
<span style="float:right;"><label>Mode:</label> <select id="embeddings-mode"><option value="insert">Insert at cursor position</option><option value="append">Append at the end</option></select>
|
||||||
</div>
|
</div>
|
||||||
<div id="embeddings-list">
|
<div id="embeddings-list">
|
||||||
@ -686,6 +754,34 @@
|
|||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
||||||
|
<dialog id="use-as-thumb-dialog">
|
||||||
|
<div id="use-as-thumb-dialog-header" class="dialog-header">
|
||||||
|
<div id="use-as-thumb-dialog-header-left" class="dialog-header-left">
|
||||||
|
<h4>Use as thumbnail</h4>
|
||||||
|
<span>Use a pictures as thumbnail for embeddings, LORAs, etc.</span>
|
||||||
|
</div>
|
||||||
|
<div id="use-as-thumb-dialog-header-right">
|
||||||
|
<i id="use-as-thumb-dialog-close-button" class="fa-solid fa-xmark fa-lg"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="use-as-thumb-grid">
|
||||||
|
<div class="use-as-thumb-preview">
|
||||||
|
<div id="use-as-thumb-img-container"><img id="use-as-thumb-image" src="/media/images/noimg.png" width="512" height="512"></div>
|
||||||
|
</div>
|
||||||
|
<div class="use-as-thumb-select">
|
||||||
|
<label for="use-as-thumb-select">Use the thumbnail for:</label><br>
|
||||||
|
<select id="use-as-thumb-select" size="16" multiple>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="use-as-thumb-buttons">
|
||||||
|
<button class="tertiaryButton" id="use-as-thumb-save">Save thumbnail</button>
|
||||||
|
<button class="tertiaryButton" id="use-as-thumb-cancel">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
<div id="image-editor" class="popup image-editor-popup">
|
<div id="image-editor" class="popup image-editor-popup">
|
||||||
<div>
|
<div>
|
||||||
<i class="close-button fa-solid fa-xmark"></i>
|
<i class="close-button fa-solid fa-xmark"></i>
|
||||||
@ -721,13 +817,13 @@
|
|||||||
<div id="footer-spacer"></div>
|
<div id="footer-spacer"></div>
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
<div class="line-separator"> </div>
|
<div class="line-separator"> </div>
|
||||||
<p>If you found this project useful and want to help keep it alive, please <a href="https://ko-fi.com/easydiffusion" target="_blank"><img src="/media/images/kofi.png" id="coffeeButton"></a> to help cover the cost of development and maintenance! Thank you for your support!</p>
|
|
||||||
<p>Please feel free to join the <a href="https://discord.com/invite/u9yhsFmEkB" target="_blank">discord community</a> or <a href="https://github.com/easydiffusion/easydiffusion/issues" target="_blank">file an issue</a> if you have any problems or suggestions in using this interface.</p>
|
<p>Please feel free to join the <a href="https://discord.com/invite/u9yhsFmEkB" target="_blank">discord community</a> or <a href="https://github.com/easydiffusion/easydiffusion/issues" target="_blank">file an issue</a> if you have any problems or suggestions in using this interface.</p>
|
||||||
<div id="footer-legal">
|
<div id="footer-legal">
|
||||||
<p><b>Disclaimer:</b> The authors of this project are not responsible for any content generated using this interface.</p>
|
<p><b>Disclaimer:</b> The authors of this project are not responsible for any content generated using this interface.</p>
|
||||||
<p>This license of this software forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, <br/>spread misinformation and target vulnerable groups. For the full list of restrictions please read <a href="https://github.com/easydiffusion/easydiffusion/blob/main/LICENSE" target="_blank">the license</a>.</p>
|
<p>This license of this software forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, <br/>spread misinformation and target vulnerable groups. For the full list of restrictions please read <a href="https://github.com/easydiffusion/easydiffusion/blob/main/LICENSE" target="_blank">the license</a>.</p>
|
||||||
<p>By using this software, you consent to the terms and conditions of the license.</p>
|
<p>By using this software, you consent to the terms and conditions of the license.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<input id="test_diffusers" type="checkbox" style="display: none" checked />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
@ -739,6 +835,8 @@
|
|||||||
<script src="media/js/auto-save.js"></script>
|
<script src="media/js/auto-save.js"></script>
|
||||||
|
|
||||||
<script src="media/js/searchable-models.js"></script>
|
<script src="media/js/searchable-models.js"></script>
|
||||||
|
<script src="media/js/multi-model-selector.js"></script>
|
||||||
|
<script src="media/js/task-manager.js"></script>
|
||||||
<script src="media/js/main.js"></script>
|
<script src="media/js/main.js"></script>
|
||||||
<script src="media/js/plugins.js"></script>
|
<script src="media/js/plugins.js"></script>
|
||||||
<script src="media/js/themes.js"></script>
|
<script src="media/js/themes.js"></script>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from easydiffusion import model_manager, app, server
|
from easydiffusion import model_manager, app, server, bucket_manager
|
||||||
from easydiffusion.server import server_api # required for uvicorn
|
from easydiffusion.server import server_api # required for uvicorn
|
||||||
|
|
||||||
app.init()
|
app.init()
|
||||||
@ -8,6 +8,7 @@ server.init()
|
|||||||
# Init the app
|
# Init the app
|
||||||
model_manager.init()
|
model_manager.init()
|
||||||
app.init_render_threads()
|
app.init_render_threads()
|
||||||
|
bucket_manager.init()
|
||||||
|
|
||||||
# start the browser ui
|
# start the browser ui
|
||||||
app.open_browser()
|
app.open_browser()
|
||||||
|
58
ui/media/css/croppr.css
Normal file
58
ui/media/css/croppr.css
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
.croppr-container * {
|
||||||
|
user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
box-sizing: border-box;
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.croppr-container img {
|
||||||
|
vertical-align: middle;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.croppr {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.croppr-overlay {
|
||||||
|
background: rgba(0,0,0,0.5);
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 1;
|
||||||
|
cursor: crosshair;
|
||||||
|
}
|
||||||
|
|
||||||
|
.croppr-region {
|
||||||
|
border: 1px dashed rgba(0, 0, 0, 0.5);
|
||||||
|
position: absolute;
|
||||||
|
z-index: 3;
|
||||||
|
cursor: move;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.croppr-imageClipped {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 2;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.croppr-handle {
|
||||||
|
border: 1px solid black;
|
||||||
|
background-color: white;
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 4;
|
||||||
|
top: 0;
|
||||||
|
}
|
@ -230,3 +230,26 @@
|
|||||||
.inpainter .load_mask {
|
.inpainter .load_mask {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.editor-canvas-overlay {
|
||||||
|
cursor: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-brush-preview {
|
||||||
|
position: fixed;
|
||||||
|
background: black;
|
||||||
|
opacity: 0.3;
|
||||||
|
borderRadius: 50%;
|
||||||
|
cursor: none;
|
||||||
|
pointer-events: none;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-options-container > * > *:not(.active):not(.button) {
|
||||||
|
border: 1px dotted slategray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image_editor_opacity .editor-options-container > * > *:not(.active):not(.button) {
|
||||||
|
border: 1px dotted slategray;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ code {
|
|||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
transform: translateY(4px);
|
transform: translateY(4px);
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
#prompt {
|
#prompt {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -476,6 +477,7 @@ dialog {
|
|||||||
background: var(--background-color2);
|
background: var(--background-color2);
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
box-shadow: 0px 0px 30px black;
|
||||||
border: 2px solid rgb(255 255 255 / 10%);
|
border: 2px solid rgb(255 255 255 / 10%);
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
@ -607,11 +609,18 @@ div.img-preview img {
|
|||||||
margin: auto;
|
margin: auto;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
|
#help-links ul {
|
||||||
|
list-style-type: disc;
|
||||||
|
padding-left: 12pt;
|
||||||
|
}
|
||||||
#help-links li {
|
#help-links li {
|
||||||
padding-bottom: 12pt;
|
padding-bottom: 6pt;
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
}
|
}
|
||||||
|
#help-links ul li {
|
||||||
|
display: list-item;
|
||||||
|
}
|
||||||
#help-links li .fa-fw {
|
#help-links li .fa-fw {
|
||||||
padding-right: 2pt;
|
padding-right: 2pt;
|
||||||
}
|
}
|
||||||
@ -1088,7 +1097,7 @@ input::file-selector-button {
|
|||||||
.tab-content-inner {
|
.tab-content-inner {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
.tab {
|
#top-nav .tab {
|
||||||
font-size: 0;
|
font-size: 0;
|
||||||
}
|
}
|
||||||
.tab .icon {
|
.tab .icon {
|
||||||
@ -1114,6 +1123,9 @@ input::file-selector-button {
|
|||||||
#preview-tools button .icon {
|
#preview-tools button .icon {
|
||||||
font-size: 12pt;
|
font-size: 12pt;
|
||||||
}
|
}
|
||||||
|
#show-download-popup .fa-solid {
|
||||||
|
font-size: 12pt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 500px) {
|
@media screen and (max-width: 500px) {
|
||||||
@ -1202,6 +1214,12 @@ input::file-selector-button {
|
|||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tooltip-container {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
.simple-tooltip.right {
|
.simple-tooltip.right {
|
||||||
right: 0px;
|
right: 0px;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
@ -1418,6 +1436,10 @@ div.task-fs-initimage {
|
|||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
div.task-fs-initimage img {
|
||||||
|
max-height: 70vH;
|
||||||
|
max-width: 70vW;
|
||||||
|
}
|
||||||
div.task-initimg:hover div.task-fs-initimage {
|
div.task-initimg:hover div.task-fs-initimage {
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -1433,6 +1455,10 @@ div.top-right {
|
|||||||
right: 8px;
|
right: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.task-fs-initimage .top-right button {
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
#small_image_warning {
|
#small_image_warning {
|
||||||
font-size: smaller;
|
font-size: smaller;
|
||||||
color: var(--status-orange);
|
color: var(--status-orange);
|
||||||
@ -1460,6 +1486,9 @@ button#save-system-settings-btn {
|
|||||||
cursor: pointer;;
|
cursor: pointer;;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.validation-failed {
|
||||||
|
border: solid 2px red;
|
||||||
|
}
|
||||||
/* SCROLLBARS */
|
/* SCROLLBARS */
|
||||||
:root {
|
:root {
|
||||||
--scrollbar-width: 14px;
|
--scrollbar-width: 14px;
|
||||||
@ -1650,6 +1679,35 @@ body.wait-pause {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.spinner-container {
|
||||||
|
width: 80px;
|
||||||
|
height: 100px;
|
||||||
|
margin: 100px auto;
|
||||||
|
margin-top: 30vH;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-block {
|
||||||
|
position: relative;
|
||||||
|
box-sizing: border-box;
|
||||||
|
float: left;
|
||||||
|
margin: 0 10px 10px 0;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
border-radius: 3px;
|
||||||
|
background: var(--accent-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-block:nth-child(4n+1) { animation: spinner-wave 2s ease .0s infinite; }
|
||||||
|
.spinner-block:nth-child(4n+2) { animation: spinner-wave 2s ease .2s infinite; }
|
||||||
|
.spinner-block:nth-child(4n+3) { animation: spinner-wave 2s ease .4s infinite; }
|
||||||
|
.spinner-block:nth-child(4n+4) { animation: spinner-wave 2s ease .6s infinite; margin-right: 0; }
|
||||||
|
|
||||||
|
@keyframes spinner-wave {
|
||||||
|
0% { top: 0; opacity: 1; }
|
||||||
|
50% { top: 30px; opacity: .2; }
|
||||||
|
100% { top: 0; opacity: 1; }
|
||||||
|
}
|
||||||
|
|
||||||
#embeddings-dialog {
|
#embeddings-dialog {
|
||||||
overflow: clip;
|
overflow: clip;
|
||||||
}
|
}
|
||||||
@ -1664,6 +1722,12 @@ body.wait-pause {
|
|||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 1400px) {
|
||||||
|
#embeddings-list {
|
||||||
|
width: 80vW;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#embeddings-list button {
|
#embeddings-list button {
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
color: var(--button-color);
|
color: var(--button-color);
|
||||||
@ -1741,6 +1805,32 @@ body.wait-pause {
|
|||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.use-as-thumb-grid { display: grid;
|
||||||
|
grid-template-columns: 1fr auto;
|
||||||
|
grid-template-rows: 1fr auto;
|
||||||
|
gap: 8px 8px;
|
||||||
|
grid-auto-flow: row;
|
||||||
|
grid-template-areas:
|
||||||
|
"uat-preview uat-select"
|
||||||
|
"uat-preview uat-buttons";
|
||||||
|
}
|
||||||
|
|
||||||
|
.use-as-thumb-preview {
|
||||||
|
justify-self: center;
|
||||||
|
align-self: center;
|
||||||
|
grid-area: uat-preview;
|
||||||
|
}
|
||||||
|
|
||||||
|
.use-as-thumb-select {
|
||||||
|
grid-area: uat-select;
|
||||||
|
}
|
||||||
|
|
||||||
|
.use-as-thumb-buttons {
|
||||||
|
justify-self: center;
|
||||||
|
grid-area: uat-buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.diffusers-disabled-on-startup .diffusers-restart-needed {
|
.diffusers-disabled-on-startup .diffusers-restart-needed {
|
||||||
font-size: 0;
|
font-size: 0;
|
||||||
}
|
}
|
||||||
@ -1778,6 +1868,10 @@ div#recent-resolutions-popup small {
|
|||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div#common-resolution-list button {
|
||||||
|
background: var(--background-color1);
|
||||||
|
}
|
||||||
|
|
||||||
td#image-size-options small {
|
td#image-size-options small {
|
||||||
margin-right: 0px !important;
|
margin-right: 0px !important;
|
||||||
}
|
}
|
||||||
@ -1794,6 +1888,27 @@ div#enlarge-buttons {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.two-column { display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
grid-template-rows: 1fr;
|
||||||
|
gap: 0px 0.5em;
|
||||||
|
grid-auto-flow: row;
|
||||||
|
grid-template-areas:
|
||||||
|
"left-column right-column";
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-column {
|
||||||
|
justify-self: center;
|
||||||
|
align-self: center;
|
||||||
|
grid-area: left-column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-column {
|
||||||
|
justify-self: center;
|
||||||
|
align-self: center;
|
||||||
|
grid-area: right-column;
|
||||||
|
}
|
||||||
|
|
||||||
.clickable {
|
.clickable {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
@ -1828,7 +1943,100 @@ div#enlarge-buttons {
|
|||||||
width: 77%;
|
width: 77%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.drop-area {
|
||||||
|
width: 45%;
|
||||||
|
height: 50px;
|
||||||
|
border: 2px dashed #ccc;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 50px;
|
||||||
|
font-size: small;
|
||||||
|
color: #ccc;
|
||||||
|
border-radius: 10px;
|
||||||
|
display: none;
|
||||||
|
margin: 12px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#num_outputs_total {
|
||||||
|
width: 42pt;
|
||||||
|
}
|
||||||
|
#num_outputs_parallel {
|
||||||
|
width: 42pt;
|
||||||
|
}
|
||||||
|
.model_entry .model_weight {
|
||||||
|
width: 50pt;
|
||||||
|
}
|
||||||
|
|
||||||
/* hack for fixing Image Modifier Improvements plugin */
|
/* hack for fixing Image Modifier Improvements plugin */
|
||||||
#imageTagPopupContainer {
|
#imageTagPopupContainer {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 400px) {
|
||||||
|
.editor-slider {
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
input::-webkit-outer-spin-button,
|
||||||
|
input::-webkit-inner-spin-button {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
input[type=number] {
|
||||||
|
-moz-appearance: textfield;
|
||||||
|
/* Firefox */
|
||||||
|
}
|
||||||
|
#num_outputs_total {
|
||||||
|
width: 27pt;
|
||||||
|
}
|
||||||
|
#num_outputs_parallel {
|
||||||
|
width: 27pt;
|
||||||
|
margin-left: -4pt;
|
||||||
|
}
|
||||||
|
.model_entry .model_weight {
|
||||||
|
width: 30pt;
|
||||||
|
}
|
||||||
|
#width {
|
||||||
|
width: 50pt;
|
||||||
|
}
|
||||||
|
#height {
|
||||||
|
width: 50pt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media screen and (max-width: 460px) {
|
||||||
|
#widthLabel small span {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#widthLabel small:after {
|
||||||
|
content: "(w)";
|
||||||
|
}
|
||||||
|
#heightLabel small span {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#heightLabel small:after {
|
||||||
|
content: "(h)";
|
||||||
|
}
|
||||||
|
#prompt-toolbar-right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
#editor-settings label {
|
||||||
|
font-size: 9pt;
|
||||||
|
}
|
||||||
|
#editor-settings .model-filter {
|
||||||
|
width: 56%;
|
||||||
|
}
|
||||||
|
#vae_model {
|
||||||
|
width: 65% !important;
|
||||||
|
}
|
||||||
|
.model_entry .model_name {
|
||||||
|
width: 60% !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#supportBanner {
|
||||||
|
font-size: 9pt;
|
||||||
|
padding: 5pt;
|
||||||
|
border: 1px solid var(--background-color2);
|
||||||
|
margin-bottom: 5pt;
|
||||||
|
border-radius: 4pt;
|
||||||
|
padding-top: 6pt;
|
||||||
|
color: var(--small-label-color);
|
||||||
|
}
|
||||||
|
BIN
ui/media/images/noimg.png
Normal file
BIN
ui/media/images/noimg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -15,14 +15,12 @@ const SETTINGS_IDS_LIST = [
|
|||||||
"stable_diffusion_model",
|
"stable_diffusion_model",
|
||||||
"clip_skip",
|
"clip_skip",
|
||||||
"vae_model",
|
"vae_model",
|
||||||
"hypernetwork_model",
|
|
||||||
"sampler_name",
|
"sampler_name",
|
||||||
"width",
|
"width",
|
||||||
"height",
|
"height",
|
||||||
"num_inference_steps",
|
"num_inference_steps",
|
||||||
"guidance_scale",
|
"guidance_scale",
|
||||||
"prompt_strength",
|
"prompt_strength",
|
||||||
"hypernetwork_strength",
|
|
||||||
"tiling",
|
"tiling",
|
||||||
"output_format",
|
"output_format",
|
||||||
"output_quality",
|
"output_quality",
|
||||||
@ -45,6 +43,7 @@ const SETTINGS_IDS_LIST = [
|
|||||||
"sound_toggle",
|
"sound_toggle",
|
||||||
"vram_usage_level",
|
"vram_usage_level",
|
||||||
"confirm_dangerous_actions",
|
"confirm_dangerous_actions",
|
||||||
|
"profileName",
|
||||||
"metadata_output_format",
|
"metadata_output_format",
|
||||||
"auto_save_settings",
|
"auto_save_settings",
|
||||||
"apply_color_correction",
|
"apply_color_correction",
|
||||||
@ -54,10 +53,19 @@ const SETTINGS_IDS_LIST = [
|
|||||||
"zip_toggle",
|
"zip_toggle",
|
||||||
"tree_toggle",
|
"tree_toggle",
|
||||||
"json_toggle",
|
"json_toggle",
|
||||||
|
"extract_lora_from_prompt",
|
||||||
|
"embedding-card-size-selector",
|
||||||
|
"lora_model",
|
||||||
|
"enable_vae_tiling",
|
||||||
]
|
]
|
||||||
|
|
||||||
const IGNORE_BY_DEFAULT = ["prompt"]
|
const IGNORE_BY_DEFAULT = ["prompt"]
|
||||||
|
|
||||||
|
if (!testDiffusers.checked) {
|
||||||
|
SETTINGS_IDS_LIST.push("hypernetwork_model")
|
||||||
|
SETTINGS_IDS_LIST.push("hypernetwork_strength")
|
||||||
|
}
|
||||||
|
|
||||||
const SETTINGS_SECTIONS = [
|
const SETTINGS_SECTIONS = [
|
||||||
// gets the "keys" property filled in with an ordered list of settings in this section via initSettings
|
// gets the "keys" property filled in with an ordered list of settings in this section via initSettings
|
||||||
{ id: "editor-inputs", name: "Prompt" },
|
{ id: "editor-inputs", name: "Prompt" },
|
||||||
|
1189
ui/media/js/croppr.js
Executable file
1189
ui/media/js/croppr.js
Executable file
File diff suppressed because it is too large
Load Diff
@ -268,7 +268,11 @@ const TASK_MAPPING = {
|
|||||||
tiling: {
|
tiling: {
|
||||||
name: "Tiling",
|
name: "Tiling",
|
||||||
setUI: (val) => {
|
setUI: (val) => {
|
||||||
|
if (val === null || val === "None") {
|
||||||
|
tilingField.value = "none"
|
||||||
|
} else {
|
||||||
tilingField.value = val
|
tilingField.value = val
|
||||||
|
}
|
||||||
},
|
},
|
||||||
readUI: () => tilingField.value,
|
readUI: () => tilingField.value,
|
||||||
parse: (val) => val,
|
parse: (val) => val,
|
||||||
@ -289,42 +293,56 @@ const TASK_MAPPING = {
|
|||||||
readUI: () => vaeModelField.value,
|
readUI: () => vaeModelField.value,
|
||||||
parse: (val) => val,
|
parse: (val) => val,
|
||||||
},
|
},
|
||||||
|
use_controlnet_model: {
|
||||||
|
name: "ControlNet model",
|
||||||
|
setUI: (use_controlnet_model) => {
|
||||||
|
controlnetModelField.value = getModelPath(use_controlnet_model, [".pth", ".safetensors"])
|
||||||
|
},
|
||||||
|
readUI: () => controlnetModelField.value,
|
||||||
|
parse: (val) => val,
|
||||||
|
},
|
||||||
|
control_filter_to_apply: {
|
||||||
|
name: "ControlNet Filter",
|
||||||
|
setUI: (control_filter_to_apply) => {
|
||||||
|
controlImageFilterField.value = control_filter_to_apply
|
||||||
|
},
|
||||||
|
readUI: () => controlImageFilterField.value,
|
||||||
|
parse: (val) => val,
|
||||||
|
},
|
||||||
use_lora_model: {
|
use_lora_model: {
|
||||||
name: "LoRA model",
|
name: "LoRA model",
|
||||||
setUI: (use_lora_model) => {
|
setUI: (use_lora_model) => {
|
||||||
// create rows
|
let modelPaths = []
|
||||||
for (let i = loraModels.length; i < use_lora_model.length; i++) {
|
use_lora_model = Array.isArray(use_lora_model) ? use_lora_model : [use_lora_model]
|
||||||
createLoraEntry()
|
use_lora_model.forEach((m) => {
|
||||||
|
if (m.includes("models\\lora\\")) {
|
||||||
|
m = m.split("models\\lora\\")[1]
|
||||||
|
} else if (m.includes("models\\\\lora\\\\")) {
|
||||||
|
m = m.split("models\\\\lora\\\\")[1]
|
||||||
|
} else if (m.includes("models/lora/")) {
|
||||||
|
m = m.split("models/lora/")[1]
|
||||||
}
|
}
|
||||||
|
m = m.replaceAll("\\\\", "/")
|
||||||
use_lora_model.forEach((model_name, i) => {
|
m = getModelPath(m, [".ckpt", ".safetensors"])
|
||||||
let field = loraModels[i][0]
|
modelPaths.push(m)
|
||||||
const oldVal = field.value
|
|
||||||
|
|
||||||
if (model_name !== "") {
|
|
||||||
model_name = getModelPath(model_name, [".ckpt", ".safetensors"])
|
|
||||||
model_name = model_name !== "" ? model_name : oldVal
|
|
||||||
}
|
|
||||||
field.value = model_name
|
|
||||||
})
|
})
|
||||||
|
loraModelField.modelNames = modelPaths
|
||||||
// clear the remaining entries
|
|
||||||
let container = document.querySelector("#lora_model_container .model_entries")
|
|
||||||
for (let i = use_lora_model.length; i < loraModels.length; i++) {
|
|
||||||
let modelEntry = loraModels[i][2]
|
|
||||||
container.removeChild(modelEntry)
|
|
||||||
}
|
|
||||||
|
|
||||||
loraModels.splice(use_lora_model.length)
|
|
||||||
},
|
},
|
||||||
readUI: () => {
|
readUI: () => {
|
||||||
let values = loraModels.map((e) => e[0].value)
|
return loraModelField.modelNames
|
||||||
values = values.filter((e) => e.trim() !== "")
|
|
||||||
values = values.length > 0 ? values : "None"
|
|
||||||
return values
|
|
||||||
},
|
},
|
||||||
parse: (val) => {
|
parse: (val) => {
|
||||||
val = !val || val === "None" ? "" : val
|
val = !val || val === "None" ? "" : val
|
||||||
|
if (typeof val === "string" && val.includes(",")) {
|
||||||
|
val = val.split(",")
|
||||||
|
val = val.map((v) => v.trim())
|
||||||
|
val = val.map((v) => v.replaceAll("\\", "\\\\"))
|
||||||
|
val = val.map((v) => v.replaceAll('"', ""))
|
||||||
|
val = val.map((v) => v.replaceAll("'", ""))
|
||||||
|
val = val.map((v) => '"' + v + '"')
|
||||||
|
val = "[" + val + "]"
|
||||||
|
val = JSON.parse(val)
|
||||||
|
}
|
||||||
val = Array.isArray(val) ? val : [val]
|
val = Array.isArray(val) ? val : [val]
|
||||||
return val
|
return val
|
||||||
},
|
},
|
||||||
@ -332,31 +350,17 @@ const TASK_MAPPING = {
|
|||||||
lora_alpha: {
|
lora_alpha: {
|
||||||
name: "LoRA Strength",
|
name: "LoRA Strength",
|
||||||
setUI: (lora_alpha) => {
|
setUI: (lora_alpha) => {
|
||||||
for (let i = loraModels.length; i < lora_alpha.length; i++) {
|
lora_alpha = Array.isArray(lora_alpha) ? lora_alpha : [lora_alpha]
|
||||||
createLoraEntry()
|
loraModelField.modelWeights = lora_alpha
|
||||||
}
|
|
||||||
|
|
||||||
lora_alpha.forEach((model_strength, i) => {
|
|
||||||
let field = loraModels[i][1]
|
|
||||||
field.value = model_strength
|
|
||||||
})
|
|
||||||
|
|
||||||
// clear the remaining entries
|
|
||||||
let container = document.querySelector("#lora_model_container .model_entries")
|
|
||||||
for (let i = lora_alpha.length; i < loraModels.length; i++) {
|
|
||||||
let modelEntry = loraModels[i][2]
|
|
||||||
container.removeChild(modelEntry)
|
|
||||||
}
|
|
||||||
|
|
||||||
loraModels.splice(lora_alpha.length)
|
|
||||||
},
|
},
|
||||||
readUI: () => {
|
readUI: () => {
|
||||||
let models = loraModels.filter((e) => e[0].value.trim() !== "")
|
return loraModelField.modelWeights
|
||||||
let values = models.map((e) => e[1].value)
|
|
||||||
values = values.length > 0 ? values : 0
|
|
||||||
return values
|
|
||||||
},
|
},
|
||||||
parse: (val) => {
|
parse: (val) => {
|
||||||
|
if (typeof val === "string" && val.includes(",")) {
|
||||||
|
val = "[" + val.replaceAll("'", '"') + "]"
|
||||||
|
val = JSON.parse(val)
|
||||||
|
}
|
||||||
val = Array.isArray(val) ? val : [val]
|
val = Array.isArray(val) ? val : [val]
|
||||||
val = val.map((e) => parseFloat(e))
|
val = val.map((e) => parseFloat(e))
|
||||||
return val
|
return val
|
||||||
@ -472,11 +476,8 @@ function restoreTaskToUI(task, fieldsToSkip) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!("use_lora_model" in task.reqBody)) {
|
if (!("use_lora_model" in task.reqBody)) {
|
||||||
loraModels.forEach((e) => {
|
loraModelField.modelNames = []
|
||||||
e[0].value = ""
|
loraModelField.modelWeights = []
|
||||||
e[1].value = 0
|
|
||||||
e[0].dispatchEvent(new Event("change"))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore the original prompt if provided (e.g. use settings), fallback to prompt as needed (e.g. copy/paste or d&d)
|
// restore the original prompt if provided (e.g. use settings), fallback to prompt as needed (e.g. copy/paste or d&d)
|
||||||
@ -519,10 +520,23 @@ function restoreTaskToUI(task, fieldsToSkip) {
|
|||||||
)
|
)
|
||||||
initImagePreview.src = task.reqBody.init_image
|
initImagePreview.src = task.reqBody.init_image
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hide/show controlnet picture as needed
|
||||||
|
if (IMAGE_REGEX.test(controlImagePreview.src) && task.reqBody.control_image == undefined) {
|
||||||
|
// hide source image
|
||||||
|
controlImageClearBtn.dispatchEvent(new Event("click"))
|
||||||
|
} else if (task.reqBody.control_image !== undefined) {
|
||||||
|
// listen for inpainter loading event, which happens AFTER the main image loads (which reloads the inpai
|
||||||
|
controlImagePreview.src = task.reqBody.control_image
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function readUI() {
|
function readUI() {
|
||||||
const reqBody = {}
|
const reqBody = {}
|
||||||
for (const key in TASK_MAPPING) {
|
for (const key in TASK_MAPPING) {
|
||||||
|
if (testDiffusers.checked && (key === "use_hypernetwork_model" || key === "hypernetwork_strength")) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
reqBody[key] = TASK_MAPPING[key].readUI()
|
reqBody[key] = TASK_MAPPING[key].readUI()
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@ -569,6 +583,11 @@ const TASK_TEXT_MAPPING = {
|
|||||||
use_stable_diffusion_model: "Stable Diffusion model",
|
use_stable_diffusion_model: "Stable Diffusion model",
|
||||||
use_hypernetwork_model: "Hypernetwork model",
|
use_hypernetwork_model: "Hypernetwork model",
|
||||||
hypernetwork_strength: "Hypernetwork Strength",
|
hypernetwork_strength: "Hypernetwork Strength",
|
||||||
|
use_lora_model: "LoRA model",
|
||||||
|
lora_alpha: "LoRA Strength",
|
||||||
|
use_controlnet_model: "ControlNet model",
|
||||||
|
control_filter_to_apply: "ControlNet Filter",
|
||||||
|
tiling: "Seamless Tiling",
|
||||||
}
|
}
|
||||||
function parseTaskFromText(str) {
|
function parseTaskFromText(str) {
|
||||||
const taskReqBody = {}
|
const taskReqBody = {}
|
||||||
|
2
ui/media/js/exif-reader.js
Normal file
2
ui/media/js/exif-reader.js
Normal file
File diff suppressed because one or more lines are too long
1239
ui/media/js/main.js
1239
ui/media/js/main.js
File diff suppressed because it is too large
Load Diff
256
ui/media/js/multi-model-selector.js
Normal file
256
ui/media/js/multi-model-selector.js
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
/**
|
||||||
|
* A component consisting of multiple model dropdowns, along with a "weight" field per model.
|
||||||
|
*
|
||||||
|
* Behaves like a single input element, giving an object in response to the .value field.
|
||||||
|
*
|
||||||
|
* Inspired by the design of the ModelDropdown component (searchable-models.js).
|
||||||
|
*/
|
||||||
|
|
||||||
|
class MultiModelSelector {
|
||||||
|
root
|
||||||
|
modelType
|
||||||
|
modelNameFriendly
|
||||||
|
defaultWeight
|
||||||
|
weightStep
|
||||||
|
|
||||||
|
modelContainer
|
||||||
|
addNewButton
|
||||||
|
|
||||||
|
counter = 0
|
||||||
|
|
||||||
|
/* MIMIC A REGULAR INPUT FIELD */
|
||||||
|
get id() {
|
||||||
|
return this.root.id
|
||||||
|
}
|
||||||
|
get parentElement() {
|
||||||
|
return this.root.parentElement
|
||||||
|
}
|
||||||
|
get parentNode() {
|
||||||
|
return this.root.parentNode
|
||||||
|
}
|
||||||
|
get value() {
|
||||||
|
return { modelNames: this.modelNames, modelWeights: this.modelWeights }
|
||||||
|
}
|
||||||
|
set value(modelData) {
|
||||||
|
if (typeof modelData !== "object") {
|
||||||
|
throw new Error("Multi-model selector expects an object containing modelNames and modelWeights as keys!")
|
||||||
|
}
|
||||||
|
if (!("modelNames" in modelData) || !("modelWeights" in modelData)) {
|
||||||
|
throw new Error("modelNames or modelWeights not present in the data passed to the multi-model selector")
|
||||||
|
}
|
||||||
|
|
||||||
|
let newModelNames = modelData["modelNames"]
|
||||||
|
let newModelWeights = modelData["modelWeights"]
|
||||||
|
if (newModelNames.length !== newModelWeights.length) {
|
||||||
|
throw new Error("Need to pass an equal number of modelNames and modelWeights!")
|
||||||
|
}
|
||||||
|
|
||||||
|
// update weight first, name second.
|
||||||
|
// for some unholy reason this order matters for dispatch chains
|
||||||
|
// the root of all this unholiness is because searchable-models automatically dispatches an update event
|
||||||
|
// as soon as the value is updated via JS, which is against the DOM pattern of not dispatching an event automatically
|
||||||
|
// unless the caller explicitly dispatches the event.
|
||||||
|
this.modelWeights = newModelWeights
|
||||||
|
this.modelNames = newModelNames
|
||||||
|
}
|
||||||
|
get disabled() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
set disabled(state) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
getModelElements(ignoreEmpty = false) {
|
||||||
|
let entries = this.root.querySelectorAll(".model_entry")
|
||||||
|
entries = [...entries]
|
||||||
|
let elements = entries.map((e) => {
|
||||||
|
let modelName = e.querySelector(".model_name").field
|
||||||
|
let modelWeight = e.querySelector(".model_weight")
|
||||||
|
if (ignoreEmpty && modelName.value.trim() === "") {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return { name: modelName, weight: modelWeight }
|
||||||
|
})
|
||||||
|
elements = elements.filter((e) => e !== null)
|
||||||
|
return elements
|
||||||
|
}
|
||||||
|
addEventListener(type, listener, options) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
dispatchEvent(event) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
appendChild(option) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
// remember 'this' - http://blog.niftysnippets.org/2008/04/you-must-remember-this.html
|
||||||
|
bind(f, obj) {
|
||||||
|
return function() {
|
||||||
|
return f.apply(obj, arguments)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(root, modelType, modelNameFriendly = undefined, defaultWeight = 0.5, weightStep = 0.02) {
|
||||||
|
this.root = root
|
||||||
|
this.modelType = modelType
|
||||||
|
this.modelNameFriendly = modelNameFriendly || modelType
|
||||||
|
this.defaultWeight = defaultWeight
|
||||||
|
this.weightStep = weightStep
|
||||||
|
|
||||||
|
let self = this
|
||||||
|
document.addEventListener("refreshModels", function() {
|
||||||
|
setTimeout(self.bind(self.populateModels, self), 1)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.createStructure()
|
||||||
|
this.populateModels()
|
||||||
|
}
|
||||||
|
|
||||||
|
createStructure() {
|
||||||
|
this.modelContainer = document.createElement("div")
|
||||||
|
this.modelContainer.className = "model_entries"
|
||||||
|
this.root.appendChild(this.modelContainer)
|
||||||
|
|
||||||
|
this.addNewButton = document.createElement("button")
|
||||||
|
this.addNewButton.className = "add_model_entry"
|
||||||
|
this.addNewButton.innerHTML = '<i class="fa-solid fa-plus"></i> add another ' + this.modelNameFriendly
|
||||||
|
this.addNewButton.addEventListener("click", this.bind(this.addModelEntry, this))
|
||||||
|
this.root.appendChild(this.addNewButton)
|
||||||
|
}
|
||||||
|
|
||||||
|
populateModels() {
|
||||||
|
if (this.root.dataset.path === "") {
|
||||||
|
if (this.length === 0) {
|
||||||
|
this.addModelEntry() // create a single blank entry
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.value = JSON.parse(this.root.dataset.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addModelEntry() {
|
||||||
|
let idx = this.counter++
|
||||||
|
let currLength = this.length
|
||||||
|
|
||||||
|
const modelElement = document.createElement("div")
|
||||||
|
modelElement.className = "model_entry"
|
||||||
|
modelElement.innerHTML = `
|
||||||
|
<input id="${this.modelType}_${idx}" class="model_name model-filter" type="text" spellcheck="false" autocomplete="off" data-path="" />
|
||||||
|
<input class="model_weight" type="number" step="${this.weightStep}" value="${this.defaultWeight}" pattern="^-?[0-9]*\.?[0-9]*$" onkeypress="preventNonNumericalInput(event)">
|
||||||
|
`
|
||||||
|
this.modelContainer.appendChild(modelElement)
|
||||||
|
|
||||||
|
let modelNameEl = modelElement.querySelector(".model_name")
|
||||||
|
modelNameEl.field = new ModelDropdown(modelNameEl, this.modelType, "None")
|
||||||
|
let modelWeightEl = modelElement.querySelector(".model_weight")
|
||||||
|
|
||||||
|
let self = this
|
||||||
|
|
||||||
|
function makeUpdateEvent(type) {
|
||||||
|
return function(e) {
|
||||||
|
e.stopPropagation()
|
||||||
|
|
||||||
|
let modelData = self.value
|
||||||
|
self.root.dataset.path = JSON.stringify(modelData)
|
||||||
|
|
||||||
|
self.root.dispatchEvent(new Event(type))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modelNameEl.addEventListener("change", makeUpdateEvent("change"))
|
||||||
|
modelNameEl.addEventListener("input", makeUpdateEvent("input"))
|
||||||
|
modelWeightEl.addEventListener("change", makeUpdateEvent("change"))
|
||||||
|
modelWeightEl.addEventListener("input", makeUpdateEvent("input"))
|
||||||
|
|
||||||
|
let removeBtn = document.createElement("button")
|
||||||
|
removeBtn.className = "remove_model_btn"
|
||||||
|
removeBtn.setAttribute("title", "Remove model")
|
||||||
|
removeBtn.innerHTML = '<i class="fa-solid fa-minus"></i>'
|
||||||
|
|
||||||
|
if (currLength === 0) {
|
||||||
|
removeBtn.classList.add("displayNone")
|
||||||
|
}
|
||||||
|
|
||||||
|
removeBtn.addEventListener(
|
||||||
|
"click",
|
||||||
|
this.bind(function(e) {
|
||||||
|
this.modelContainer.removeChild(modelElement)
|
||||||
|
|
||||||
|
makeUpdateEvent("change")(e)
|
||||||
|
}, this)
|
||||||
|
)
|
||||||
|
|
||||||
|
modelElement.appendChild(removeBtn)
|
||||||
|
}
|
||||||
|
|
||||||
|
removeModelEntry() {
|
||||||
|
if (this.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let lastEntry = this.modelContainer.lastElementChild
|
||||||
|
lastEntry.remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
get length() {
|
||||||
|
return this.getModelElements().length
|
||||||
|
}
|
||||||
|
|
||||||
|
get modelNames() {
|
||||||
|
return this.getModelElements(true).map((e) => e.name.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
set modelNames(newModelNames) {
|
||||||
|
this.resizeEntryList(newModelNames.length)
|
||||||
|
|
||||||
|
if (newModelNames.length === 0) {
|
||||||
|
this.getModelElements()[0].name.value = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// assign to the corresponding elements
|
||||||
|
let currElements = this.getModelElements()
|
||||||
|
for (let i = 0; i < newModelNames.length; i++) {
|
||||||
|
let curr = currElements[i]
|
||||||
|
|
||||||
|
curr.name.value = newModelNames[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get modelWeights() {
|
||||||
|
return this.getModelElements(true).map((e) => e.weight.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
set modelWeights(newModelWeights) {
|
||||||
|
this.resizeEntryList(newModelWeights.length)
|
||||||
|
|
||||||
|
if (newModelWeights.length === 0) {
|
||||||
|
this.getModelElements()[0].weight.value = this.defaultWeight
|
||||||
|
}
|
||||||
|
|
||||||
|
// assign to the corresponding elements
|
||||||
|
let currElements = this.getModelElements()
|
||||||
|
for (let i = 0; i < newModelWeights.length; i++) {
|
||||||
|
let curr = currElements[i]
|
||||||
|
|
||||||
|
curr.weight.value = newModelWeights[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resizeEntryList(newLength) {
|
||||||
|
if (newLength === 0) {
|
||||||
|
newLength = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
let currLength = this.length
|
||||||
|
if (currLength < newLength) {
|
||||||
|
for (let i = currLength; i < newLength; i++) {
|
||||||
|
this.addModelEntry()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let i = newLength; i < currLength; i++) {
|
||||||
|
this.removeModelEntry()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -97,6 +97,17 @@ var PARAMETERS = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "models_dir",
|
||||||
|
type: ParameterType.custom,
|
||||||
|
icon: "fa-folder-tree",
|
||||||
|
label: "Models Folder",
|
||||||
|
note: "Path to the 'models' folder. Please save and refresh the page after changing this.",
|
||||||
|
saveInAppConfig: true,
|
||||||
|
render: (parameter) => {
|
||||||
|
return `<input id="${parameter.id}" name="${parameter.id}" size="30">`
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "block_nsfw",
|
id: "block_nsfw",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
@ -121,6 +132,15 @@ var PARAMETERS = [
|
|||||||
icon: "fa-arrow-down-short-wide",
|
icon: "fa-arrow-down-short-wide",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "extract_lora_from_prompt",
|
||||||
|
type: ParameterType.checkbox,
|
||||||
|
label: "Extract LoRA tags from the prompt",
|
||||||
|
note:
|
||||||
|
"Automatically extract lora tags like <lora:name:0.4> from the prompt, and apply the correct LoRA (if present)",
|
||||||
|
icon: "fa-code",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "ui_open_browser_on_start",
|
id: "ui_open_browser_on_start",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
@ -185,6 +205,17 @@ var PARAMETERS = [
|
|||||||
icon: "fa-check-double",
|
icon: "fa-check-double",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "profileName",
|
||||||
|
type: ParameterType.custom,
|
||||||
|
label: "Profile Name",
|
||||||
|
note:
|
||||||
|
"Name of the profile for model manager settings, e.g. thumbnails for embeddings. Use this to have different settings for different users.",
|
||||||
|
render: (parameter) => {
|
||||||
|
return `<input id="${parameter.id}" name="${parameter.id}" value="default" size="12">`
|
||||||
|
},
|
||||||
|
icon: "fa-user-gear",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "listen_to_network",
|
id: "listen_to_network",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
@ -218,13 +249,13 @@ var PARAMETERS = [
|
|||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "test_diffusers",
|
id: "use_v3_engine",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Test Diffusers",
|
label: "Use the new v3 engine (diffusers)",
|
||||||
note:
|
note:
|
||||||
"<b>Experimental! Can have bugs!</b> Use upcoming features (like LoRA) in our new engine. Please press Save, then restart the program after changing this.",
|
"Use our new v3 engine, with additional features like LoRA, ControlNet, SDXL, Embeddings, Tiling and lots more! Please press Save, then restart the program after changing this.",
|
||||||
icon: "fa-bolt",
|
icon: "fa-bolt",
|
||||||
default: false,
|
default: true,
|
||||||
saveInAppConfig: true,
|
saveInAppConfig: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -400,7 +431,9 @@ let listenPortField = document.querySelector("#listen_port")
|
|||||||
let useBetaChannelField = document.querySelector("#use_beta_channel")
|
let useBetaChannelField = document.querySelector("#use_beta_channel")
|
||||||
let uiOpenBrowserOnStartField = document.querySelector("#ui_open_browser_on_start")
|
let uiOpenBrowserOnStartField = document.querySelector("#ui_open_browser_on_start")
|
||||||
let confirmDangerousActionsField = document.querySelector("#confirm_dangerous_actions")
|
let confirmDangerousActionsField = document.querySelector("#confirm_dangerous_actions")
|
||||||
let testDiffusers = document.querySelector("#test_diffusers")
|
let testDiffusers = document.querySelector("#use_v3_engine")
|
||||||
|
let profileNameField = document.querySelector("#profileName")
|
||||||
|
let modelsDirField = document.querySelector("#models_dir")
|
||||||
|
|
||||||
let saveSettingsBtn = document.querySelector("#save-system-settings-btn")
|
let saveSettingsBtn = document.querySelector("#save-system-settings-btn")
|
||||||
|
|
||||||
@ -432,8 +465,6 @@ async function getAppConfig() {
|
|||||||
if (config.update_branch === "beta") {
|
if (config.update_branch === "beta") {
|
||||||
useBetaChannelField.checked = true
|
useBetaChannelField.checked = true
|
||||||
document.querySelector("#updateBranchLabel").innerText = "(beta)"
|
document.querySelector("#updateBranchLabel").innerText = "(beta)"
|
||||||
} else {
|
|
||||||
getParameterSettingsEntry("test_diffusers").classList.add("displayNone")
|
|
||||||
}
|
}
|
||||||
if (config.ui && config.ui.open_browser_on_start === false) {
|
if (config.ui && config.ui.open_browser_on_start === false) {
|
||||||
uiOpenBrowserOnStartField.checked = false
|
uiOpenBrowserOnStartField.checked = false
|
||||||
@ -444,12 +475,17 @@ async function getAppConfig() {
|
|||||||
if (config.net && config.net.listen_port !== undefined) {
|
if (config.net && config.net.listen_port !== undefined) {
|
||||||
listenPortField.value = config.net.listen_port
|
listenPortField.value = config.net.listen_port
|
||||||
}
|
}
|
||||||
|
modelsDirField.value = config.models_dir
|
||||||
|
|
||||||
const testDiffusersEnabled = config.test_diffusers && config.update_branch !== "main"
|
let testDiffusersEnabled = true
|
||||||
|
if (config.use_v3_engine === false) {
|
||||||
|
testDiffusersEnabled = false
|
||||||
|
}
|
||||||
testDiffusers.checked = testDiffusersEnabled
|
testDiffusers.checked = testDiffusersEnabled
|
||||||
|
document.querySelector("#test_diffusers").checked = testDiffusers.checked // don't break plugins
|
||||||
|
|
||||||
if (config.config_on_startup) {
|
if (config.config_on_startup) {
|
||||||
if (config.config_on_startup?.test_diffusers && config.update_branch !== "main") {
|
if (config.config_on_startup?.use_v3_engine) {
|
||||||
document.body.classList.add("diffusers-enabled-on-startup")
|
document.body.classList.add("diffusers-enabled-on-startup")
|
||||||
document.body.classList.remove("diffusers-disabled-on-startup")
|
document.body.classList.remove("diffusers-disabled-on-startup")
|
||||||
} else {
|
} else {
|
||||||
@ -462,7 +498,9 @@ async function getAppConfig() {
|
|||||||
document.querySelector("#lora_model_container").style.display = "none"
|
document.querySelector("#lora_model_container").style.display = "none"
|
||||||
document.querySelector("#tiling_container").style.display = "none"
|
document.querySelector("#tiling_container").style.display = "none"
|
||||||
document.querySelector("#controlnet_model_container").style.display = "none"
|
document.querySelector("#controlnet_model_container").style.display = "none"
|
||||||
|
document.querySelector("#hypernetwork_model_container").style.display = ""
|
||||||
document.querySelector("#hypernetwork_strength_container").style.display = ""
|
document.querySelector("#hypernetwork_strength_container").style.display = ""
|
||||||
|
document.querySelector("#negative-embeddings-button").style.display = "none"
|
||||||
|
|
||||||
document.querySelectorAll("#sampler_name option.diffusers-only").forEach((option) => {
|
document.querySelectorAll("#sampler_name option.diffusers-only").forEach((option) => {
|
||||||
option.style.display = "none"
|
option.style.display = "none"
|
||||||
@ -474,6 +512,7 @@ async function getAppConfig() {
|
|||||||
document.querySelector("#lora_model_container").style.display = ""
|
document.querySelector("#lora_model_container").style.display = ""
|
||||||
document.querySelector("#tiling_container").style.display = ""
|
document.querySelector("#tiling_container").style.display = ""
|
||||||
document.querySelector("#controlnet_model_container").style.display = ""
|
document.querySelector("#controlnet_model_container").style.display = ""
|
||||||
|
document.querySelector("#hypernetwork_model_container").style.display = "none"
|
||||||
document.querySelector("#hypernetwork_strength_container").style.display = "none"
|
document.querySelector("#hypernetwork_strength_container").style.display = "none"
|
||||||
|
|
||||||
document.querySelectorAll("#sampler_name option.k_diffusion-only").forEach((option) => {
|
document.querySelectorAll("#sampler_name option.k_diffusion-only").forEach((option) => {
|
||||||
@ -481,12 +520,15 @@ async function getAppConfig() {
|
|||||||
})
|
})
|
||||||
document.querySelector("#clip_skip_config").classList.remove("displayNone")
|
document.querySelector("#clip_skip_config").classList.remove("displayNone")
|
||||||
document.querySelector("#embeddings-button").classList.remove("displayNone")
|
document.querySelector("#embeddings-button").classList.remove("displayNone")
|
||||||
document.querySelector("#negative-embeddings-button").classList.remove("displayNone")
|
|
||||||
IMAGE_STEP_SIZE = 8
|
IMAGE_STEP_SIZE = 8
|
||||||
customWidthField.step = IMAGE_STEP_SIZE
|
customWidthField.step = IMAGE_STEP_SIZE
|
||||||
customHeightField.step = IMAGE_STEP_SIZE
|
customHeightField.step = IMAGE_STEP_SIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.force_save_metadata) {
|
||||||
|
metadataOutputFormatField.value = config.force_save_metadata
|
||||||
|
}
|
||||||
|
|
||||||
console.log("get config status response", config)
|
console.log("get config status response", config)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
@ -698,10 +740,13 @@ async function getSystemInfo() {
|
|||||||
force = res["enforce_output_dir"]
|
force = res["enforce_output_dir"]
|
||||||
if (force == true) {
|
if (force == true) {
|
||||||
saveToDiskField.checked = true
|
saveToDiskField.checked = true
|
||||||
metadataOutputFormatField.disabled = false
|
metadataOutputFormatField.disabled = res["enforce_output_metadata"]
|
||||||
|
diskPathField.disabled = true
|
||||||
}
|
}
|
||||||
saveToDiskField.disabled = force
|
saveToDiskField.disabled = force
|
||||||
diskPathField.disabled = force
|
} else {
|
||||||
|
diskPathField.disabled = !saveToDiskField.checked
|
||||||
|
metadataOutputFormatField.disabled = !saveToDiskField.checked
|
||||||
}
|
}
|
||||||
setDiskPath(res["default_output_dir"], force)
|
setDiskPath(res["default_output_dir"], force)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -794,11 +839,3 @@ navigator.permissions.query({ name: "clipboard-write" }).then(function(result) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
document.addEventListener("system_info_update", (e) => setDeviceInfo(e.detail))
|
document.addEventListener("system_info_update", (e) => setDeviceInfo(e.detail))
|
||||||
|
|
||||||
useBetaChannelField.addEventListener("change", (e) => {
|
|
||||||
if (e.target.checked) {
|
|
||||||
getParameterSettingsEntry("test_diffusers").classList.remove("displayNone")
|
|
||||||
} else {
|
|
||||||
getParameterSettingsEntry("test_diffusers").classList.add("displayNone")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
@ -118,14 +118,17 @@ class ModelDropdown {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
saveCurrentSelection(elem, value, path) {
|
saveCurrentSelection(elem, value, path, dispatchEvent = true) {
|
||||||
this.currentSelection.elem = elem
|
this.currentSelection.elem = elem
|
||||||
this.currentSelection.value = value
|
this.currentSelection.value = value
|
||||||
this.currentSelection.path = path
|
this.currentSelection.path = path
|
||||||
this.modelFilter.dataset.path = path
|
this.modelFilter.dataset.path = path
|
||||||
this.modelFilter.value = value
|
this.modelFilter.value = value
|
||||||
|
|
||||||
|
if (dispatchEvent) {
|
||||||
this.modelFilter.dispatchEvent(new Event("change"))
|
this.modelFilter.dispatchEvent(new Event("change"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
processClick(e) {
|
processClick(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@ -348,13 +351,13 @@ class ModelDropdown {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectEntry(path) {
|
selectEntry(path, dispatchEvent = true) {
|
||||||
if (path !== undefined) {
|
if (path !== undefined) {
|
||||||
const entries = this.modelElements
|
const entries = this.modelElements
|
||||||
|
|
||||||
for (const elem of entries) {
|
for (const elem of entries) {
|
||||||
if (elem.dataset.path == path) {
|
if (elem.dataset.path == path) {
|
||||||
this.saveCurrentSelection(elem, elem.innerText, elem.dataset.path)
|
this.saveCurrentSelection(elem, elem.innerText, elem.dataset.path, dispatchEvent)
|
||||||
this.highlightedModelEntry = elem
|
this.highlightedModelEntry = elem
|
||||||
elem.scrollIntoView({ block: "nearest" })
|
elem.scrollIntoView({ block: "nearest" })
|
||||||
break
|
break
|
||||||
@ -529,7 +532,7 @@ class ModelDropdown {
|
|||||||
rootModelList.style.minWidth = modelFilterStyle.width
|
rootModelList.style.minWidth = modelFilterStyle.width
|
||||||
})
|
})
|
||||||
|
|
||||||
this.selectEntry(this.activeModel)
|
this.selectEntry(this.activeModel, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
409
ui/media/js/task-manager.js
Normal file
409
ui/media/js/task-manager.js
Normal file
@ -0,0 +1,409 @@
|
|||||||
|
const htmlTaskMap = new WeakMap()
|
||||||
|
|
||||||
|
const pauseBtn = document.querySelector("#pause")
|
||||||
|
const resumeBtn = document.querySelector("#resume")
|
||||||
|
const processOrder = document.querySelector("#process_order_toggle")
|
||||||
|
|
||||||
|
let pauseClient = false
|
||||||
|
|
||||||
|
async function onIdle() {
|
||||||
|
const serverCapacity = SD.serverCapacity
|
||||||
|
if (pauseClient === true) {
|
||||||
|
await resumeClient()
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const taskEntry of getUncompletedTaskEntries()) {
|
||||||
|
if (SD.activeTasks.size >= serverCapacity) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
const task = htmlTaskMap.get(taskEntry)
|
||||||
|
if (!task) {
|
||||||
|
const taskStatusLabel = taskEntry.querySelector(".taskStatusLabel")
|
||||||
|
taskStatusLabel.style.display = "none"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
await onTaskStart(task)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUncompletedTaskEntries() {
|
||||||
|
const taskEntries = Array.from(document.querySelectorAll("#preview .imageTaskContainer .taskStatusLabel"))
|
||||||
|
.filter((taskLabel) => taskLabel.style.display !== "none")
|
||||||
|
.map(function(taskLabel) {
|
||||||
|
let imageTaskContainer = taskLabel.parentNode
|
||||||
|
while (!imageTaskContainer.classList.contains("imageTaskContainer") && imageTaskContainer.parentNode) {
|
||||||
|
imageTaskContainer = imageTaskContainer.parentNode
|
||||||
|
}
|
||||||
|
return imageTaskContainer
|
||||||
|
})
|
||||||
|
if (!processOrder.checked) {
|
||||||
|
taskEntries.reverse()
|
||||||
|
}
|
||||||
|
return taskEntries
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onTaskStart(task) {
|
||||||
|
if (!task.isProcessing || task.batchesDone >= task.batchCount) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof task.startTime !== "number") {
|
||||||
|
task.startTime = Date.now()
|
||||||
|
}
|
||||||
|
if (!("instances" in task)) {
|
||||||
|
task["instances"] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
task["stopTask"].innerHTML = '<i class="fa-solid fa-circle-stop"></i> Stop'
|
||||||
|
task["taskStatusLabel"].innerText = "Starting"
|
||||||
|
task["taskStatusLabel"].classList.add("waitingTaskLabel")
|
||||||
|
|
||||||
|
if (task.previewTaskReq !== undefined) {
|
||||||
|
let controlImagePreview = task.taskConfig.querySelector(".controlnet-img-preview > img")
|
||||||
|
try {
|
||||||
|
let result = await SD.filter(task.previewTaskReq)
|
||||||
|
|
||||||
|
controlImagePreview.src = result.output[0]
|
||||||
|
let controlImageLargePreview = task.taskConfig.querySelector(
|
||||||
|
".controlnet-img-preview .task-fs-initimage img"
|
||||||
|
)
|
||||||
|
controlImageLargePreview.src = controlImagePreview.src
|
||||||
|
} catch (error) {
|
||||||
|
console.log("filter error", error)
|
||||||
|
}
|
||||||
|
|
||||||
|
delete task.previewTaskReq
|
||||||
|
}
|
||||||
|
|
||||||
|
let newTaskReqBody = task.reqBody
|
||||||
|
if (task.batchCount > 1) {
|
||||||
|
// Each output render batch needs it's own task reqBody instance to avoid altering the other runs after they are completed.
|
||||||
|
newTaskReqBody = Object.assign({}, task.reqBody)
|
||||||
|
if (task.batchesDone == task.batchCount - 1) {
|
||||||
|
// Last batch of the task
|
||||||
|
// If the number of parallel jobs is no factor of the total number of images, the last batch must create less than "parallel jobs count" images
|
||||||
|
// E.g. with numOutputsTotal = 6 and num_outputs = 5, the last batch shall only generate 1 image.
|
||||||
|
newTaskReqBody.num_outputs = task.numOutputsTotal - task.reqBody.num_outputs * (task.batchCount - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const startSeed = task.seed || newTaskReqBody.seed
|
||||||
|
const genSeeds = Boolean(
|
||||||
|
typeof newTaskReqBody.seed !== "number" || (newTaskReqBody.seed === task.seed && task.numOutputsTotal > 1)
|
||||||
|
)
|
||||||
|
if (genSeeds) {
|
||||||
|
newTaskReqBody.seed = parseInt(startSeed) + task.batchesDone * task.reqBody.num_outputs
|
||||||
|
}
|
||||||
|
|
||||||
|
const outputContainer = document.createElement("div")
|
||||||
|
outputContainer.className = "img-batch"
|
||||||
|
task.outputContainer.insertBefore(outputContainer, task.outputContainer.firstChild)
|
||||||
|
|
||||||
|
const eventInfo = { reqBody: newTaskReqBody }
|
||||||
|
const callbacksPromises = PLUGINS["TASK_CREATE"].map((hook) => {
|
||||||
|
if (typeof hook !== "function") {
|
||||||
|
console.error("The provided TASK_CREATE hook is not a function. Hook: %o", hook)
|
||||||
|
return Promise.reject(new Error("hook is not a function."))
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Promise.resolve(hook.call(task, eventInfo))
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
return Promise.reject(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
await Promise.allSettled(callbacksPromises)
|
||||||
|
let instance = eventInfo.instance
|
||||||
|
if (!instance) {
|
||||||
|
const factory = PLUGINS.OUTPUTS_FORMATS.get(eventInfo.reqBody?.output_format || newTaskReqBody.output_format)
|
||||||
|
if (factory) {
|
||||||
|
instance = await Promise.resolve(factory(eventInfo.reqBody || newTaskReqBody))
|
||||||
|
}
|
||||||
|
if (!instance) {
|
||||||
|
console.error(
|
||||||
|
`${factory ? "Factory " + String(factory) : "No factory defined"} for output format ${eventInfo.reqBody
|
||||||
|
?.output_format || newTaskReqBody.output_format}. Instance is ${instance ||
|
||||||
|
"undefined"}. Using default renderer.`
|
||||||
|
)
|
||||||
|
instance = new SD.RenderTask(eventInfo.reqBody || newTaskReqBody)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task["instances"].push(instance)
|
||||||
|
task.batchesDone++
|
||||||
|
|
||||||
|
document.dispatchEvent(new CustomEvent("before_task_start", { detail: { task: task } }))
|
||||||
|
|
||||||
|
instance.enqueue(getTaskUpdater(task, newTaskReqBody, outputContainer)).then(
|
||||||
|
(renderResult) => {
|
||||||
|
onRenderTaskCompleted(task, newTaskReqBody, instance, outputContainer, renderResult)
|
||||||
|
},
|
||||||
|
(reason) => {
|
||||||
|
onTaskErrorHandler(task, newTaskReqBody, instance, reason)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
document.dispatchEvent(new CustomEvent("after_task_start", { detail: { task: task } }))
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTaskUpdater(task, reqBody, outputContainer) {
|
||||||
|
const outputMsg = task["outputMsg"]
|
||||||
|
const progressBar = task["progressBar"]
|
||||||
|
const progressBarInner = progressBar.querySelector("div")
|
||||||
|
|
||||||
|
const batchCount = task.batchCount
|
||||||
|
let lastStatus = undefined
|
||||||
|
return async function(event) {
|
||||||
|
if (this.status !== lastStatus) {
|
||||||
|
lastStatus = this.status
|
||||||
|
switch (this.status) {
|
||||||
|
case SD.TaskStatus.pending:
|
||||||
|
task["taskStatusLabel"].innerText = "Pending"
|
||||||
|
task["taskStatusLabel"].classList.add("waitingTaskLabel")
|
||||||
|
break
|
||||||
|
case SD.TaskStatus.waiting:
|
||||||
|
task["taskStatusLabel"].innerText = "Waiting"
|
||||||
|
task["taskStatusLabel"].classList.add("waitingTaskLabel")
|
||||||
|
task["taskStatusLabel"].classList.remove("activeTaskLabel")
|
||||||
|
break
|
||||||
|
case SD.TaskStatus.processing:
|
||||||
|
case SD.TaskStatus.completed:
|
||||||
|
task["taskStatusLabel"].innerText = "Processing"
|
||||||
|
task["taskStatusLabel"].classList.add("activeTaskLabel")
|
||||||
|
task["taskStatusLabel"].classList.remove("waitingTaskLabel")
|
||||||
|
break
|
||||||
|
case SD.TaskStatus.stopped:
|
||||||
|
break
|
||||||
|
case SD.TaskStatus.failed:
|
||||||
|
if (!SD.isServerAvailable()) {
|
||||||
|
logError(
|
||||||
|
"Stable Diffusion is still starting up, please wait. If this goes on beyond a few minutes, Stable Diffusion has probably crashed. Please check the error message in the command-line window.",
|
||||||
|
event,
|
||||||
|
outputMsg
|
||||||
|
)
|
||||||
|
} else if (typeof event?.response === "object") {
|
||||||
|
let msg = "Stable Diffusion had an error reading the response:<br/><pre>"
|
||||||
|
if (this.exception) {
|
||||||
|
msg += `Error: ${this.exception.message}<br/>`
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// 'Response': body stream already read
|
||||||
|
msg += "Read: " + (await event.response.text())
|
||||||
|
} catch (e) {
|
||||||
|
msg += "Unexpected end of stream. "
|
||||||
|
}
|
||||||
|
const bufferString = event.reader.bufferedString
|
||||||
|
if (bufferString) {
|
||||||
|
msg += "Buffered data: " + bufferString
|
||||||
|
}
|
||||||
|
msg += "</pre>"
|
||||||
|
logError(msg, event, outputMsg)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ("update" in event) {
|
||||||
|
const stepUpdate = event.update
|
||||||
|
if (!("step" in stepUpdate)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// task.instances can be a mix of different tasks with uneven number of steps (Render Vs Filter Tasks)
|
||||||
|
const instancesWithProgressUpdates = task.instances.filter((instance) => instance.step !== undefined)
|
||||||
|
const overallStepCount =
|
||||||
|
instancesWithProgressUpdates.reduce(
|
||||||
|
(sum, instance) =>
|
||||||
|
sum +
|
||||||
|
(instance.isPending
|
||||||
|
? Math.max(0, instance.step || stepUpdate.step) /
|
||||||
|
(instance.total_steps || stepUpdate.total_steps)
|
||||||
|
: 1),
|
||||||
|
0 // Initial value
|
||||||
|
) * stepUpdate.total_steps // Scale to current number of steps.
|
||||||
|
const totalSteps = instancesWithProgressUpdates.reduce(
|
||||||
|
(sum, instance) => sum + (instance.total_steps || stepUpdate.total_steps),
|
||||||
|
stepUpdate.total_steps * (batchCount - task.batchesDone) // Initial value at (unstarted task count * Nbr of steps)
|
||||||
|
)
|
||||||
|
const percent = Math.min(100, 100 * (overallStepCount / totalSteps)).toFixed(0)
|
||||||
|
|
||||||
|
const timeTaken = stepUpdate.step_time // sec
|
||||||
|
const stepsRemaining = Math.max(0, totalSteps - overallStepCount)
|
||||||
|
const timeRemaining = timeTaken < 0 ? "" : millisecondsToStr(stepsRemaining * timeTaken * 1000)
|
||||||
|
outputMsg.innerHTML = `Batch ${task.batchesDone} of ${batchCount}. Generating image(s): ${percent}%. Time remaining (approx): ${timeRemaining}`
|
||||||
|
outputMsg.style.display = "block"
|
||||||
|
progressBarInner.style.width = `${percent}%`
|
||||||
|
|
||||||
|
if (stepUpdate.output) {
|
||||||
|
document.dispatchEvent(
|
||||||
|
new CustomEvent("on_task_step", {
|
||||||
|
detail: {
|
||||||
|
task: task,
|
||||||
|
reqBody: reqBody,
|
||||||
|
stepUpdate: stepUpdate,
|
||||||
|
outputContainer: outputContainer,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onRenderTaskCompleted(task, reqBody, instance, outputContainer, stepUpdate) {
|
||||||
|
if (typeof stepUpdate === "object") {
|
||||||
|
if (stepUpdate.status === "succeeded") {
|
||||||
|
document.dispatchEvent(
|
||||||
|
new CustomEvent("on_render_task_success", {
|
||||||
|
detail: {
|
||||||
|
task: task,
|
||||||
|
reqBody: reqBody,
|
||||||
|
stepUpdate: stepUpdate,
|
||||||
|
outputContainer: outputContainer,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
task.isProcessing = false
|
||||||
|
document.dispatchEvent(
|
||||||
|
new CustomEvent("on_render_task_fail", {
|
||||||
|
detail: {
|
||||||
|
task: task,
|
||||||
|
reqBody: reqBody,
|
||||||
|
stepUpdate: stepUpdate,
|
||||||
|
outputContainer: outputContainer,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (task.isProcessing && task.batchesDone < task.batchCount) {
|
||||||
|
task["taskStatusLabel"].innerText = "Pending"
|
||||||
|
task["taskStatusLabel"].classList.add("waitingTaskLabel")
|
||||||
|
task["taskStatusLabel"].classList.remove("activeTaskLabel")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ("instances" in task && task.instances.some((ins) => ins != instance && ins.isPending)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
task.isProcessing = false
|
||||||
|
task["stopTask"].innerHTML = '<i class="fa-solid fa-trash-can"></i> Remove'
|
||||||
|
task["taskStatusLabel"].style.display = "none"
|
||||||
|
|
||||||
|
let time = millisecondsToStr(Date.now() - task.startTime)
|
||||||
|
|
||||||
|
if (task.batchesDone == task.batchCount) {
|
||||||
|
if (!task.outputMsg.innerText.toLowerCase().includes("error")) {
|
||||||
|
task.outputMsg.innerText = `Processed ${task.numOutputsTotal} images in ${time}`
|
||||||
|
}
|
||||||
|
task.progressBar.style.height = "0px"
|
||||||
|
task.progressBar.style.border = "0px solid var(--background-color3)"
|
||||||
|
task.progressBar.classList.remove("active")
|
||||||
|
// setStatus("request", "done", "success")
|
||||||
|
} else {
|
||||||
|
task.outputMsg.innerText += `. Task ended after ${time}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (randomSeedField.checked) { // we already update this before the task starts
|
||||||
|
// seedField.value = task.seed
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (SD.activeTasks.size > 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const uncompletedTasks = getUncompletedTaskEntries()
|
||||||
|
if (uncompletedTasks && uncompletedTasks.length > 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pauseClient) {
|
||||||
|
resumeBtn.click()
|
||||||
|
}
|
||||||
|
|
||||||
|
document.dispatchEvent(
|
||||||
|
new CustomEvent("on_all_tasks_complete", {
|
||||||
|
detail: {},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function resumeClient() {
|
||||||
|
if (pauseClient) {
|
||||||
|
document.body.classList.remove("wait-pause")
|
||||||
|
document.body.classList.add("pause")
|
||||||
|
}
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
let playbuttonclick = function() {
|
||||||
|
resumeBtn.removeEventListener("click", playbuttonclick)
|
||||||
|
resolve("resolved")
|
||||||
|
}
|
||||||
|
resumeBtn.addEventListener("click", playbuttonclick)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function abortTask(task) {
|
||||||
|
if (!task.isProcessing) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
task.isProcessing = false
|
||||||
|
task.progressBar.classList.remove("active")
|
||||||
|
task["taskStatusLabel"].style.display = "none"
|
||||||
|
task["stopTask"].innerHTML = '<i class="fa-solid fa-trash-can"></i> Remove'
|
||||||
|
if (!task.instances?.some((r) => r.isPending)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
task.instances.forEach((instance) => {
|
||||||
|
try {
|
||||||
|
instance.abort()
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function stopAllTasks() {
|
||||||
|
getUncompletedTaskEntries().forEach((taskEntry) => {
|
||||||
|
const taskStatusLabel = taskEntry.querySelector(".taskStatusLabel")
|
||||||
|
if (taskStatusLabel) {
|
||||||
|
taskStatusLabel.style.display = "none"
|
||||||
|
}
|
||||||
|
const task = htmlTaskMap.get(taskEntry)
|
||||||
|
if (!task) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
abortTask(task)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function onTaskErrorHandler(task, reqBody, instance, reason) {
|
||||||
|
if (!task.isProcessing) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log("Render request %o, Instance: %o, Error: %s", reqBody, instance, reason)
|
||||||
|
abortTask(task)
|
||||||
|
const outputMsg = task["outputMsg"]
|
||||||
|
logError(
|
||||||
|
"Stable Diffusion had an error. Please check the logs in the command-line window. <br/><br/>" +
|
||||||
|
reason +
|
||||||
|
"<br/><pre>" +
|
||||||
|
reason.stack +
|
||||||
|
"</pre>",
|
||||||
|
task,
|
||||||
|
outputMsg
|
||||||
|
)
|
||||||
|
// setStatus("request", "error", "error")
|
||||||
|
}
|
||||||
|
|
||||||
|
pauseBtn.addEventListener("click", function() {
|
||||||
|
pauseClient = true
|
||||||
|
pauseBtn.style.display = "none"
|
||||||
|
resumeBtn.style.display = "inline"
|
||||||
|
document.body.classList.add("wait-pause")
|
||||||
|
})
|
||||||
|
|
||||||
|
resumeBtn.addEventListener("click", function() {
|
||||||
|
pauseClient = false
|
||||||
|
resumeBtn.style.display = "none"
|
||||||
|
pauseBtn.style.display = "inline"
|
||||||
|
document.body.classList.remove("pause")
|
||||||
|
document.body.classList.remove("wait-pause")
|
||||||
|
})
|
@ -1097,6 +1097,48 @@ async function deleteKeys(keyToDelete) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {String} Data URL of the image
|
||||||
|
* @param {Integer} Top left X-coordinate of the crop area
|
||||||
|
* @param {Integer} Top left Y-coordinate of the crop area
|
||||||
|
* @param {Integer} Width of the crop area
|
||||||
|
* @param {Integer} Height of the crop area
|
||||||
|
* @return {String}
|
||||||
|
*/
|
||||||
|
function cropImageDataUrl(dataUrl, x, y, width, height) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const image = new Image()
|
||||||
|
image.src = dataUrl
|
||||||
|
|
||||||
|
image.onload = () => {
|
||||||
|
const canvas = document.createElement('canvas')
|
||||||
|
canvas.width = width
|
||||||
|
canvas.height = height
|
||||||
|
|
||||||
|
const ctx = canvas.getContext('2d')
|
||||||
|
ctx.drawImage(image, x, y, width, height, 0, 0, width, height)
|
||||||
|
|
||||||
|
const croppedDataUrl = canvas.toDataURL('image/png')
|
||||||
|
resolve(croppedDataUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
image.onerror = (error) => {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {String} HTML representing a single element
|
||||||
|
* @return {Element}
|
||||||
|
*/
|
||||||
|
function htmlToElement(html) {
|
||||||
|
var template = document.createElement('template');
|
||||||
|
html = html.trim(); // Never return a text node of whitespace as the result
|
||||||
|
template.innerHTML = html;
|
||||||
|
return template.content.firstChild;
|
||||||
|
}
|
||||||
|
|
||||||
function modalDialogCloseOnBackdropClick(dialog) {
|
function modalDialogCloseOnBackdropClick(dialog) {
|
||||||
dialog.addEventListener('mousedown', function (event) {
|
dialog.addEventListener('mousedown', function (event) {
|
||||||
// Firefox creates an event with clientX|Y = 0|0 when choosing an <option>.
|
// Firefox creates an event with clientX|Y = 0|0 when choosing an <option>.
|
||||||
@ -1156,4 +1198,37 @@ function makeDialogDraggable(element) {
|
|||||||
})() )
|
})() )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function logMsg(msg, level, outputMsg) {
|
||||||
|
if (outputMsg.hasChildNodes()) {
|
||||||
|
outputMsg.appendChild(document.createElement("br"))
|
||||||
|
}
|
||||||
|
if (level === "error") {
|
||||||
|
outputMsg.innerHTML += '<span style="color: red">Error: ' + msg + "</span>"
|
||||||
|
} else if (level === "warn") {
|
||||||
|
outputMsg.innerHTML += '<span style="color: orange">Warning: ' + msg + "</span>"
|
||||||
|
} else {
|
||||||
|
outputMsg.innerText += msg
|
||||||
|
}
|
||||||
|
console.log(level, msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
function logError(msg, res, outputMsg) {
|
||||||
|
logMsg(msg, "error", outputMsg)
|
||||||
|
|
||||||
|
console.log("request error", res)
|
||||||
|
console.trace()
|
||||||
|
// setStatus("request", "error", "error")
|
||||||
|
}
|
||||||
|
|
||||||
|
function playSound() {
|
||||||
|
const audio = new Audio("/media/ding.mp3")
|
||||||
|
audio.volume = 0.2
|
||||||
|
var promise = audio.play()
|
||||||
|
if (promise !== undefined) {
|
||||||
|
promise
|
||||||
|
.then((_) => {})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn("browser blocked autoplay")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,11 @@
|
|||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
promptField.addEventListener('input', function(e) {
|
promptField.addEventListener('input', function(e) {
|
||||||
|
let loraExtractSetting = document.getElementById("extract_lora_from_prompt")
|
||||||
|
if (!loraExtractSetting.checked) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const { LoRA, prompt } = extractLoraTags(e.target.value);
|
const { LoRA, prompt } = extractLoraTags(e.target.value);
|
||||||
//console.log('e.target: ' + JSON.stringify(LoRA));
|
//console.log('e.target: ' + JSON.stringify(LoRA));
|
||||||
|
|
||||||
@ -20,44 +25,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (LoRA !== null && LoRA.length > 0 && testDiffusers?.checked) {
|
if (LoRA !== null && LoRA.length > 0 && testDiffusers?.checked) {
|
||||||
for (let i = 0; i < LoRA.length; i++) {
|
let modelNames = LoRA.map(e => e.lora_model_0)
|
||||||
//if (loraModelField.value !== LoRA[0].lora_model) {
|
let modelWeights = LoRA.map(e => e.lora_alpha_0)
|
||||||
// Set the new LoRA value
|
loraModelField.value = {modelNames: modelNames, modelWeights: modelWeights}
|
||||||
//console.log("Loading info");
|
|
||||||
//console.log(LoRA[0].lora_model_0);
|
|
||||||
//console.log(JSON.stringify(LoRa));
|
|
||||||
|
|
||||||
let lora = `lora_model_${i}`;
|
showToast("Prompt successfully processed")
|
||||||
let alpha = `lora_alpha_${i}`;
|
|
||||||
let loramodel = document.getElementById(lora);
|
|
||||||
let alphavalue = document.getElementById(alpha);
|
|
||||||
loramodel.setAttribute("data-path", LoRA[i].lora_model_0);
|
|
||||||
loramodel.value = LoRA[i].lora_model_0;
|
|
||||||
alphavalue.value = LoRA[i].lora_alpha_0;
|
|
||||||
if (i != LoRA.length - 1)
|
|
||||||
createLoraEntry();
|
|
||||||
}
|
|
||||||
//loraAlphaSlider.value = loraAlphaField.value * 100;
|
|
||||||
//TBD.value = LoRA[0].blockweights; // block weights not supported by ED at this time
|
|
||||||
//}
|
|
||||||
showToast("Prompt successfully processed", LoRA[0].lora_model_0);
|
|
||||||
//console.log('LoRa: ' + LoRA[0].lora_model_0);
|
|
||||||
//showToast("Prompt successfully processed", lora_model_0.value);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//promptField.dispatchEvent(new Event('change'));
|
//promptField.dispatchEvent(new Event('change'));
|
||||||
});
|
});
|
||||||
|
|
||||||
function isModelAvailable(array, searchString) {
|
|
||||||
const foundItem = array.find(function(item) {
|
|
||||||
item = item.toString().toLowerCase();
|
|
||||||
return item === searchString.toLowerCase()
|
|
||||||
});
|
|
||||||
|
|
||||||
return foundItem || "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract LoRA tags from strings
|
// extract LoRA tags from strings
|
||||||
function extractLoraTags(prompt) {
|
function extractLoraTags(prompt) {
|
||||||
// Define the regular expression for the tags
|
// Define the regular expression for the tags
|
||||||
@ -68,11 +46,13 @@
|
|||||||
|
|
||||||
// Iterate over the string, finding matches
|
// Iterate over the string, finding matches
|
||||||
for (const match of prompt.matchAll(regex)) {
|
for (const match of prompt.matchAll(regex)) {
|
||||||
const modelFileName = isModelAvailable(modelsCache.options.lora, match[1].trim())
|
const modelFileName = match[1].trim()
|
||||||
if (modelFileName !== "") {
|
const loraPathes = getAllModelPathes("lora", modelFileName)
|
||||||
|
if (loraPathes.length > 0) {
|
||||||
|
const loraPath = loraPathes[0]
|
||||||
// Initialize an object to hold a match
|
// Initialize an object to hold a match
|
||||||
let loraTag = {
|
let loraTag = {
|
||||||
lora_model_0: modelFileName,
|
lora_model_0: loraPath,
|
||||||
}
|
}
|
||||||
//console.log("Model:" + modelFileName);
|
//console.log("Model:" + modelFileName);
|
||||||
|
|
||||||
|
@ -1,454 +0,0 @@
|
|||||||
;(function() {
|
|
||||||
"use strict"
|
|
||||||
|
|
||||||
///////////////////// Function section
|
|
||||||
function smoothstep(x) {
|
|
||||||
return x * x * (3 - 2 * x)
|
|
||||||
}
|
|
||||||
|
|
||||||
function smootherstep(x) {
|
|
||||||
return x * x * x * (x * (x * 6 - 15) + 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
function smootheststep(x) {
|
|
||||||
let y = -20 * Math.pow(x, 7)
|
|
||||||
y += 70 * Math.pow(x, 6)
|
|
||||||
y -= 84 * Math.pow(x, 5)
|
|
||||||
y += 35 * Math.pow(x, 4)
|
|
||||||
return y
|
|
||||||
}
|
|
||||||
function getCurrentTime() {
|
|
||||||
const now = new Date()
|
|
||||||
let hours = now.getHours()
|
|
||||||
let minutes = now.getMinutes()
|
|
||||||
let seconds = now.getSeconds()
|
|
||||||
|
|
||||||
hours = hours < 10 ? `0${hours}` : hours
|
|
||||||
minutes = minutes < 10 ? `0${minutes}` : minutes
|
|
||||||
seconds = seconds < 10 ? `0${seconds}` : seconds
|
|
||||||
|
|
||||||
return `${hours}:${minutes}:${seconds}`
|
|
||||||
}
|
|
||||||
|
|
||||||
function addLogMessage(message) {
|
|
||||||
const logContainer = document.getElementById("merge-log")
|
|
||||||
logContainer.innerHTML += `<i>${getCurrentTime()}</i> ${message}<br>`
|
|
||||||
|
|
||||||
// Scroll to the bottom of the log
|
|
||||||
logContainer.scrollTop = logContainer.scrollHeight
|
|
||||||
|
|
||||||
document.querySelector("#merge-log-container").style.display = "block"
|
|
||||||
}
|
|
||||||
|
|
||||||
function addLogSeparator() {
|
|
||||||
const logContainer = document.getElementById("merge-log")
|
|
||||||
logContainer.innerHTML += "<hr>"
|
|
||||||
|
|
||||||
logContainer.scrollTop = logContainer.scrollHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawDiagram(fn) {
|
|
||||||
const SIZE = 300
|
|
||||||
const canvas = document.getElementById("merge-canvas")
|
|
||||||
canvas.height = canvas.width = SIZE
|
|
||||||
const ctx = canvas.getContext("2d")
|
|
||||||
|
|
||||||
// Draw coordinate system
|
|
||||||
ctx.scale(1, -1)
|
|
||||||
ctx.translate(0, -canvas.height)
|
|
||||||
ctx.lineWidth = 1
|
|
||||||
ctx.beginPath()
|
|
||||||
|
|
||||||
ctx.strokeStyle = "white"
|
|
||||||
ctx.moveTo(0, 0)
|
|
||||||
ctx.lineTo(0, SIZE)
|
|
||||||
ctx.lineTo(SIZE, SIZE)
|
|
||||||
ctx.lineTo(SIZE, 0)
|
|
||||||
ctx.lineTo(0, 0)
|
|
||||||
ctx.lineTo(SIZE, SIZE)
|
|
||||||
ctx.stroke()
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.setLineDash([1, 2])
|
|
||||||
const n = SIZE / 10
|
|
||||||
for (let i = n; i < SIZE; i += n) {
|
|
||||||
ctx.moveTo(0, i)
|
|
||||||
ctx.lineTo(SIZE, i)
|
|
||||||
ctx.moveTo(i, 0)
|
|
||||||
ctx.lineTo(i, SIZE)
|
|
||||||
}
|
|
||||||
ctx.stroke()
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.setLineDash([])
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.strokeStyle = "black"
|
|
||||||
ctx.lineWidth = 3
|
|
||||||
// Plot function
|
|
||||||
const numSamples = 20
|
|
||||||
for (let i = 0; i <= numSamples; i++) {
|
|
||||||
const x = i / numSamples
|
|
||||||
const y = fn(x)
|
|
||||||
|
|
||||||
const canvasX = x * SIZE
|
|
||||||
const canvasY = y * SIZE
|
|
||||||
|
|
||||||
if (i === 0) {
|
|
||||||
ctx.moveTo(canvasX, canvasY)
|
|
||||||
} else {
|
|
||||||
ctx.lineTo(canvasX, canvasY)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctx.stroke()
|
|
||||||
// Plot alpha values (yellow boxes)
|
|
||||||
let start = parseFloat(document.querySelector("#merge-start").value)
|
|
||||||
let step = parseFloat(document.querySelector("#merge-step").value)
|
|
||||||
let iterations = document.querySelector("#merge-count").value >> 0
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.fillStyle = "yellow"
|
|
||||||
for (let i = 0; i < iterations; i++) {
|
|
||||||
const alpha = (start + i * step) / 100
|
|
||||||
const x = alpha * SIZE
|
|
||||||
const y = fn(alpha) * SIZE
|
|
||||||
if (x <= SIZE) {
|
|
||||||
ctx.rect(x - 3, y - 3, 6, 6)
|
|
||||||
ctx.fill()
|
|
||||||
} else {
|
|
||||||
ctx.strokeStyle = "red"
|
|
||||||
ctx.moveTo(0, 0)
|
|
||||||
ctx.lineTo(0, SIZE)
|
|
||||||
ctx.lineTo(SIZE, SIZE)
|
|
||||||
ctx.lineTo(SIZE, 0)
|
|
||||||
ctx.lineTo(0, 0)
|
|
||||||
ctx.lineTo(SIZE, SIZE)
|
|
||||||
ctx.stroke()
|
|
||||||
addLogMessage("<i>Warning: maximum ratio is ≥ 100%</i>")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateChart() {
|
|
||||||
let fn = (x) => x
|
|
||||||
switch (document.querySelector("#merge-interpolation").value) {
|
|
||||||
case "SmoothStep":
|
|
||||||
fn = smoothstep
|
|
||||||
break
|
|
||||||
case "SmootherStep":
|
|
||||||
fn = smootherstep
|
|
||||||
break
|
|
||||||
case "SmoothestStep":
|
|
||||||
fn = smootheststep
|
|
||||||
break
|
|
||||||
}
|
|
||||||
drawDiagram(fn)
|
|
||||||
}
|
|
||||||
createTab({
|
|
||||||
id: "merge",
|
|
||||||
icon: "fa-code-merge",
|
|
||||||
label: "Merge models",
|
|
||||||
css: `
|
|
||||||
#tab-content-merge .tab-content-inner {
|
|
||||||
max-width: 100%;
|
|
||||||
padding: 10pt;
|
|
||||||
}
|
|
||||||
.merge-container {
|
|
||||||
margin-left: 15%;
|
|
||||||
margin-right: 15%;
|
|
||||||
text-align: left;
|
|
||||||
display: inline-grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
grid-template-rows: auto auto auto;
|
|
||||||
gap: 0px 0px;
|
|
||||||
grid-auto-flow: row;
|
|
||||||
grid-template-areas:
|
|
||||||
"merge-input merge-config"
|
|
||||||
"merge-buttons merge-buttons";
|
|
||||||
}
|
|
||||||
.merge-container p {
|
|
||||||
margin-top: 3pt;
|
|
||||||
margin-bottom: 3pt;
|
|
||||||
}
|
|
||||||
.merge-config .tab-content {
|
|
||||||
background: var(--background-color1);
|
|
||||||
border-radius: 3pt;
|
|
||||||
}
|
|
||||||
.merge-config .tab-content-inner {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.merge-input {
|
|
||||||
grid-area: merge-input;
|
|
||||||
padding-left:1em;
|
|
||||||
}
|
|
||||||
.merge-config {
|
|
||||||
grid-area: merge-config;
|
|
||||||
padding:1em;
|
|
||||||
}
|
|
||||||
.merge-config input {
|
|
||||||
margin-bottom: 3px;
|
|
||||||
}
|
|
||||||
.merge-config select {
|
|
||||||
margin-bottom: 3px;
|
|
||||||
}
|
|
||||||
.merge-buttons {
|
|
||||||
grid-area: merge-buttons;
|
|
||||||
padding:1em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#merge-button {
|
|
||||||
padding: 8px;
|
|
||||||
width:20em;
|
|
||||||
}
|
|
||||||
div#merge-log {
|
|
||||||
height:150px;
|
|
||||||
overflow-x:hidden;
|
|
||||||
overflow-y:scroll;
|
|
||||||
background:var(--background-color1);
|
|
||||||
border-radius: 3pt;
|
|
||||||
}
|
|
||||||
div#merge-log i {
|
|
||||||
color: hsl(var(--accent-hue), 100%, calc(2*var(--accent-lightness)));
|
|
||||||
font-family: monospace;
|
|
||||||
}
|
|
||||||
.disabled {
|
|
||||||
background: var(--background-color4);
|
|
||||||
color: var(--text-color);
|
|
||||||
}
|
|
||||||
#merge-type-tabs {
|
|
||||||
border-bottom: 1px solid black;
|
|
||||||
}
|
|
||||||
#merge-log-container {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.merge-container #merge-warning {
|
|
||||||
color: rgb(153, 153, 153);
|
|
||||||
}`,
|
|
||||||
content: `
|
|
||||||
<div class="merge-container panel-box">
|
|
||||||
<div class="merge-input">
|
|
||||||
<p><label for="#mergeModelA">Select Model A:</label></p>
|
|
||||||
<input id="mergeModelA" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
|
||||||
<p><label for="#mergeModelB">Select Model B:</label></p>
|
|
||||||
<input id="mergeModelB" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
|
||||||
<br/><br/>
|
|
||||||
<p id="merge-warning"><small><b>Important:</b> Please merge models of similar type.<br/>For e.g. <code>SD 1.4</code> models with only <code>SD 1.4/1.5</code> models,<br/><code>SD 2.0</code> with <code>SD 2.0</code>-type, and <code>SD 2.1</code> with <code>SD 2.1</code>-type models.</small></p>
|
|
||||||
<br/>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td><label for="#merge-filename">Output file name:</label></td>
|
|
||||||
<td><input id="merge-filename" size=24> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Base name of the output file.<br>Mix ratio and file suffix will be appended to this.</span></i></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><label for="#merge-fp">Output precision:</label></td>
|
|
||||||
<td><select id="merge-fp">
|
|
||||||
<option value="fp16">fp16 (smaller file size)</option>
|
|
||||||
<option value="fp32">fp32 (larger file size)</option>
|
|
||||||
</select>
|
|
||||||
<i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Image generation uses fp16, so it's a good choice.<br>Use fp32 if you want to use the result models for more mixes</span></i>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><label for="#merge-format">Output file format:</label></td>
|
|
||||||
<td><select id="merge-format">
|
|
||||||
<option value="safetensors">Safetensors (recommended)</option>
|
|
||||||
<option value="ckpt">CKPT/Pickle (legacy format)</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br/>
|
|
||||||
<div id="merge-log-container">
|
|
||||||
<p><label for="#merge-log">Log messages:</label></p>
|
|
||||||
<div id="merge-log"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="merge-config">
|
|
||||||
<div class="tab-container">
|
|
||||||
<span id="tab-merge-opts-single" class="tab active">
|
|
||||||
<span>Make a single file</small></span>
|
|
||||||
</span>
|
|
||||||
<span id="tab-merge-opts-batch" class="tab">
|
|
||||||
<span>Make multiple variations</small></span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div id="tab-content-merge-opts-single" class="tab-content active">
|
|
||||||
<div class="tab-content-inner">
|
|
||||||
<small>Saves a single merged model file, at the specified merge ratio.</small><br/><br/>
|
|
||||||
<label for="#single-merge-ratio-slider">Merge ratio:</label>
|
|
||||||
<input id="single-merge-ratio-slider" name="single-merge-ratio-slider" class="editor-slider" value="50" type="range" min="1" max="1000">
|
|
||||||
<input id="single-merge-ratio" size=2 value="5">%
|
|
||||||
<i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Model A's contribution to the mix. The rest will be from Model B.</span></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="tab-content-merge-opts-batch" class="tab-content">
|
|
||||||
<div class="tab-content-inner">
|
|
||||||
<small>Saves multiple variations of the model, at different merge ratios.<br/>Each variation will be saved as a separate file.</small><br/><br/>
|
|
||||||
<table>
|
|
||||||
<tr><td><label for="#merge-count">Number of variations:</label></td>
|
|
||||||
<td> <input id="merge-count" size=2 value="5"></td>
|
|
||||||
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Number of models to create</span></i></td></tr>
|
|
||||||
<tr><td><label for="#merge-start">Starting merge ratio:</label></td>
|
|
||||||
<td> <input id="merge-start" size=2 value="5">%</td>
|
|
||||||
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Smallest share of model A in the mix</span></i></td></tr>
|
|
||||||
<tr><td><label for="#merge-step">Increment each step:</label></td>
|
|
||||||
<td> <input id="merge-step" size=2 value="10">%</td>
|
|
||||||
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Share of model A added into the mix per step</span></i></td></tr>
|
|
||||||
<tr><td><label for="#merge-interpolation">Interpolation model:</label></td>
|
|
||||||
<td> <select id="merge-interpolation">
|
|
||||||
<option>Exact</option>
|
|
||||||
<option>SmoothStep</option>
|
|
||||||
<option>SmootherStep</option>
|
|
||||||
<option>SmoothestStep</option>
|
|
||||||
</select></td>
|
|
||||||
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Sigmoid function to be applied to the model share before mixing</span></i></td></tr>
|
|
||||||
</table>
|
|
||||||
<br/>
|
|
||||||
<small>Preview of variation ratios:</small><br/>
|
|
||||||
<canvas id="merge-canvas" width="400" height="400"></canvas>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="merge-buttons">
|
|
||||||
<button id="merge-button" class="primaryButton">Merge models</button>
|
|
||||||
</div>
|
|
||||||
</div>`,
|
|
||||||
onOpen: ({ firstOpen }) => {
|
|
||||||
if (!firstOpen) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const tabSettingsSingle = document.querySelector("#tab-merge-opts-single")
|
|
||||||
const tabSettingsBatch = document.querySelector("#tab-merge-opts-batch")
|
|
||||||
linkTabContents(tabSettingsSingle)
|
|
||||||
linkTabContents(tabSettingsBatch)
|
|
||||||
|
|
||||||
console.log("Activate")
|
|
||||||
let mergeModelAField = new ModelDropdown(document.querySelector("#mergeModelA"), "stable-diffusion")
|
|
||||||
let mergeModelBField = new ModelDropdown(document.querySelector("#mergeModelB"), "stable-diffusion")
|
|
||||||
updateChart()
|
|
||||||
|
|
||||||
// slider
|
|
||||||
const singleMergeRatioField = document.querySelector("#single-merge-ratio")
|
|
||||||
const singleMergeRatioSlider = document.querySelector("#single-merge-ratio-slider")
|
|
||||||
|
|
||||||
function updateSingleMergeRatio() {
|
|
||||||
singleMergeRatioField.value = singleMergeRatioSlider.value / 10
|
|
||||||
singleMergeRatioField.dispatchEvent(new Event("change"))
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateSingleMergeRatioSlider() {
|
|
||||||
if (singleMergeRatioField.value < 0) {
|
|
||||||
singleMergeRatioField.value = 0
|
|
||||||
} else if (singleMergeRatioField.value > 100) {
|
|
||||||
singleMergeRatioField.value = 100
|
|
||||||
}
|
|
||||||
|
|
||||||
singleMergeRatioSlider.value = singleMergeRatioField.value * 10
|
|
||||||
singleMergeRatioSlider.dispatchEvent(new Event("change"))
|
|
||||||
}
|
|
||||||
|
|
||||||
singleMergeRatioSlider.addEventListener("input", updateSingleMergeRatio)
|
|
||||||
singleMergeRatioField.addEventListener("input", updateSingleMergeRatioSlider)
|
|
||||||
updateSingleMergeRatio()
|
|
||||||
|
|
||||||
document.querySelector(".merge-config").addEventListener("change", updateChart)
|
|
||||||
|
|
||||||
document.querySelector("#merge-button").addEventListener("click", async function(e) {
|
|
||||||
// Build request template
|
|
||||||
let model0 = mergeModelAField.value
|
|
||||||
let model1 = mergeModelBField.value
|
|
||||||
let request = { model0: model0, model1: model1 }
|
|
||||||
request["use_fp16"] = document.querySelector("#merge-fp").value == "fp16"
|
|
||||||
let iterations = document.querySelector("#merge-count").value >> 0
|
|
||||||
let start = parseFloat(document.querySelector("#merge-start").value)
|
|
||||||
let step = parseFloat(document.querySelector("#merge-step").value)
|
|
||||||
|
|
||||||
if (isTabActive(tabSettingsSingle)) {
|
|
||||||
start = parseFloat(singleMergeRatioField.value)
|
|
||||||
step = 0
|
|
||||||
iterations = 1
|
|
||||||
addLogMessage(`merge ratio = ${start}%`)
|
|
||||||
} else {
|
|
||||||
addLogMessage(`start = ${start}%`)
|
|
||||||
addLogMessage(`step = ${step}%`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (start + (iterations - 1) * step >= 100) {
|
|
||||||
addLogMessage("<i>Aborting: maximum ratio is ≥ 100%</i>")
|
|
||||||
addLogMessage("Reduce the number of variations or the step size")
|
|
||||||
addLogSeparator()
|
|
||||||
document.querySelector("#merge-count").focus()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.querySelector("#merge-filename").value == "") {
|
|
||||||
addLogMessage("<i>Aborting: No output file name specified</i>")
|
|
||||||
addLogSeparator()
|
|
||||||
document.querySelector("#merge-filename").focus()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable merge button
|
|
||||||
e.target.disabled = true
|
|
||||||
e.target.classList.add("disabled")
|
|
||||||
let cursor = $("body").css("cursor")
|
|
||||||
let label = document.querySelector("#merge-button").innerHTML
|
|
||||||
$("body").css("cursor", "progress")
|
|
||||||
document.querySelector("#merge-button").innerHTML = "Merging models ..."
|
|
||||||
|
|
||||||
addLogMessage("Merging models")
|
|
||||||
addLogMessage("Model A: " + model0)
|
|
||||||
addLogMessage("Model B: " + model1)
|
|
||||||
|
|
||||||
// Batch main loop
|
|
||||||
for (let i = 0; i < iterations; i++) {
|
|
||||||
let alpha = (start + i * step) / 100
|
|
||||||
|
|
||||||
if (isTabActive(tabSettingsBatch)) {
|
|
||||||
switch (document.querySelector("#merge-interpolation").value) {
|
|
||||||
case "SmoothStep":
|
|
||||||
alpha = smoothstep(alpha)
|
|
||||||
break
|
|
||||||
case "SmootherStep":
|
|
||||||
alpha = smootherstep(alpha)
|
|
||||||
break
|
|
||||||
case "SmoothestStep":
|
|
||||||
alpha = smootheststep(alpha)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addLogMessage(`merging batch job ${i + 1}/${iterations}, alpha = ${alpha.toFixed(5)}...`)
|
|
||||||
|
|
||||||
request["out_path"] = document.querySelector("#merge-filename").value
|
|
||||||
request["out_path"] += "-" + alpha.toFixed(5) + "." + document.querySelector("#merge-format").value
|
|
||||||
addLogMessage(` filename: ${request["out_path"]}`)
|
|
||||||
|
|
||||||
// sdkit documentation: "ratio - the ratio of the second model. 1 means only the second model will be used."
|
|
||||||
request["ratio"] = 1-alpha
|
|
||||||
let res = await fetch("/model/merge", {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify(request),
|
|
||||||
})
|
|
||||||
const data = await res.json()
|
|
||||||
addLogMessage(JSON.stringify(data))
|
|
||||||
}
|
|
||||||
addLogMessage(
|
|
||||||
"<b>Done.</b> The models have been saved to your <tt>models/stable-diffusion</tt> folder."
|
|
||||||
)
|
|
||||||
addLogSeparator()
|
|
||||||
// Re-enable merge button
|
|
||||||
$("body").css("cursor", cursor)
|
|
||||||
document.querySelector("#merge-button").innerHTML = label
|
|
||||||
e.target.disabled = false
|
|
||||||
e.target.classList.remove("disabled")
|
|
||||||
|
|
||||||
// Update model list
|
|
||||||
stableDiffusionModelField.innerHTML = ""
|
|
||||||
vaeModelField.innerHTML = ""
|
|
||||||
hypernetworkModelField.innerHTML = ""
|
|
||||||
await getModels()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})()
|
|
770
ui/plugins/ui/model-tools.plugin.js
Normal file
770
ui/plugins/ui/model-tools.plugin.js
Normal file
@ -0,0 +1,770 @@
|
|||||||
|
;(function() {
|
||||||
|
"use strict"
|
||||||
|
|
||||||
|
let mergeCSS = `
|
||||||
|
/*********** Main tab ***********/
|
||||||
|
.tab-centered {
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#model-tool-tab-content {
|
||||||
|
background-color: var(--background-color3);
|
||||||
|
}
|
||||||
|
|
||||||
|
#model-tool-tab-content .tab-content-inner {
|
||||||
|
text-align: initial;
|
||||||
|
}
|
||||||
|
|
||||||
|
#model-tool-tab-bar .tab {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
border-top-left-radius: var(--input-border-radius);
|
||||||
|
background-color: var(--background-color3);
|
||||||
|
padding: 6px 6px 0.8em 6px;
|
||||||
|
}
|
||||||
|
#tab-content-merge .tab-content-inner {
|
||||||
|
max-width: 100%;
|
||||||
|
padding: 10pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********** Merge UI ***********/
|
||||||
|
.merge-model-container {
|
||||||
|
margin-left: 15%;
|
||||||
|
margin-right: 15%;
|
||||||
|
text-align: left;
|
||||||
|
display: inline-grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
grid-template-rows: auto auto auto;
|
||||||
|
gap: 0px 0px;
|
||||||
|
grid-auto-flow: row;
|
||||||
|
grid-template-areas:
|
||||||
|
"merge-input merge-config"
|
||||||
|
"merge-buttons merge-buttons";
|
||||||
|
}
|
||||||
|
.merge-model-container p {
|
||||||
|
margin-top: 3pt;
|
||||||
|
margin-bottom: 3pt;
|
||||||
|
}
|
||||||
|
.merge-config .tab-content {
|
||||||
|
background: var(--background-color1);
|
||||||
|
border-radius: 3pt;
|
||||||
|
}
|
||||||
|
.merge-config .tab-content-inner {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.merge-input {
|
||||||
|
grid-area: merge-input;
|
||||||
|
padding-left:1em;
|
||||||
|
}
|
||||||
|
.merge-config {
|
||||||
|
grid-area: merge-config;
|
||||||
|
padding:1em;
|
||||||
|
}
|
||||||
|
.merge-config input {
|
||||||
|
margin-bottom: 3px;
|
||||||
|
}
|
||||||
|
.merge-config select {
|
||||||
|
margin-bottom: 3px;
|
||||||
|
}
|
||||||
|
.merge-buttons {
|
||||||
|
grid-area: merge-buttons;
|
||||||
|
padding:1em;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
#merge-button {
|
||||||
|
padding: 8px;
|
||||||
|
width:20em;
|
||||||
|
}
|
||||||
|
div#merge-log {
|
||||||
|
height:150px;
|
||||||
|
overflow-x:hidden;
|
||||||
|
overflow-y:scroll;
|
||||||
|
background:var(--background-color1);
|
||||||
|
border-radius: 3pt;
|
||||||
|
}
|
||||||
|
div#merge-log i {
|
||||||
|
color: hsl(var(--accent-hue), 100%, calc(2*var(--accent-lightness)));
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
.disabled {
|
||||||
|
background: var(--background-color4);
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
#merge-type-tabs {
|
||||||
|
border-bottom: 1px solid black;
|
||||||
|
}
|
||||||
|
#merge-log-container {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.merge-model-container #merge-warning {
|
||||||
|
color: var(--small-label-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********** LORA UI ***********/
|
||||||
|
.lora-manager-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: 0px 8px;
|
||||||
|
grid-auto-flow: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 1501px) {
|
||||||
|
.lora-manager-grid textarea {
|
||||||
|
height:350px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid {
|
||||||
|
grid-template-columns: auto 1fr 1fr;
|
||||||
|
grid-template-rows: auto 1fr;
|
||||||
|
grid-template-areas:
|
||||||
|
"selector selector selector"
|
||||||
|
"thumbnail keywords notes";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 1001px) and (max-width: 1500px) {
|
||||||
|
.lora-manager-grid textarea {
|
||||||
|
height:250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid {
|
||||||
|
grid-template-columns: auto auto;
|
||||||
|
grid-template-rows: auto auto auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"selector selector"
|
||||||
|
"thumbnail keywords"
|
||||||
|
"thumbnail notes";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 1000px) {
|
||||||
|
.lora-manager-grid textarea {
|
||||||
|
height:200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid {
|
||||||
|
grid-template-columns: auto;
|
||||||
|
grid-template-rows: auto auto auto auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"selector"
|
||||||
|
"keywords"
|
||||||
|
"thumbnail"
|
||||||
|
"notes";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid-selector {
|
||||||
|
grid-area: selector;
|
||||||
|
justify-self: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid-thumbnail {
|
||||||
|
grid-area: thumbnail;
|
||||||
|
justify-self: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid-keywords {
|
||||||
|
grid-area: keywords;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid-notes {
|
||||||
|
grid-area: notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid p {
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
|
|
||||||
|
let mergeUI = `
|
||||||
|
<div class="merge-model-container panel-box">
|
||||||
|
<div class="merge-input">
|
||||||
|
<p><label for="#mergeModelA">Select Model A:</label></p>
|
||||||
|
<input id="mergeModelA" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
||||||
|
<p><label for="#mergeModelB">Select Model B:</label></p>
|
||||||
|
<input id="mergeModelB" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
||||||
|
<br/><br/>
|
||||||
|
<p id="merge-warning"><small><b>Important:</b> Please merge models of similar type.<br/>For e.g. <code>SD 1.4</code> models with only <code>SD 1.4/1.5</code> models,<br/><code>SD 2.0</code> with <code>SD 2.0</code>-type, and <code>SD 2.1</code> with <code>SD 2.1</code>-type models.</small></p>
|
||||||
|
<br/>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><label for="#merge-filename">Output file name:</label></td>
|
||||||
|
<td><input id="merge-filename" size=24> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Base name of the output file.<br>Mix ratio and file suffix will be appended to this.</span></i></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="#merge-fp">Output precision:</label></td>
|
||||||
|
<td><select id="merge-fp">
|
||||||
|
<option value="fp16">fp16 (smaller file size)</option>
|
||||||
|
<option value="fp32">fp32 (larger file size)</option>
|
||||||
|
</select>
|
||||||
|
<i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Image generation uses fp16, so it's a good choice.<br>Use fp32 if you want to use the result models for more mixes</span></i>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="#merge-format">Output file format:</label></td>
|
||||||
|
<td><select id="merge-format">
|
||||||
|
<option value="safetensors">Safetensors (recommended)</option>
|
||||||
|
<option value="ckpt">CKPT/Pickle (legacy format)</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
<div id="merge-log-container">
|
||||||
|
<p><label for="#merge-log">Log messages:</label></p>
|
||||||
|
<div id="merge-log"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="merge-config">
|
||||||
|
<div class="tab-container">
|
||||||
|
<span id="tab-merge-opts-single" class="tab active">
|
||||||
|
<span>Make a single file</small></span>
|
||||||
|
</span>
|
||||||
|
<span id="tab-merge-opts-batch" class="tab">
|
||||||
|
<span>Make multiple variations</small></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div id="tab-content-merge-opts-single" class="tab-content active">
|
||||||
|
<div class="tab-content-inner">
|
||||||
|
<small>Saves a single merged model file, at the specified merge ratio.</small><br/><br/>
|
||||||
|
<label for="#single-merge-ratio-slider">Merge ratio:</label>
|
||||||
|
<input id="single-merge-ratio-slider" name="single-merge-ratio-slider" class="editor-slider" value="50" type="range" min="1" max="1000">
|
||||||
|
<input id="single-merge-ratio" size=2 value="5">%
|
||||||
|
<i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Model A's contribution to the mix. The rest will be from Model B.</span></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="tab-content-merge-opts-batch" class="tab-content">
|
||||||
|
<div class="tab-content-inner">
|
||||||
|
<small>Saves multiple variations of the model, at different merge ratios.<br/>Each variation will be saved as a separate file.</small><br/><br/>
|
||||||
|
<table>
|
||||||
|
<tr><td><label for="#merge-count">Number of variations:</label></td>
|
||||||
|
<td> <input id="merge-count" size=2 value="5"></td>
|
||||||
|
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Number of models to create</span></i></td></tr>
|
||||||
|
<tr><td><label for="#merge-start">Starting merge ratio:</label></td>
|
||||||
|
<td> <input id="merge-start" size=2 value="5">%</td>
|
||||||
|
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Smallest share of model A in the mix</span></i></td></tr>
|
||||||
|
<tr><td><label for="#merge-step">Increment each step:</label></td>
|
||||||
|
<td> <input id="merge-step" size=2 value="10">%</td>
|
||||||
|
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Share of model A added into the mix per step</span></i></td></tr>
|
||||||
|
<tr><td><label for="#merge-interpolation">Interpolation model:</label></td>
|
||||||
|
<td> <select id="merge-interpolation">
|
||||||
|
<option>Exact</option>
|
||||||
|
<option>SmoothStep</option>
|
||||||
|
<option>SmootherStep</option>
|
||||||
|
<option>SmoothestStep</option>
|
||||||
|
</select></td>
|
||||||
|
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Sigmoid function to be applied to the model share before mixing</span></i></td></tr>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
<small>Preview of variation ratios:</small><br/>
|
||||||
|
<canvas id="merge-canvas" width="400" height="400"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="merge-buttons">
|
||||||
|
<button id="merge-button" class="primaryButton">Merge models</button>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
|
||||||
|
|
||||||
|
let loraUI=`
|
||||||
|
<div class="panel-box lora-manager-grid">
|
||||||
|
<div class="lora-manager-grid-selector">
|
||||||
|
<label for="#loraModel">Select Lora:</label>
|
||||||
|
<input id="loraModel" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
||||||
|
</div>
|
||||||
|
<div class="lora-manager-grid-thumbnail">
|
||||||
|
<p style="height:2em;">Thumbnail:</p>
|
||||||
|
<div style="position:relative; height:256px; width:256px;background-color:#222;border-radius:1em;margin-bottom:1em;">
|
||||||
|
<i id="lora-manager-image-placeholder" class="fa-regular fa-image" style="font-size:500%;color:#555;position:absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);"></i>
|
||||||
|
<img id="lora-manager-image" class="displayNone" style="border-radius:6px;max-height:256px;max-width:256px;"/>
|
||||||
|
</div>
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<button class="tertiaryButton" id="lora-manager-upload-button"><i class="fa-solid fa-upload"></i> Upload new thumbnail</button>
|
||||||
|
<input id="lora-manager-upload-input" name="lora-manager-upload-input" type="file" class="displayNone">
|
||||||
|
<!-- button class="tertiaryButton"><i class="fa-solid fa-trash-can"></i> Remove</button -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="lora-manager-grid-keywords">
|
||||||
|
<p style="height:2em;">Keywords:
|
||||||
|
<span style="float:right;margin-bottom:4px;"><button id="lora-keyword-from-civitai" class="tertiaryButton smallButton">Import from Civitai</button></span></p>
|
||||||
|
<textarea style="width:100%;resize:vertical;" id="lora-manager-keywords" placeholder="Put LORA specific keywords here..."></textarea>
|
||||||
|
<p style="color:var(--small-label-color);">
|
||||||
|
<b>LORA model keywords</b> can be used via the <code>+ Embeddings</code> button. They get added to the embedding
|
||||||
|
keyword menu when the LORA has been selected in the image settings.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="lora-manager-grid-notes">
|
||||||
|
<p style="height:2em;">Notes:</p>
|
||||||
|
<textarea style="width:100%;resize:vertical;" id="lora-manager-notes" placeholder="Place for things you want to remember..."></textarea>
|
||||||
|
<p id="civitai-section" class="displayNone">
|
||||||
|
<b>Civitai model page:</b>
|
||||||
|
<a id="civitai-model-page" target="_blank"></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
|
||||||
|
let tabHTML=`
|
||||||
|
<div id="model-tool-tab-bar" class="tab-container tab-centered">
|
||||||
|
<span id="tab-model-loraUI" class="tab active">
|
||||||
|
<span><i class="fa-solid fa-key"></i> Lora Keywords</small></span>
|
||||||
|
</span>
|
||||||
|
<span id="tab-model-mergeUI" class="tab">
|
||||||
|
<span><i class="fa-solid fa-code-merge"></i> Merge Models</small></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div id="model-tool-tab-content" class="panel-box">
|
||||||
|
<div id="tab-content-model-loraUI" class="tab-content active">
|
||||||
|
<div class="tab-content-inner">
|
||||||
|
${loraUI}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="tab-content-model-mergeUI" class="tab-content">
|
||||||
|
<div class="tab-content-inner">
|
||||||
|
${mergeUI}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////// Function section
|
||||||
|
function smoothstep(x) {
|
||||||
|
return x * x * (3 - 2 * x)
|
||||||
|
}
|
||||||
|
|
||||||
|
function smootherstep(x) {
|
||||||
|
return x * x * x * (x * (x * 6 - 15) + 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
function smootheststep(x) {
|
||||||
|
let y = -20 * Math.pow(x, 7)
|
||||||
|
y += 70 * Math.pow(x, 6)
|
||||||
|
y -= 84 * Math.pow(x, 5)
|
||||||
|
y += 35 * Math.pow(x, 4)
|
||||||
|
return y
|
||||||
|
}
|
||||||
|
function getCurrentTime() {
|
||||||
|
const now = new Date()
|
||||||
|
let hours = now.getHours()
|
||||||
|
let minutes = now.getMinutes()
|
||||||
|
let seconds = now.getSeconds()
|
||||||
|
|
||||||
|
hours = hours < 10 ? `0${hours}` : hours
|
||||||
|
minutes = minutes < 10 ? `0${minutes}` : minutes
|
||||||
|
seconds = seconds < 10 ? `0${seconds}` : seconds
|
||||||
|
|
||||||
|
return `${hours}:${minutes}:${seconds}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function addLogMessage(message) {
|
||||||
|
const logContainer = document.getElementById("merge-log")
|
||||||
|
logContainer.innerHTML += `<i>${getCurrentTime()}</i> ${message}<br>`
|
||||||
|
|
||||||
|
// Scroll to the bottom of the log
|
||||||
|
logContainer.scrollTop = logContainer.scrollHeight
|
||||||
|
|
||||||
|
document.querySelector("#merge-log-container").style.display = "block"
|
||||||
|
}
|
||||||
|
|
||||||
|
function addLogSeparator() {
|
||||||
|
const logContainer = document.getElementById("merge-log")
|
||||||
|
logContainer.innerHTML += "<hr>"
|
||||||
|
|
||||||
|
logContainer.scrollTop = logContainer.scrollHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawDiagram(fn) {
|
||||||
|
const SIZE = 300
|
||||||
|
const canvas = document.getElementById("merge-canvas")
|
||||||
|
canvas.height = canvas.width = SIZE
|
||||||
|
const ctx = canvas.getContext("2d")
|
||||||
|
|
||||||
|
// Draw coordinate system
|
||||||
|
ctx.scale(1, -1)
|
||||||
|
ctx.translate(0, -canvas.height)
|
||||||
|
ctx.lineWidth = 1
|
||||||
|
ctx.beginPath()
|
||||||
|
|
||||||
|
ctx.strokeStyle = "white"
|
||||||
|
ctx.moveTo(0, 0)
|
||||||
|
ctx.lineTo(0, SIZE)
|
||||||
|
ctx.lineTo(SIZE, SIZE)
|
||||||
|
ctx.lineTo(SIZE, 0)
|
||||||
|
ctx.lineTo(0, 0)
|
||||||
|
ctx.lineTo(SIZE, SIZE)
|
||||||
|
ctx.stroke()
|
||||||
|
ctx.beginPath()
|
||||||
|
ctx.setLineDash([1, 2])
|
||||||
|
const n = SIZE / 10
|
||||||
|
for (let i = n; i < SIZE; i += n) {
|
||||||
|
ctx.moveTo(0, i)
|
||||||
|
ctx.lineTo(SIZE, i)
|
||||||
|
ctx.moveTo(i, 0)
|
||||||
|
ctx.lineTo(i, SIZE)
|
||||||
|
}
|
||||||
|
ctx.stroke()
|
||||||
|
ctx.beginPath()
|
||||||
|
ctx.setLineDash([])
|
||||||
|
ctx.beginPath()
|
||||||
|
ctx.strokeStyle = "black"
|
||||||
|
ctx.lineWidth = 3
|
||||||
|
// Plot function
|
||||||
|
const numSamples = 20
|
||||||
|
for (let i = 0; i <= numSamples; i++) {
|
||||||
|
const x = i / numSamples
|
||||||
|
const y = fn(x)
|
||||||
|
|
||||||
|
const canvasX = x * SIZE
|
||||||
|
const canvasY = y * SIZE
|
||||||
|
|
||||||
|
if (i === 0) {
|
||||||
|
ctx.moveTo(canvasX, canvasY)
|
||||||
|
} else {
|
||||||
|
ctx.lineTo(canvasX, canvasY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.stroke()
|
||||||
|
// Plot alpha values (yellow boxes)
|
||||||
|
let start = parseFloat(document.querySelector("#merge-start").value)
|
||||||
|
let step = parseFloat(document.querySelector("#merge-step").value)
|
||||||
|
let iterations = document.querySelector("#merge-count").value >> 0
|
||||||
|
ctx.beginPath()
|
||||||
|
ctx.fillStyle = "yellow"
|
||||||
|
for (let i = 0; i < iterations; i++) {
|
||||||
|
const alpha = (start + i * step) / 100
|
||||||
|
const x = alpha * SIZE
|
||||||
|
const y = fn(alpha) * SIZE
|
||||||
|
if (x <= SIZE) {
|
||||||
|
ctx.rect(x - 3, y - 3, 6, 6)
|
||||||
|
ctx.fill()
|
||||||
|
} else {
|
||||||
|
ctx.strokeStyle = "red"
|
||||||
|
ctx.moveTo(0, 0)
|
||||||
|
ctx.lineTo(0, SIZE)
|
||||||
|
ctx.lineTo(SIZE, SIZE)
|
||||||
|
ctx.lineTo(SIZE, 0)
|
||||||
|
ctx.lineTo(0, 0)
|
||||||
|
ctx.lineTo(SIZE, SIZE)
|
||||||
|
ctx.stroke()
|
||||||
|
addLogMessage("<i>Warning: maximum ratio is ≥ 100%</i>")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateChart() {
|
||||||
|
let fn = (x) => x
|
||||||
|
switch (document.querySelector("#merge-interpolation").value) {
|
||||||
|
case "SmoothStep":
|
||||||
|
fn = smoothstep
|
||||||
|
break
|
||||||
|
case "SmootherStep":
|
||||||
|
fn = smootherstep
|
||||||
|
break
|
||||||
|
case "SmoothestStep":
|
||||||
|
fn = smootheststep
|
||||||
|
break
|
||||||
|
}
|
||||||
|
drawDiagram(fn)
|
||||||
|
}
|
||||||
|
|
||||||
|
function initMergeUI() {
|
||||||
|
const tabSettingsSingle = document.querySelector("#tab-merge-opts-single")
|
||||||
|
const tabSettingsBatch = document.querySelector("#tab-merge-opts-batch")
|
||||||
|
linkTabContents(tabSettingsSingle)
|
||||||
|
linkTabContents(tabSettingsBatch)
|
||||||
|
|
||||||
|
let mergeModelAField = new ModelDropdown(document.querySelector("#mergeModelA"), "stable-diffusion")
|
||||||
|
let mergeModelBField = new ModelDropdown(document.querySelector("#mergeModelB"), "stable-diffusion")
|
||||||
|
updateChart()
|
||||||
|
|
||||||
|
// slider
|
||||||
|
const singleMergeRatioField = document.querySelector("#single-merge-ratio")
|
||||||
|
const singleMergeRatioSlider = document.querySelector("#single-merge-ratio-slider")
|
||||||
|
|
||||||
|
function updateSingleMergeRatio() {
|
||||||
|
singleMergeRatioField.value = singleMergeRatioSlider.value / 10
|
||||||
|
singleMergeRatioField.dispatchEvent(new Event("change"))
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSingleMergeRatioSlider() {
|
||||||
|
if (singleMergeRatioField.value < 0) {
|
||||||
|
singleMergeRatioField.value = 0
|
||||||
|
} else if (singleMergeRatioField.value > 100) {
|
||||||
|
singleMergeRatioField.value = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
singleMergeRatioSlider.value = singleMergeRatioField.value * 10
|
||||||
|
singleMergeRatioSlider.dispatchEvent(new Event("change"))
|
||||||
|
}
|
||||||
|
|
||||||
|
singleMergeRatioSlider.addEventListener("input", updateSingleMergeRatio)
|
||||||
|
singleMergeRatioField.addEventListener("input", updateSingleMergeRatioSlider)
|
||||||
|
updateSingleMergeRatio()
|
||||||
|
|
||||||
|
document.querySelector(".merge-config").addEventListener("change", updateChart)
|
||||||
|
|
||||||
|
document.querySelector("#merge-button").addEventListener("click", async function(e) {
|
||||||
|
// Build request template
|
||||||
|
let model0 = mergeModelAField.value
|
||||||
|
let model1 = mergeModelBField.value
|
||||||
|
let request = { model0: model0, model1: model1 }
|
||||||
|
request["use_fp16"] = document.querySelector("#merge-fp").value == "fp16"
|
||||||
|
let iterations = document.querySelector("#merge-count").value >> 0
|
||||||
|
let start = parseFloat(document.querySelector("#merge-start").value)
|
||||||
|
let step = parseFloat(document.querySelector("#merge-step").value)
|
||||||
|
|
||||||
|
if (isTabActive(tabSettingsSingle)) {
|
||||||
|
start = parseFloat(singleMergeRatioField.value)
|
||||||
|
step = 0
|
||||||
|
iterations = 1
|
||||||
|
addLogMessage(`merge ratio = ${start}%`)
|
||||||
|
} else {
|
||||||
|
addLogMessage(`start = ${start}%`)
|
||||||
|
addLogMessage(`step = ${step}%`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start + (iterations - 1) * step >= 100) {
|
||||||
|
addLogMessage("<i>Aborting: maximum ratio is ≥ 100%</i>")
|
||||||
|
addLogMessage("Reduce the number of variations or the step size")
|
||||||
|
addLogSeparator()
|
||||||
|
document.querySelector("#merge-count").focus()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.querySelector("#merge-filename").value == "") {
|
||||||
|
addLogMessage("<i>Aborting: No output file name specified</i>")
|
||||||
|
addLogSeparator()
|
||||||
|
document.querySelector("#merge-filename").focus()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable merge button
|
||||||
|
e.target.disabled = true
|
||||||
|
e.target.classList.add("disabled")
|
||||||
|
let cursor = $("body").css("cursor")
|
||||||
|
let label = document.querySelector("#merge-button").innerHTML
|
||||||
|
$("body").css("cursor", "progress")
|
||||||
|
document.querySelector("#merge-button").innerHTML = "Merging models ..."
|
||||||
|
|
||||||
|
addLogMessage("Merging models")
|
||||||
|
addLogMessage("Model A: " + model0)
|
||||||
|
addLogMessage("Model B: " + model1)
|
||||||
|
|
||||||
|
// Batch main loop
|
||||||
|
for (let i = 0; i < iterations; i++) {
|
||||||
|
let alpha = (start + i * step) / 100
|
||||||
|
|
||||||
|
if (isTabActive(tabSettingsBatch)) {
|
||||||
|
switch (document.querySelector("#merge-interpolation").value) {
|
||||||
|
case "SmoothStep":
|
||||||
|
alpha = smoothstep(alpha)
|
||||||
|
break
|
||||||
|
case "SmootherStep":
|
||||||
|
alpha = smootherstep(alpha)
|
||||||
|
break
|
||||||
|
case "SmoothestStep":
|
||||||
|
alpha = smootheststep(alpha)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addLogMessage(`merging batch job ${i + 1}/${iterations}, alpha = ${alpha.toFixed(5)}...`)
|
||||||
|
|
||||||
|
request["out_path"] = document.querySelector("#merge-filename").value
|
||||||
|
request["out_path"] += "-" + alpha.toFixed(5) + "." + document.querySelector("#merge-format").value
|
||||||
|
addLogMessage(` filename: ${request["out_path"]}`)
|
||||||
|
|
||||||
|
// sdkit documentation: "ratio - the ratio of the second model. 1 means only the second model will be used."
|
||||||
|
request["ratio"] = 1-alpha
|
||||||
|
let res = await fetch("/model/merge", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify(request),
|
||||||
|
})
|
||||||
|
const data = await res.json()
|
||||||
|
addLogMessage(JSON.stringify(data))
|
||||||
|
}
|
||||||
|
addLogMessage(
|
||||||
|
"<b>Done.</b> The models have been saved to your <tt>models/stable-diffusion</tt> folder."
|
||||||
|
)
|
||||||
|
addLogSeparator()
|
||||||
|
// Re-enable merge button
|
||||||
|
$("body").css("cursor", cursor)
|
||||||
|
document.querySelector("#merge-button").innerHTML = label
|
||||||
|
e.target.disabled = false
|
||||||
|
e.target.classList.remove("disabled")
|
||||||
|
|
||||||
|
// Update model list
|
||||||
|
stableDiffusionModelField.innerHTML = ""
|
||||||
|
vaeModelField.innerHTML = ""
|
||||||
|
hypernetworkModelField.innerHTML = ""
|
||||||
|
await getModels()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const LoraUI = {
|
||||||
|
modelField: undefined,
|
||||||
|
keywordsField: undefined,
|
||||||
|
notesField: undefined,
|
||||||
|
civitaiImportBtn: undefined,
|
||||||
|
civitaiSecion: undefined,
|
||||||
|
civitaiAnchor: undefined,
|
||||||
|
image: undefined,
|
||||||
|
imagePlaceholder: undefined,
|
||||||
|
|
||||||
|
init() {
|
||||||
|
LoraUI.modelField = new ModelDropdown(document.querySelector("#loraModel"), "lora", "None")
|
||||||
|
LoraUI.keywordsField = document.querySelector("#lora-manager-keywords")
|
||||||
|
LoraUI.notesField = document.querySelector("#lora-manager-notes")
|
||||||
|
LoraUI.civitaiImportBtn = document.querySelector("#lora-keyword-from-civitai")
|
||||||
|
LoraUI.civitaiSection = document.querySelector("#civitai-section")
|
||||||
|
LoraUI.civitaiAnchor = document.querySelector("#civitai-model-page")
|
||||||
|
LoraUI.image = document.querySelector("#lora-manager-image")
|
||||||
|
LoraUI.imagePlaceholder = document.querySelector("#lora-manager-image-placeholder")
|
||||||
|
LoraUI.uploadBtn = document.querySelector("#lora-manager-upload-button")
|
||||||
|
LoraUI.uploadInput = document.querySelector("#lora-manager-upload-input")
|
||||||
|
|
||||||
|
LoraUI.modelField.addEventListener("change", LoraUI.updateFields)
|
||||||
|
LoraUI.keywordsField.addEventListener("focusout", LoraUI.saveInfos)
|
||||||
|
LoraUI.notesField.addEventListener("focusout", LoraUI.saveInfos)
|
||||||
|
LoraUI.civitaiImportBtn.addEventListener("click", LoraUI.importFromCivitai)
|
||||||
|
|
||||||
|
LoraUI.uploadBtn.addEventListener("click", (e) => LoraUI.uploadInput.click())
|
||||||
|
LoraUI.uploadInput.addEventListener("change", LoraUI.uploadLoraThumb)
|
||||||
|
|
||||||
|
document.addEventListener("saveThumb", LoraUI.updateFields)
|
||||||
|
|
||||||
|
LoraUI.updateFields()
|
||||||
|
},
|
||||||
|
|
||||||
|
uploadLoraThumb(e) {
|
||||||
|
console.log(e)
|
||||||
|
if (LoraUI.uploadInput.files.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let reader = new FileReader()
|
||||||
|
let file = LoraUI.uploadInput.files[0]
|
||||||
|
|
||||||
|
reader.addEventListener("load", (event) => {
|
||||||
|
let img = document.createElement("img")
|
||||||
|
img.src = reader.result
|
||||||
|
onUseAsThumbnailClick(
|
||||||
|
{
|
||||||
|
use_lora_model: LoraUI.modelField.value,
|
||||||
|
},
|
||||||
|
img
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
reader.readAsDataURL(file)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
updateFields() {
|
||||||
|
document.getElementById("civitai-section").classList.add("displayNone")
|
||||||
|
Bucket.retrieve(`modelinfo/lora/${LoraUI.modelField.value}`)
|
||||||
|
.then((info) => {
|
||||||
|
if (info == null) {
|
||||||
|
LoraUI.keywordsField.value = ""
|
||||||
|
LoraUI.notesField.value = ""
|
||||||
|
LoraUI.hideCivitaiLink()
|
||||||
|
} else {
|
||||||
|
LoraUI.keywordsField.value = info.keywords.join("\n")
|
||||||
|
LoraUI.notesField.value = info.notes
|
||||||
|
if ("civitai" in info && info["civitai"] != null) {
|
||||||
|
LoraUI.showCivitaiLink(info.civitai)
|
||||||
|
} else {
|
||||||
|
LoraUI.hideCivitaiLink()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Bucket.getImageAsDataURL(`${profileNameField.value}/lora/${LoraUI.modelField.value}.png`)
|
||||||
|
.then((data) => {
|
||||||
|
LoraUI.image.src=data
|
||||||
|
LoraUI.image.classList.remove("displayNone")
|
||||||
|
LoraUI.imagePlaceholder.classList.add("displayNone")
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
LoraUI.image.classList.add("displayNone")
|
||||||
|
LoraUI.imagePlaceholder.classList.remove("displayNone")
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
saveInfos() {
|
||||||
|
let info = {
|
||||||
|
keywords: LoraUI.keywordsField.value
|
||||||
|
.split("\n")
|
||||||
|
.filter((x) => (x != "")),
|
||||||
|
notes: LoraUI.notesField.value,
|
||||||
|
civitai: LoraUI.civitaiSection.checkVisibility() ? LoraUI.civitaiAnchor.href : null,
|
||||||
|
}
|
||||||
|
Bucket.store(`modelinfo/lora/${LoraUI.modelField.value}`, info)
|
||||||
|
},
|
||||||
|
|
||||||
|
importFromCivitai() {
|
||||||
|
document.body.style["cursor"] = "progress"
|
||||||
|
fetch("/sha256/lora/"+LoraUI.modelField.value)
|
||||||
|
.then((result) => result.json())
|
||||||
|
.then((json) => fetch("https://civitai.com/api/v1/model-versions/by-hash/" + json.digest))
|
||||||
|
.then((result) => result.json())
|
||||||
|
.then((json) => {
|
||||||
|
document.body.style["cursor"] = "default"
|
||||||
|
if (json == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ("trainedWords" in json) {
|
||||||
|
LoraUI.keywordsField.value = json["trainedWords"].join("\n")
|
||||||
|
} else {
|
||||||
|
showToast("No keyword info found.")
|
||||||
|
}
|
||||||
|
if ("modelId" in json) {
|
||||||
|
LoraUI.showCivitaiLink("https://civitai.com/models/" + json.modelId)
|
||||||
|
} else {
|
||||||
|
LoraUI.hideCivitaiLink()
|
||||||
|
}
|
||||||
|
|
||||||
|
LoraUI.saveInfos()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
showCivitaiLink(href) {
|
||||||
|
LoraUI.civitaiSection.classList.remove("displayNone")
|
||||||
|
LoraUI.civitaiAnchor.href = href
|
||||||
|
LoraUI.civitaiAnchor.innerHTML = LoraUI.civitaiAnchor.href
|
||||||
|
},
|
||||||
|
|
||||||
|
hideCivitaiLink() {
|
||||||
|
LoraUI.civitaiSection.classList.add("displayNone")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createTab({
|
||||||
|
id: "merge",
|
||||||
|
icon: "fa-toolbox",
|
||||||
|
label: "Model tools",
|
||||||
|
css: mergeCSS,
|
||||||
|
content: tabHTML,
|
||||||
|
onOpen: ({ firstOpen }) => {
|
||||||
|
if (!firstOpen) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
initMergeUI()
|
||||||
|
LoraUI.init()
|
||||||
|
const tabMergeUI = document.querySelector("#tab-model-mergeUI")
|
||||||
|
const tabLoraUI = document.querySelector("#tab-model-loraUI")
|
||||||
|
linkTabContents(tabMergeUI)
|
||||||
|
linkTabContents(tabLoraUI)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})()
|
||||||
|
async function getLoraKeywords(model) {
|
||||||
|
return Bucket.retrieve(`modelinfo/lora/${model}`)
|
||||||
|
.then((info) => info ? info.keywords : [])
|
||||||
|
}
|
Reference in New Issue
Block a user