Adityadn commited on
Commit
d26632f
1 Parent(s): 4c01549

Upload 39 files

Browse files
.dockerignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .idea
.gitignore ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__
2
+ *.ckpt
3
+ *.safetensors
4
+ *.pth
5
+ *.pt
6
+ *.bin
7
+ *.patch
8
+ *.backup
9
+ *.corrupted
10
+ *.partial
11
+ *.onnx
12
+ sorted_styles.json
13
+ /input
14
+ /cache
15
+ /language/default.json
16
+ /test_imgs
17
+ config.txt
18
+ config_modification_tutorial.txt
19
+ user_path_config.txt
20
+ user_path_config-deprecated.txt
21
+ /modules/*.png
22
+ /repositories
23
+ /fooocus_env
24
+ /venv
25
+ /tmp
26
+ /ui-config.json
27
+ /outputs
28
+ /config.json
29
+ /log
30
+ /webui.settings.bat
31
+ /embeddings
32
+ /styles.csv
33
+ /params.txt
34
+ /styles.csv.bak
35
+ /webui-user.bat
36
+ /webui-user.sh
37
+ /interrogate
38
+ /user.css
39
+ /.idea
40
+ /notification.ogg
41
+ /notification.mp3
42
+ /SwinIR
43
+ /textual_inversion
44
+ .vscode
45
+ /extensions
46
+ /test/stdout.txt
47
+ /test/stderr.txt
48
+ /cache.json*
49
+ /config_states/
50
+ /node_modules
51
+ /package-lock.json
52
+ /.coverage*
53
+ /auth.json
54
+ .DS_Store
.run anime.bat ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .python\\ai\\python.exe -s entry_with_update.py --attention-split --always-cpu --preset anime
2
+ pause
.run default.bat ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .python\\ai\\python.exe -s entry_with_update.py --attention-split --always-cpu --preset default
2
+ pause
.run lcm.bat ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .python\\ai\\python.exe -s entry_with_update.py --attention-split --always-cpu --preset lcm
2
+ pause
.run realistic.bat ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .python\\ai\\python.exe -s entry_with_update.py --attention-split --always-cpu --preset realistic
2
+ pause
.run sai.bat ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .python\\ai\\python.exe -s entry_with_update.py --attention-split --always-cpu --preset sai
2
+ pause
.run.bat ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .python\\ai\\python.exe -s entry_with_update.py --always-cpu --attention-split --always-download-new-model
2
+ pause
Dockerfile ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:12.3.1-base-ubuntu22.04
2
+ ENV DEBIAN_FRONTEND noninteractive
3
+ ENV CMDARGS --listen
4
+
5
+ RUN apt-get update -y && \
6
+ apt-get install -y curl libgl1 libglib2.0-0 python3-pip python-is-python3 git && \
7
+ apt-get clean && \
8
+ rm -rf /var/lib/apt/lists/*
9
+
10
+ COPY requirements_docker.txt requirements_versions.txt /tmp/
11
+ RUN pip install --no-cache-dir -r /tmp/requirements_docker.txt -r /tmp/requirements_versions.txt && \
12
+ rm -f /tmp/requirements_docker.txt /tmp/requirements_versions.txt
13
+ RUN pip install --no-cache-dir xformers==0.0.22 --no-dependencies
14
+ RUN curl -fsL -o /usr/local/lib/python3.10/dist-packages/gradio/frpc_linux_amd64_v0.2 https://cdn-media.huggingface.co/frpc-gradio-0.2/frpc_linux_amd64 && \
15
+ chmod +x /usr/local/lib/python3.10/dist-packages/gradio/frpc_linux_amd64_v0.2
16
+
17
+ RUN adduser --disabled-password --gecos '' user && \
18
+ mkdir -p /content/app /content/data
19
+
20
+ COPY entrypoint.sh /content/
21
+ RUN chown -R user:user /content
22
+
23
+ WORKDIR /content
24
+ USER user
25
+
26
+ RUN git clone https://github.com/lllyasviel/Fooocus /content/app
27
+ RUN mv /content/app/models /content/app/models.org
28
+
29
+ CMD [ "sh", "-c", "/content/entrypoint.sh ${CMDARGS}" ]
LICENSE ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <https://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <https://www.gnu.org/licenses/why-not-lgpl.html>.
aiDescTerminal.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import numpy as np
4
+ from PIL import Image
5
+ import requests
6
+ from io import BytesIO
7
+
8
+ root = os.path.dirname(os.path.abspath(__file__))
9
+ sys.path.append(root)
10
+ os.chdir(root)
11
+
12
+ import modules.config
13
+ import modules.html
14
+ import modules.flags as flags
15
+ import modules.meta_parser
16
+
17
+ def download_image(url):
18
+ response = requests.get(url)
19
+ img = Image.open(BytesIO(response.content)).convert("RGB")
20
+ return img
21
+
22
+ def trigger_describe(mode, img_path):
23
+ print("Running")
24
+ print("Press Ctrl+C for Stop ")
25
+ if mode == flags.desc_type_photo:
26
+ from extras.interrogate import default_interrogator as default_interrogator_photo
27
+ if img_path.startswith('http'):
28
+ img = download_image(img_path)
29
+ else:
30
+ img = Image.open(img_path).convert("RGB")
31
+ return default_interrogator_photo(img), ["Fooocus V2", "Fooocus Enhance", "Fooocus Sharp"]
32
+ elif mode == flags.desc_type_anime:
33
+ from extras.wd14tagger import default_interrogator as default_interrogator_anime
34
+ if img_path.startswith('http'):
35
+ img = download_image(img_path)
36
+ elif isinstance(img_path, str):
37
+ # Load the image if the input is a path
38
+ img = Image.open(img_path).convert("RGB")
39
+ elif isinstance(img_path, np.ndarray):
40
+ # Use the provided NumPy array directly
41
+ img = Image.fromarray(img_path).convert("RGB")
42
+ else:
43
+ raise ValueError("Invalid image format. Please provide a valid path or NumPy array.")
44
+
45
+ # Convert the image to a NumPy array
46
+ img_array = np.array(img)
47
+
48
+ return default_interrogator_anime(img_array), ["Fooocus V2", "Fooocus Masterpiece"]
49
+ return mode, ["Fooocus V2"]
50
+
51
+ style_selections = modules.config.default_styles
52
+
53
+ def run_describe(image_path, content_type):
54
+ desc_input_image = image_path
55
+ desc_method = content_type
56
+
57
+ result, style_selections = None, None
58
+
59
+ if desc_method in ["Photograph", "1", ""]:
60
+ desc_method = "Photograph (1)"
61
+ result, style_selections = trigger_describe(flags.desc_type_photo, desc_input_image)
62
+ elif desc_method in ["Art/Anime", "2"]:
63
+ desc_method = "Art/Anime (2)"
64
+ result, style_selections = trigger_describe(flags.desc_type_anime, desc_input_image)
65
+ else:
66
+ print("ERROR!")
67
+
68
+ if result or style_selections != "":
69
+ style_selections = ""
70
+ print("Result:", result)
71
+ # print("Style Selections:", style_selections)
72
+ quit()
73
+
74
+ if __name__ == "__main__":
75
+ desc_input_image = input("Path to Image (local path or URL): ")
76
+
77
+ if desc_input_image == "":
78
+ desc_input_image = "./imgs/Gambar1.jpg"
79
+
80
+ print(f"You use: {desc_input_image}")
81
+
82
+ desc_method = input(
83
+ """
84
+ Select Content Type:
85
+ Photograph (1)
86
+ Art/Anime (2)
87
+ """
88
+ )
89
+
90
+ run_describe(desc_input_image, desc_method)
aiDescUI.py ADDED
@@ -0,0 +1,688 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ import os
4
+ # import json
5
+ import time
6
+ import shared
7
+ import modules.config
8
+ # import fooocus_version
9
+ import modules.html
10
+ import modules.async_worker as worker
11
+ import modules.constants as constants
12
+ import modules.flags as flags
13
+ import modules.gradio_hijack as grh
14
+ import modules.style_sorter as style_sorter
15
+ import modules.meta_parser
16
+ import args_manager
17
+ import copy
18
+
19
+ from modules.sdxl_styles import legal_style_names
20
+ from modules.private_logger import get_current_html_path
21
+ from modules.ui_gradio_extensions import reload_javascript
22
+ from modules.auth import auth_enabled, check_auth
23
+ # from modules.util import is_json
24
+
25
+ # def get_task(*args):
26
+ # args = list(args)
27
+ # args.pop(0)
28
+
29
+ # return worker.AsyncTask(args=args)
30
+
31
+ # def generate_clicked(task):
32
+ # import ldm_patched.modules.model_management as model_management
33
+
34
+ # with model_management.interrupt_processing_mutex:
35
+ # model_management.interrupt_processing = False
36
+ # # outputs=[progress_html, progress_window, progress_gallery, gallery]
37
+ # execution_start_time = time.perf_counter()
38
+ # finished = False
39
+
40
+ # yield gr.update(visible=True, value=modules.html.make_progress_html(1, 'Waiting for task to start ...')), \
41
+ # gr.update(visible=True, value=None), \
42
+ # gr.update(visible=False, value=None), \
43
+ # gr.update(visible=False)
44
+
45
+ # worker.async_tasks.append(task)
46
+
47
+ # while not finished:
48
+ # time.sleep(0.01)
49
+ # if len(task.yields) > 0:
50
+ # flag, product = task.yields.pop(0)
51
+ # if flag == 'preview':
52
+
53
+ # # help bad internet connection by skipping duplicated preview
54
+ # if len(task.yields) > 0: # if we have the next item
55
+ # if task.yields[0][0] == 'preview': # if the next item is also a preview
56
+ # # print('Skipped one preview for better internet connection.')
57
+ # continue
58
+
59
+ # percentage, title, image = product
60
+ # yield gr.update(visible=True, value=modules.html.make_progress_html(percentage, title)), \
61
+ # gr.update(visible=True, value=image) if image is not None else gr.update(), \
62
+ # gr.update(), \
63
+ # gr.update(visible=False)
64
+ # if flag == 'results':
65
+ # yield gr.update(visible=True), \
66
+ # gr.update(visible=True), \
67
+ # gr.update(visible=True, value=product), \
68
+ # gr.update(visible=False)
69
+ # if flag == 'finish':
70
+ # yield gr.update(visible=False), \
71
+ # gr.update(visible=False), \
72
+ # gr.update(visible=False), \
73
+ # gr.update(visible=True, value=product)
74
+ # finished = True
75
+
76
+ # # delete Fooocus temp images, only keep gradio temp images
77
+ # if args_manager.args.disable_image_log:
78
+ # for filepath in product:
79
+ # if isinstance(filepath, str) and os.path.exists(filepath):
80
+ # os.remove(filepath)
81
+
82
+ # execution_time = time.perf_counter() - execution_start_time
83
+ # print(f'Total time: {execution_time:.2f} seconds')
84
+ # return
85
+
86
+
87
+ reload_javascript()
88
+
89
+ title = 'AI Describe Image'
90
+
91
+ if isinstance(args_manager.args.preset, str):
92
+ title += ' ' + args_manager.args.preset
93
+
94
+ shared.gradio_root = gr.Blocks(
95
+ title=title,
96
+ css=modules.html.css).queue()
97
+
98
+ with shared.gradio_root:
99
+ # currentTask = gr.State(worker.AsyncTask(args=[]))
100
+ with gr.Row():
101
+ with gr.Column(scale=2):
102
+ # with gr.Row():
103
+ # progress_window = grh.Image(label='Preview', show_label=True, visible=False, height=768,
104
+ # elem_classes=['main_view'])
105
+ # progress_gallery = gr.Gallery(label='Finished Images', show_label=True, object_fit='contain',
106
+ # height=768, visible=False, elem_classes=['main_view', 'image_gallery'])
107
+ # progress_html = gr.HTML(value=modules.html.make_progress_html(32, 'Progress 32%'), visible=False,
108
+ # elem_id='progress-bar', elem_classes='progress-bar')
109
+ # gallery = gr.Gallery(label='Gallery', show_label=False, object_fit='contain', visible=True, height=768,
110
+ # elem_classes=['resizable_area', 'main_view', 'final_gallery', 'image_gallery'],
111
+ # elem_id='final_gallery')
112
+ with gr.Row(visible=True) as image_input_panel:
113
+ with gr.Tabs():
114
+ # with gr.TabItem(label='Upscale or Variation') as uov_tab:
115
+ # with gr.Row():
116
+ # with gr.Column():
117
+ # uov_input_image = grh.Image(label='Drag above image to here', source='upload', type='numpy')
118
+ # with gr.Column():
119
+ # uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list, value=flags.disabled)
120
+ # gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/390" target="_blank">\U0001F4D4 Document</a>')
121
+ # with gr.TabItem(label='Image Prompt') as ip_tab:
122
+ # with gr.Row():
123
+ # ip_images = []
124
+ # ip_types = []
125
+ # ip_stops = []
126
+ # ip_weights = []
127
+ # ip_ctrls = []
128
+ # ip_ad_cols = []
129
+ # for _ in range(flags.controlnet_image_count):
130
+ # with gr.Column():
131
+ # ip_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False, height=300)
132
+ # ip_images.append(ip_image)
133
+ # ip_ctrls.append(ip_image)
134
+ # with gr.Column(visible=False) as ad_col:
135
+ # with gr.Row():
136
+ # default_end, default_weight = flags.default_parameters[flags.default_ip]
137
+
138
+ # ip_stop = gr.Slider(label='Stop At', minimum=0.0, maximum=1.0, step=0.001, value=default_end)
139
+ # ip_stops.append(ip_stop)
140
+ # ip_ctrls.append(ip_stop)
141
+
142
+ # ip_weight = gr.Slider(label='Weight', minimum=0.0, maximum=2.0, step=0.001, value=default_weight)
143
+ # ip_weights.append(ip_weight)
144
+ # ip_ctrls.append(ip_weight)
145
+
146
+ # ip_type = gr.Radio(label='Type', choices=flags.ip_list, value=flags.default_ip, container=False)
147
+ # ip_types.append(ip_type)
148
+ # ip_ctrls.append(ip_type)
149
+
150
+ # ip_type.change(lambda x: flags.default_parameters[x], inputs=[ip_type], outputs=[ip_stop, ip_weight], queue=False, show_progress=False)
151
+ # ip_ad_cols.append(ad_col)
152
+ # ip_advanced = gr.Checkbox(label='Advanced', value=False, container=False)
153
+ # gr.HTML('* \"Image Prompt\" is powered by Fooocus Image Mixture Engine (v1.0.1). <a href="https://github.com/lllyasviel/Fooocus/discussions/557" target="_blank">\U0001F4D4 Document</a>')
154
+
155
+ # def ip_advance_checked(x):
156
+ # return [gr.update(visible=x)] * len(ip_ad_cols) + \
157
+ # [flags.default_ip] * len(ip_types) + \
158
+ # [flags.default_parameters[flags.default_ip][0]] * len(ip_stops) + \
159
+ # [flags.default_parameters[flags.default_ip][1]] * len(ip_weights)
160
+
161
+ # ip_advanced.change(ip_advance_checked, inputs=ip_advanced,
162
+ # outputs=ip_ad_cols + ip_types + ip_stops + ip_weights,
163
+ # queue=False, show_progress=False)
164
+ # with gr.TabItem(label='Inpaint or Outpaint') as inpaint_tab:
165
+ # with gr.Row():
166
+ # inpaint_input_image = grh.Image(label='Drag inpaint or outpaint image to here', source='upload', type='numpy', tool='sketch', height=500, brush_color="#FFFFFF", elem_id='inpaint_canvas')
167
+ # inpaint_mask_image = grh.Image(label='Mask Upload', source='upload', type='numpy', height=500, visible=False)
168
+
169
+ # with gr.Row():
170
+ # inpaint_additional_prompt = gr.Textbox(placeholder="Describe what you want to inpaint.", elem_id='inpaint_additional_prompt', label='Inpaint Additional Prompt', visible=False)
171
+ # outpaint_selections = gr.CheckboxGroup(choices=['Left', 'Right', 'Top', 'Bottom'], value=[], label='Outpaint Direction')
172
+ # inpaint_mode = gr.Dropdown(choices=modules.flags.inpaint_options, value=modules.flags.inpaint_option_default, label='Method')
173
+ # example_inpaint_prompts = gr.Dataset(samples=modules.config.example_inpaint_prompts, label='Additional Prompt Quick List', components=[inpaint_additional_prompt], visible=False)
174
+ # gr.HTML('* Powered by Fooocus Inpaint Engine <a href="https://github.com/lllyasviel/Fooocus/discussions/414" target="_blank">\U0001F4D4 Document</a>')
175
+ # example_inpaint_prompts.click(lambda x: x[0], inputs=example_inpaint_prompts, outputs=inpaint_additional_prompt, show_progress=False, queue=False)
176
+ with gr.TabItem(label='Describe') as desc_tab:
177
+ with gr.Row():
178
+ with gr.Column():
179
+ desc_input_image = grh.Image(label='Drag any image to here', source='upload', type='numpy')
180
+ with gr.Column():
181
+ # with gr.Row(elem_classes='type_row'):
182
+ with gr.Row():
183
+ prompt = gr.Textbox(label="Output", show_label=True, elem_id='positive_prompt', container=True, autofocus=True, show_copy_button=True, interactive=True)
184
+
185
+ default_prompt = modules.config.default_prompt
186
+ if isinstance(default_prompt, str) and default_prompt != '':
187
+ shared.gradio_root.load(lambda: default_prompt, outputs=prompt)
188
+
189
+ # with gr.Column(scale=3, min_width=0):
190
+ # generate_button = gr.Button(label="Generate", value="Generate", elem_classes='type_row', elem_id='generate_button', visible=True)
191
+ # load_parameter_button = gr.Button(label="Load Parameters", value="Load Parameters", elem_classes='type_row', elem_id='load_parameter_button', visible=False)
192
+ # skip_button = gr.Button(label="Skip", value="Skip", elem_classes='type_row_half', visible=False)
193
+ # stop_button = gr.Button(label="Stop", value="Stop", elem_classes='type_row_half', elem_id='stop_button', visible=False)
194
+
195
+ # def stop_clicked(currentTask):
196
+ # import ldm_patched.modules.model_management as model_management
197
+ # currentTask.last_stop = 'stop'
198
+ # if (currentTask.processing):
199
+ # model_management.interrupt_current_processing()
200
+ # return currentTask
201
+
202
+ # def skip_clicked(currentTask):
203
+ # import ldm_patched.modules.model_management as model_management
204
+ # currentTask.last_stop = 'skip'
205
+ # if (currentTask.processing):
206
+ # model_management.interrupt_current_processing()
207
+ # return currentTask
208
+
209
+ # stop_button.click(stop_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False, _js='cancelGenerateForever')
210
+ # skip_button.click(skip_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False)
211
+ # with gr.Row(elem_classes='advanced_check_row'):
212
+ # # input_image_checkbox = gr.Checkbox(label='Input Image', value=False, container=False, elem_classes='min_check')
213
+ # advanced_checkbox = gr.Checkbox(label='Advanced', value=modules.config.default_advanced_checkbox, container=False, elem_classes='min_check')
214
+ with gr.Row():
215
+ desc_method = gr.Radio(
216
+ label='Content Type',
217
+ choices=[flags.desc_type_photo, flags.desc_type_anime],
218
+ value=flags.desc_type_photo)
219
+ desc_btn = gr.Button(value='Describe this Image into Prompt')
220
+ # gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/1363" target="_blank">\U0001F4D4 Document</a>')
221
+ # with gr.TabItem(label='Metadata') as load_tab:
222
+ # with gr.Column():
223
+ # metadata_input_image = grh.Image(label='Drag any image generated by Fooocus here', source='upload', type='filepath')
224
+ # metadata_json = gr.JSON(label='Metadata')
225
+ # metadata_import_button = gr.Button(value='Apply Metadata')
226
+
227
+ # def trigger_metadata_preview(filepath):
228
+ # parameters, metadata_scheme = modules.meta_parser.read_info_from_image(filepath)
229
+
230
+ # results = {}
231
+ # if parameters is not None:
232
+ # results['parameters'] = parameters
233
+
234
+ # if isinstance(metadata_scheme, flags.MetadataScheme):
235
+ # results['metadata_scheme'] = metadata_scheme.value
236
+
237
+ # return results
238
+
239
+ # metadata_input_image.upload(trigger_metadata_preview, inputs=metadata_input_image,
240
+ # outputs=metadata_json, queue=False, show_progress=True)
241
+
242
+ switch_js = "(x) => {if(x){viewer_to_bottom(100);viewer_to_bottom(500);}else{viewer_to_top();} return x;}"
243
+ down_js = "() => {viewer_to_bottom();}"
244
+
245
+ # input_image_checkbox.change(lambda x: gr.update(visible=x), inputs=input_image_checkbox,
246
+ # outputs=image_input_panel, queue=False, show_progress=False, _js=switch_js)
247
+ # ip_advanced.change(lambda: None, queue=False, show_progress=False, _js=down_js)
248
+
249
+ # current_tab = gr.Textbox(value='desc', visible=False)
250
+ # # uov_tab.select(lambda: 'uov', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
251
+ # # inpaint_tab.select(lambda: 'inpaint', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
252
+ # # ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
253
+ # desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
254
+
255
+ # with gr.Column(scale=1, visible=modules.config.default_advanced_checkbox) as advanced_column:
256
+ # with gr.Tab(label='Setting'):
257
+ # performance_selection = gr.Radio(label='Performance',
258
+ # choices=modules.flags.performance_selections,
259
+ # value=modules.config.default_performance)
260
+ # aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios,
261
+ # value=modules.config.default_aspect_ratio, info='width × height',
262
+ # elem_classes='aspect_ratios')
263
+ # image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number)
264
+
265
+ # output_format = gr.Radio(label='Output Format',
266
+ # choices=modules.flags.output_formats,
267
+ # value=modules.config.default_output_format)
268
+
269
+ # negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.",
270
+ # info='Describing what you do not want to see.', lines=2,
271
+ # elem_id='negative_prompt',
272
+ # value=modules.config.default_prompt_negative)
273
+ # seed_random = gr.Checkbox(label='Random', value=True)
274
+ # image_seed = gr.Textbox(label='Seed', value=0, max_lines=1, visible=False) # workaround for https://github.com/gradio-app/gradio/issues/5354
275
+
276
+ # def random_checked(r):
277
+ # return gr.update(visible=not r)
278
+
279
+ # def refresh_seed(r, seed_string):
280
+ # if r:
281
+ # return random.randint(constants.MIN_SEED, constants.MAX_SEED)
282
+ # else:
283
+ # try:
284
+ # seed_value = int(seed_string)
285
+ # if constants.MIN_SEED <= seed_value <= constants.MAX_SEED:
286
+ # return seed_value
287
+ # except ValueError:
288
+ # pass
289
+ # return random.randint(constants.MIN_SEED, constants.MAX_SEED)
290
+
291
+ # seed_random.change(random_checked, inputs=[seed_random], outputs=[image_seed],
292
+ # queue=False, show_progress=False)
293
+
294
+ # def update_history_link():
295
+ # if args_manager.args.disable_image_log:
296
+ # return gr.update(value='')
297
+
298
+ # return gr.update(value=f'<a href="file={get_current_html_path(output_format)}" target="_blank">\U0001F4DA History Log</a>')
299
+
300
+ # history_link = gr.HTML()
301
+ # shared.gradio_root.load(update_history_link, outputs=history_link, queue=False, show_progress=False)
302
+
303
+ # with gr.Tab(label='Style'):
304
+ # style_sorter.try_load_sorted_styles(
305
+ # style_names=legal_style_names,
306
+ # default_selected=modules.config.default_styles)
307
+
308
+ # style_search_bar = gr.Textbox(show_label=False, container=False,
309
+ # placeholder="\U0001F50E Type here to search styles ...",
310
+ # value="",
311
+ # label='Search Styles')
312
+ # style_selections = gr.CheckboxGroup(show_label=False, container=False,
313
+ # choices=copy.deepcopy(style_sorter.all_styles),
314
+ # value=copy.deepcopy(modules.config.default_styles),
315
+ # label='Selected Styles',
316
+ # elem_classes=['style_selections'])
317
+ # gradio_receiver_style_selections = gr.Textbox(elem_id='gradio_receiver_style_selections', visible=False)
318
+
319
+ # shared.gradio_root.load(lambda: gr.update(choices=copy.deepcopy(style_sorter.all_styles)),
320
+ # outputs=style_selections)
321
+
322
+ # style_search_bar.change(style_sorter.search_styles,
323
+ # inputs=[style_selections, style_search_bar],
324
+ # outputs=style_selections,
325
+ # queue=False,
326
+ # show_progress=False).then(
327
+ # lambda: None, _js='()=>{refresh_style_localization();}')
328
+
329
+ # gradio_receiver_style_selections.input(style_sorter.sort_styles,
330
+ # inputs=style_selections,
331
+ # outputs=style_selections,
332
+ # queue=False,
333
+ # show_progress=False).then(
334
+ # lambda: None, _js='()=>{refresh_style_localization();}')
335
+
336
+ # with gr.Tab(label='Model'):
337
+ # with gr.Group():
338
+ # with gr.Row():
339
+ # base_model = gr.Dropdown(label='Base Model (SDXL only)', choices=modules.config.model_filenames, value=modules.config.default_base_model_name, show_label=True)
340
+ # refiner_model = gr.Dropdown(label='Refiner (SDXL or SD 1.5)', choices=['None'] + modules.config.model_filenames, value=modules.config.default_refiner_model_name, show_label=True)
341
+
342
+ # refiner_switch = gr.Slider(label='Refiner Switch At', minimum=0.1, maximum=1.0, step=0.0001,
343
+ # info='Use 0.4 for SD1.5 realistic models; '
344
+ # 'or 0.667 for SD1.5 anime models; '
345
+ # 'or 0.8 for XL-refiners; '
346
+ # 'or any value for switching two SDXL models.',
347
+ # value=modules.config.default_refiner_switch,
348
+ # visible=modules.config.default_refiner_model_name != 'None')
349
+
350
+ # refiner_model.change(lambda x: gr.update(visible=x != 'None'),
351
+ # inputs=refiner_model, outputs=refiner_switch, show_progress=False, queue=False)
352
+
353
+ # with gr.Group():
354
+ # lora_ctrls = []
355
+
356
+ # for i, (n, v) in enumerate(modules.config.default_loras):
357
+ # with gr.Row():
358
+ # lora_enabled = gr.Checkbox(label='Enable', value=True,
359
+ # elem_classes=['lora_enable', 'min_check'], scale=1)
360
+ # lora_model = gr.Dropdown(label=f'LoRA {i + 1}',
361
+ # choices=['None'] + modules.config.lora_filenames, value=n,
362
+ # elem_classes='lora_model', scale=5)
363
+ # lora_weight = gr.Slider(label='Weight', minimum=modules.config.default_loras_min_weight,
364
+ # maximum=modules.config.default_loras_max_weight, step=0.01, value=v,
365
+ # elem_classes='lora_weight', scale=5)
366
+ # lora_ctrls += [lora_enabled, lora_model, lora_weight]
367
+
368
+ # with gr.Row():
369
+ # model_refresh = gr.Button(label='Refresh', value='\U0001f504 Refresh All Files', variant='secondary', elem_classes='refresh_button')
370
+ # with gr.Tab(label='Advanced'):
371
+ # guidance_scale = gr.Slider(label='Guidance Scale', minimum=1.0, maximum=30.0, step=0.01,
372
+ # value=modules.config.default_cfg_scale,
373
+ # info='Higher value means style is cleaner, vivider, and more artistic.')
374
+ # sharpness = gr.Slider(label='Image Sharpness', minimum=0.0, maximum=30.0, step=0.001,
375
+ # value=modules.config.default_sample_sharpness,
376
+ # info='Higher value means image and texture are sharper.')
377
+ # gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/117" target="_blank">\U0001F4D4 Document</a>')
378
+ # dev_mode = gr.Checkbox(label='Developer Debug Mode', value=False, container=False)
379
+
380
+ # with gr.Column(visible=False) as dev_tools:
381
+ # with gr.Tab(label='Debug Tools'):
382
+ # adm_scaler_positive = gr.Slider(label='Positive ADM Guidance Scaler', minimum=0.1, maximum=3.0,
383
+ # step=0.001, value=1.5, info='The scaler multiplied to positive ADM (use 1.0 to disable). ')
384
+ # adm_scaler_negative = gr.Slider(label='Negative ADM Guidance Scaler', minimum=0.1, maximum=3.0,
385
+ # step=0.001, value=0.8, info='The scaler multiplied to negative ADM (use 1.0 to disable). ')
386
+ # adm_scaler_end = gr.Slider(label='ADM Guidance End At Step', minimum=0.0, maximum=1.0,
387
+ # step=0.001, value=0.3,
388
+ # info='When to end the guidance from positive/negative ADM. ')
389
+
390
+ # refiner_swap_method = gr.Dropdown(label='Refiner swap method', value=flags.refiner_swap_method,
391
+ # choices=['joint', 'separate', 'vae'])
392
+
393
+ # adaptive_cfg = gr.Slider(label='CFG Mimicking from TSNR', minimum=1.0, maximum=30.0, step=0.01,
394
+ # value=modules.config.default_cfg_tsnr,
395
+ # info='Enabling Fooocus\'s implementation of CFG mimicking for TSNR '
396
+ # '(effective when real CFG > mimicked CFG).')
397
+ # sampler_name = gr.Dropdown(label='Sampler', choices=flags.sampler_list,
398
+ # value=modules.config.default_sampler)
399
+ # scheduler_name = gr.Dropdown(label='Scheduler', choices=flags.scheduler_list,
400
+ # value=modules.config.default_scheduler)
401
+
402
+ # generate_image_grid = gr.Checkbox(label='Generate Image Grid for Each Batch',
403
+ # info='(Experimental) This may cause performance problems on some computers and certain internet conditions.',
404
+ # value=False)
405
+
406
+ # overwrite_step = gr.Slider(label='Forced Overwrite of Sampling Step',
407
+ # minimum=-1, maximum=200, step=1,
408
+ # value=modules.config.default_overwrite_step,
409
+ # info='Set as -1 to disable. For developer debugging.')
410
+ # overwrite_switch = gr.Slider(label='Forced Overwrite of Refiner Switch Step',
411
+ # minimum=-1, maximum=200, step=1,
412
+ # value=modules.config.default_overwrite_switch,
413
+ # info='Set as -1 to disable. For developer debugging.')
414
+ # overwrite_width = gr.Slider(label='Forced Overwrite of Generating Width',
415
+ # minimum=-1, maximum=2048, step=1, value=-1,
416
+ # info='Set as -1 to disable. For developer debugging. '
417
+ # 'Results will be worse for non-standard numbers that SDXL is not trained on.')
418
+ # overwrite_height = gr.Slider(label='Forced Overwrite of Generating Height',
419
+ # minimum=-1, maximum=2048, step=1, value=-1,
420
+ # info='Set as -1 to disable. For developer debugging. '
421
+ # 'Results will be worse for non-standard numbers that SDXL is not trained on.')
422
+ # overwrite_vary_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Vary"',
423
+ # minimum=-1, maximum=1.0, step=0.001, value=-1,
424
+ # info='Set as negative number to disable. For developer debugging.')
425
+ # overwrite_upscale_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Upscale"',
426
+ # minimum=-1, maximum=1.0, step=0.001, value=-1,
427
+ # info='Set as negative number to disable. For developer debugging.')
428
+ # disable_preview = gr.Checkbox(label='Disable Preview', value=False,
429
+ # info='Disable preview during generation.')
430
+ # disable_intermediate_results = gr.Checkbox(label='Disable Intermediate Results',
431
+ # value=modules.config.default_performance == 'Extreme Speed',
432
+ # interactive=modules.config.default_performance != 'Extreme Speed',
433
+ # info='Disable intermediate results during generation, only show final gallery.')
434
+ # disable_seed_increment = gr.Checkbox(label='Disable seed increment',
435
+ # info='Disable automatic seed increment when image number is > 1.',
436
+ # value=False)
437
+
438
+ # # if not args_manager.args.disable_metadata:
439
+ # # save_metadata_to_images = gr.Checkbox(label='Save Metadata to Images', value=modules.config.default_save_metadata_to_images,
440
+ # # info='Adds parameters to generated images allowing manual regeneration.')
441
+ # # metadata_scheme = gr.Radio(label='Metadata Scheme', choices=flags.metadata_scheme, value=modules.config.default_metadata_scheme,
442
+ # # info='Image Prompt parameters are not included. Use png and a1111 for compatibility with Civitai.',
443
+ # # visible=modules.config.default_save_metadata_to_images)
444
+
445
+ # # save_metadata_to_images.change(lambda x: gr.update(visible=x), inputs=[save_metadata_to_images], outputs=[metadata_scheme],
446
+ # # queue=False, show_progress=False)
447
+
448
+ # # with gr.Tab(label='Control'):
449
+ # # debugging_cn_preprocessor = gr.Checkbox(label='Debug Preprocessors', value=False,
450
+ # # info='See the results from preprocessors.')
451
+ # # skipping_cn_preprocessor = gr.Checkbox(label='Skip Preprocessors', value=False,
452
+ # # info='Do not preprocess images. (Inputs are already canny/depth/cropped-face/etc.)')
453
+
454
+ # # mixing_image_prompt_and_vary_upscale = gr.Checkbox(label='Mixing Image Prompt and Vary/Upscale',
455
+ # # value=False)
456
+ # # mixing_image_prompt_and_inpaint = gr.Checkbox(label='Mixing Image Prompt and Inpaint',
457
+ # # value=False)
458
+
459
+ # # controlnet_softness = gr.Slider(label='Softness of ControlNet', minimum=0.0, maximum=1.0,
460
+ # # step=0.001, value=0.25,
461
+ # # info='Similar to the Control Mode in A1111 (use 0.0 to disable). ')
462
+
463
+ # # with gr.Tab(label='Canny'):
464
+ # # canny_low_threshold = gr.Slider(label='Canny Low Threshold', minimum=1, maximum=255,
465
+ # # step=1, value=64)
466
+ # # canny_high_threshold = gr.Slider(label='Canny High Threshold', minimum=1, maximum=255,
467
+ # # step=1, value=128)
468
+
469
+ # # with gr.Tab(label='Inpaint'):
470
+ # # debugging_inpaint_preprocessor = gr.Checkbox(label='Debug Inpaint Preprocessing', value=False)
471
+ # # inpaint_disable_initial_latent = gr.Checkbox(label='Disable initial latent in inpaint', value=False)
472
+ # # inpaint_engine = gr.Dropdown(label='Inpaint Engine',
473
+ # # value=modules.config.default_inpaint_engine_version,
474
+ # # choices=flags.inpaint_engine_versions,
475
+ # # info='Version of Fooocus inpaint model')
476
+ # # inpaint_strength = gr.Slider(label='Inpaint Denoising Strength',
477
+ # # minimum=0.0, maximum=1.0, step=0.001, value=1.0,
478
+ # # info='Same as the denoising strength in A1111 inpaint. '
479
+ # # 'Only used in inpaint, not used in outpaint. '
480
+ # # '(Outpaint always use 1.0)')
481
+ # # inpaint_respective_field = gr.Slider(label='Inpaint Respective Field',
482
+ # # minimum=0.0, maximum=1.0, step=0.001, value=0.618,
483
+ # # info='The area to inpaint. '
484
+ # # 'Value 0 is same as "Only Masked" in A1111. '
485
+ # # 'Value 1 is same as "Whole Image" in A1111. '
486
+ # # 'Only used in inpaint, not used in outpaint. '
487
+ # # '(Outpaint always use 1.0)')
488
+ # # inpaint_erode_or_dilate = gr.Slider(label='Mask Erode or Dilate',
489
+ # # minimum=-64, maximum=64, step=1, value=0,
490
+ # # info='Positive value will make white area in the mask larger, '
491
+ # # 'negative value will make white area smaller.'
492
+ # # '(default is 0, always process before any mask invert)')
493
+ # # inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=False)
494
+ # # invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False)
495
+
496
+ # # inpaint_ctrls = [debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine,
497
+ # # inpaint_strength, inpaint_respective_field,
498
+ # # inpaint_mask_upload_checkbox, invert_mask_checkbox, inpaint_erode_or_dilate]
499
+
500
+ # # inpaint_mask_upload_checkbox.change(lambda x: gr.update(visible=x),
501
+ # # inputs=inpaint_mask_upload_checkbox,
502
+ # # outputs=inpaint_mask_image, queue=False, show_progress=False)
503
+
504
+ # with gr.Tab(label='FreeU'):
505
+ # freeu_enabled = gr.Checkbox(label='Enabled', value=False)
506
+ # freeu_b1 = gr.Slider(label='B1', minimum=0, maximum=2, step=0.01, value=1.01)
507
+ # freeu_b2 = gr.Slider(label='B2', minimum=0, maximum=2, step=0.01, value=1.02)
508
+ # freeu_s1 = gr.Slider(label='S1', minimum=0, maximum=4, step=0.01, value=0.99)
509
+ # freeu_s2 = gr.Slider(label='S2', minimum=0, maximum=4, step=0.01, value=0.95)
510
+ # freeu_ctrls = [freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2]
511
+
512
+ # def dev_mode_checked(r):
513
+ # return gr.update(visible=r)
514
+
515
+
516
+ # dev_mode.change(dev_mode_checked, inputs=[dev_mode], outputs=[dev_tools],
517
+ # queue=False, show_progress=False)
518
+
519
+ # def model_refresh_clicked():
520
+ # modules.config.update_all_model_names()
521
+ # results = [gr.update(choices=modules.config.model_filenames)]
522
+ # results += [gr.update(choices=['None'] + modules.config.model_filenames)]
523
+ # for i in range(modules.config.default_max_lora_number):
524
+ # results += [gr.update(interactive=True), gr.update(choices=['None'] + modules.config.lora_filenames), gr.update()]
525
+ # return results
526
+
527
+ # model_refresh.click(model_refresh_clicked, [], [base_model, refiner_model] + lora_ctrls,
528
+ # queue=False, show_progress=False)
529
+
530
+ # performance_selection.change(lambda x: [gr.update(interactive=x != 'Extreme Speed')] * 11 +
531
+ # [gr.update(visible=x != 'Extreme Speed')] * 1 +
532
+ # [gr.update(interactive=x != 'Extreme Speed', value=x == 'Extreme Speed', )] * 1,
533
+ # inputs=performance_selection,
534
+ # outputs=[
535
+ # guidance_scale, sharpness, adm_scaler_end, adm_scaler_positive,
536
+ # adm_scaler_negative, refiner_switch, refiner_model, sampler_name,
537
+ # scheduler_name, adaptive_cfg, refiner_swap_method, negative_prompt, disable_intermediate_results
538
+ # ], queue=False, show_progress=False)
539
+
540
+ # output_format.input(lambda x: gr.update(output_format=x), inputs=output_format)
541
+
542
+ # advanced_checkbox.change(lambda x: gr.update(visible=x), advanced_checkbox, advanced_column,
543
+ # queue=False, show_progress=False) \
544
+ # .then(fn=lambda: None, _js='refresh_grid_delayed', queue=False, show_progress=False)
545
+
546
+ # def inpaint_mode_change(mode):
547
+ # assert mode in modules.flags.inpaint_options
548
+
549
+ # # inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
550
+ # # inpaint_disable_initial_latent, inpaint_engine,
551
+ # # inpaint_strength, inpaint_respective_field
552
+
553
+ # if mode == modules.flags.inpaint_option_detail:
554
+ # return [
555
+ # gr.update(visible=True), gr.update(visible=False, value=[]),
556
+ # gr.Dataset.update(visible=True, samples=modules.config.example_inpaint_prompts),
557
+ # False, 'None', 0.5, 0.0
558
+ # ]
559
+
560
+ # if mode == modules.flags.inpaint_option_modify:
561
+ # return [
562
+ # gr.update(visible=True), gr.update(visible=False, value=[]),
563
+ # gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts),
564
+ # True, modules.config.default_inpaint_engine_version, 1.0, 0.0
565
+ # ]
566
+
567
+ # return [
568
+ # gr.update(visible=False, value=''), gr.update(visible=True),
569
+ # gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts),
570
+ # False, modules.config.default_inpaint_engine_version, 1.0, 0.618
571
+ # ]
572
+
573
+ # inpaint_mode.input(inpaint_mode_change, inputs=inpaint_mode, outputs=[
574
+ # inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
575
+ # inpaint_disable_initial_latent, inpaint_engine,
576
+ # inpaint_strength, inpaint_respective_field
577
+ # ], show_progress=False, queue=False)
578
+
579
+ # ctrls = [currentTask, generate_image_grid]
580
+ # ctrls += [
581
+ # prompt, negative_prompt, style_selections,
582
+ # performance_selection, aspect_ratios_selection, image_number, output_format, image_seed, sharpness, guidance_scale
583
+ # ]
584
+
585
+ # ctrls += [base_model, refiner_model, refiner_switch] + lora_ctrls
586
+ # # ctrls += [input_image_checkbox, current_tab]
587
+ # # ctrls += [uov_method, uov_input_image]
588
+ # # ctrls += [outpaint_selections, inpaint_input_image, inpaint_additional_prompt, inpaint_mask_image]
589
+ # ctrls += [disable_preview, disable_intermediate_results, disable_seed_increment]
590
+ # ctrls += [adm_scaler_positive, adm_scaler_negative, adm_scaler_end, adaptive_cfg]
591
+ # ctrls += [sampler_name, scheduler_name]
592
+ # ctrls += [overwrite_step, overwrite_switch, overwrite_width, overwrite_height, overwrite_vary_strength]
593
+ # ctrls += [overwrite_upscale_strength, mixing_image_prompt_and_vary_upscale, mixing_image_prompt_and_inpaint]
594
+ # ctrls += [debugging_cn_preprocessor, skipping_cn_preprocessor, canny_low_threshold, canny_high_threshold]
595
+ # ctrls += [refiner_swap_method, controlnet_softness]
596
+ # ctrls += freeu_ctrls
597
+ # ctrls += inpaint_ctrls
598
+
599
+ # if not args_manager.args.disable_metadata:
600
+ # ctrls += [save_metadata_to_images, metadata_scheme]
601
+
602
+ # ctrls += ip_ctrls
603
+
604
+ # state_is_generating = gr.State(False)
605
+
606
+ # def parse_meta(raw_prompt_txt, is_generating):
607
+ # loaded_json = None
608
+ # if is_json(raw_prompt_txt):
609
+ # loaded_json = json.loads(raw_prompt_txt)
610
+
611
+ # if loaded_json is None:
612
+ # if is_generating:
613
+ # return gr.update(), gr.update(), gr.update()
614
+ # else:
615
+ # return gr.update(), gr.update(visible=True), gr.update(visible=False)
616
+
617
+ # return json.dumps(loaded_json), gr.update(visible=False), gr.update(visible=True)
618
+
619
+ # prompt.input(parse_meta, inputs=[prompt, state_is_generating], outputs=[prompt, generate_button, load_parameter_button], queue=False, show_progress=False)
620
+
621
+ # load_data_outputs = [advanced_checkbox, image_number, prompt, negative_prompt, style_selections,
622
+ # performance_selection, overwrite_step, overwrite_switch, aspect_ratios_selection,
623
+ # overwrite_width, overwrite_height, guidance_scale, sharpness, adm_scaler_positive,
624
+ # adm_scaler_negative, adm_scaler_end, refiner_swap_method, adaptive_cfg, base_model,
625
+ # refiner_model, refiner_switch, sampler_name, scheduler_name, seed_random, image_seed,
626
+ # generate_button, load_parameter_button] + freeu_ctrls + lora_ctrls
627
+
628
+ # load_parameter_button.click(modules.meta_parser.load_parameter_button_click, inputs=[prompt, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=False)
629
+
630
+ # # def trigger_metadata_import(filepath, state_is_generating):
631
+ # # parameters, metadata_scheme = modules.meta_parser.read_info_from_image(filepath)
632
+ # # if parameters is None:
633
+ # # print('Could not find metadata in the image!')
634
+ # # parsed_parameters = {}
635
+ # # else:
636
+ # # metadata_parser = modules.meta_parser.get_metadata_parser(metadata_scheme)
637
+ # # parsed_parameters = metadata_parser.parse_json(parameters)
638
+
639
+ # # return modules.meta_parser.load_parameter_button_click(parsed_parameters, state_is_generating)
640
+
641
+
642
+ # # metadata_import_button.click(trigger_metadata_import, inputs=[metadata_input_image, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=True) \
643
+ # # .then(style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False)
644
+
645
+ # generate_button.click(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), [], True),
646
+ # outputs=[stop_button, skip_button, generate_button, gallery, state_is_generating]) \
647
+ # .then(fn=refresh_seed, inputs=[seed_random, image_seed], outputs=image_seed) \
648
+ # .then(fn=get_task, inputs=ctrls, outputs=currentTask) \
649
+ # .then(fn=generate_clicked, inputs=currentTask, outputs=[progress_html, progress_window, progress_gallery, gallery]) \
650
+ # .then(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), gr.update(visible=False, interactive=False), False),
651
+ # outputs=[generate_button, stop_button, skip_button, state_is_generating]) \
652
+ # .then(fn=update_history_link, outputs=history_link) \
653
+ # .then(fn=lambda: None, _js='playNotification').then(fn=lambda: None, _js='refresh_grid_delayed')
654
+
655
+ for notification_file in ['notification.ogg', 'notification.mp3']:
656
+ if os.path.exists(notification_file):
657
+ gr.Audio(interactive=False, value=notification_file, elem_id='audio_notification', visible=False)
658
+ break
659
+
660
+ def trigger_describe(mode, img):
661
+ if mode == flags.desc_type_photo:
662
+ from extras.interrogate import default_interrogator as default_interrogator_photo
663
+ return default_interrogator_photo(img), ["Fooocus V2", "Fooocus Enhance", "Fooocus Sharp"]
664
+ if mode == flags.desc_type_anime:
665
+ from extras.wd14tagger import default_interrogator as default_interrogator_anime
666
+ return default_interrogator_anime(img), ["Fooocus V2", "Fooocus Masterpiece"]
667
+ return mode, ["Fooocus V2"]
668
+
669
+ desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image],
670
+ outputs=prompt, show_progress=True, queue=True)
671
+
672
+
673
+ def dump_default_english_config():
674
+ from modules.localization import dump_english_config
675
+ dump_english_config(grh.all_components)
676
+
677
+
678
+ # dump_default_english_config()
679
+
680
+ shared.gradio_root.launch(
681
+ inbrowser=args_manager.args.in_browser,
682
+ server_name=args_manager.args.listen,
683
+ server_port=args_manager.args.port,
684
+ share=args_manager.args.share,
685
+ auth=check_auth if (args_manager.args.share or args_manager.args.listen) and auth_enabled else None,
686
+ allowed_paths=[modules.config.path_outputs],
687
+ blocked_paths=[constants.AUTH_FILENAME]
688
+ )
app.html ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <script
2
+ type="module"
3
+ src="https://gradio.s3-us-west-2.amazonaws.com/4.21.0/gradio.js"
4
+ ></script>
5
+
6
+ <gradio-app src="https://Adityadn-test.hf.space"></gradio-app>
args_manager.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ldm_patched.modules.args_parser as args_parser
2
+ import os
3
+
4
+ from tempfile import gettempdir
5
+
6
+ args_parser.parser.add_argument("--share", action='store_true', help="Set whether to share on Gradio.")
7
+ args_parser.parser.add_argument("--preset", type=str, default=None, help="Apply specified UI preset.")
8
+
9
+ args_parser.parser.add_argument("--language", type=str, default='default',
10
+ help="Translate UI using json files in [language] folder. "
11
+ "For example, [--language example] will use [language/example.json] for translation.")
12
+
13
+ # For example, https://github.com/lllyasviel/Fooocus/issues/849
14
+ args_parser.parser.add_argument("--disable-offload-from-vram", action="store_true",
15
+ help="Force loading models to vram when the unload can be avoided. "
16
+ "Some Mac users may need this.")
17
+
18
+ args_parser.parser.add_argument("--theme", type=str, help="launches the UI with light or dark theme", default=None)
19
+ args_parser.parser.add_argument("--disable-image-log", action='store_true',
20
+ help="Prevent writing images and logs to hard drive.")
21
+
22
+ args_parser.parser.add_argument("--disable-analytics", action='store_true',
23
+ help="Disables analytics for Gradio.")
24
+
25
+ args_parser.parser.add_argument("--disable-metadata", action='store_true',
26
+ help="Disables saving metadata to images.")
27
+
28
+ args_parser.parser.add_argument("--disable-preset-download", action='store_true',
29
+ help="Disables downloading models for presets", default=False)
30
+
31
+ args_parser.parser.add_argument("--always-download-new-model", action='store_true',
32
+ help="Always download newer models ", default=False)
33
+
34
+ args_parser.parser.set_defaults(
35
+ disable_cuda_malloc=True,
36
+ in_browser=True,
37
+ port=None
38
+ )
39
+
40
+ args_parser.args = args_parser.parser.parse_args()
41
+
42
+ # (Disable by default because of issues like https://github.com/lllyasviel/Fooocus/issues/724)
43
+ args_parser.args.always_offload_from_vram = not args_parser.args.disable_offload_from_vram
44
+
45
+ if args_parser.args.disable_analytics:
46
+ import os
47
+ os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
48
+
49
+ if args_parser.args.disable_in_browser:
50
+ args_parser.args.in_browser = False
51
+
52
+ if args_parser.args.temp_path is None:
53
+ args_parser.args.temp_path = os.path.join(gettempdir(), 'Fooocus')
54
+
55
+ args = args_parser.args
auth-example.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "user": "sitting-duck-1",
4
+ "pass": "very-bad-publicly-known-password-change-it"
5
+ }
6
+ ]
build_launcher.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ win32_root = os.path.dirname(os.path.dirname(__file__))
4
+ python_embeded_path = os.path.join(win32_root, 'python_embeded')
5
+
6
+ is_win32_standalone_build = os.path.exists(python_embeded_path) and os.path.isdir(python_embeded_path)
7
+
8
+ win32_cmd = '''
9
+ .\python_embeded\python.exe -s Fooocus\entry_with_update.py {cmds} %*
10
+ pause
11
+ '''
12
+
13
+
14
+ def build_launcher():
15
+ if not is_win32_standalone_build:
16
+ return
17
+
18
+ presets = [None, 'anime', 'realistic']
19
+
20
+ for preset in presets:
21
+ win32_cmd_preset = win32_cmd.replace('{cmds}', '' if preset is None else f'--preset {preset}')
22
+ bat_path = os.path.join(win32_root, 'run.bat' if preset is None else f'run_{preset}.bat')
23
+ if not os.path.exists(bat_path):
24
+ with open(bat_path, "w", encoding="utf-8") as f:
25
+ f.write(win32_cmd_preset)
26
+ return
config.txt ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "path_checkpoints": [
3
+ "models\\checkpoints"
4
+ ],
5
+ "path_loras": [
6
+ "models\\loras"
7
+ ],
8
+ "path_embeddings": "models\\embeddings",
9
+ "path_vae_approx": "models\\vae_approx",
10
+ "path_upscale_models": "models\\upscale_models",
11
+ "path_inpaint": "models\\inpaint",
12
+ "path_controlnet": "models\\controlnet",
13
+ "path_clip_vision": "models\\clip_vision",
14
+ "path_fooocus_expansion": "models\\prompt_expansion\\fooocus_expansion",
15
+ "path_outputs": "outputs"
16
+ }
config_modification_tutorial.txt ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You can modify your "D:\\ADITYA FILE\\Developer\\MICROSOFT\\Microsoft Visual Studio Code\\Project\\Application Website\\Nyxel\\Flowly AI\\My Project\\AI Image\\config.txt" using the below keys, formats, and examples.
2
+ Do not modify this file. Modifications in this file will not take effect.
3
+ This file is a tutorial and example. Please edit "D:\\ADITYA FILE\\Developer\\MICROSOFT\\Microsoft Visual Studio Code\\Project\\Application Website\\Nyxel\\Flowly AI\\My Project\\AI Image\\config.txt" to really change any settings.
4
+ Remember to split the paths with "\\" rather than "\", and there is no "," before the last "}".
5
+
6
+
7
+ {
8
+ "path_checkpoints": [
9
+ "models\\checkpoints"
10
+ ],
11
+ "path_loras": [
12
+ "models\\loras"
13
+ ],
14
+ "path_embeddings": "models\\embeddings",
15
+ "path_vae_approx": "models\\vae_approx",
16
+ "path_upscale_models": "models\\upscale_models",
17
+ "path_inpaint": "models\\inpaint",
18
+ "path_controlnet": "models\\controlnet",
19
+ "path_clip_vision": "models\\clip_vision",
20
+ "path_fooocus_expansion": "models\\prompt_expansion\\fooocus_expansion",
21
+ "path_outputs": "outputs",
22
+ "default_model": "juggernautXL_v8Rundiffusion.safetensors",
23
+ "previous_default_models": [
24
+ "juggernautXL_version8Rundiffusion.safetensors",
25
+ "juggernautXL_version7Rundiffusion.safetensors",
26
+ "juggernautXL_v7Rundiffusion.safetensors",
27
+ "juggernautXL_version6Rundiffusion.safetensors",
28
+ "juggernautXL_v6Rundiffusion.safetensors"
29
+ ],
30
+ "default_refiner": "None",
31
+ "default_refiner_switch": 0.5,
32
+ "default_loras_min_weight": -2,
33
+ "default_loras_max_weight": 2,
34
+ "default_loras": [
35
+ [
36
+ "sd_xl_offset_example-lora_1.0.safetensors",
37
+ 0.1
38
+ ],
39
+ [
40
+ "None",
41
+ 1.0
42
+ ],
43
+ [
44
+ "None",
45
+ 1.0
46
+ ],
47
+ [
48
+ "None",
49
+ 1.0
50
+ ],
51
+ [
52
+ "None",
53
+ 1.0
54
+ ]
55
+ ],
56
+ "default_max_lora_number": 5,
57
+ "default_cfg_scale": 4.0,
58
+ "default_sample_sharpness": 2.0,
59
+ "default_sampler": "dpmpp_2m_sde_gpu",
60
+ "default_scheduler": "karras",
61
+ "default_styles": [
62
+ "Fooocus V2",
63
+ "Fooocus Enhance",
64
+ "Fooocus Sharp"
65
+ ],
66
+ "default_prompt_negative": "",
67
+ "default_prompt": "",
68
+ "default_performance": "Speed",
69
+ "default_advanced_checkbox": false,
70
+ "default_max_image_number": 32,
71
+ "default_output_format": "png",
72
+ "default_image_number": 2,
73
+ "checkpoint_downloads": {
74
+ "juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors"
75
+ },
76
+ "lora_downloads": {
77
+ "sd_xl_offset_example-lora_1.0.safetensors": "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_offset_example-lora_1.0.safetensors"
78
+ },
79
+ "embeddings_downloads": {},
80
+ "available_aspect_ratios": [
81
+ "704*1408",
82
+ "704*1344",
83
+ "768*1344",
84
+ "768*1280",
85
+ "832*1216",
86
+ "832*1152",
87
+ "896*1152",
88
+ "896*1088",
89
+ "960*1088",
90
+ "960*1024",
91
+ "1024*1024",
92
+ "1024*960",
93
+ "1088*960",
94
+ "1088*896",
95
+ "1152*896",
96
+ "1152*832",
97
+ "1216*832",
98
+ "1280*768",
99
+ "1344*768",
100
+ "1344*704",
101
+ "1408*704",
102
+ "1472*704",
103
+ "1536*640",
104
+ "1600*640",
105
+ "1664*576",
106
+ "1728*576"
107
+ ],
108
+ "default_aspect_ratio": "1152*896",
109
+ "default_inpaint_engine_version": "v2.6",
110
+ "default_cfg_tsnr": 7.0,
111
+ "default_overwrite_step": -1,
112
+ "default_overwrite_switch": -1,
113
+ "example_inpaint_prompts": [
114
+ "highly detailed face",
115
+ "detailed girl face",
116
+ "detailed man face",
117
+ "detailed hand",
118
+ "beautiful eyes"
119
+ ],
120
+ "default_save_metadata_to_images": false,
121
+ "default_metadata_scheme": "fooocus",
122
+ "metadata_created_by": ""
123
+ }
docker-compose.yml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.9'
2
+
3
+ volumes:
4
+ fooocus-data:
5
+
6
+ services:
7
+ app:
8
+ build: .
9
+ image: fooocus
10
+ ports:
11
+ - "7865:7865"
12
+ environment:
13
+ - CMDARGS=--listen # Arguments for launch.py.
14
+ - DATADIR=/content/data # Directory which stores models, outputs dir
15
+ - config_path=/content/data/config.txt
16
+ - config_example_path=/content/data/config_modification_tutorial.txt
17
+ - path_checkpoints=/content/data/models/checkpoints/
18
+ - path_loras=/content/data/models/loras/
19
+ - path_embeddings=/content/data/models/embeddings/
20
+ - path_vae_approx=/content/data/models/vae_approx/
21
+ - path_upscale_models=/content/data/models/upscale_models/
22
+ - path_inpaint=/content/data/models/inpaint/
23
+ - path_controlnet=/content/data/models/controlnet/
24
+ - path_clip_vision=/content/data/models/clip_vision/
25
+ - path_fooocus_expansion=/content/data/models/prompt_expansion/fooocus_expansion/
26
+ - path_outputs=/content/app/outputs/ # Warning: If it is not located under '/content/app', you can't see history log!
27
+ volumes:
28
+ - fooocus-data:/content/data
29
+ #- ./models:/import/models # Once you import files, you don't need to mount again.
30
+ #- ./outputs:/import/outputs # Once you import files, you don't need to mount again.
31
+ tty: true
32
+ deploy:
33
+ resources:
34
+ reservations:
35
+ devices:
36
+ - driver: nvidia
37
+ device_ids: ['0']
38
+ capabilities: [compute, utility]
docker.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Fooocus on Docker
2
+
3
+ The docker image is based on NVIDIA CUDA 12.3 and PyTorch 2.0, see [Dockerfile](Dockerfile) and [requirements_docker.txt](requirements_docker.txt) for details.
4
+
5
+ ## Quick start
6
+
7
+ **This is just an easy way for testing. Please find more information in the [notes](#notes).**
8
+
9
+ 1. Clone this repository
10
+ 2. Build the image with `docker compose build`
11
+ 3. Run the docker container with `docker compose up`. Building the image takes some time.
12
+
13
+ When you see the message `Use the app with http://0.0.0.0:7865/` in the console, you can access the URL in your browser.
14
+
15
+ Your models and outputs are stored in the `fooocus-data` volume, which, depending on OS, is stored in `/var/lib/docker/volumes`.
16
+
17
+ ## Details
18
+
19
+ ### Update the container manually
20
+
21
+ When you are using `docker compose up` continuously, the container is not updated to the latest version of Fooocus automatically.
22
+ Run `git pull` before executing `docker compose build --no-cache` to build an image with the latest Fooocus version.
23
+ You can then start it with `docker compose up`
24
+
25
+ ### Import models, outputs
26
+ If you want to import files from models or the outputs folder, you can uncomment the following settings in the [docker-compose.yml](docker-compose.yml):
27
+ ```
28
+ #- ./models:/import/models # Once you import files, you don't need to mount again.
29
+ #- ./outputs:/import/outputs # Once you import files, you don't need to mount again.
30
+ ```
31
+ After running `docker compose up`, your files will be copied into `/content/data/models` and `/content/data/outputs`
32
+ Since `/content/data` is a persistent volume folder, your files will be persisted even when you re-run `docker compose up --build` without above volume settings.
33
+
34
+
35
+ ### Paths inside the container
36
+
37
+ |Path|Details|
38
+ |-|-|
39
+ |/content/app|The application stored folder|
40
+ |/content/app/models.org|Original 'models' folder.<br> Files are copied to the '/content/app/models' which is symlinked to '/content/data/models' every time the container boots. (Existing files will not be overwritten.) |
41
+ |/content/data|Persistent volume mount point|
42
+ |/content/data/models|The folder is symlinked to '/content/app/models'|
43
+ |/content/data/outputs|The folder is symlinked to '/content/app/outputs'|
44
+
45
+ ### Environments
46
+
47
+ You can change `config.txt` parameters by using environment variables.
48
+ **The priority of using the environments is higher than the values defined in `config.txt`, and they will be saved to the `config_modification_tutorial.txt`**
49
+
50
+ Docker specified environments are there. They are used by 'entrypoint.sh'
51
+ |Environment|Details|
52
+ |-|-|
53
+ |DATADIR|'/content/data' location.|
54
+ |CMDARGS|Arguments for [entry_with_update.py](entry_with_update.py) which is called by [entrypoint.sh](entrypoint.sh)|
55
+ |config_path|'config.txt' location|
56
+ |config_example_path|'config_modification_tutorial.txt' location|
57
+
58
+ You can also use the same json key names and values explained in the 'config_modification_tutorial.txt' as the environments.
59
+ See examples in the [docker-compose.yml](docker-compose.yml)
60
+
61
+ ## Notes
62
+
63
+ - Please keep 'path_outputs' under '/content/app'. Otherwise, you may get an error when you open the history log.
64
+ - Docker on Mac/Windows still has issues in the form of slow volume access when you use "bind mount" volumes. Please refer to [this article](https://docs.docker.com/storage/volumes/#use-a-volume-with-docker-compose) for not using "bind mount".
65
+ - The MPS backend (Metal Performance Shaders, Apple Silicon M1/M2/etc.) is not yet supported in Docker, see https://github.com/pytorch/pytorch/issues/81224
66
+ - You can also use `docker compose up -d` to start the container detached and connect to the logs with `docker compose logs -f`. This way you can also close the terminal and keep the container running.
entry_with_update.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+
5
+ root = os.path.dirname(os.path.abspath(__file__))
6
+ sys.path.append(root)
7
+ os.chdir(root)
8
+
9
+
10
+ try:
11
+ import pygit2
12
+ pygit2.option(pygit2.GIT_OPT_SET_OWNER_VALIDATION, 0)
13
+
14
+ repo = pygit2.Repository(os.path.abspath(os.path.dirname(__file__)))
15
+
16
+ branch_name = repo.head.shorthand
17
+
18
+ remote_name = 'origin'
19
+ remote = repo.remotes[remote_name]
20
+
21
+ remote.fetch()
22
+
23
+ local_branch_ref = f'refs/heads/{branch_name}'
24
+ local_branch = repo.lookup_reference(local_branch_ref)
25
+
26
+ remote_reference = f'refs/remotes/{remote_name}/{branch_name}'
27
+ remote_commit = repo.revparse_single(remote_reference)
28
+
29
+ merge_result, _ = repo.merge_analysis(remote_commit.id)
30
+
31
+ if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE:
32
+ print("Already up-to-date")
33
+ elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD:
34
+ local_branch.set_target(remote_commit.id)
35
+ repo.head.set_target(remote_commit.id)
36
+ repo.checkout_tree(repo.get(remote_commit.id))
37
+ repo.reset(local_branch.target, pygit2.GIT_RESET_HARD)
38
+ print("Fast-forward merge")
39
+ elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL:
40
+ print("Update failed - Did you modify any file?")
41
+ except Exception as e:
42
+ print('Update failed.')
43
+ print(str(e))
44
+
45
+ print('Update succeeded.')
46
+ from aiDescUI import *
entrypoint.sh ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ ORIGINALDIR=/content/app
4
+ # Use predefined DATADIR if it is defined
5
+ [[ x"${DATADIR}" == "x" ]] && DATADIR=/content/data
6
+
7
+ # Make persistent dir from original dir
8
+ function mklink () {
9
+ mkdir -p $DATADIR/$1
10
+ ln -s $DATADIR/$1 $ORIGINALDIR
11
+ }
12
+
13
+ # Copy old files from import dir
14
+ function import () {
15
+ (test -d /import/$1 && cd /import/$1 && cp -Rpn . $DATADIR/$1/)
16
+ }
17
+
18
+ cd $ORIGINALDIR
19
+
20
+ # models
21
+ mklink models
22
+ # Copy original files
23
+ (cd $ORIGINALDIR/models.org && cp -Rpn . $ORIGINALDIR/models/)
24
+ # Import old files
25
+ import models
26
+
27
+ # outputs
28
+ mklink outputs
29
+ # Import old files
30
+ import outputs
31
+
32
+ # Start application
33
+ python launch.py $*
environment.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ name: fooocus
2
+ channels:
3
+ - defaults
4
+ dependencies:
5
+ - python=3.10
6
+ - pip=23.0
7
+ - packaging
experiments_expansion.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from modules.expansion import FooocusExpansion
2
+
3
+ expansion = FooocusExpansion()
4
+
5
+ text = 'a handsome man'
6
+
7
+ for i in range(64):
8
+ print(expansion(text, seed=i))
experiments_face.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import extras.face_crop as cropper
3
+
4
+
5
+ img = cv2.imread('lena.png')
6
+ result = cropper.crop_image(img)
7
+ cv2.imwrite('lena_result.png', result)
experiments_interrogate.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ from extras.interrogate import default_interrogator as default_interrogator_photo
3
+ from extras.wd14tagger import default_interrogator as default_interrogator_anime
4
+
5
+ img = cv2.imread('./test_imgs/red_box.jpg')[:, :, ::-1].copy()
6
+ print(default_interrogator_photo(img))
7
+ img = cv2.imread('./test_imgs/miku.jpg')[:, :, ::-1].copy()
8
+ print(default_interrogator_anime(img))
fooocus_colab.ipynb ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {
7
+ "id": "VjYy0F2gZIPR"
8
+ },
9
+ "outputs": [],
10
+ "source": [
11
+ "!pip install pygit2==1.12.2\n",
12
+ "%cd /content\n",
13
+ "!git clone https://github.com/lllyasviel/Fooocus.git\n",
14
+ "%cd /content/Fooocus\n",
15
+ "!python entry_with_update.py --share\n"
16
+ ]
17
+ }
18
+ ],
19
+ "metadata": {
20
+ "accelerator": "GPU",
21
+ "colab": {
22
+ "gpuType": "T4",
23
+ "provenance": []
24
+ },
25
+ "kernelspec": {
26
+ "display_name": "Python 3",
27
+ "name": "python3"
28
+ },
29
+ "language_info": {
30
+ "name": "python"
31
+ }
32
+ },
33
+ "nbformat": 4,
34
+ "nbformat_minor": 0
35
+ }
fooocus_version.py ADDED
@@ -0,0 +1 @@
 
 
1
+ version = '2.2.1'
launch.py ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import ssl
4
+
5
+ print('[System ARGV] ' + str(sys.argv))
6
+
7
+ root = os.path.dirname(os.path.abspath(__file__))
8
+ sys.path.append(root)
9
+ os.chdir(root)
10
+
11
+ os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
12
+ os.environ["PYTORCH_MPS_HIGH_WATERMARK_RATIO"] = "0.0"
13
+ if "GRADIO_SERVER_PORT" not in os.environ:
14
+ os.environ["GRADIO_SERVER_PORT"] = "7865"
15
+
16
+ ssl._create_default_https_context = ssl._create_unverified_context
17
+
18
+
19
+ import platform
20
+ import fooocus_version
21
+
22
+ from build_launcher import build_launcher
23
+ from modules.launch_util import is_installed, run, python, run_pip, requirements_met
24
+ from modules.model_loader import load_file_from_url
25
+
26
+
27
+ REINSTALL_ALL = False
28
+ TRY_INSTALL_XFORMERS = False
29
+
30
+
31
+ def prepare_environment():
32
+ torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu121")
33
+ torch_command = os.environ.get('TORCH_COMMAND',
34
+ f"pip install torch==2.1.0 torchvision==0.16.0 --extra-index-url {torch_index_url}")
35
+ requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt")
36
+
37
+ print(f"Python {sys.version}")
38
+ print(f"Fooocus version: {fooocus_version.version}")
39
+
40
+ if REINSTALL_ALL or not is_installed("torch") or not is_installed("torchvision"):
41
+ run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
42
+
43
+ if TRY_INSTALL_XFORMERS:
44
+ if REINSTALL_ALL or not is_installed("xformers"):
45
+ xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.23')
46
+ if platform.system() == "Windows":
47
+ if platform.python_version().startswith("3.10"):
48
+ run_pip(f"install -U -I --no-deps {xformers_package}", "xformers", live=True)
49
+ else:
50
+ print("Installation of xformers is not supported in this version of Python.")
51
+ print(
52
+ "You can also check this and build manually: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Xformers#building-xformers-on-windows-by-duckness")
53
+ if not is_installed("xformers"):
54
+ exit(0)
55
+ elif platform.system() == "Linux":
56
+ run_pip(f"install -U -I --no-deps {xformers_package}", "xformers")
57
+
58
+ if REINSTALL_ALL or not requirements_met(requirements_file):
59
+ run_pip(f"install -r \"{requirements_file}\"", "requirements")
60
+
61
+ return
62
+
63
+
64
+ vae_approx_filenames = [
65
+ ('xlvaeapp.pth', 'https://huggingface.co/lllyasviel/misc/resolve/main/xlvaeapp.pth'),
66
+ ('vaeapp_sd15.pth', 'https://huggingface.co/lllyasviel/misc/resolve/main/vaeapp_sd15.pt'),
67
+ ('xl-to-v1_interposer-v3.1.safetensors',
68
+ 'https://huggingface.co/lllyasviel/misc/resolve/main/xl-to-v1_interposer-v3.1.safetensors')
69
+ ]
70
+
71
+ def ini_args():
72
+ from args_manager import args
73
+ return args
74
+
75
+
76
+ prepare_environment()
77
+ build_launcher()
78
+ args = ini_args()
79
+
80
+
81
+ if args.gpu_device_id is not None:
82
+ os.environ['CUDA_VISIBLE_DEVICES'] = str(args.gpu_device_id)
83
+ print("Set device to:", args.gpu_device_id)
84
+
85
+
86
+ from modules import config
87
+
88
+ def download_models():
89
+ for file_name, url in vae_approx_filenames:
90
+ load_file_from_url(url=url, model_dir=config.path_vae_approx, file_name=file_name)
91
+
92
+ load_file_from_url(
93
+ url='https://huggingface.co/lllyasviel/misc/resolve/main/fooocus_expansion.bin',
94
+ model_dir=config.path_fooocus_expansion,
95
+ file_name='pytorch_model.bin'
96
+ )
97
+
98
+ if args.disable_preset_download:
99
+ print('Skipped model download.')
100
+ return
101
+
102
+ if not args.always_download_new_model:
103
+ if not os.path.exists(os.path.join(config.paths_checkpoints[0], config.default_base_model_name)):
104
+ for alternative_model_name in config.previous_default_models:
105
+ if os.path.exists(os.path.join(config.paths_checkpoints[0], alternative_model_name)):
106
+ print(f'You do not have [{config.default_base_model_name}] but you have [{alternative_model_name}].')
107
+ print(f'Fooocus will use [{alternative_model_name}] to avoid downloading new models, '
108
+ f'but you are not using latest models.')
109
+ print('Use --always-download-new-model to avoid fallback and always get new models.')
110
+ config.checkpoint_downloads = {}
111
+ config.default_base_model_name = alternative_model_name
112
+ break
113
+
114
+ for file_name, url in config.checkpoint_downloads.items():
115
+ load_file_from_url(url=url, model_dir=config.paths_checkpoints[0], file_name=file_name)
116
+ for file_name, url in config.embeddings_downloads.items():
117
+ load_file_from_url(url=url, model_dir=config.path_embeddings, file_name=file_name)
118
+ for file_name, url in config.lora_downloads.items():
119
+ load_file_from_url(url=url, model_dir=config.paths_loras[0], file_name=file_name)
120
+
121
+ return
122
+
123
+
124
+ download_models()
125
+
126
+
127
+ from webui import *
notification-example.ogg ADDED
Binary file (59 kB). View file
 
readme.md ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align=center>
2
+ <img src="https://github.com/lllyasviel/Fooocus/assets/19834515/483fb86d-c9a2-4c20-997c-46dafc124f25">
3
+
4
+ **Non-cherry-picked** random batch by just typing two words "forest elf",
5
+
6
+ without any parameter tweaking, without any strange prompt tags.
7
+
8
+ See also **non-cherry-picked** generalization and diversity tests [here](https://github.com/lllyasviel/Fooocus/discussions/2067) and [here](https://github.com/lllyasviel/Fooocus/discussions/808) and [here](https://github.com/lllyasviel/Fooocus/discussions/679) and [here](https://github.com/lllyasviel/Fooocus/discussions/679#realistic).
9
+
10
+ In the entire open source community, only Fooocus can achieve this level of **non-cherry-picked** quality.
11
+
12
+ </div>
13
+
14
+
15
+ # Fooocus
16
+
17
+ Fooocus is an image generating software (based on [Gradio](https://www.gradio.app/)).
18
+
19
+ Fooocus is a rethinking of Stable Diffusion and Midjourney’s designs:
20
+
21
+ * Learned from Stable Diffusion, the software is offline, open source, and free.
22
+
23
+ * Learned from Midjourney, the manual tweaking is not needed, and users only need to focus on the prompts and images.
24
+
25
+ Fooocus has included and automated [lots of inner optimizations and quality improvements](#tech_list). Users can forget all those difficult technical parameters, and just enjoy the interaction between human and computer to "explore new mediums of thought and expanding the imaginative powers of the human species" `[1]`.
26
+
27
+ Fooocus has simplified the installation. Between pressing "download" and generating the first image, the number of needed mouse clicks is strictly limited to less than 3. Minimal GPU memory requirement is 4GB (Nvidia).
28
+
29
+ `[1]` David Holz, 2019.
30
+
31
+ **Recently many fake websites exist on Google when you search “fooocus”. Do not trust those – here is the only official source of Fooocus.**
32
+
33
+ ## [Installing Fooocus](#download)
34
+
35
+ # Moving from Midjourney to Fooocus
36
+
37
+ Using Fooocus is as easy as (probably easier than) Midjourney – but this does not mean we lack functionality. Below are the details.
38
+
39
+ | Midjourney | Fooocus |
40
+ | - | - |
41
+ | High-quality text-to-image without needing much prompt engineering or parameter tuning. <br> (Unknown method) | High-quality text-to-image without needing much prompt engineering or parameter tuning. <br> (Fooocus has an offline GPT-2 based prompt processing engine and lots of sampling improvements so that results are always beautiful, no matter if your prompt is as short as “house in garden” or as long as 1000 words) |
42
+ | V1 V2 V3 V4 | Input Image -> Upscale or Variation -> Vary (Subtle) / Vary (Strong)|
43
+ | U1 U2 U3 U4 | Input Image -> Upscale or Variation -> Upscale (1.5x) / Upscale (2x) |
44
+ | Inpaint / Up / Down / Left / Right (Pan) | Input Image -> Inpaint or Outpaint -> Inpaint / Up / Down / Left / Right <br> (Fooocus uses its own inpaint algorithm and inpaint models so that results are more satisfying than all other software that uses standard SDXL inpaint method/model) |
45
+ | Image Prompt | Input Image -> Image Prompt <br> (Fooocus uses its own image prompt algorithm so that result quality and prompt understanding are more satisfying than all other software that uses standard SDXL methods like standard IP-Adapters or Revisions) |
46
+ | --style | Advanced -> Style |
47
+ | --stylize | Advanced -> Advanced -> Guidance |
48
+ | --niji | [Multiple launchers: "run.bat", "run_anime.bat", and "run_realistic.bat".](https://github.com/lllyasviel/Fooocus/discussions/679) <br> Fooocus support SDXL models on Civitai <br> (You can google search “Civitai” if you do not know about it) |
49
+ | --quality | Advanced -> Quality |
50
+ | --repeat | Advanced -> Image Number |
51
+ | Multi Prompts (::) | Just use multiple lines of prompts |
52
+ | Prompt Weights | You can use " I am (happy:1.5)". <br> Fooocus uses A1111's reweighting algorithm so that results are better than ComfyUI if users directly copy prompts from Civitai. (Because if prompts are written in ComfyUI's reweighting, users are less likely to copy prompt texts as they prefer dragging files) <br> To use embedding, you can use "(embedding:file_name:1.1)" |
53
+ | --no | Advanced -> Negative Prompt |
54
+ | --ar | Advanced -> Aspect Ratios |
55
+ | InsightFace | Input Image -> Image Prompt -> Advanced -> FaceSwap |
56
+ | Describe | Input Image -> Describe |
57
+
58
+ We also have a few things borrowed from the best parts of LeonardoAI:
59
+
60
+ | LeonardoAI | Fooocus |
61
+ | - | - |
62
+ | Prompt Magic | Advanced -> Style -> Fooocus V2 |
63
+ | Advanced Sampler Parameters (like Contrast/Sharpness/etc) | Advanced -> Advanced -> Sampling Sharpness / etc |
64
+ | User-friendly ControlNets | Input Image -> Image Prompt -> Advanced |
65
+
66
+ Fooocus also developed many "fooocus-only" features for advanced users to get perfect results. [Click here to browse the advanced features.](https://github.com/lllyasviel/Fooocus/discussions/117)
67
+
68
+ # Download
69
+
70
+ ### Windows
71
+
72
+ You can directly download Fooocus with:
73
+
74
+ **[>>> Click here to download <<<](https://github.com/lllyasviel/Fooocus/releases/download/release/Fooocus_win64_2-1-831.7z)**
75
+
76
+ After you download the file, please uncompress it and then run the "run.bat".
77
+
78
+ ![image](https://github.com/lllyasviel/Fooocus/assets/19834515/c49269c4-c274-4893-b368-047c401cc58c)
79
+
80
+ The first time you launch the software, it will automatically download models:
81
+
82
+ 1. It will download [default models](#models) to the folder "Fooocus\models\checkpoints" given different presets. You can download them in advance if you do not want automatic download.
83
+ 2. Note that if you use inpaint, at the first time you inpaint an image, it will download [Fooocus's own inpaint control model from here](https://huggingface.co/lllyasviel/fooocus_inpaint/resolve/main/inpaint_v26.fooocus.patch) as the file "Fooocus\models\inpaint\inpaint_v26.fooocus.patch" (the size of this file is 1.28GB).
84
+
85
+ After Fooocus 2.1.60, you will also have `run_anime.bat` and `run_realistic.bat`. They are different model presets (and require different models, but they will be automatically downloaded). [Check here for more details](https://github.com/lllyasviel/Fooocus/discussions/679).
86
+
87
+ ![image](https://github.com/lllyasviel/Fooocus/assets/19834515/d386f817-4bd7-490c-ad89-c1e228c23447)
88
+
89
+ If you already have these files, you can copy them to the above locations to speed up installation.
90
+
91
+ Note that if you see **"MetadataIncompleteBuffer" or "PytorchStreamReader"**, then your model files are corrupted. Please download models again.
92
+
93
+ Below is a test on a relatively low-end laptop with **16GB System RAM** and **6GB VRAM** (Nvidia 3060 laptop). The speed on this machine is about 1.35 seconds per iteration. Pretty impressive – nowadays laptops with 3060 are usually at very acceptable price.
94
+
95
+ ![image](https://github.com/lllyasviel/Fooocus/assets/19834515/938737a5-b105-4f19-b051-81356cb7c495)
96
+
97
+ Besides, recently many other software report that Nvidia driver above 532 is sometimes 10x slower than Nvidia driver 531. If your generation time is very long, consider download [Nvidia Driver 531 Laptop](https://www.nvidia.com/download/driverResults.aspx/199991/en-us/) or [Nvidia Driver 531 Desktop](https://www.nvidia.com/download/driverResults.aspx/199990/en-us/).
98
+
99
+ Note that the minimal requirement is **4GB Nvidia GPU memory (4GB VRAM)** and **8GB system memory (8GB RAM)**. This requires using Microsoft’s Virtual Swap technique, which is automatically enabled by your Windows installation in most cases, so you often do not need to do anything about it. However, if you are not sure, or if you manually turned it off (would anyone really do that?), or **if you see any "RuntimeError: CPUAllocator"**, you can enable it here:
100
+
101
+ <details>
102
+ <summary>Click here to see the image instructions. </summary>
103
+
104
+ ![image](https://github.com/lllyasviel/Fooocus/assets/19834515/2a06b130-fe9b-4504-94f1-2763be4476e9)
105
+
106
+ **And make sure that you have at least 40GB free space on each drive if you still see "RuntimeError: CPUAllocator" !**
107
+
108
+ </details>
109
+
110
+ Please open an issue if you use similar devices but still cannot achieve acceptable performances.
111
+
112
+ Note that the [minimal requirement](#minimal-requirement) for different platforms is different.
113
+
114
+ See also the common problems and troubleshoots [here](troubleshoot.md).
115
+
116
+ ### Colab
117
+
118
+ (Last tested - 2023 Dec 12)
119
+
120
+ | Colab | Info
121
+ | --- | --- |
122
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/lllyasviel/Fooocus/blob/main/fooocus_colab.ipynb) | Fooocus Official
123
+
124
+ In Colab, you can modify the last line to `!python entry_with_update.py --share` or `!python entry_with_update.py --preset anime --share` or `!python entry_with_update.py --preset realistic --share` for Fooocus Default/Anime/Realistic Edition.
125
+
126
+ Note that this Colab will disable refiner by default because Colab free's resources are relatively limited (and some "big" features like image prompt may cause free-tier Colab to disconnect). We make sure that basic text-to-image is always working on free-tier Colab.
127
+
128
+ Thanks to [camenduru](https://github.com/camenduru)!
129
+
130
+ ### Linux (Using Anaconda)
131
+
132
+ If you want to use Anaconda/Miniconda, you can
133
+
134
+ git clone https://github.com/lllyasviel/Fooocus.git
135
+ cd Fooocus
136
+ conda env create -f environment.yaml
137
+ conda activate fooocus
138
+ pip install -r requirements_versions.txt
139
+
140
+ Then download the models: download [default models](#models) to the folder "Fooocus\models\checkpoints". **Or let Fooocus automatically download the models** using the launcher:
141
+
142
+ conda activate fooocus
143
+ python entry_with_update.py
144
+
145
+ Or, if you want to open a remote port, use
146
+
147
+ conda activate fooocus
148
+ python entry_with_update.py --listen
149
+
150
+ Use `python entry_with_update.py --preset anime` or `python entry_with_update.py --preset realistic` for Fooocus Anime/Realistic Edition.
151
+
152
+ ### Linux (Using Python Venv)
153
+
154
+ Your Linux needs to have **Python 3.10** installed, and let's say your Python can be called with the command **python3** with your venv system working; you can
155
+
156
+ git clone https://github.com/lllyasviel/Fooocus.git
157
+ cd Fooocus
158
+ python3 -m venv fooocus_env
159
+ source fooocus_env/bin/activate
160
+ pip install -r requirements_versions.txt
161
+
162
+ See the above sections for model downloads. You can launch the software with:
163
+
164
+ source fooocus_env/bin/activate
165
+ python entry_with_update.py
166
+
167
+ Or, if you want to open a remote port, use
168
+
169
+ source fooocus_env/bin/activate
170
+ python entry_with_update.py --listen
171
+
172
+ Use `python entry_with_update.py --preset anime` or `python entry_with_update.py --preset realistic` for Fooocus Anime/Realistic Edition.
173
+
174
+ ### Linux (Using native system Python)
175
+
176
+ If you know what you are doing, and your Linux already has **Python 3.10** installed, and your Python can be called with the command **python3** (and Pip with **pip3**), you can
177
+
178
+ git clone https://github.com/lllyasviel/Fooocus.git
179
+ cd Fooocus
180
+ pip3 install -r requirements_versions.txt
181
+
182
+ See the above sections for model downloads. You can launch the software with:
183
+
184
+ python3 entry_with_update.py
185
+
186
+ Or, if you want to open a remote port, use
187
+
188
+ python3 entry_with_update.py --listen
189
+
190
+ Use `python entry_with_update.py --preset anime` or `python entry_with_update.py --preset realistic` for Fooocus Anime/Realistic Edition.
191
+
192
+ ### Linux (AMD GPUs)
193
+
194
+ Note that the [minimal requirement](#minimal-requirement) for different platforms is different.
195
+
196
+ Same with the above instructions. You need to change torch to the AMD version
197
+
198
+ pip uninstall torch torchvision torchaudio torchtext functorch xformers
199
+ pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.6
200
+
201
+ AMD is not intensively tested, however. The AMD support is in beta.
202
+
203
+ Use `python entry_with_update.py --preset anime` or `python entry_with_update.py --preset realistic` for Fooocus Anime/Realistic Edition.
204
+
205
+ ### Windows (AMD GPUs)
206
+
207
+ Note that the [minimal requirement](#minimal-requirement) for different platforms is different.
208
+
209
+ Same with Windows. Download the software and edit the content of `run.bat` as:
210
+
211
+ .\python_embeded\python.exe -m pip uninstall torch torchvision torchaudio torchtext functorch xformers -y
212
+ .\python_embeded\python.exe -m pip install torch-directml
213
+ .\python_embeded\python.exe -s Fooocus\entry_with_update.py --directml
214
+ pause
215
+
216
+ Then run the `run.bat`.
217
+
218
+ AMD is not intensively tested, however. The AMD support is in beta.
219
+
220
+ For AMD, use `.\python_embeded\python.exe entry_with_update.py --directml --preset anime` or `.\python_embeded\python.exe entry_with_update.py --directml --preset realistic` for Fooocus Anime/Realistic Edition.
221
+
222
+ ### Mac
223
+
224
+ Note that the [minimal requirement](#minimal-requirement) for different platforms is different.
225
+
226
+ Mac is not intensively tested. Below is an unofficial guideline for using Mac. You can discuss problems [here](https://github.com/lllyasviel/Fooocus/pull/129).
227
+
228
+ You can install Fooocus on Apple Mac silicon (M1 or M2) with macOS 'Catalina' or a newer version. Fooocus runs on Apple silicon computers via [PyTorch](https://pytorch.org/get-started/locally/) MPS device acceleration. Mac Silicon computers don't come with a dedicated graphics card, resulting in significantly longer image processing times compared to computers with dedicated graphics cards.
229
+
230
+ 1. Install the conda package manager and pytorch nightly. Read the [Accelerated PyTorch training on Mac](https://developer.apple.com/metal/pytorch/) Apple Developer guide for instructions. Make sure pytorch recognizes your MPS device.
231
+ 1. Open the macOS Terminal app and clone this repository with `git clone https://github.com/lllyasviel/Fooocus.git`.
232
+ 1. Change to the new Fooocus directory, `cd Fooocus`.
233
+ 1. Create a new conda environment, `conda env create -f environment.yaml`.
234
+ 1. Activate your new conda environment, `conda activate fooocus`.
235
+ 1. Install the packages required by Fooocus, `pip install -r requirements_versions.txt`.
236
+ 1. Launch Fooocus by running `python entry_with_update.py`. (Some Mac M2 users may need `python entry_with_update.py --disable-offload-from-vram` to speed up model loading/unloading.) The first time you run Fooocus, it will automatically download the Stable Diffusion SDXL models and will take a significant amount of time, depending on your internet connection.
237
+
238
+ Use `python entry_with_update.py --preset anime` or `python entry_with_update.py --preset realistic` for Fooocus Anime/Realistic Edition.
239
+
240
+ ### Docker
241
+
242
+ See [docker.md](docker.md)
243
+
244
+ ### Download Previous Version
245
+
246
+ See the guidelines [here](https://github.com/lllyasviel/Fooocus/discussions/1405).
247
+
248
+ ## Minimal Requirement
249
+
250
+ Below is the minimal requirement for running Fooocus locally. If your device capability is lower than this spec, you may not be able to use Fooocus locally. (Please let us know, in any case, if your device capability is lower but Fooocus still works.)
251
+
252
+ | Operating System | GPU | Minimal GPU Memory | Minimal System Memory | [System Swap](troubleshoot.md) | Note |
253
+ |-------------------|------------------------------|------------------------------|---------------------------|--------------------------------|----------------------------------------------------------------------------|
254
+ | Windows/Linux | Nvidia RTX 4XXX | 4GB | 8GB | Required | fastest |
255
+ | Windows/Linux | Nvidia RTX 3XXX | 4GB | 8GB | Required | usually faster than RTX 2XXX |
256
+ | Windows/Linux | Nvidia RTX 2XXX | 4GB | 8GB | Required | usually faster than GTX 1XXX |
257
+ | Windows/Linux | Nvidia GTX 1XXX | 8GB (&ast; 6GB uncertain) | 8GB | Required | only marginally faster than CPU |
258
+ | Windows/Linux | Nvidia GTX 9XX | 8GB | 8GB | Required | faster or slower than CPU |
259
+ | Windows/Linux | Nvidia GTX < 9XX | Not supported | / | / | / |
260
+ | Windows | AMD GPU | 8GB (updated 2023 Dec 30) | 8GB | Required | via DirectML (&ast; ROCm is on hold), about 3x slower than Nvidia RTX 3XXX |
261
+ | Linux | AMD GPU | 8GB | 8GB | Required | via ROCm, about 1.5x slower than Nvidia RTX 3XXX |
262
+ | Mac | M1/M2 MPS | Shared | Shared | Shared | about 9x slower than Nvidia RTX 3XXX |
263
+ | Windows/Linux/Mac | only use CPU | 0GB | 32GB | Required | about 17x slower than Nvidia RTX 3XXX |
264
+
265
+ &ast; AMD GPU ROCm (on hold): The AMD is still working on supporting ROCm on Windows.
266
+
267
+ &ast; Nvidia GTX 1XXX 6GB uncertain: Some people report 6GB success on GTX 10XX, but some other people report failure cases.
268
+
269
+ *Note that Fooocus is only for extremely high quality image generating. We will not support smaller models to reduce the requirement and sacrifice result quality.*
270
+
271
+ ## Troubleshoot
272
+
273
+ See the common problems [here](troubleshoot.md).
274
+
275
+ ## Default Models
276
+ <a name="models"></a>
277
+
278
+ Given different goals, the default models and configs of Fooocus are different:
279
+
280
+ | Task | Windows | Linux args | Main Model | Refiner | Config |
281
+ | --- | --- | --- | --- | --- |--------------------------------------------------------------------------------|
282
+ | General | run.bat | | juggernautXL_v8Rundiffusion | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/default.json) |
283
+ | Realistic | run_realistic.bat | --preset realistic | realisticStockPhoto_v20 | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/realistic.json) |
284
+ | Anime | run_anime.bat | --preset anime | animaPencilXL_v100 | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/anime.json) |
285
+
286
+ Note that the download is **automatic** - you do not need to do anything if the internet connection is okay. However, you can download them manually if you (or move them from somewhere else) have your own preparation.
287
+
288
+ ## UI Access and Authentication
289
+ In addition to running on localhost, Fooocus can also expose its UI in two ways:
290
+ * Local UI listener: use `--listen` (specify port e.g. with `--port 8888`).
291
+ * API access: use `--share` (registers an endpoint at `.gradio.live`).
292
+
293
+ In both ways the access is unauthenticated by default. You can add basic authentication by creating a file called `auth.json` in the main directory, which contains a list of JSON objects with the keys `user` and `pass` (see example in [auth-example.json](./auth-example.json)).
294
+
295
+ ## List of "Hidden" Tricks
296
+ <a name="tech_list"></a>
297
+
298
+ The below things are already inside the software, and **users do not need to do anything about these**.
299
+
300
+ 1. GPT2-based [prompt expansion as a dynamic style "Fooocus V2".](https://github.com/lllyasviel/Fooocus/discussions/117#raw) (similar to Midjourney's hidden pre-processing and "raw" mode, or the LeonardoAI's Prompt Magic).
301
+ 2. Native refiner swap inside one single k-sampler. The advantage is that the refiner model can now reuse the base model's momentum (or ODE's history parameters) collected from k-sampling to achieve more coherent sampling. In Automatic1111's high-res fix and ComfyUI's node system, the base model and refiner use two independent k-samplers, which means the momentum is largely wasted, and the sampling continuity is broken. Fooocus uses its own advanced k-diffusion sampling that ensures seamless, native, and continuous swap in a refiner setup. (Update Aug 13: Actually, I discussed this with Automatic1111 several days ago, and it seems that the “native refiner swap inside one single k-sampler” is [merged]( https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/12371) into the dev branch of webui. Great!)
302
+ 3. Negative ADM guidance. Because the highest resolution level of XL Base does not have cross attentions, the positive and negative signals for XL's highest resolution level cannot receive enough contrasts during the CFG sampling, causing the results to look a bit plastic or overly smooth in certain cases. Fortunately, since the XL's highest resolution level is still conditioned on image aspect ratios (ADM), we can modify the adm on the positive/negative side to compensate for the lack of CFG contrast in the highest resolution level. (Update Aug 16, the IOS App [Draw Things](https://apps.apple.com/us/app/draw-things-ai-generation/id6444050820) will support Negative ADM Guidance. Great!)
303
+ 4. We implemented a carefully tuned variation of Section 5.1 of ["Improving Sample Quality of Diffusion Models Using Self-Attention Guidance"](https://arxiv.org/pdf/2210.00939.pdf). The weight is set to very low, but this is Fooocus's final guarantee to make sure that the XL will never yield an overly smooth or plastic appearance (examples [here](https://github.com/lllyasviel/Fooocus/discussions/117#sharpness)). This can almost eliminate all cases for which XL still occasionally produces overly smooth results, even with negative ADM guidance. (Update 2023 Aug 18, the Gaussian kernel of SAG is changed to an anisotropic kernel for better structure preservation and fewer artifacts.)
304
+ 5. We modified the style templates a bit and added the "cinematic-default".
305
+ 6. We tested the "sd_xl_offset_example-lora_1.0.safetensors" and it seems that when the lora weight is below 0.5, the results are always better than XL without lora.
306
+ 7. The parameters of samplers are carefully tuned.
307
+ 8. Because XL uses positional encoding for generation resolution, images generated by several fixed resolutions look a bit better than those from arbitrary resolutions (because the positional encoding is not very good at handling int numbers that are unseen during training). This suggests that the resolutions in UI may be hard coded for best results.
308
+ 9. Separated prompts for two different text encoders seem unnecessary. Separated prompts for the base model and refiner may work, but the effects are random, and we refrain from implementing this.
309
+ 10. The DPM family seems well-suited for XL since XL sometimes generates overly smooth texture, but the DPM family sometimes generates overly dense detail in texture. Their joint effect looks neutral and appealing to human perception.
310
+ 11. A carefully designed system for balancing multiple styles as well as prompt expansion.
311
+ 12. Using automatic1111's method to normalize prompt emphasizing. This significantly improves results when users directly copy prompts from civitai.
312
+ 13. The joint swap system of the refiner now also supports img2img and upscale in a seamless way.
313
+ 14. CFG Scale and TSNR correction (tuned for SDXL) when CFG is bigger than 10.
314
+
315
+ ## Customization
316
+
317
+ After the first time you run Fooocus, a config file will be generated at `Fooocus\config.txt`. This file can be edited to change the model path or default parameters.
318
+
319
+ For example, an edited `Fooocus\config.txt` (this file will be generated after the first launch) may look like this:
320
+
321
+ ```json
322
+ {
323
+ "path_checkpoints": "D:\\Fooocus\\models\\checkpoints",
324
+ "path_loras": "D:\\Fooocus\\models\\loras",
325
+ "path_embeddings": "D:\\Fooocus\\models\\embeddings",
326
+ "path_vae_approx": "D:\\Fooocus\\models\\vae_approx",
327
+ "path_upscale_models": "D:\\Fooocus\\models\\upscale_models",
328
+ "path_inpaint": "D:\\Fooocus\\models\\inpaint",
329
+ "path_controlnet": "D:\\Fooocus\\models\\controlnet",
330
+ "path_clip_vision": "D:\\Fooocus\\models\\clip_vision",
331
+ "path_fooocus_expansion": "D:\\Fooocus\\models\\prompt_expansion\\fooocus_expansion",
332
+ "path_outputs": "D:\\Fooocus\\outputs",
333
+ "default_model": "realisticStockPhoto_v10.safetensors",
334
+ "default_refiner": "",
335
+ "default_loras": [["lora_filename_1.safetensors", 0.5], ["lora_filename_2.safetensors", 0.5]],
336
+ "default_cfg_scale": 3.0,
337
+ "default_sampler": "dpmpp_2m",
338
+ "default_scheduler": "karras",
339
+ "default_negative_prompt": "low quality",
340
+ "default_positive_prompt": "",
341
+ "default_styles": [
342
+ "Fooocus V2",
343
+ "Fooocus Photograph",
344
+ "Fooocus Negative"
345
+ ]
346
+ }
347
+ ```
348
+
349
+ Many other keys, formats, and examples are in `Fooocus\config_modification_tutorial.txt` (this file will be generated after the first launch).
350
+
351
+ Consider twice before you really change the config. If you find yourself breaking things, just delete `Fooocus\config.txt`. Fooocus will go back to default.
352
+
353
+ A safer way is just to try "run_anime.bat" or "run_realistic.bat" - they should already be good enough for different tasks.
354
+
355
+ ~Note that `user_path_config.txt` is deprecated and will be removed soon.~ (Edit: it is already removed.)
356
+
357
+ ### All CMD Flags
358
+
359
+ ```
360
+ entry_with_update.py [-h] [--listen [IP]] [--port PORT]
361
+ [--disable-header-check [ORIGIN]]
362
+ [--web-upload-size WEB_UPLOAD_SIZE]
363
+ [--external-working-path PATH [PATH ...]]
364
+ [--output-path OUTPUT_PATH] [--temp-path TEMP_PATH]
365
+ [--cache-path CACHE_PATH] [--in-browser]
366
+ [--disable-in-browser] [--gpu-device-id DEVICE_ID]
367
+ [--async-cuda-allocation | --disable-async-cuda-allocation]
368
+ [--disable-attention-upcast] [--all-in-fp32 | --all-in-fp16]
369
+ [--unet-in-bf16 | --unet-in-fp16 | --unet-in-fp8-e4m3fn | --unet-in-fp8-e5m2]
370
+ [--vae-in-fp16 | --vae-in-fp32 | --vae-in-bf16]
371
+ [--clip-in-fp8-e4m3fn | --clip-in-fp8-e5m2 | --clip-in-fp16 | --clip-in-fp32]
372
+ [--directml [DIRECTML_DEVICE]] [--disable-ipex-hijack]
373
+ [--preview-option [none,auto,fast,taesd]]
374
+ [--attention-split | --attention-quad | --attention-pytorch]
375
+ [--disable-xformers]
376
+ [--always-gpu | --always-high-vram | --always-normal-vram |
377
+ --always-low-vram | --always-no-vram | --always-cpu [CPU_NUM_THREADS]]
378
+ [--always-offload-from-vram] [--disable-server-log]
379
+ [--debug-mode] [--is-windows-embedded-python]
380
+ [--disable-server-info] [--share] [--preset PRESET]
381
+ [--language LANGUAGE] [--disable-offload-from-vram]
382
+ [--theme THEME] [--disable-image-log]
383
+ ```
384
+
385
+ ## Advanced Features
386
+
387
+ [Click here to browse the advanced features.](https://github.com/lllyasviel/Fooocus/discussions/117)
388
+
389
+ Fooocus also has many community forks, just like SD-WebUI's [vladmandic/automatic](https://github.com/vladmandic/automatic) and [anapnoe/stable-diffusion-webui-ux](https://github.com/anapnoe/stable-diffusion-webui-ux), for enthusiastic users who want to try!
390
+
391
+ | Fooocus' forks |
392
+ | - |
393
+ | [fenneishi/Fooocus-Control](https://github.com/fenneishi/Fooocus-Control) </br>[runew0lf/RuinedFooocus](https://github.com/runew0lf/RuinedFooocus) </br> [MoonRide303/Fooocus-MRE](https://github.com/MoonRide303/Fooocus-MRE) </br> [metercai/SimpleSDXL](https://github.com/metercai/SimpleSDXL) </br> and so on ... |
394
+
395
+ See also [About Forking and Promotion of Forks](https://github.com/lllyasviel/Fooocus/discussions/699).
396
+
397
+ ## Thanks
398
+
399
+ Special thanks to [twri](https://github.com/twri) and [3Diva](https://github.com/3Diva) and [Marc K3nt3L](https://github.com/K3nt3L) for creating additional SDXL styles available in Fooocus. Thanks [daswer123](https://github.com/daswer123) for contributing the Canvas Zoom!
400
+
401
+ ## Update Log
402
+
403
+ The log is [here](update_log.md).
404
+
405
+ ## Localization/Translation/I18N
406
+
407
+ **We need your help!** Please help translate Fooocus into international languages.
408
+
409
+ You can put json files in the `language` folder to translate the user interface.
410
+
411
+ For example, below is the content of `Fooocus/language/example.json`:
412
+
413
+ ```json
414
+ {
415
+ "Generate": "生成",
416
+ "Input Image": "入力画像",
417
+ "Advanced": "고급",
418
+ "SAI 3D Model": "SAI 3D Modèle"
419
+ }
420
+ ```
421
+
422
+ If you add `--language example` arg, Fooocus will read `Fooocus/language/example.json` to translate the UI.
423
+
424
+ For example, you can edit the ending line of Windows `run.bat` as
425
+
426
+ .\python_embeded\python.exe -s Fooocus\entry_with_update.py --language example
427
+
428
+ Or `run_anime.bat` as
429
+
430
+ .\python_embeded\python.exe -s Fooocus\entry_with_update.py --language example --preset anime
431
+
432
+ Or `run_realistic.bat` as
433
+
434
+ .\python_embeded\python.exe -s Fooocus\entry_with_update.py --language example --preset realistic
435
+
436
+ For practical translation, you may create your own file like `Fooocus/language/jp.json` or `Fooocus/language/cn.json` and then use flag `--language jp` or `--language cn`. Apparently, these files do not exist now. **We need your help to create these files!**
437
+
438
+ Note that if no `--language` is given and at the same time `Fooocus/language/default.json` exists, Fooocus will always load `Fooocus/language/default.json` for translation. By default, the file `Fooocus/language/default.json` does not exist.
requirements_docker.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ torch==2.0.1
2
+ torchvision==0.15.2
3
+ torchaudio==2.0.2
4
+ torchtext==0.15.2
5
+ torchdata==0.6.1
requirements_versions.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torchsde==0.2.5
2
+ einops==0.4.1
3
+ transformers==4.30.2
4
+ safetensors==0.3.1
5
+ accelerate==0.21.0
6
+ pyyaml==6.0
7
+ Pillow==9.2.0
8
+ scipy==1.9.3
9
+ tqdm==4.64.1
10
+ psutil==5.9.5
11
+ pytorch_lightning==1.9.4
12
+ omegaconf==2.2.3
13
+ gradio==3.41.2
14
+ pygit2==1.12.2
15
+ opencv-contrib-python==4.8.0.74
16
+ httpx==0.24.1
17
+ onnxruntime==1.16.3
18
+ timm==0.9.2
shared.py ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio_root = None
sorted_styles.json ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ "Fooocus V2",
3
+ "Fooocus Enhance",
4
+ "Fooocus Sharp",
5
+ "AI V2",
6
+ "Fooocus Masterpiece",
7
+ "Fooocus Photograph",
8
+ "Fooocus Negative",
9
+ "Fooocus Cinematic",
10
+ "SAI 3D Model",
11
+ "SAI Analog Film",
12
+ "SAI Anime",
13
+ "SAI Cinematic",
14
+ "SAI Comic Book",
15
+ "SAI Craft Clay",
16
+ "SAI Digital Art",
17
+ "SAI Enhance",
18
+ "SAI Fantasy Art",
19
+ "SAI Isometric",
20
+ "SAI Line Art",
21
+ "SAI Lowpoly",
22
+ "SAI Neonpunk",
23
+ "SAI Origami",
24
+ "SAI Photographic",
25
+ "SAI Pixel Art",
26
+ "SAI Texture",
27
+ "MRE Cinematic Dynamic",
28
+ "MRE Spontaneous Picture",
29
+ "MRE Artistic Vision",
30
+ "MRE Dark Dream",
31
+ "MRE Gloomy Art",
32
+ "MRE Bad Dream",
33
+ "MRE Underground",
34
+ "MRE Surreal Painting",
35
+ "MRE Dynamic Illustration",
36
+ "MRE Undead Art",
37
+ "MRE Elemental Art",
38
+ "MRE Space Art",
39
+ "MRE Ancient Illustration",
40
+ "MRE Brave Art",
41
+ "MRE Heroic Fantasy",
42
+ "MRE Dark Cyberpunk",
43
+ "MRE Lyrical Geometry",
44
+ "MRE Sumi E Symbolic",
45
+ "MRE Sumi E Detailed",
46
+ "MRE Manga",
47
+ "MRE Anime",
48
+ "MRE Comic",
49
+ "Ads Advertising",
50
+ "Ads Automotive",
51
+ "Ads Corporate",
52
+ "Ads Fashion Editorial",
53
+ "Ads Food Photography",
54
+ "Ads Gourmet Food Photography",
55
+ "Ads Luxury",
56
+ "Ads Real Estate",
57
+ "Ads Retail",
58
+ "Artstyle Abstract",
59
+ "Artstyle Abstract Expressionism",
60
+ "Artstyle Art Deco",
61
+ "Artstyle Art Nouveau",
62
+ "Artstyle Constructivist",
63
+ "Artstyle Cubist",
64
+ "Artstyle Expressionist",
65
+ "Artstyle Graffiti",
66
+ "Artstyle Hyperrealism",
67
+ "Artstyle Impressionist",
68
+ "Artstyle Pointillism",
69
+ "Artstyle Pop Art",
70
+ "Artstyle Psychedelic",
71
+ "Artstyle Renaissance",
72
+ "Artstyle Steampunk",
73
+ "Artstyle Surrealist",
74
+ "Artstyle Typography",
75
+ "Artstyle Watercolor",
76
+ "Futuristic Biomechanical",
77
+ "Futuristic Biomechanical Cyberpunk",
78
+ "Futuristic Cybernetic",
79
+ "Futuristic Cybernetic Robot",
80
+ "Futuristic Cyberpunk Cityscape",
81
+ "Futuristic Futuristic",
82
+ "Futuristic Retro Cyberpunk",
83
+ "Futuristic Retro Futurism",
84
+ "Futuristic Sci Fi",
85
+ "Futuristic Vaporwave",
86
+ "Game Bubble Bobble",
87
+ "Game Cyberpunk Game",
88
+ "Game Fighting Game",
89
+ "Game Gta",
90
+ "Game Mario",
91
+ "Game Minecraft",
92
+ "Game Pokemon",
93
+ "Game Retro Arcade",
94
+ "Game Retro Game",
95
+ "Game Rpg Fantasy Game",
96
+ "Game Strategy Game",
97
+ "Game Streetfighter",
98
+ "Game Zelda",
99
+ "Misc Architectural",
100
+ "Misc Disco",
101
+ "Misc Dreamscape",
102
+ "Misc Dystopian",
103
+ "Misc Fairy Tale",
104
+ "Misc Gothic",
105
+ "Misc Grunge",
106
+ "Misc Horror",
107
+ "Misc Kawaii",
108
+ "Misc Lovecraftian",
109
+ "Misc Macabre",
110
+ "Misc Manga",
111
+ "Misc Metropolis",
112
+ "Misc Minimalist",
113
+ "Misc Monochrome",
114
+ "Misc Nautical",
115
+ "Misc Space",
116
+ "Misc Stained Glass",
117
+ "Misc Techwear Fashion",
118
+ "Misc Tribal",
119
+ "Misc Zentangle",
120
+ "Papercraft Collage",
121
+ "Papercraft Flat Papercut",
122
+ "Papercraft Kirigami",
123
+ "Papercraft Paper Mache",
124
+ "Papercraft Paper Quilling",
125
+ "Papercraft Papercut Collage",
126
+ "Papercraft Papercut Shadow Box",
127
+ "Papercraft Stacked Papercut",
128
+ "Papercraft Thick Layered Papercut",
129
+ "Photo Alien",
130
+ "Photo Film Noir",
131
+ "Photo Glamour",
132
+ "Photo Hdr",
133
+ "Photo Iphone Photographic",
134
+ "Photo Long Exposure",
135
+ "Photo Neon Noir",
136
+ "Photo Silhouette",
137
+ "Photo Tilt Shift",
138
+ "Cinematic Diva",
139
+ "Abstract Expressionism",
140
+ "Academia",
141
+ "Action Figure",
142
+ "Adorable 3D Character",
143
+ "Adorable Kawaii",
144
+ "Art Deco",
145
+ "Art Nouveau",
146
+ "Astral Aura",
147
+ "Avant Garde",
148
+ "Baroque",
149
+ "Bauhaus Style Poster",
150
+ "Blueprint Schematic Drawing",
151
+ "Caricature",
152
+ "Cel Shaded Art",
153
+ "Character Design Sheet",
154
+ "Classicism Art",
155
+ "Color Field Painting",
156
+ "Colored Pencil Art",
157
+ "Conceptual Art",
158
+ "Constructivism",
159
+ "Cubism",
160
+ "Dadaism",
161
+ "Dark Fantasy",
162
+ "Dark Moody Atmosphere",
163
+ "Dmt Art Style",
164
+ "Doodle Art",
165
+ "Double Exposure",
166
+ "Dripping Paint Splatter Art",
167
+ "Expressionism",
168
+ "Faded Polaroid Photo",
169
+ "Fauvism",
170
+ "Flat 2d Art",
171
+ "Fortnite Art Style",
172
+ "Futurism",
173
+ "Glitchcore",
174
+ "Glo Fi",
175
+ "Googie Art Style",
176
+ "Graffiti Art",
177
+ "Harlem Renaissance Art",
178
+ "High Fashion",
179
+ "Idyllic",
180
+ "Impressionism",
181
+ "Infographic Drawing",
182
+ "Ink Dripping Drawing",
183
+ "Japanese Ink Drawing",
184
+ "Knolling Photography",
185
+ "Light Cheery Atmosphere",
186
+ "Logo Design",
187
+ "Luxurious Elegance",
188
+ "Macro Photography",
189
+ "Mandola Art",
190
+ "Marker Drawing",
191
+ "Medievalism",
192
+ "Minimalism",
193
+ "Neo Baroque",
194
+ "Neo Byzantine",
195
+ "Neo Futurism",
196
+ "Neo Impressionism",
197
+ "Neo Rococo",
198
+ "Neoclassicism",
199
+ "Op Art",
200
+ "Ornate And Intricate",
201
+ "Pencil Sketch Drawing",
202
+ "Pop Art 2",
203
+ "Rococo",
204
+ "Silhouette Art",
205
+ "Simple Vector Art",
206
+ "Sketchup",
207
+ "Steampunk 2",
208
+ "Surrealism",
209
+ "Suprematism",
210
+ "Terragen",
211
+ "Tranquil Relaxing Atmosphere",
212
+ "Sticker Designs",
213
+ "Vibrant Rim Light",
214
+ "Volumetric Lighting",
215
+ "Watercolor 2",
216
+ "Whimsical And Playful",
217
+ "Mk Chromolithography",
218
+ "Mk Cross Processing Print",
219
+ "Mk Dufaycolor Photograph",
220
+ "Mk Herbarium",
221
+ "Mk Punk Collage",
222
+ "Mk Mosaic",
223
+ "Mk Van Gogh",
224
+ "Mk Coloring Book",
225
+ "Mk Singer Sargent",
226
+ "Mk Pollock",
227
+ "Mk Basquiat",
228
+ "Mk Andy Warhol",
229
+ "Mk Halftone Print",
230
+ "Mk Gond Painting",
231
+ "Mk Albumen Print",
232
+ "Mk Aquatint Print",
233
+ "Mk Anthotype Print",
234
+ "Mk Inuit Carving",
235
+ "Mk Bromoil Print",
236
+ "Mk Calotype Print",
237
+ "Mk Color Sketchnote",
238
+ "Mk Cibulak Porcelain",
239
+ "Mk Alcohol Ink Art",
240
+ "Mk One Line Art",
241
+ "Mk Blacklight Paint",
242
+ "Mk Carnival Glass",
243
+ "Mk Cyanotype Print",
244
+ "Mk Cross Stitching",
245
+ "Mk Encaustic Paint",
246
+ "Mk Embroidery",
247
+ "Mk Gyotaku",
248
+ "Mk Luminogram",
249
+ "Mk Lite Brite Art",
250
+ "Mk Mokume Gane",
251
+ "Pebble Art",
252
+ "Mk Palekh",
253
+ "Mk Suminagashi",
254
+ "Mk Scrimshaw",
255
+ "Mk Shibori",
256
+ "Mk Vitreous Enamel",
257
+ "Mk Ukiyo E",
258
+ "Mk Vintage Airline Poster",
259
+ "Mk Vintage Travel Poster",
260
+ "Mk Bauhaus Style",
261
+ "Mk Afrofuturism",
262
+ "Mk Atompunk",
263
+ "Mk Constructivism",
264
+ "Mk Chicano Art",
265
+ "Mk De Stijl",
266
+ "Mk Dayak Art",
267
+ "Mk Fayum Portrait",
268
+ "Mk Illuminated Manuscript",
269
+ "Mk Kalighat Painting",
270
+ "Mk Madhubani Painting",
271
+ "Mk Pictorialism",
272
+ "Mk Pichwai Painting",
273
+ "Mk Patachitra Painting",
274
+ "Mk Samoan Art Inspired",
275
+ "Mk Tlingit Art",
276
+ "Mk Adnate Style",
277
+ "Mk Ron English Style",
278
+ "Mk Shepard Fairey Style"
279
+ ]
troubleshoot.md ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Below are many common problems that people encountered:
2
+
3
+ ### RuntimeError: CPUAllocator
4
+
5
+ See also the section: **System Swap**
6
+
7
+ ### Model loaded, then paused, then nothing happens
8
+
9
+ See also the section: **System Swap**
10
+
11
+ ### Segmentation Fault
12
+
13
+ See also the section: **System Swap**
14
+
15
+ ### Aborted
16
+
17
+ See also the section: **System Swap**
18
+
19
+ ### core dumped
20
+
21
+ See also the section: **System Swap**
22
+
23
+ ### Killed
24
+
25
+ See also the section: **System Swap**
26
+
27
+ ### ^C, then quit
28
+
29
+ See also the section: **System Swap**
30
+
31
+ ### adm 2816, then stuck
32
+
33
+ See also the section: **System Swap**
34
+
35
+ ### Connection errored out
36
+
37
+ See also the section: **System Swap**
38
+
39
+ ### Error 1006
40
+
41
+ See also the section: **System Swap**
42
+
43
+ ### WinError 10060
44
+
45
+ See also the section: **System Swap**
46
+
47
+ ### Read timed out
48
+
49
+ See also the section: **System Swap**
50
+
51
+ ### No error, but the console close in a flash. Cannot find any error.
52
+
53
+ See also the section: **System Swap**
54
+
55
+ ### Model loading is extremely slow (more than 1 minute)
56
+
57
+ See also the section: **System Swap**
58
+
59
+ ### System Swap
60
+
61
+ All above problems are caused by the fact that you do not have enough System Swap.
62
+
63
+ Please make sure that you have at least 40GB System Swap. In fact, it does not need so much Swap, but 40Gb should be safe for you to run Fooocus in 100% success.
64
+
65
+ (If you have more than 64GB RAM, then *perhaps* you do not need any System Swap, but we are not exactly sure about this.)
66
+
67
+ Also, if your system swap is on HDD, the speed of model loading will be very slow. Please try best to put system swap on SSD.
68
+
69
+ If you are using Linux/Mac, please follow your provider's instructions to set Swap Space. Herein, the "provider" refers to Ubuntu official, CentOS official, Mac official, etc.
70
+
71
+ If you are using Windows, you can set Swap here:
72
+
73
+ ![swap](https://github.com/lllyasviel/Fooocus/assets/19834515/2a06b130-fe9b-4504-94f1-2763be4476e9)
74
+
75
+ If you use both HDD and SSD, you *may* test some settings on the above step 7 to try best to put swap area on SSD, so that the speed of model loading will be faster.
76
+
77
+ **Important: Microsoft Windows 10/11 by default automate system swap for you so that you do not need to touch this dangerous setting. If you do not have enough system swap, just make sure that you have at least 40GB free space on each disk.** The Microsoft Windows 10/11 will automatically make swap areas for you.
78
+
79
+ Also, if you obtain Microsoft Windows 10/11 from some unofficial Chinese or Russian provider, they may have modified the default setting of system swap to advertise some "Enhanced Windows 10/11" (but actually they are just making things worse rather than improve things). In those cases, you may need to manually check if your system swap setting is consistent to the above screenshot.
80
+
81
+ Finally, note that you need to restart computer to activate any changes in system swap.
82
+
83
+ ### MetadataIncompleteBuffer
84
+
85
+ See also the section: **Model corrupted**
86
+
87
+ ### PytorchStreamReader failed
88
+
89
+ See also the section: **Model corrupted**
90
+
91
+ ### Model corrupted
92
+
93
+ If you see Model Corrupted, then your model is corrupted. Fooocus will re-download corrupted models for you if your internet connection is good. Otherwise, you may also manually download models. You can find model url and their local location in the console each time a model download is requested.
94
+
95
+ ### UserWarning: The operator 'aten::std_mean.correction' is not currently supported on the DML
96
+
97
+ This is a warning that you can ignore.
98
+
99
+ ### Torch not compiled with CUDA enabled
100
+
101
+ You are not following the official installation guide.
102
+
103
+ Please do not trust those wrong tutorials on the internet, and please only trust the official installation guide.
104
+
105
+ ### subprocess-exited-with-error
106
+
107
+ Please use python 3.10
108
+
109
+ Also, you are not following the official installation guide.
110
+
111
+ Please do not trust those wrong tutorials on the internet, and please only trust the official installation guide.
112
+
113
+ ### SSL: CERTIFICATE_VERIFY_FAILED
114
+
115
+ Are you living in China? If yes, please consider turn off VPN, and/or try to download models manually.
116
+
117
+ If you get this error elsewhere in the world, then you may need to look at [this search](https://www.google.com/search?q=SSL+Certificate+Error). We cannot give very specific guide to fix this since the cause can vary a lot.
118
+
119
+ ### CUDA kernel errors might be asynchronously reported at some other API call
120
+
121
+ A very small amount of devices does have this problem. The cause can be complicated but usually can be resolved after following these steps:
122
+
123
+ 1. Make sure that you are using official version and latest version installed from [here](https://github.com/lllyasviel/Fooocus#download). (Some forks and other versions are more likely to cause this problem.)
124
+ 2. Upgrade your Nvidia driver to the latest version. (Usually the version of your Nvidia driver should be 53X, not 3XX or 4XX.)
125
+ 3. If things still do not work, then perhaps it is a problem with CUDA 12. You can use CUDA 11 and Xformers to try to solve this problem. We have prepared all files for you, and please do NOT install any CUDA or other environment on you own. The only one official way to do this is: (1) Backup and delete your `python_embeded` folder (near the `run.bat`); (2) Download the "previous_old_xformers_env.7z" from the [release page](https://github.com/lllyasviel/Fooocus/releases/tag/release), decompress it, and put the newly extracted `python_embeded` folder near your `run.bat`; (3) run Fooocus.
126
+ 4. If it still does not work, please open an issue for us to take a look.
127
+
128
+ ### Found no NVIDIA driver on your system
129
+
130
+ Please upgrade your Nvidia Driver.
131
+
132
+ If you are using AMD, please follow official installation guide.
133
+
134
+ ### NVIDIA driver too old
135
+
136
+ Please upgrade your Nvidia Driver.
137
+
138
+ ### I am using Mac, the speed is very slow.
139
+
140
+ Some MAC users may need `--disable-offload-from-vram` to speed up model loading.
141
+
142
+ Besides, the current support for MAC is very experimental, and we encourage users to also try Diffusionbee or Drawingthings: they are developed only for MAC.
143
+
144
+ ### I am using Nvidia with 8GB VRAM, I get CUDA Out Of Memory
145
+
146
+ It is a BUG. Please let us know as soon as possible. Please make an issue. See also [minimal requirements](https://github.com/lllyasviel/Fooocus/tree/main?tab=readme-ov-file#minimal-requirement).
147
+
148
+ ### I am using Nvidia with 6GB VRAM, I get CUDA Out Of Memory
149
+
150
+ It is very likely a BUG. Please let us know as soon as possible. Please make an issue. See also [minimal requirements](https://github.com/lllyasviel/Fooocus/tree/main?tab=readme-ov-file#minimal-requirement).
151
+
152
+ ### I am using Nvidia with 4GB VRAM with Float16 support, like RTX 3050, I get CUDA Out Of Memory
153
+
154
+ It is a BUG. Please let us know as soon as possible. Please make an issue. See also [minimal requirements](https://github.com/lllyasviel/Fooocus/tree/main?tab=readme-ov-file#minimal-requirement).
155
+
156
+ ### I am using Nvidia with 4GB VRAM without Float16 support, like GTX 960, I get CUDA Out Of Memory
157
+
158
+ Supporting GPU with 4GB VRAM without fp16 is extremely difficult, and you may not be able to use SDXL. However, you may still make an issue and let us know. You may try SD1.5 in Automatic1111 or other software for your device. See also [minimal requirements](https://github.com/lllyasviel/Fooocus/tree/main?tab=readme-ov-file#minimal-requirement).
159
+
160
+ ### I am using AMD GPU on Windows, I get CUDA Out Of Memory
161
+
162
+ Current AMD support is very experimental for Windows. If you see this, then perhaps you cannot use Fooocus on this device on Windows.
163
+
164
+ However, if you re able to run SDXL on this same device on any other software, please let us know immediately, and we will support it as soon as possible. If no other software can enable your device to run SDXL on Windows, then we also do not have much to help.
165
+
166
+ Besides, the AMD support on Linux is slightly better because it will use ROCM. You may also try it if you are willing to change OS to linux. See also [minimal requirements](https://github.com/lllyasviel/Fooocus/tree/main?tab=readme-ov-file#minimal-requirement).
167
+
168
+ ### I am using AMD GPU on Linux, I get CUDA Out Of Memory
169
+
170
+ Current AMD support for Linux is better than that for Windows, but still, very experimental. However, if you re able to run SDXL on this same device on any other software, please let us know immediately, and we will support it as soon as possible. If no other software can enable your device to run SDXL on Windows, then we also do not have much to help. See also [minimal requirements](https://github.com/lllyasviel/Fooocus/tree/main?tab=readme-ov-file#minimal-requirement).
171
+
172
+ ### I tried flags like --lowvram or --gpu-only or --bf16 or so on, and things are not getting any better?
173
+
174
+ Please remove these flags if you are mislead by some wrong tutorials. In most cases these flags are making things worse and introducing more problems.
175
+
176
+ ### Fooocus suddenly becomes very slow and I have not changed anything
177
+
178
+ Are you accidentally running two Fooocus at the same time?
update_log.md ADDED
@@ -0,0 +1,632 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # [2.2.1](https://github.com/lllyasviel/Fooocus/releases/tag/2.2.1)
2
+
3
+ * Fix some small bugs (e.g. image grid, upscale fast 2x, LoRA weight width in Firefox)
4
+ * Allow prompt weights in array syntax
5
+ * Add steps override and metadata scheme to history log
6
+
7
+ # [2.2.0](https://github.com/lllyasviel/Fooocus/releases/tag/2.2.0)
8
+
9
+ * Isolate every image generation to truly allow multi-user usage
10
+ * Add array support, changes the main prompt when increasing the image number. Syntax: `[[red, green, blue]] flower`
11
+ * Add optional metadata to images, allowing you to regenerate and modify them later with the same parameters
12
+ * Now supports native PNG, JPG and WEBP image generation
13
+ * Add Docker support
14
+
15
+ # [2.1.865](https://github.com/lllyasviel/Fooocus/releases/tag/2.1.865)
16
+
17
+ * Various bugfixes
18
+ * Add authentication to --listen
19
+
20
+ # 2.1.864
21
+
22
+ * New model list. See also discussions.
23
+
24
+ # 2.1.861 (requested update)
25
+
26
+ (2023 Dec 21) Hi all, the feature updating of Fooocus will be paused for about two or three weeks because we have some other workloads. See you soon and we will come back in mid or late Jan. However, you may still see updates if other collaborators are fixing bugs or solving problems.
27
+
28
+ * Show image preview in Style when mouse hover.
29
+
30
+ # 2.1.860 (requested update)
31
+
32
+ * Allow upload inpaint mask in developer mode.
33
+
34
+ # 2.1.857 (requested update)
35
+
36
+ * Begin to support 8GB AMD GPU on Windows.
37
+
38
+ # 2.1.854
39
+
40
+ * Add a button to copy parameters to clipboard in log.
41
+ * Allow users to load parameters directly by pasting parameters to prompt.
42
+
43
+ # 2.1.853
44
+
45
+ * Add Marc K3nt3L's styles. Thanks [Marc K3nt3L](https://github.com/K3nt3L)!
46
+
47
+ # 2.1.852
48
+
49
+ * New Log System: Log system now uses tables. If this is breaking some other browser extension or javascript developments, see also [use previous version](https://github.com/lllyasviel/Fooocus/discussions/1405).
50
+
51
+ # 2.1.846
52
+
53
+ * Many users reported that image quality is different from 2.1.824. We reviewed all codes and fixed several precision problems in 2.1.846.
54
+
55
+ # 2.1.843
56
+
57
+ * Many improvements to Canvas. Thanks CanvasZoom author!
58
+
59
+ # 2.1.841
60
+
61
+ * Backend maintain.
62
+ * Fix some potential frozen after model mismatch.
63
+ * Fix crash when cfg=1 when using anime preset.
64
+ * Added some guidelines for troubleshoot the "CUDA kernel errors asynchronously" problem.
65
+ * Fix inpaint device problem in `--always-gpu` mode.
66
+
67
+ # 2.1.839
68
+
69
+ * Maintained some computation codes in backend for efficiency.
70
+ * Added a note about Seed Breaking Change.
71
+
72
+ **Seed Breaking Change**: Note that 2.1.825-2.1.839 is seed breaking change. The computation float point is changed and some seeds may give slightly different results. The minor change in 2.1.825-2.1.839 do not influence image quality. See also [use previous version](https://github.com/lllyasviel/Fooocus/discussions/1405).
73
+
74
+ # 2.1.837
75
+
76
+ * Fix some precision-related problems.
77
+
78
+ # 2.1.836
79
+
80
+ * Avoid blip tokenizer download from torch hub
81
+
82
+ # 2.1.831
83
+
84
+ * Input Image -> Describe (Midjourney Describe)
85
+
86
+ # 2.1.830
87
+
88
+ * SegmindVega support.
89
+
90
+ # 2.1.829
91
+
92
+ * Change SDE tree to CPU on AMD/DirectMl to avoid potential problems.
93
+
94
+ # 2.1.828
95
+
96
+ * Allow to disable gradio analytics.
97
+ * Use html table in log.
98
+ * fix some SSL problems.
99
+
100
+ # 2.1.826
101
+
102
+ * New backend.
103
+ * FP8 support (see also the new cmd flag list in Readme, eg, --unet-in-fp8-e4m3fn and --unet-in-fp8-e5m2).
104
+ * Fix some MPS problems.
105
+ * GLoRA support.
106
+ * Turbo scheduler.
107
+
108
+ # 2.1.823
109
+
110
+ (2023 Nov 26) Hi all, the feature updating of Fooocus will be paused for about two or three weeks because we have some other workloads. See you soon and we will come back in mid December. However, you may still see updates if other collaborators are fixing bugs or solving problems.
111
+
112
+ * Fix some potential problem when LoRAs has clip keys and user want to load those LoRAs to refiners.
113
+
114
+ # 2.1.822
115
+
116
+ * New inpaint system (inpaint beta test ends).
117
+
118
+ # 2.1.821
119
+
120
+ * New UI for LoRAs.
121
+ * Improved preset system: normalized preset keys and file names.
122
+ * Improved session system: now multiple users can use one Fooocus at the same time without seeing others' results.
123
+ * Improved some computation related to model precision.
124
+ * Improved config loading system with user-friendly prints.
125
+
126
+ # 2.1.820
127
+
128
+ * support "--disable-image-log" to prevent writing images and logs to hard drive.
129
+
130
+ # 2.1.819
131
+
132
+ * Allow disabling preview in dev tools.
133
+
134
+ # 2.1.818
135
+
136
+ * Fix preset lora failed to load when the weight is exactly one.
137
+
138
+ # 2.1.817
139
+
140
+ * support "--theme dark" and "--theme light".
141
+ * added preset files "default" and "lcm", these presets exist but will not create launcher files (will not be exposed to users) to keep entry clean. The "--preset lcm" is equivalent to select "Extreme Speed" in UI, but will likely to make some online service deploying easier.
142
+
143
+ # 2.1.815
144
+
145
+ * Multiple loras in preset.
146
+
147
+ # 2.1.814
148
+
149
+ * Allow using previous preset of official SAI SDXL by modify the args to '--preset sai'. ~Note that this preset will set inpaint engine back to previous v1 to get same results like before. To change the inpaint engine to v2.6, use the dev tools -> inpaint engine -> v2.6.~ (update: it is not needed now after some tests.)
150
+
151
+ # 2.1.813
152
+
153
+ * Allow preset to set default inpaint engine.
154
+
155
+ # 2.1.812
156
+
157
+ * Allow preset to set default performance.
158
+ * heunpp2 sampler.
159
+
160
+ # 2.1.810
161
+
162
+ * Added hints to config_modification_tutorial.txt
163
+ * Removed user hacked aspect ratios in I18N english templates, but it will still be read like before.
164
+ * fix some style sorting problem again (perhaps should try Gradio 4.0 later).
165
+ * Refreshed I18N english templates with more keys.
166
+
167
+ # 2.1.809
168
+
169
+ * fix some sorting problem.
170
+
171
+ # 2.1.808
172
+
173
+ * Aspect ratios now show aspect ratios.
174
+ * Added style search.
175
+ * Added style sorting/ordering/favorites.
176
+
177
+ # 2.1.807
178
+
179
+ * Click on image to see it in full screen.
180
+
181
+ # 2.1.806
182
+
183
+ * Fix some lora problems related to clip.
184
+
185
+ # 2.1.805
186
+
187
+ * Responsive UI for small screens.
188
+ * Added skip preprocessor in dev tools.
189
+
190
+ # 2.1.802
191
+
192
+ * Default inpaint engine changed to v2.6. You can still use inpaint engine v1 in dev tools.
193
+ * Fix some VRAM problems.
194
+
195
+ # 2.1.799
196
+
197
+ * Added 'Extreme Speed' performance mode (based on LCM). The previous complicated settings are not needed now.
198
+
199
+ # 2.1.798
200
+
201
+ * added lcm scheduler - LCM may need to set both sampler and scheduler to "lcm". Other than that, see the description in 2.1.782 logs.
202
+
203
+ # 2.1.797
204
+
205
+ * fixed some dependency problems with facexlib and filterpy.
206
+
207
+ # 2.1.793
208
+
209
+ * Added many javascripts to improve user experience. Now users with small screen will always see full canvas without needing to scroll.
210
+
211
+ # 2.1.790
212
+
213
+ * Face swap (in line with Midjourney InsightFace): Input Image -> Image Prompt -> Advanced -> FaceSwap
214
+ * The performance is super high. Use it carefully and never use it in any illegal things!
215
+ * This implementation will crop faces for you and you do NOT need to crop faces before feeding images into Fooocus. (If you previously manually crop faces from images for other software, you do not need to do that now in Fooocus.)
216
+
217
+ # 2.1.788
218
+
219
+ * Fixed some math problems in previous versions.
220
+ * Inpaint engine v2.6 join the beta test of Fooocus inpaint models. Use it in dev tools -> inpaint engine -> v2.6 .
221
+
222
+ # 2.1.785
223
+
224
+ * The `user_path_config.txt` is deprecated since 2.1.785. If you are using it right now, please use the new `config.txt` instead. See also the new documentation in the Readme.
225
+ * The paths in `user_path_config.txt` will still be loaded in recent versions, but it will be removed soon.
226
+ * We use very user-friendly method to automatically transfer your path settings from `user_path_config.txt` to `config.txt` and usually you do not need to do anything.
227
+ * The new `config.txt` will never save default values so the default value changes in scripts will not be prevented by old config files.
228
+
229
+ # 2.1.782
230
+
231
+ 2.1.782 is mainly an update for a new LoRA system that supports both SDXL loras and SD1.5 loras.
232
+
233
+ Now when you load a lora, the following things will happen:
234
+
235
+ 1. try to load the lora to the base model, if failed (model mismatch), then try to load the lora to refiner.
236
+ 2. try to load the lora to refiner, if failed (model mismatch) then do nothing.
237
+
238
+ In this way, Fooocus 2.1.782 can benefit from all models and loras from CivitAI with both SDXL and SD1.5 ecosystem, using the unique Fooocus swap algorithm, to achieve extremely high quality results (although the default setting is already very high quality), especially in some anime use cases, if users really want to play with all these things.
239
+
240
+ Recently the community also developed LCM loras. Users can use it by setting the sampler as 'LCM', scheduler as 'sgm_uniform' (Update in 2.1.798: scheduler should also be "lcm"), the forced overwrite of sampling step as 4 to 8, and CFG guidance as 1.0, in dev tools. Do not forget to change the LCM lora weight to 1.0 (many people forget this and report failure cases). Also, set refiner to None. If LCM's feedback in the artists community is good (not the feedback in the programmer community of Stable Diffusion), Fooocus may add some other shortcuts in the future.
241
+
242
+ # 2.1.781
243
+
244
+ (2023 Oct 26) Hi all, the feature updating of Fooocus will (really, really, this time) be paused for about two or three weeks because we really have some other workloads. Thanks for the passion of you all (and we in fact have kept updating even after last pausing announcement a week ago, because of many great feedbacks) - see you soon and we will come back in mid November. However, you may still see updates if other collaborators are fixing bugs or solving problems.
245
+
246
+ * Disable refiner to speed up when new users mistakenly set same model to base and refiner.
247
+
248
+ # 2.1.779
249
+
250
+ * Disable image grid by default because many users reports performance issues. For example, https://github.com/lllyasviel/Fooocus/issues/829 and so on. The image grid will cause problem when user hard drive is not super fast, or when user internet connection is not very good (eg, run in remote). The option is moved to dev tools if users want to use it. We will take a look at it later.
251
+
252
+ # 2.1.776
253
+
254
+ * Support Ctrl+Up/Down Arrow to change prompt emphasizing weights.
255
+
256
+ # 2.1.750
257
+
258
+ * New UI: now you can get each image during generating.
259
+
260
+ # 2.1.743
261
+
262
+ * Improved GPT2 by removing some tokens that may corrupt styles.
263
+
264
+ # 2.1.741
265
+
266
+ Style Updates:
267
+
268
+ * "Default (Slightly Cinematic)" as renamed to "Fooocus Cinematic".
269
+ * "Default (Slightly Cinematic)" is canceled from default style selections.
270
+ * Added "Fooocus Sharp". This style combines many CivitAI prompts that reduces SDXL blurry and improves sharpness in a relatively natural way.
271
+ * Added "Fooocus Enhance". This style mainly use the very popular [default negative prompts from JuggernautXL](https://civitai.com/models/133005) and some other enhancing words. JuggernautXL's negative prompt has been proved to be very effective in many recent image posts on CivitAI to improve JuggernautXL and many other models.
272
+ * "Fooocus Sharp" and "Fooocus Enhance" and "Fooocus V2" becomes the new default set of styles.
273
+ * Removed the default text in the "negative prompt" input area since it is not necessary now.
274
+ * You can reproduce previous results by using "Fooocus Cinematic".
275
+ * "Fooocus Sharp" and "Fooocus Enhance" may undergo minor revision in future updates.
276
+
277
+ # 2.1.739
278
+
279
+ * Added support for authentication in --share mode (via auth.json).
280
+
281
+ # 2.1.737
282
+
283
+ * Allowed customizing resolutions in config.
284
+
285
+ Modifying this will make results worse if you do not understand how Positional Encoding works.
286
+
287
+ You have been warned.
288
+
289
+ If you do not know why numbers must be transformed with many Sin and Cos functions (yes, those Trigonometric functions that you learn in junior high school) before they are fed to SDXL, we do not encourage you to change this - you will become a victim of Positional Encoding. You are likely to suffer from an easy-to-fail tool, rather than getting more control.
290
+
291
+ Your knowledge gained from SD1.5 (for example, resolution numbers divided by 8 or 64 are good enough for UNet) does not work in SDXL. The SDXL uses Positional Encoding. The SD1.5 does not use Positional Encoding. They are completely different.
292
+
293
+ Your knowledge gained from other resources (for example, resolutions around 1024 are good enough for SDXL) is wrong. The SDXL uses Positional Encoding. People who say "all resolutions around 1024 are good" do not understand what is Positional Encoding. They are not intentionally misleading. They are just not aware of the fact that SDXL is using Positional Encoding.
294
+
295
+ The number 1152 must be exactly 1152, not 1152-1, not 1152+1, not 1152-8, not 1152+8. The number 1152 must be exactly 1152. Just Google what is a Positional Encoding.
296
+
297
+ Again, if you do not understand how Positional Encoding works, just do not change the resolution numbers.
298
+
299
+ # 2.1.735
300
+
301
+ * Fixed many problems related to torch autocast.
302
+
303
+ # 2.1.733
304
+
305
+ * Increased allowed random seed range.
306
+
307
+ # 2.1.728
308
+
309
+ * Fixed some potential numerical problems since 2.1.723
310
+
311
+ # 2.1.723
312
+
313
+ * Improve Fooocus Anime a bit by using better SD1.5 refining formulation.
314
+
315
+ # 2.1.722
316
+
317
+ * Now it is possible to translate 100% all texts in the UI.
318
+
319
+ # 2.1.721
320
+
321
+ * Added language/en.json to make translation easier.
322
+
323
+ # 2.1.720
324
+
325
+ * Added Canvas Zoom to inpaint canvas
326
+ * Fixed the problem that image will be cropped in UI when the uploaded image is too wide.
327
+
328
+ # 2.1.719
329
+
330
+ * I18N
331
+
332
+ # 2.1.718
333
+
334
+ * Corrected handling dash in wildcard names, more wildcards (extended-color).
335
+
336
+ # 2.1.717
337
+
338
+ * Corrected displaying multi-line prompts in Private Log.
339
+
340
+ # 2.1.716
341
+
342
+ * Added support for nested wildcards, more wildcards (flower, color_flower).
343
+
344
+ # 2.1.714
345
+
346
+ * Fixed resolution problems.
347
+
348
+ # 2.1.712
349
+
350
+ * Cleaned up Private Log (most users won't need information about raw prompts).
351
+
352
+ # 2.1.711
353
+
354
+ * Added more information about prompts in Private Log.
355
+ * Made wildcards in negative prompt use different seed.
356
+
357
+ # 2.1.710
358
+
359
+ * Added information about wildcards usage in console log.
360
+
361
+ # 2.1.709
362
+
363
+ * Allowed changing default values of advanced checkbox and image number.
364
+
365
+ # 2.1.707
366
+
367
+ * Updated Gradio to v3.41.2.
368
+
369
+ # 2.1.703
370
+
371
+ * Fixed many previous problems related to inpaint.
372
+
373
+ # 2.1.702
374
+
375
+ * Corrected reading empty negative prompt from config (it shouldn't turn into None).
376
+
377
+ # 2.1.701
378
+
379
+ * Updated FreeU node to v2 (gives less overcooked results).
380
+
381
+ # 2.1.699
382
+
383
+ * Disabled smart memory management (solves some memory issues).
384
+
385
+ # 2.1.698
386
+
387
+ * Added support for loading model files from subfolders.
388
+
389
+ # 2.1.696
390
+
391
+ * Improved wildcards implementation (using same wildcard multiple times will now return different values).
392
+
393
+ **(2023 Oct 18) Again, the feature updating of Fooocus will be paused for about two or three weeks because we have some other workloads - we will come back in early or mid November. However, you may still see updates if other collaborators are fixing bugs or solving problems.**
394
+
395
+ # 2.1.695 (requested emergency bug fix)
396
+
397
+ * Reduced 3.4GB RAM use when swapping base model.
398
+ * Reduced 372MB VRAM use in VAE decoding after using control model in image prompt.
399
+ * Note that Official ComfyUI (d44a2de) will run out of VRAM when using sdxl and control-lora on 2060 6GB that does not support float16 at resolution 1024. Fooocus 2.1.695 succeeded in outputting images without OOM using exactly same devices.
400
+
401
+ (2023 Oct 17) Announcement of update being paused.
402
+
403
+ # 2.1.693
404
+
405
+ * Putting custom styles before pre-defined styles.
406
+ * Avoided the consusion between Fooocus Anime preset and Fooocus Anime style (Fooocus Anime style is renamed to Fooocus Masterpiece because it does not make images Anime-looking if not using with Fooocus Anime preset).
407
+ * Fixed some minor bugs in Fooocus Anime preset's prompt emphasizing of commas.
408
+ * Supported and documented embedding grammar (and wildcards grammar).
409
+ * This release is a relative stable version and many features are determined now.
410
+
411
+ # 2.1.687
412
+
413
+ * Added support for wildcards (using files from wildcards folder - try prompts like `__color__ sports car` with different seeds).
414
+
415
+ # 2.1.682
416
+
417
+ * Added support for custom styles (loaded from JSON files placed in sdxl_styles folder).
418
+
419
+ # 2.1.681
420
+
421
+ * Added support for generate hotkey (CTRL+ENTER).
422
+ * Added support for generate forever (RMB on Generate button).
423
+ * Added support for playing sound when generation is finished ('notification.ogg' or 'notification.mp3').
424
+
425
+ # 2.1.62
426
+
427
+ * Preset system. Added anime and realistic support.
428
+
429
+ # 2.1.52
430
+
431
+ * removed pygit2 dependency (expect auto update) so that people will never have permission denied problems.
432
+
433
+ # 2.1.50
434
+
435
+ * Begin to support sd1.5 as refiner. This method scale sigmas given SD15/Xl latent scale and is probably the most correct way to do it. I am going to write a discussion soon.
436
+
437
+ # 2.1.25
438
+
439
+ AMD support on Linux and Windows.
440
+
441
+ # 2.1.0
442
+
443
+ * Image Prompt
444
+ * Finished the "Moving from Midjourney" Table
445
+
446
+ # 2.0.85
447
+
448
+ * Speed Up Again
449
+
450
+ # 2.0.80
451
+
452
+ * Improved the scheduling of ADM guidance and CFG mimicking for better visual quality in high frequency domain and small objects.
453
+
454
+ # 2.0.80
455
+
456
+ * Rework many patches and some UI details.
457
+ * Speed up processing.
458
+ * Move Colab to independent branch.
459
+ * Implemented CFG Scale and TSNR correction when CFG is bigger than 10.
460
+ * Implemented Developer Mode with more options to debug.
461
+
462
+ ### 2.0.72
463
+
464
+ (2023 sep 21) The feature updating of Fooocus will be paused for about two or three weeks because we have some events and travelling - we will come back in early or mid October.
465
+
466
+ ### 2.0.72
467
+
468
+ * Allow users to choose path of models.
469
+
470
+ ### 2.0.65
471
+
472
+ * Inpaint model released.
473
+
474
+ ### 2.0.50
475
+
476
+ * Variation/Upscale (Midjourney Toolbar) implemented.
477
+
478
+ ### 2.0.16
479
+
480
+ * Virtual memory system implemented. Now Colab can run both base model and refiner model with 7.8GB RAM + 5.3GB VRAM, and it never crashes.
481
+ * If you are lucky enough to read this line, keep in mind that ComfyUI cannot do this. This is very reasonable that Fooocus is more optimized because it only need to handle a fixed pipeline, but ComfyUI need to consider arbitrary pipelines.
482
+ * But if we just consider the optimization of this fixed workload, after 2.0.16, Fooocus has become the most optimized SDXL app, outperforming ComfyUI.
483
+
484
+ ### 2.0.0
485
+
486
+ * V2 released.
487
+ * completely rewrite text processing pipeline (higher image quality and prompt understanding).
488
+ * support multi-style.
489
+ * In 100 tests (prompts written by ChatGPT), V2 default results outperform V1 default results in 87 cases, evaluated by two human.
490
+ * In 100 tests (prompts written by ChatGPT), V2 prompt understanding outperform V1 prompt understanding in 81 cases, evaluated by two human, in both default setting and multi/single style mode.
491
+ * Because the above number is above 80%, we view this as a major update and directly jump to 2.0.0.
492
+ * Some other things are renamed.
493
+
494
+ ### 1.0.67
495
+
496
+ * Use dynamic weighting and lower weights for prompt expansion.
497
+
498
+ ### 1.0.64
499
+
500
+ * Fixed a small OOM problem.
501
+
502
+ ### 1.0.62
503
+
504
+ * Change prompt expansion to suffix mode for better balance of semantic and style (and debugging).
505
+
506
+ ### 1.0.60
507
+
508
+ * Tune the balance between style and Prompt Expansion.
509
+
510
+ ### 1.0.56
511
+
512
+ * Begin to use magic split.
513
+
514
+ ### 1.0.55
515
+
516
+ * Minor changes of Prompt Expansion.
517
+
518
+ ### 1.0.52
519
+
520
+ * Reduce the semantic corruption of Prompt Expansion.
521
+
522
+ ### 1.0.51
523
+
524
+ * Speed up Prompt Expansion a bit.
525
+
526
+ ### 1.0.50
527
+
528
+ * Prompt expansion and a "Raw mode" to turn it off (similar to Midjourney's "raw").
529
+
530
+ ### 1.0.45
531
+
532
+ * Reworked SAG, removed unnecessary patch
533
+ * Reworked anisotropic filters for faster compute.
534
+ * Replaced with guided anisotropic filter for less distortion.
535
+
536
+ ### 1.0.41
537
+
538
+ (The update of Fooocus will be paused for a period of time for AUTOMATIC1111 sd-webui 1.6.X, and some features will also be implemented as webui extensions)
539
+
540
+ ### 1.0.40
541
+
542
+ * Behaviors reverted to 1.0.36 again (refiner steps). The 1.0.36 is too perfect and too typical; beating 1.0.36 is just impossible.
543
+
544
+ ### 1.0.39
545
+
546
+ * Reverted unstable changes between 1.0.37 and 1.0.38 .
547
+ * Increased refiner steps to half of sampling steps.
548
+
549
+ ### 1.0.36
550
+
551
+ * Change gaussian kernel to anisotropic kernel.
552
+
553
+ ### 1.0.34
554
+
555
+ * Random seed restoring.
556
+
557
+ ### 1.0.33
558
+
559
+ * Hide items in log when images are removed.
560
+
561
+ ### 1.0.32
562
+
563
+ * Fooocus private log
564
+
565
+ ### 1.0.31
566
+
567
+ * Fix typo and UI.
568
+
569
+ ### 1.0.29
570
+
571
+ * Added "Advanced->Advanced->Advanced" block for future development.
572
+
573
+ ### 1.0.29
574
+
575
+ * Fix overcook problem in 1.0.28
576
+
577
+ ### 1.0.28
578
+
579
+ * SAG implemented
580
+
581
+ ### 1.0.27
582
+
583
+ * Fix small problem in textbox css
584
+
585
+ ### 1.0.25
586
+
587
+ * support sys.argv --listen --share --port
588
+
589
+ ### 1.0.24
590
+
591
+ * Taller input textbox.
592
+
593
+ ### 1.0.23
594
+
595
+ * Added some hints on linux after UI start so users know the App does not fail.
596
+
597
+ ### 1.0.20
598
+
599
+ * Support linux.
600
+
601
+ ### 1.0.20
602
+
603
+ * Speed-up text encoder.
604
+
605
+ ### 1.0.20
606
+
607
+ * Re-write UI to use async codes: (1) for faster start, and (2) for better live preview.
608
+ * Removed opencv dependency
609
+ * Plan to support Linux soon
610
+
611
+ ### 1.0.19
612
+
613
+ * Unlock to allow changing model.
614
+
615
+ ### 1.0.17
616
+
617
+ * Change default model to SDXL-1.0-vae-0.9. (This means the models will be downloaded again, but we should do it as early as possible so that all new users only need to download once. Really sorry for day-0 users. But frankly this is not too late considering that the project is just publicly available in less than 24 hours - if it has been a week then we will prefer more lightweight tricks to update.)
618
+
619
+ ### 1.0.16
620
+
621
+ * Implemented "Fooocus/outputs" folder for saving user results.
622
+ * Ignored cv2 errors when preview fails.
623
+ * Mentioned future AMD support in Readme.
624
+ * Created this log.
625
+
626
+ ### 1.0.15
627
+
628
+ Publicly available.
629
+
630
+ ### 1.0.0
631
+
632
+ Initial Version.
vercel.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builds": [
3
+ {
4
+ "src": "app.py",
5
+ "use": "@vercel/python"
6
+ }
7
+ ],
8
+ "routes": [
9
+ {
10
+ "src": "./",
11
+ "dest": "app.py"
12
+ }
13
+ ]
14
+ }
webui.py ADDED
@@ -0,0 +1,688 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ import os
4
+ import json
5
+ import time
6
+ import shared
7
+ import modules.config
8
+ import fooocus_version
9
+ import modules.html
10
+ import modules.async_worker as worker
11
+ import modules.constants as constants
12
+ import modules.flags as flags
13
+ import modules.gradio_hijack as grh
14
+ import modules.style_sorter as style_sorter
15
+ import modules.meta_parser
16
+ import args_manager
17
+ import copy
18
+
19
+ from modules.sdxl_styles import legal_style_names
20
+ from modules.private_logger import get_current_html_path
21
+ from modules.ui_gradio_extensions import reload_javascript
22
+ from modules.auth import auth_enabled, check_auth
23
+ from modules.util import is_json
24
+
25
+ def get_task(*args):
26
+ args = list(args)
27
+ args.pop(0)
28
+
29
+ return worker.AsyncTask(args=args)
30
+
31
+ def generate_clicked(task):
32
+ import ldm_patched.modules.model_management as model_management
33
+
34
+ with model_management.interrupt_processing_mutex:
35
+ model_management.interrupt_processing = False
36
+ # outputs=[progress_html, progress_window, progress_gallery, gallery]
37
+ execution_start_time = time.perf_counter()
38
+ finished = False
39
+
40
+ yield gr.update(visible=True, value=modules.html.make_progress_html(1, 'Waiting for task to start ...')), \
41
+ gr.update(visible=True, value=None), \
42
+ gr.update(visible=False, value=None), \
43
+ gr.update(visible=False)
44
+
45
+ worker.async_tasks.append(task)
46
+
47
+ while not finished:
48
+ time.sleep(0.01)
49
+ if len(task.yields) > 0:
50
+ flag, product = task.yields.pop(0)
51
+ if flag == 'preview':
52
+
53
+ # help bad internet connection by skipping duplicated preview
54
+ if len(task.yields) > 0: # if we have the next item
55
+ if task.yields[0][0] == 'preview': # if the next item is also a preview
56
+ # print('Skipped one preview for better internet connection.')
57
+ continue
58
+
59
+ percentage, title, image = product
60
+ yield gr.update(visible=True, value=modules.html.make_progress_html(percentage, title)), \
61
+ gr.update(visible=True, value=image) if image is not None else gr.update(), \
62
+ gr.update(), \
63
+ gr.update(visible=False)
64
+ if flag == 'results':
65
+ yield gr.update(visible=True), \
66
+ gr.update(visible=True), \
67
+ gr.update(visible=True, value=product), \
68
+ gr.update(visible=False)
69
+ if flag == 'finish':
70
+ yield gr.update(visible=False), \
71
+ gr.update(visible=False), \
72
+ gr.update(visible=False), \
73
+ gr.update(visible=True, value=product)
74
+ finished = True
75
+
76
+ # delete Fooocus temp images, only keep gradio temp images
77
+ if args_manager.args.disable_image_log:
78
+ for filepath in product:
79
+ if isinstance(filepath, str) and os.path.exists(filepath):
80
+ os.remove(filepath)
81
+
82
+ execution_time = time.perf_counter() - execution_start_time
83
+ print(f'Total time: {execution_time:.2f} seconds')
84
+ return
85
+
86
+
87
+ reload_javascript()
88
+
89
+ title = f'Fooocus {fooocus_version.version}'
90
+
91
+ if isinstance(args_manager.args.preset, str):
92
+ title += ' ' + args_manager.args.preset
93
+
94
+ shared.gradio_root = gr.Blocks(
95
+ title=title,
96
+ css=modules.html.css).queue()
97
+
98
+ with shared.gradio_root:
99
+ currentTask = gr.State(worker.AsyncTask(args=[]))
100
+ with gr.Row():
101
+ with gr.Column(scale=2):
102
+ with gr.Row():
103
+ progress_window = grh.Image(label='Preview', show_label=True, visible=False, height=768,
104
+ elem_classes=['main_view'])
105
+ progress_gallery = gr.Gallery(label='Finished Images', show_label=True, object_fit='contain',
106
+ height=768, visible=False, elem_classes=['main_view', 'image_gallery'])
107
+ progress_html = gr.HTML(value=modules.html.make_progress_html(32, 'Progress 32%'), visible=False,
108
+ elem_id='progress-bar', elem_classes='progress-bar')
109
+ gallery = gr.Gallery(label='Gallery', show_label=False, object_fit='contain', visible=True, height=768,
110
+ elem_classes=['resizable_area', 'main_view', 'final_gallery', 'image_gallery'],
111
+ elem_id='final_gallery')
112
+ with gr.Row(elem_classes='type_row'):
113
+ with gr.Column(scale=17):
114
+ prompt = gr.Textbox(show_label=False, placeholder="Type prompt here or paste parameters.", elem_id='positive_prompt',
115
+ container=False, autofocus=True, elem_classes='type_row', lines=1024)
116
+
117
+ default_prompt = modules.config.default_prompt
118
+ if isinstance(default_prompt, str) and default_prompt != '':
119
+ shared.gradio_root.load(lambda: default_prompt, outputs=prompt)
120
+
121
+ with gr.Column(scale=3, min_width=0):
122
+ generate_button = gr.Button(label="Generate", value="Generate", elem_classes='type_row', elem_id='generate_button', visible=True)
123
+ load_parameter_button = gr.Button(label="Load Parameters", value="Load Parameters", elem_classes='type_row', elem_id='load_parameter_button', visible=False)
124
+ skip_button = gr.Button(label="Skip", value="Skip", elem_classes='type_row_half', visible=False)
125
+ stop_button = gr.Button(label="Stop", value="Stop", elem_classes='type_row_half', elem_id='stop_button', visible=False)
126
+
127
+ def stop_clicked(currentTask):
128
+ import ldm_patched.modules.model_management as model_management
129
+ currentTask.last_stop = 'stop'
130
+ if (currentTask.processing):
131
+ model_management.interrupt_current_processing()
132
+ return currentTask
133
+
134
+ def skip_clicked(currentTask):
135
+ import ldm_patched.modules.model_management as model_management
136
+ currentTask.last_stop = 'skip'
137
+ if (currentTask.processing):
138
+ model_management.interrupt_current_processing()
139
+ return currentTask
140
+
141
+ stop_button.click(stop_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False, _js='cancelGenerateForever')
142
+ skip_button.click(skip_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False)
143
+ with gr.Row(elem_classes='advanced_check_row'):
144
+ input_image_checkbox = gr.Checkbox(label='Input Image', value=False, container=False, elem_classes='min_check')
145
+ advanced_checkbox = gr.Checkbox(label='Advanced', value=modules.config.default_advanced_checkbox, container=False, elem_classes='min_check')
146
+ with gr.Row(visible=False) as image_input_panel:
147
+ with gr.Tabs():
148
+ with gr.TabItem(label='Upscale or Variation') as uov_tab:
149
+ with gr.Row():
150
+ with gr.Column():
151
+ uov_input_image = grh.Image(label='Drag above image to here', source='upload', type='numpy')
152
+ with gr.Column():
153
+ uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list, value=flags.disabled)
154
+ gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/390" target="_blank">\U0001F4D4 Document</a>')
155
+ with gr.TabItem(label='Image Prompt') as ip_tab:
156
+ with gr.Row():
157
+ ip_images = []
158
+ ip_types = []
159
+ ip_stops = []
160
+ ip_weights = []
161
+ ip_ctrls = []
162
+ ip_ad_cols = []
163
+ for _ in range(flags.controlnet_image_count):
164
+ with gr.Column():
165
+ ip_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False, height=300)
166
+ ip_images.append(ip_image)
167
+ ip_ctrls.append(ip_image)
168
+ with gr.Column(visible=False) as ad_col:
169
+ with gr.Row():
170
+ default_end, default_weight = flags.default_parameters[flags.default_ip]
171
+
172
+ ip_stop = gr.Slider(label='Stop At', minimum=0.0, maximum=1.0, step=0.001, value=default_end)
173
+ ip_stops.append(ip_stop)
174
+ ip_ctrls.append(ip_stop)
175
+
176
+ ip_weight = gr.Slider(label='Weight', minimum=0.0, maximum=2.0, step=0.001, value=default_weight)
177
+ ip_weights.append(ip_weight)
178
+ ip_ctrls.append(ip_weight)
179
+
180
+ ip_type = gr.Radio(label='Type', choices=flags.ip_list, value=flags.default_ip, container=False)
181
+ ip_types.append(ip_type)
182
+ ip_ctrls.append(ip_type)
183
+
184
+ ip_type.change(lambda x: flags.default_parameters[x], inputs=[ip_type], outputs=[ip_stop, ip_weight], queue=False, show_progress=False)
185
+ ip_ad_cols.append(ad_col)
186
+ ip_advanced = gr.Checkbox(label='Advanced', value=False, container=False)
187
+ gr.HTML('* \"Image Prompt\" is powered by Fooocus Image Mixture Engine (v1.0.1). <a href="https://github.com/lllyasviel/Fooocus/discussions/557" target="_blank">\U0001F4D4 Document</a>')
188
+
189
+ def ip_advance_checked(x):
190
+ return [gr.update(visible=x)] * len(ip_ad_cols) + \
191
+ [flags.default_ip] * len(ip_types) + \
192
+ [flags.default_parameters[flags.default_ip][0]] * len(ip_stops) + \
193
+ [flags.default_parameters[flags.default_ip][1]] * len(ip_weights)
194
+
195
+ ip_advanced.change(ip_advance_checked, inputs=ip_advanced,
196
+ outputs=ip_ad_cols + ip_types + ip_stops + ip_weights,
197
+ queue=False, show_progress=False)
198
+ with gr.TabItem(label='Inpaint or Outpaint') as inpaint_tab:
199
+ with gr.Row():
200
+ inpaint_input_image = grh.Image(label='Drag inpaint or outpaint image to here', source='upload', type='numpy', tool='sketch', height=500, brush_color="#FFFFFF", elem_id='inpaint_canvas')
201
+ inpaint_mask_image = grh.Image(label='Mask Upload', source='upload', type='numpy', height=500, visible=False)
202
+
203
+ with gr.Row():
204
+ inpaint_additional_prompt = gr.Textbox(placeholder="Describe what you want to inpaint.", elem_id='inpaint_additional_prompt', label='Inpaint Additional Prompt', visible=False)
205
+ outpaint_selections = gr.CheckboxGroup(choices=['Left', 'Right', 'Top', 'Bottom'], value=[], label='Outpaint Direction')
206
+ inpaint_mode = gr.Dropdown(choices=modules.flags.inpaint_options, value=modules.flags.inpaint_option_default, label='Method')
207
+ example_inpaint_prompts = gr.Dataset(samples=modules.config.example_inpaint_prompts, label='Additional Prompt Quick List', components=[inpaint_additional_prompt], visible=False)
208
+ gr.HTML('* Powered by Fooocus Inpaint Engine <a href="https://github.com/lllyasviel/Fooocus/discussions/414" target="_blank">\U0001F4D4 Document</a>')
209
+ example_inpaint_prompts.click(lambda x: x[0], inputs=example_inpaint_prompts, outputs=inpaint_additional_prompt, show_progress=False, queue=False)
210
+ with gr.TabItem(label='Describe') as desc_tab:
211
+ with gr.Row():
212
+ with gr.Column():
213
+ desc_input_image = grh.Image(label='Drag any image to here', source='upload', type='numpy')
214
+ with gr.Column():
215
+ desc_method = gr.Radio(
216
+ label='Content Type',
217
+ choices=[flags.desc_type_photo, flags.desc_type_anime],
218
+ value=flags.desc_type_photo)
219
+ desc_btn = gr.Button(value='Describe this Image into Prompt')
220
+ gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/1363" target="_blank">\U0001F4D4 Document</a>')
221
+ with gr.TabItem(label='Metadata') as load_tab:
222
+ with gr.Column():
223
+ metadata_input_image = grh.Image(label='Drag any image generated by Fooocus here', source='upload', type='filepath')
224
+ metadata_json = gr.JSON(label='Metadata')
225
+ metadata_import_button = gr.Button(value='Apply Metadata')
226
+
227
+ def trigger_metadata_preview(filepath):
228
+ parameters, metadata_scheme = modules.meta_parser.read_info_from_image(filepath)
229
+
230
+ results = {}
231
+ if parameters is not None:
232
+ results['parameters'] = parameters
233
+
234
+ if isinstance(metadata_scheme, flags.MetadataScheme):
235
+ results['metadata_scheme'] = metadata_scheme.value
236
+
237
+ return results
238
+
239
+ metadata_input_image.upload(trigger_metadata_preview, inputs=metadata_input_image,
240
+ outputs=metadata_json, queue=False, show_progress=True)
241
+
242
+ switch_js = "(x) => {if(x){viewer_to_bottom(100);viewer_to_bottom(500);}else{viewer_to_top();} return x;}"
243
+ down_js = "() => {viewer_to_bottom();}"
244
+
245
+ input_image_checkbox.change(lambda x: gr.update(visible=x), inputs=input_image_checkbox,
246
+ outputs=image_input_panel, queue=False, show_progress=False, _js=switch_js)
247
+ ip_advanced.change(lambda: None, queue=False, show_progress=False, _js=down_js)
248
+
249
+ current_tab = gr.Textbox(value='uov', visible=False)
250
+ uov_tab.select(lambda: 'uov', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
251
+ inpaint_tab.select(lambda: 'inpaint', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
252
+ ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
253
+ desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
254
+
255
+ with gr.Column(scale=1, visible=modules.config.default_advanced_checkbox) as advanced_column:
256
+ with gr.Tab(label='Setting'):
257
+ performance_selection = gr.Radio(label='Performance',
258
+ choices=modules.flags.performance_selections,
259
+ value=modules.config.default_performance)
260
+ aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios,
261
+ value=modules.config.default_aspect_ratio, info='width × height',
262
+ elem_classes='aspect_ratios')
263
+ image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number)
264
+
265
+ output_format = gr.Radio(label='Output Format',
266
+ choices=modules.flags.output_formats,
267
+ value=modules.config.default_output_format)
268
+
269
+ negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.",
270
+ info='Describing what you do not want to see.', lines=2,
271
+ elem_id='negative_prompt',
272
+ value=modules.config.default_prompt_negative)
273
+ seed_random = gr.Checkbox(label='Random', value=True)
274
+ image_seed = gr.Textbox(label='Seed', value=0, max_lines=1, visible=False) # workaround for https://github.com/gradio-app/gradio/issues/5354
275
+
276
+ def random_checked(r):
277
+ return gr.update(visible=not r)
278
+
279
+ def refresh_seed(r, seed_string):
280
+ if r:
281
+ return random.randint(constants.MIN_SEED, constants.MAX_SEED)
282
+ else:
283
+ try:
284
+ seed_value = int(seed_string)
285
+ if constants.MIN_SEED <= seed_value <= constants.MAX_SEED:
286
+ return seed_value
287
+ except ValueError:
288
+ pass
289
+ return random.randint(constants.MIN_SEED, constants.MAX_SEED)
290
+
291
+ seed_random.change(random_checked, inputs=[seed_random], outputs=[image_seed],
292
+ queue=False, show_progress=False)
293
+
294
+ def update_history_link():
295
+ if args_manager.args.disable_image_log:
296
+ return gr.update(value='')
297
+
298
+ return gr.update(value=f'<a href="file={get_current_html_path(output_format)}" target="_blank">\U0001F4DA History Log</a>')
299
+
300
+ history_link = gr.HTML()
301
+ shared.gradio_root.load(update_history_link, outputs=history_link, queue=False, show_progress=False)
302
+
303
+ with gr.Tab(label='Style'):
304
+ style_sorter.try_load_sorted_styles(
305
+ style_names=legal_style_names,
306
+ default_selected=modules.config.default_styles)
307
+
308
+ style_search_bar = gr.Textbox(show_label=False, container=False,
309
+ placeholder="\U0001F50E Type here to search styles ...",
310
+ value="",
311
+ label='Search Styles')
312
+ style_selections = gr.CheckboxGroup(show_label=False, container=False,
313
+ choices=copy.deepcopy(style_sorter.all_styles),
314
+ value=copy.deepcopy(modules.config.default_styles),
315
+ label='Selected Styles',
316
+ elem_classes=['style_selections'])
317
+ gradio_receiver_style_selections = gr.Textbox(elem_id='gradio_receiver_style_selections', visible=False)
318
+
319
+ shared.gradio_root.load(lambda: gr.update(choices=copy.deepcopy(style_sorter.all_styles)),
320
+ outputs=style_selections)
321
+
322
+ style_search_bar.change(style_sorter.search_styles,
323
+ inputs=[style_selections, style_search_bar],
324
+ outputs=style_selections,
325
+ queue=False,
326
+ show_progress=False).then(
327
+ lambda: None, _js='()=>{refresh_style_localization();}')
328
+
329
+ gradio_receiver_style_selections.input(style_sorter.sort_styles,
330
+ inputs=style_selections,
331
+ outputs=style_selections,
332
+ queue=False,
333
+ show_progress=False).then(
334
+ lambda: None, _js='()=>{refresh_style_localization();}')
335
+
336
+ with gr.Tab(label='Model'):
337
+ with gr.Group():
338
+ with gr.Row():
339
+ base_model = gr.Dropdown(label='Base Model (SDXL only)', choices=modules.config.model_filenames, value=modules.config.default_base_model_name, show_label=True)
340
+ refiner_model = gr.Dropdown(label='Refiner (SDXL or SD 1.5)', choices=['None'] + modules.config.model_filenames, value=modules.config.default_refiner_model_name, show_label=True)
341
+
342
+ refiner_switch = gr.Slider(label='Refiner Switch At', minimum=0.1, maximum=1.0, step=0.0001,
343
+ info='Use 0.4 for SD1.5 realistic models; '
344
+ 'or 0.667 for SD1.5 anime models; '
345
+ 'or 0.8 for XL-refiners; '
346
+ 'or any value for switching two SDXL models.',
347
+ value=modules.config.default_refiner_switch,
348
+ visible=modules.config.default_refiner_model_name != 'None')
349
+
350
+ refiner_model.change(lambda x: gr.update(visible=x != 'None'),
351
+ inputs=refiner_model, outputs=refiner_switch, show_progress=False, queue=False)
352
+
353
+ with gr.Group():
354
+ lora_ctrls = []
355
+
356
+ for i, (n, v) in enumerate(modules.config.default_loras):
357
+ with gr.Row():
358
+ lora_enabled = gr.Checkbox(label='Enable', value=True,
359
+ elem_classes=['lora_enable', 'min_check'], scale=1)
360
+ lora_model = gr.Dropdown(label=f'LoRA {i + 1}',
361
+ choices=['None'] + modules.config.lora_filenames, value=n,
362
+ elem_classes='lora_model', scale=5)
363
+ lora_weight = gr.Slider(label='Weight', minimum=modules.config.default_loras_min_weight,
364
+ maximum=modules.config.default_loras_max_weight, step=0.01, value=v,
365
+ elem_classes='lora_weight', scale=5)
366
+ lora_ctrls += [lora_enabled, lora_model, lora_weight]
367
+
368
+ with gr.Row():
369
+ model_refresh = gr.Button(label='Refresh', value='\U0001f504 Refresh All Files', variant='secondary', elem_classes='refresh_button')
370
+ with gr.Tab(label='Advanced'):
371
+ guidance_scale = gr.Slider(label='Guidance Scale', minimum=1.0, maximum=30.0, step=0.01,
372
+ value=modules.config.default_cfg_scale,
373
+ info='Higher value means style is cleaner, vivider, and more artistic.')
374
+ sharpness = gr.Slider(label='Image Sharpness', minimum=0.0, maximum=30.0, step=0.001,
375
+ value=modules.config.default_sample_sharpness,
376
+ info='Higher value means image and texture are sharper.')
377
+ gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/117" target="_blank">\U0001F4D4 Document</a>')
378
+ dev_mode = gr.Checkbox(label='Developer Debug Mode', value=False, container=False)
379
+
380
+ with gr.Column(visible=False) as dev_tools:
381
+ with gr.Tab(label='Debug Tools'):
382
+ adm_scaler_positive = gr.Slider(label='Positive ADM Guidance Scaler', minimum=0.1, maximum=3.0,
383
+ step=0.001, value=1.5, info='The scaler multiplied to positive ADM (use 1.0 to disable). ')
384
+ adm_scaler_negative = gr.Slider(label='Negative ADM Guidance Scaler', minimum=0.1, maximum=3.0,
385
+ step=0.001, value=0.8, info='The scaler multiplied to negative ADM (use 1.0 to disable). ')
386
+ adm_scaler_end = gr.Slider(label='ADM Guidance End At Step', minimum=0.0, maximum=1.0,
387
+ step=0.001, value=0.3,
388
+ info='When to end the guidance from positive/negative ADM. ')
389
+
390
+ refiner_swap_method = gr.Dropdown(label='Refiner swap method', value=flags.refiner_swap_method,
391
+ choices=['joint', 'separate', 'vae'])
392
+
393
+ adaptive_cfg = gr.Slider(label='CFG Mimicking from TSNR', minimum=1.0, maximum=30.0, step=0.01,
394
+ value=modules.config.default_cfg_tsnr,
395
+ info='Enabling Fooocus\'s implementation of CFG mimicking for TSNR '
396
+ '(effective when real CFG > mimicked CFG).')
397
+ sampler_name = gr.Dropdown(label='Sampler', choices=flags.sampler_list,
398
+ value=modules.config.default_sampler)
399
+ scheduler_name = gr.Dropdown(label='Scheduler', choices=flags.scheduler_list,
400
+ value=modules.config.default_scheduler)
401
+
402
+ generate_image_grid = gr.Checkbox(label='Generate Image Grid for Each Batch',
403
+ info='(Experimental) This may cause performance problems on some computers and certain internet conditions.',
404
+ value=False)
405
+
406
+ overwrite_step = gr.Slider(label='Forced Overwrite of Sampling Step',
407
+ minimum=-1, maximum=200, step=1,
408
+ value=modules.config.default_overwrite_step,
409
+ info='Set as -1 to disable. For developer debugging.')
410
+ overwrite_switch = gr.Slider(label='Forced Overwrite of Refiner Switch Step',
411
+ minimum=-1, maximum=200, step=1,
412
+ value=modules.config.default_overwrite_switch,
413
+ info='Set as -1 to disable. For developer debugging.')
414
+ overwrite_width = gr.Slider(label='Forced Overwrite of Generating Width',
415
+ minimum=-1, maximum=2048, step=1, value=-1,
416
+ info='Set as -1 to disable. For developer debugging. '
417
+ 'Results will be worse for non-standard numbers that SDXL is not trained on.')
418
+ overwrite_height = gr.Slider(label='Forced Overwrite of Generating Height',
419
+ minimum=-1, maximum=2048, step=1, value=-1,
420
+ info='Set as -1 to disable. For developer debugging. '
421
+ 'Results will be worse for non-standard numbers that SDXL is not trained on.')
422
+ overwrite_vary_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Vary"',
423
+ minimum=-1, maximum=1.0, step=0.001, value=-1,
424
+ info='Set as negative number to disable. For developer debugging.')
425
+ overwrite_upscale_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Upscale"',
426
+ minimum=-1, maximum=1.0, step=0.001, value=-1,
427
+ info='Set as negative number to disable. For developer debugging.')
428
+ disable_preview = gr.Checkbox(label='Disable Preview', value=False,
429
+ info='Disable preview during generation.')
430
+ disable_intermediate_results = gr.Checkbox(label='Disable Intermediate Results',
431
+ value=modules.config.default_performance == 'Extreme Speed',
432
+ interactive=modules.config.default_performance != 'Extreme Speed',
433
+ info='Disable intermediate results during generation, only show final gallery.')
434
+ disable_seed_increment = gr.Checkbox(label='Disable seed increment',
435
+ info='Disable automatic seed increment when image number is > 1.',
436
+ value=False)
437
+
438
+ if not args_manager.args.disable_metadata:
439
+ save_metadata_to_images = gr.Checkbox(label='Save Metadata to Images', value=modules.config.default_save_metadata_to_images,
440
+ info='Adds parameters to generated images allowing manual regeneration.')
441
+ metadata_scheme = gr.Radio(label='Metadata Scheme', choices=flags.metadata_scheme, value=modules.config.default_metadata_scheme,
442
+ info='Image Prompt parameters are not included. Use png and a1111 for compatibility with Civitai.',
443
+ visible=modules.config.default_save_metadata_to_images)
444
+
445
+ save_metadata_to_images.change(lambda x: gr.update(visible=x), inputs=[save_metadata_to_images], outputs=[metadata_scheme],
446
+ queue=False, show_progress=False)
447
+
448
+ with gr.Tab(label='Control'):
449
+ debugging_cn_preprocessor = gr.Checkbox(label='Debug Preprocessors', value=False,
450
+ info='See the results from preprocessors.')
451
+ skipping_cn_preprocessor = gr.Checkbox(label='Skip Preprocessors', value=False,
452
+ info='Do not preprocess images. (Inputs are already canny/depth/cropped-face/etc.)')
453
+
454
+ mixing_image_prompt_and_vary_upscale = gr.Checkbox(label='Mixing Image Prompt and Vary/Upscale',
455
+ value=False)
456
+ mixing_image_prompt_and_inpaint = gr.Checkbox(label='Mixing Image Prompt and Inpaint',
457
+ value=False)
458
+
459
+ controlnet_softness = gr.Slider(label='Softness of ControlNet', minimum=0.0, maximum=1.0,
460
+ step=0.001, value=0.25,
461
+ info='Similar to the Control Mode in A1111 (use 0.0 to disable). ')
462
+
463
+ with gr.Tab(label='Canny'):
464
+ canny_low_threshold = gr.Slider(label='Canny Low Threshold', minimum=1, maximum=255,
465
+ step=1, value=64)
466
+ canny_high_threshold = gr.Slider(label='Canny High Threshold', minimum=1, maximum=255,
467
+ step=1, value=128)
468
+
469
+ with gr.Tab(label='Inpaint'):
470
+ debugging_inpaint_preprocessor = gr.Checkbox(label='Debug Inpaint Preprocessing', value=False)
471
+ inpaint_disable_initial_latent = gr.Checkbox(label='Disable initial latent in inpaint', value=False)
472
+ inpaint_engine = gr.Dropdown(label='Inpaint Engine',
473
+ value=modules.config.default_inpaint_engine_version,
474
+ choices=flags.inpaint_engine_versions,
475
+ info='Version of Fooocus inpaint model')
476
+ inpaint_strength = gr.Slider(label='Inpaint Denoising Strength',
477
+ minimum=0.0, maximum=1.0, step=0.001, value=1.0,
478
+ info='Same as the denoising strength in A1111 inpaint. '
479
+ 'Only used in inpaint, not used in outpaint. '
480
+ '(Outpaint always use 1.0)')
481
+ inpaint_respective_field = gr.Slider(label='Inpaint Respective Field',
482
+ minimum=0.0, maximum=1.0, step=0.001, value=0.618,
483
+ info='The area to inpaint. '
484
+ 'Value 0 is same as "Only Masked" in A1111. '
485
+ 'Value 1 is same as "Whole Image" in A1111. '
486
+ 'Only used in inpaint, not used in outpaint. '
487
+ '(Outpaint always use 1.0)')
488
+ inpaint_erode_or_dilate = gr.Slider(label='Mask Erode or Dilate',
489
+ minimum=-64, maximum=64, step=1, value=0,
490
+ info='Positive value will make white area in the mask larger, '
491
+ 'negative value will make white area smaller.'
492
+ '(default is 0, always process before any mask invert)')
493
+ inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=False)
494
+ invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False)
495
+
496
+ inpaint_ctrls = [debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine,
497
+ inpaint_strength, inpaint_respective_field,
498
+ inpaint_mask_upload_checkbox, invert_mask_checkbox, inpaint_erode_or_dilate]
499
+
500
+ inpaint_mask_upload_checkbox.change(lambda x: gr.update(visible=x),
501
+ inputs=inpaint_mask_upload_checkbox,
502
+ outputs=inpaint_mask_image, queue=False, show_progress=False)
503
+
504
+ with gr.Tab(label='FreeU'):
505
+ freeu_enabled = gr.Checkbox(label='Enabled', value=False)
506
+ freeu_b1 = gr.Slider(label='B1', minimum=0, maximum=2, step=0.01, value=1.01)
507
+ freeu_b2 = gr.Slider(label='B2', minimum=0, maximum=2, step=0.01, value=1.02)
508
+ freeu_s1 = gr.Slider(label='S1', minimum=0, maximum=4, step=0.01, value=0.99)
509
+ freeu_s2 = gr.Slider(label='S2', minimum=0, maximum=4, step=0.01, value=0.95)
510
+ freeu_ctrls = [freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2]
511
+
512
+ def dev_mode_checked(r):
513
+ return gr.update(visible=r)
514
+
515
+
516
+ dev_mode.change(dev_mode_checked, inputs=[dev_mode], outputs=[dev_tools],
517
+ queue=False, show_progress=False)
518
+
519
+ def model_refresh_clicked():
520
+ modules.config.update_all_model_names()
521
+ results = [gr.update(choices=modules.config.model_filenames)]
522
+ results += [gr.update(choices=['None'] + modules.config.model_filenames)]
523
+ for i in range(modules.config.default_max_lora_number):
524
+ results += [gr.update(interactive=True), gr.update(choices=['None'] + modules.config.lora_filenames), gr.update()]
525
+ return results
526
+
527
+ model_refresh.click(model_refresh_clicked, [], [base_model, refiner_model] + lora_ctrls,
528
+ queue=False, show_progress=False)
529
+
530
+ performance_selection.change(lambda x: [gr.update(interactive=x != 'Extreme Speed')] * 11 +
531
+ [gr.update(visible=x != 'Extreme Speed')] * 1 +
532
+ [gr.update(interactive=x != 'Extreme Speed', value=x == 'Extreme Speed', )] * 1,
533
+ inputs=performance_selection,
534
+ outputs=[
535
+ guidance_scale, sharpness, adm_scaler_end, adm_scaler_positive,
536
+ adm_scaler_negative, refiner_switch, refiner_model, sampler_name,
537
+ scheduler_name, adaptive_cfg, refiner_swap_method, negative_prompt, disable_intermediate_results
538
+ ], queue=False, show_progress=False)
539
+
540
+ output_format.input(lambda x: gr.update(output_format=x), inputs=output_format)
541
+
542
+ advanced_checkbox.change(lambda x: gr.update(visible=x), advanced_checkbox, advanced_column,
543
+ queue=False, show_progress=False) \
544
+ .then(fn=lambda: None, _js='refresh_grid_delayed', queue=False, show_progress=False)
545
+
546
+ def inpaint_mode_change(mode):
547
+ assert mode in modules.flags.inpaint_options
548
+
549
+ # inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
550
+ # inpaint_disable_initial_latent, inpaint_engine,
551
+ # inpaint_strength, inpaint_respective_field
552
+
553
+ if mode == modules.flags.inpaint_option_detail:
554
+ return [
555
+ gr.update(visible=True), gr.update(visible=False, value=[]),
556
+ gr.Dataset.update(visible=True, samples=modules.config.example_inpaint_prompts),
557
+ False, 'None', 0.5, 0.0
558
+ ]
559
+
560
+ if mode == modules.flags.inpaint_option_modify:
561
+ return [
562
+ gr.update(visible=True), gr.update(visible=False, value=[]),
563
+ gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts),
564
+ True, modules.config.default_inpaint_engine_version, 1.0, 0.0
565
+ ]
566
+
567
+ return [
568
+ gr.update(visible=False, value=''), gr.update(visible=True),
569
+ gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts),
570
+ False, modules.config.default_inpaint_engine_version, 1.0, 0.618
571
+ ]
572
+
573
+ inpaint_mode.input(inpaint_mode_change, inputs=inpaint_mode, outputs=[
574
+ inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
575
+ inpaint_disable_initial_latent, inpaint_engine,
576
+ inpaint_strength, inpaint_respective_field
577
+ ], show_progress=False, queue=False)
578
+
579
+ ctrls = [currentTask, generate_image_grid]
580
+ ctrls += [
581
+ prompt, negative_prompt, style_selections,
582
+ performance_selection, aspect_ratios_selection, image_number, output_format, image_seed, sharpness, guidance_scale
583
+ ]
584
+
585
+ ctrls += [base_model, refiner_model, refiner_switch] + lora_ctrls
586
+ ctrls += [input_image_checkbox, current_tab]
587
+ ctrls += [uov_method, uov_input_image]
588
+ ctrls += [outpaint_selections, inpaint_input_image, inpaint_additional_prompt, inpaint_mask_image]
589
+ ctrls += [disable_preview, disable_intermediate_results, disable_seed_increment]
590
+ ctrls += [adm_scaler_positive, adm_scaler_negative, adm_scaler_end, adaptive_cfg]
591
+ ctrls += [sampler_name, scheduler_name]
592
+ ctrls += [overwrite_step, overwrite_switch, overwrite_width, overwrite_height, overwrite_vary_strength]
593
+ ctrls += [overwrite_upscale_strength, mixing_image_prompt_and_vary_upscale, mixing_image_prompt_and_inpaint]
594
+ ctrls += [debugging_cn_preprocessor, skipping_cn_preprocessor, canny_low_threshold, canny_high_threshold]
595
+ ctrls += [refiner_swap_method, controlnet_softness]
596
+ ctrls += freeu_ctrls
597
+ ctrls += inpaint_ctrls
598
+
599
+ if not args_manager.args.disable_metadata:
600
+ ctrls += [save_metadata_to_images, metadata_scheme]
601
+
602
+ ctrls += ip_ctrls
603
+
604
+ state_is_generating = gr.State(False)
605
+
606
+ def parse_meta(raw_prompt_txt, is_generating):
607
+ loaded_json = None
608
+ if is_json(raw_prompt_txt):
609
+ loaded_json = json.loads(raw_prompt_txt)
610
+
611
+ if loaded_json is None:
612
+ if is_generating:
613
+ return gr.update(), gr.update(), gr.update()
614
+ else:
615
+ return gr.update(), gr.update(visible=True), gr.update(visible=False)
616
+
617
+ return json.dumps(loaded_json), gr.update(visible=False), gr.update(visible=True)
618
+
619
+ prompt.input(parse_meta, inputs=[prompt, state_is_generating], outputs=[prompt, generate_button, load_parameter_button], queue=False, show_progress=False)
620
+
621
+ load_data_outputs = [advanced_checkbox, image_number, prompt, negative_prompt, style_selections,
622
+ performance_selection, overwrite_step, overwrite_switch, aspect_ratios_selection,
623
+ overwrite_width, overwrite_height, guidance_scale, sharpness, adm_scaler_positive,
624
+ adm_scaler_negative, adm_scaler_end, refiner_swap_method, adaptive_cfg, base_model,
625
+ refiner_model, refiner_switch, sampler_name, scheduler_name, seed_random, image_seed,
626
+ generate_button, load_parameter_button] + freeu_ctrls + lora_ctrls
627
+
628
+ load_parameter_button.click(modules.meta_parser.load_parameter_button_click, inputs=[prompt, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=False)
629
+
630
+ def trigger_metadata_import(filepath, state_is_generating):
631
+ parameters, metadata_scheme = modules.meta_parser.read_info_from_image(filepath)
632
+ if parameters is None:
633
+ print('Could not find metadata in the image!')
634
+ parsed_parameters = {}
635
+ else:
636
+ metadata_parser = modules.meta_parser.get_metadata_parser(metadata_scheme)
637
+ parsed_parameters = metadata_parser.parse_json(parameters)
638
+
639
+ return modules.meta_parser.load_parameter_button_click(parsed_parameters, state_is_generating)
640
+
641
+
642
+ metadata_import_button.click(trigger_metadata_import, inputs=[metadata_input_image, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=True) \
643
+ .then(style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False)
644
+
645
+ generate_button.click(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), [], True),
646
+ outputs=[stop_button, skip_button, generate_button, gallery, state_is_generating]) \
647
+ .then(fn=refresh_seed, inputs=[seed_random, image_seed], outputs=image_seed) \
648
+ .then(fn=get_task, inputs=ctrls, outputs=currentTask) \
649
+ .then(fn=generate_clicked, inputs=currentTask, outputs=[progress_html, progress_window, progress_gallery, gallery]) \
650
+ .then(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), gr.update(visible=False, interactive=False), False),
651
+ outputs=[generate_button, stop_button, skip_button, state_is_generating]) \
652
+ .then(fn=update_history_link, outputs=history_link) \
653
+ .then(fn=lambda: None, _js='playNotification').then(fn=lambda: None, _js='refresh_grid_delayed')
654
+
655
+ for notification_file in ['notification.ogg', 'notification.mp3']:
656
+ if os.path.exists(notification_file):
657
+ gr.Audio(interactive=False, value=notification_file, elem_id='audio_notification', visible=False)
658
+ break
659
+
660
+ def trigger_describe(mode, img):
661
+ if mode == flags.desc_type_photo:
662
+ from extras.interrogate import default_interrogator as default_interrogator_photo
663
+ return default_interrogator_photo(img), ["Fooocus V2", "Fooocus Enhance", "Fooocus Sharp"]
664
+ if mode == flags.desc_type_anime:
665
+ from extras.wd14tagger import default_interrogator as default_interrogator_anime
666
+ return default_interrogator_anime(img), ["Fooocus V2", "Fooocus Masterpiece"]
667
+ return mode, ["Fooocus V2"]
668
+
669
+ desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image],
670
+ outputs=[prompt, style_selections], show_progress=True, queue=True)
671
+
672
+
673
+ def dump_default_english_config():
674
+ from modules.localization import dump_english_config
675
+ dump_english_config(grh.all_components)
676
+
677
+
678
+ # dump_default_english_config()
679
+
680
+ shared.gradio_root.launch(
681
+ inbrowser=args_manager.args.in_browser,
682
+ server_name=args_manager.args.listen,
683
+ server_port=args_manager.args.port,
684
+ share=args_manager.args.share,
685
+ auth=check_auth if (args_manager.args.share or args_manager.args.listen) and auth_enabled else None,
686
+ allowed_paths=[modules.config.path_outputs],
687
+ blocked_paths=[constants.AUTH_FILENAME]
688
+ )