Spaces:
Build error
Build error
Aditya DN commited on
Upload 39 files
Browse filesFiles changed (39)
- .dockerignoreAdded+1
- .gitignoreAdded+54
- .run anime.batAdded+2
- .run default.batAdded+2
- .run lcm.batAdded+2
- .run realistic.batAdded+2
- .run sai.batAdded+2
- .run.batAdded+2
- DockerfileAdded+29
- LICENSEAdded+674
- aiDescTerminal.pyAdded+90
- aiDescUI.pyAdded+688
- app.htmlAdded+6
- args_manager.pyAdded+55
- auth-example.jsonAdded+6
- build_launcher.pyAdded+26
- config.txtAdded+16
- config_modification_tutorial.txtAdded+123
- docker-compose.ymlAdded+38
- docker.mdAdded+66
- entry_with_update.pyAdded+46
- entrypoint.shAdded+33
- environment.yamlAdded+7
- experiments_expansion.pyAdded+8
- experiments_face.pyAdded+7
- experiments_interrogate.pyAdded+8
- fooocus_colab.ipynbAdded+35
- fooocus_version.pyAdded+1
- launch.pyAdded+127
- notification-example.oggAdded
- readme.mdAdded+438
- requirements_docker.txtAdded+5
- requirements_versions.txtAdded+18
- shared.pyAdded+1
- sorted_styles.jsonAdded+279
- troubleshoot.mdAdded+178
- update_log.mdAdded+632
- vercel.jsonAdded+14
- webui.pyAdded+688
1.idea123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354__pycache__*.ckpt*.safetensors*.pth*.pt*.bin*.patch*.backup*.corrupted*.partial*.onnxsorted_styles.json/input/cache/language/default.json/test_imgsconfig.txtconfig_modification_tutorial.txtuser_path_config.txtuser_path_config-deprecated.txt/modules/*.png/repositories/fooocus_env/venv/tmp/ui-config.json/outputs/config.json/log/webui.settings.bat/embeddings/styles.csv/params.txt/styles.csv.bak/webui-user.bat/webui-user.sh/interrogate/user.css/.idea/notification.ogg/notification.mp3/SwinIR/textual_inversion.vscode/extensions/test/stdout.txt/test/stderr.txt/cache.json*/config_states//node_modules/package-lock.json/.coverage*/auth.json.DS_Store12.python\\ai\\python.exe -s entry_with_update.py --attention-split --always-cpu --preset animepause12.python\\ai\\python.exe -s entry_with_update.py --attention-split --always-cpu --preset defaultpause12.python\\ai\\python.exe -s entry_with_update.py --attention-split --always-cpu --preset lcmpause12.python\\ai\\python.exe -s entry_with_update.py --attention-split --always-cpu --preset realisticpause12.python\\ai\\python.exe -s entry_with_update.py --attention-split --always-cpu --preset saipause12.python\\ai\\python.exe -s entry_with_update.py --always-cpu --attention-split --always-download-new-modelpause1234567891011121314151617181920212223242526272829FROM nvidia/cuda:12.3.1-base-ubuntu22.04ENV DEBIAN_FRONTEND noninteractiveENV CMDARGS --listen
RUN apt-get update -y && \ apt-get install -y curl libgl1 libglib2.0-0 python3-pip python-is-python3 git && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*
COPY requirements_docker.txt requirements_versions.txt /tmp/RUN pip install --no-cache-dir -r /tmp/requirements_docker.txt -r /tmp/requirements_versions.txt && \ rm -f /tmp/requirements_docker.txt /tmp/requirements_versions.txtRUN pip install --no-cache-dir xformers==0.0.22 --no-dependenciesRUN 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 && \ chmod +x /usr/local/lib/python3.10/dist-packages/gradio/frpc_linux_amd64_v0.2
RUN adduser --disabled-password --gecos '' user && \ mkdir -p /content/app /content/data
COPY entrypoint.sh /content/RUN chown -R user:user /content
WORKDIR /contentUSER user
RUN git clone https://github.com/lllyasviel/Fooocus /content/appRUN mv /content/app/models /content/app/models.org
CMD [ "sh", "-c", "/content/entrypoint.sh ${CMDARGS}" ]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license forsoftware and other kinds of works.
The licenses for most software and other practical works are designedto take away your freedom to share and change the works. By contrast,the GNU General Public License is intended to guarantee your freedom toshare and change all versions of a program--to make sure it remains freesoftware for all its users. We, the Free Software Foundation, use theGNU General Public License for most of our software; it applies also toany other work released this way by its authors. You can apply it toyour programs, too.
When we speak of free software, we are referring to freedom, notprice. Our General Public Licenses are designed to make sure that youhave the freedom to distribute copies of free software (and charge forthem if you wish), that you receive source code or can get it if youwant it, that you can change the software or use pieces of it in newfree programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying youthese rights or asking you to surrender the rights. Therefore, you havecertain responsibilities if you distribute copies of the software, or ifyou modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whethergratis or for a fee, you must pass on to the recipients the samefreedoms that you received. You must make sure that they, too, receiveor can get the source code. And you must show them these terms so theyknow their rights.
Developers that use the GNU GPL protect your rights with two steps:(1) assert copyright on the software, and (2) offer you this Licensegiving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explainsthat there is no warranty for this free software. For both users' andauthors' sake, the GPL requires that modified versions be marked aschanged, so that their problems will not be attributed erroneously toauthors of previous versions.
Some devices are designed to deny users access to install or runmodified versions of the software inside them, although the manufacturercan do so. This is fundamentally incompatible with the aim ofprotecting users' freedom to change the software. The systematicpattern of such abuse occurs in the area of products for individuals touse, which is precisely where it is most unacceptable. Therefore, wehave designed this version of the GPL to prohibit the practice for thoseproducts. If such problems arise substantially in other domains, westand ready to extend this provision to those domains in future versionsof the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.States should not allow patents to restrict development and use ofsoftware on general-purpose computers, but in those that do, we wish toavoid the special danger that patents applied to a free program couldmake it effectively proprietary. To prevent this, the GPL assures thatpatents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution andmodification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds ofworks, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under thisLicense. Each licensee is addressed as "you". "Licensees" and"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the workin a fashion requiring copyright permission, other than the making of anexact copy. The resulting work is called a "modified version" of theearlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work basedon the Program.
To "propagate" a work means to do anything with it that, withoutpermission, would make you directly or secondarily liable forinfringement under applicable copyright law, except executing it on acomputer or modifying a private copy. Propagation includes copying,distribution (with or without modification), making available to thepublic, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables otherparties to make or receive copies. Mere interaction with a user througha computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"to the extent that it includes a convenient and prominently visiblefeature that (1) displays an appropriate copyright notice, and (2)tells the user that there is no warranty for the work (except to theextent that warranties are provided), that licensees may convey thework under this License, and how to view a copy of this License. Ifthe interface presents a list of user commands or options, such as amenu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the workfor making modifications to it. "Object code" means any non-sourceform of a work.
A "Standard Interface" means an interface that either is an officialstandard defined by a recognized standards body, or, in the case ofinterfaces specified for a particular programming language, one thatis widely used among developers working in that language.
The "System Libraries" of an executable work include anything, otherthan the work as a whole, that (a) is included in the normal form ofpackaging a Major Component, but which is not part of that MajorComponent, and (b) serves only to enable use of the work with thatMajor Component, or to implement a Standard Interface for which animplementation is available to the public in source code form. A"Major Component", in this context, means a major essential component(kernel, window system, and so on) of the specific operating system(if any) on which the executable work runs, or a compiler used toproduce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means allthe source code needed to generate, install, and (for an executablework) run the object code and to modify the work, including scripts tocontrol those activities. However, it does not include the work'sSystem Libraries, or general-purpose tools or generally available freeprograms which are used unmodified in performing those activities butwhich are not part of the work. For example, Corresponding Sourceincludes interface definition files associated with source files forthe work, and the source code for shared libraries and dynamicallylinked subprograms that the work is specifically designed to require,such as by intimate data communication or control flow between thosesubprograms and other parts of the work.
The Corresponding Source need not include anything that userscan regenerate automatically from other parts of the CorrespondingSource.
The Corresponding Source for a work in source code form is thatsame work.
2. Basic Permissions.
All rights granted under this License are granted for the term ofcopyright on the Program, and are irrevocable provided the statedconditions are met. This License explicitly affirms your unlimitedpermission to run the unmodified Program. The output from running acovered work is covered by this License only if the output, given itscontent, constitutes a covered work. This License acknowledges yourrights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do notconvey, without conditions so long as your license otherwise remainsin force. You may convey covered works to others for the sole purposeof having them make modifications exclusively for you, or provide youwith facilities for running those works, provided that you comply withthe terms of this License in conveying all material for which you donot control copyright. Those thus making or running the covered worksfor you must do so exclusively on your behalf, under your directionand control, on terms that prohibit them from making any copies ofyour copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely underthe conditions stated below. Sublicensing is not allowed; section 10makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technologicalmeasure under any applicable law fulfilling obligations under article11 of the WIPO copyright treaty adopted on 20 December 1996, orsimilar laws prohibiting or restricting circumvention of suchmeasures.
When you convey a covered work, you waive any legal power to forbidcircumvention of technological measures to the extent such circumventionis effected by exercising rights under this License with respect tothe covered work, and you disclaim any intention to limit operation ormodification of the work as a means of enforcing, against the work'susers, your or third parties' legal rights to forbid circumvention oftechnological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as youreceive it, in any medium, provided that you conspicuously andappropriately publish on each copy an appropriate copyright notice;keep intact all notices stating that this License and anynon-permissive terms added in accord with section 7 apply to the code;keep intact all notices of the absence of any warranty; and give allrecipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications toproduce it from the Program, in the form of source code under theterms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independentworks, which are not by their nature extensions of the covered work,and which are not combined with it such as to form a larger program,in or on a volume of a storage or distribution medium, is called an"aggregate" if the compilation and its resulting copyright are notused to limit the access or legal rights of the compilation's usersbeyond what the individual works permit. Inclusion of a covered workin an aggregate does not cause this License to apply to the otherparts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the termsof sections 4 and 5, provided that you also convey themachine-readable Corresponding Source under the terms of this License,in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excludedfrom the Corresponding Source as a System Library, need not beincluded in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means anytangible personal property which is normally used for personal, family,or household purposes, or (2) anything designed or sold for incorporationinto a dwelling. In determining whether a product is a consumer product,doubtful cases shall be resolved in favor of coverage. For a particularproduct received by a particular user, "normally used" refers to atypical or common use of that class of product, regardless of the statusof the particular user or of the way in which the particular useractually uses, or expects or is expected to use, the product. A productis a consumer product regardless of whether the product has substantialcommercial, industrial or non-consumer uses, unless such uses representthe only significant mode of use of the product.
"Installation Information" for a User Product means any methods,procedures, authorization keys, or other information required to installand execute modified versions of a covered work in that User Product froma modified version of its Corresponding Source. The information mustsuffice to ensure that the continued functioning of the modified objectcode is in no case prevented or interfered with solely becausemodification has been made.
If you convey an object code work under this section in, or with, orspecifically for use in, a User Product, and the conveying occurs aspart of a transaction in which the right of possession and use of theUser Product is transferred to the recipient in perpetuity or for afixed term (regardless of how the transaction is characterized), theCorresponding Source conveyed under this section must be accompaniedby the Installation Information. But this requirement does not applyif neither you nor any third party retains the ability to installmodified object code on the User Product (for example, the work hasbeen installed in ROM).
The requirement to provide Installation Information does not include arequirement to continue to provide support service, warranty, or updatesfor a work that has been modified or installed by the recipient, or forthe User Product in which it has been modified or installed. Access to anetwork may be denied when the modification itself materially andadversely affects the operation of the network or violates the rules andprotocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,in accord with this section must be in a format that is publiclydocumented (and with an implementation available to the public insource code form), and must require no special password or key forunpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of thisLicense by making exceptions from one or more of its conditions.Additional permissions that are applicable to the entire Program shallbe treated as though they were included in this License, to the extentthat they are valid under applicable law. If additional permissionsapply only to part of the Program, that part may be used separatelyunder those permissions, but the entire Program remains governed bythis License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your optionremove any additional permissions from that copy, or from any part ofit. (Additional permissions may be written to require their ownremoval in certain cases when you modify the work.) You may placeadditional permissions on material, added by you to a covered work,for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material youadd to a covered work, you may (if authorized by the copyright holders ofthat material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "furtherrestrictions" within the meaning of section 10. If the Program as youreceived it, or any part of it, contains a notice stating that it isgoverned by this License along with a term that is a furtherrestriction, you may remove that term. If a license document containsa further restriction but permits relicensing or conveying under thisLicense, you may add to a covered work material governed by the termsof that license document, provided that the further restriction doesnot survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, youmust place, in the relevant source files, a statement of theadditional terms that apply to those files, or a notice indicatingwhere to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in theform of a separately written license, or stated as exceptions;the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expresslyprovided under this License. Any attempt otherwise to propagate ormodify it is void, and will automatically terminate your rights underthis License (including any patent licenses granted under the thirdparagraph of section 11).
However, if you cease all violation of this License, then yourlicense from a particular copyright holder is reinstated (a)provisionally, unless and until the copyright holder explicitly andfinally terminates your license, and (b) permanently, if the copyrightholder fails to notify you of the violation by some reasonable meansprior to 60 days after the cessation.
Moreover, your license from a particular copyright holder isreinstated permanently if the copyright holder notifies you of theviolation by some reasonable means, this is the first time you havereceived notice of violation of this License (for any work) from thatcopyright holder, and you cure the violation prior to 30 days afteryour receipt of the notice.
Termination of your rights under this section does not terminate thelicenses of parties who have received copies or rights from you underthis License. If your rights have been terminated and not permanentlyreinstated, you do not qualify to receive new licenses for the samematerial under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive orrun a copy of the Program. Ancillary propagation of a covered workoccurring solely as a consequence of using peer-to-peer transmissionto receive a copy likewise does not require acceptance. However,nothing other than this License grants you permission to propagate ormodify any covered work. These actions infringe copyright if you donot accept this License. Therefore, by modifying or propagating acovered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automaticallyreceives a license from the original licensors, to run, modify andpropagate that work, subject to this License. You are not responsiblefor enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of anorganization, or substantially all assets of one, or subdividing anorganization, or merging organizations. If propagation of a coveredwork results from an entity transaction, each party to thattransaction who receives a copy of the work also receives whateverlicenses to the work the party's predecessor in interest had or couldgive under the previous paragraph, plus a right to possession of theCorresponding Source of the work from the predecessor in interest, ifthe predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of therights granted or affirmed under this License. For example, you maynot impose a license fee, royalty, or other charge for exercise ofrights granted under this License, and you may not initiate litigation(including a cross-claim or counterclaim in a lawsuit) alleging thatany patent claim is infringed by making, using, selling, offering forsale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under thisLicense of the Program or a work on which the Program is based. Thework thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claimsowned or controlled by the contributor, whether already acquired orhereafter acquired, that would be infringed by some manner, permittedby this License, of making, using, or selling its contributor version,but do not include claims that would be infringed only as aconsequence of further modification of the contributor version. Forpurposes of this definition, "control" includes the right to grantpatent sublicenses in a manner consistent with the requirements ofthis License.
Each contributor grants you a non-exclusive, worldwide, royalty-freepatent license under the contributor's essential patent claims, tomake, use, sell, offer for sale, import and otherwise run, modify andpropagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any expressagreement or commitment, however denominated, not to enforce a patent(such as an express permission to practice a patent or covenant not tosue for patent infringement). To "grant" such a patent license to aparty means to make such an agreement or commitment not to enforce apatent against the party.
If you convey a covered work, knowingly relying on a patent license,and the Corresponding Source of the work is not available for anyoneto copy, free of charge and under the terms of this License, through apublicly available network server or other readily accessible means,then you must either (1) cause the Corresponding Source to be soavailable, or (2) arrange to deprive yourself of the benefit of thepatent license for this particular work, or (3) arrange, in a mannerconsistent with the requirements of this License, to extend the patentlicense to downstream recipients. "Knowingly relying" means you haveactual knowledge that, but for the patent license, your conveying thecovered work in a country, or your recipient's use of the covered workin a country, would infringe one or more identifiable patents in thatcountry that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction orarrangement, you convey, or propagate by procuring conveyance of, acovered work, and grant a patent license to some of the partiesreceiving the covered work authorizing them to use, propagate, modifyor convey a specific copy of the covered work, then the patent licenseyou grant is automatically extended to all recipients of the coveredwork and works based on it.
A patent license is "discriminatory" if it does not include withinthe scope of its coverage, prohibits the exercise of, or isconditioned on the non-exercise of one or more of the rights that arespecifically granted under this License. You may not convey a coveredwork if you are a party to an arrangement with a third party that isin the business of distributing software, under which you make paymentto the third party based on the extent of your activity of conveyingthe work, and under which the third party grants, to any of theparties who would receive the covered work from you, a discriminatorypatent license (a) in connection with copies of the covered workconveyed by you (or copies made from those copies), or (b) primarilyfor and in connection with specific products or compilations thatcontain the covered work, unless you entered into that arrangement,or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limitingany implied license or other defenses to infringement that mayotherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement orotherwise) that contradict the conditions of this License, they do notexcuse you from the conditions of this License. If you cannot convey acovered work so as to satisfy simultaneously your obligations under thisLicense and any other pertinent obligations, then as a consequence you maynot convey it at all. For example, if you agree to terms that obligate youto collect a royalty for further conveying from those to whom you conveythe Program, the only way you could satisfy both those terms and thisLicense would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you havepermission to link or combine any covered work with a work licensedunder version 3 of the GNU Affero General Public License into a singlecombined work, and to convey the resulting work. The terms of thisLicense will continue to apply to the part which is the covered work,but the special requirements of the GNU Affero General Public License,section 13, concerning interaction through a network will apply to thecombination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions ofthe GNU General Public License from time to time. Such new versions willbe similar in spirit to the present version, but may differ in detail toaddress new problems or concerns.
Each version is given a distinguishing version number. If theProgram specifies that a certain numbered version of the GNU GeneralPublic License "or any later version" applies to it, you have theoption of following the terms and conditions either of that numberedversion or of any later version published by the Free SoftwareFoundation. If the Program does not specify a version number of theGNU General Public License, you may choose any version ever publishedby the Free Software Foundation.
If the Program specifies that a proxy can decide which futureversions of the GNU General Public License can be used, that proxy'spublic statement of acceptance of a version permanently authorizes youto choose that version for the Program.
Later license versions may give you additional or differentpermissions. However, no additional obligations are imposed on anyauthor or copyright holder as a result of your choosing to follow alater version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BYAPPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHTHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTYOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAMIS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OFALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITINGWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYSTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANYGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THEUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OFDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRDPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OFSUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability providedabove cannot be given local legal effect according to their terms,reviewing courts shall apply local law that most closely approximatesan absolute waiver of all civil liability in connection with theProgram, unless a warranty or assumption of liability accompanies acopy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatestpossible use to the public, the best way to achieve this is to make itfree software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safestto attach them to the start of each source file to most effectivelystate the exclusion of warranty; and each file should have at leastthe "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a shortnotice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author> This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriateparts of the General Public License. Of course, your program's commandsmight be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,if any, to sign a "copyright disclaimer" for the program, if necessary.For more information on this, and how to apply and follow the GNU GPL, see<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your programinto proprietary programs. If your program is a subroutine library, youmay consider it more useful to permit linking proprietary applications withthe library. If this is what you want to do, use the GNU Lesser GeneralPublic License instead of this License. But first, please read<https://www.gnu.org/licenses/why-not-lgpl.html>.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import osimport sysimport numpy as npfrom PIL import Imageimport requestsfrom io import BytesIO
root = os.path.dirname(os.path.abspath(__file__))sys.path.append(root)os.chdir(root)
import modules.configimport modules.htmlimport modules.flags as flagsimport modules.meta_parser
def download_image(url): response = requests.get(url) img = Image.open(BytesIO(response.content)).convert("RGB") return img
def trigger_describe(mode, img_path): print("Running") print("Press Ctrl+C for Stop ") if mode == flags.desc_type_photo: from extras.interrogate import default_interrogator as default_interrogator_photo if img_path.startswith('http'): img = download_image(img_path) else: img = Image.open(img_path).convert("RGB") return default_interrogator_photo(img), ["Fooocus V2", "Fooocus Enhance", "Fooocus Sharp"] elif mode == flags.desc_type_anime: from extras.wd14tagger import default_interrogator as default_interrogator_anime if img_path.startswith('http'): img = download_image(img_path) elif isinstance(img_path, str): # Load the image if the input is a path img = Image.open(img_path).convert("RGB") elif isinstance(img_path, np.ndarray): # Use the provided NumPy array directly img = Image.fromarray(img_path).convert("RGB") else: raise ValueError("Invalid image format. Please provide a valid path or NumPy array.") # Convert the image to a NumPy array img_array = np.array(img) return default_interrogator_anime(img_array), ["Fooocus V2", "Fooocus Masterpiece"] return mode, ["Fooocus V2"]
style_selections = modules.config.default_styles
def run_describe(image_path, content_type): desc_input_image = image_path desc_method = content_type
result, style_selections = None, None
if desc_method in ["Photograph", "1", ""]: desc_method = "Photograph (1)" result, style_selections = trigger_describe(flags.desc_type_photo, desc_input_image) elif desc_method in ["Art/Anime", "2"]: desc_method = "Art/Anime (2)" result, style_selections = trigger_describe(flags.desc_type_anime, desc_input_image) else: print("ERROR!")
if result or style_selections != "": style_selections = "" print("Result:", result) # print("Style Selections:", style_selections) quit()
if __name__ == "__main__": desc_input_image = input("Path to Image (local path or URL): ")
if desc_input_image == "": desc_input_image = "./imgs/Gambar1.jpg"
print(f"You use: {desc_input_image}")
desc_method = input( """ Select Content Type: Photograph (1) Art/Anime (2) """ )
run_describe(desc_input_image, desc_method)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688import gradio as grimport randomimport os# import jsonimport timeimport sharedimport modules.config# import fooocus_versionimport modules.htmlimport modules.async_worker as workerimport modules.constants as constantsimport modules.flags as flagsimport modules.gradio_hijack as grhimport modules.style_sorter as style_sorterimport modules.meta_parserimport args_managerimport copy
from modules.sdxl_styles import legal_style_namesfrom modules.private_logger import get_current_html_pathfrom modules.ui_gradio_extensions import reload_javascriptfrom modules.auth import auth_enabled, check_auth# from modules.util import is_json
# def get_task(*args):# args = list(args)# args.pop(0)
# return worker.AsyncTask(args=args)
# def generate_clicked(task):# import ldm_patched.modules.model_management as model_management
# with model_management.interrupt_processing_mutex:# model_management.interrupt_processing = False# # outputs=[progress_html, progress_window, progress_gallery, gallery]# execution_start_time = time.perf_counter()# finished = False
# yield gr.update(visible=True, value=modules.html.make_progress_html(1, 'Waiting for task to start ...')), \# gr.update(visible=True, value=None), \# gr.update(visible=False, value=None), \# gr.update(visible=False)
# worker.async_tasks.append(task)
# while not finished:# time.sleep(0.01)# if len(task.yields) > 0:# flag, product = task.yields.pop(0)# if flag == 'preview':
# # help bad internet connection by skipping duplicated preview# if len(task.yields) > 0: # if we have the next item# if task.yields[0][0] == 'preview': # if the next item is also a preview# # print('Skipped one preview for better internet connection.')# continue
# percentage, title, image = product# yield gr.update(visible=True, value=modules.html.make_progress_html(percentage, title)), \# gr.update(visible=True, value=image) if image is not None else gr.update(), \# gr.update(), \# gr.update(visible=False)# if flag == 'results':# yield gr.update(visible=True), \# gr.update(visible=True), \# gr.update(visible=True, value=product), \# gr.update(visible=False)# if flag == 'finish':# yield gr.update(visible=False), \# gr.update(visible=False), \# gr.update(visible=False), \# gr.update(visible=True, value=product)# finished = True
# # delete Fooocus temp images, only keep gradio temp images# if args_manager.args.disable_image_log:# for filepath in product:# if isinstance(filepath, str) and os.path.exists(filepath):# os.remove(filepath)
# execution_time = time.perf_counter() - execution_start_time# print(f'Total time: {execution_time:.2f} seconds')# return
reload_javascript()
title = 'AI Describe Image'
if isinstance(args_manager.args.preset, str): title += ' ' + args_manager.args.preset
shared.gradio_root = gr.Blocks( title=title, css=modules.html.css).queue()
with shared.gradio_root: # currentTask = gr.State(worker.AsyncTask(args=[])) with gr.Row(): with gr.Column(scale=2): # with gr.Row(): # progress_window = grh.Image(label='Preview', show_label=True, visible=False, height=768, # elem_classes=['main_view']) # progress_gallery = gr.Gallery(label='Finished Images', show_label=True, object_fit='contain', # height=768, visible=False, elem_classes=['main_view', 'image_gallery']) # progress_html = gr.HTML(value=modules.html.make_progress_html(32, 'Progress 32%'), visible=False, # elem_id='progress-bar', elem_classes='progress-bar') # gallery = gr.Gallery(label='Gallery', show_label=False, object_fit='contain', visible=True, height=768, # elem_classes=['resizable_area', 'main_view', 'final_gallery', 'image_gallery'], # elem_id='final_gallery') with gr.Row(visible=True) as image_input_panel: with gr.Tabs(): # with gr.TabItem(label='Upscale or Variation') as uov_tab: # with gr.Row(): # with gr.Column(): # uov_input_image = grh.Image(label='Drag above image to here', source='upload', type='numpy') # with gr.Column(): # uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list, value=flags.disabled) # gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/390" target="_blank">\U0001F4D4 Document</a>') # with gr.TabItem(label='Image Prompt') as ip_tab: # with gr.Row(): # ip_images = [] # ip_types = [] # ip_stops = [] # ip_weights = [] # ip_ctrls = [] # ip_ad_cols = [] # for _ in range(flags.controlnet_image_count): # with gr.Column(): # ip_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False, height=300) # ip_images.append(ip_image) # ip_ctrls.append(ip_image) # with gr.Column(visible=False) as ad_col: # with gr.Row(): # default_end, default_weight = flags.default_parameters[flags.default_ip]
# ip_stop = gr.Slider(label='Stop At', minimum=0.0, maximum=1.0, step=0.001, value=default_end) # ip_stops.append(ip_stop) # ip_ctrls.append(ip_stop)
# ip_weight = gr.Slider(label='Weight', minimum=0.0, maximum=2.0, step=0.001, value=default_weight) # ip_weights.append(ip_weight) # ip_ctrls.append(ip_weight)
# ip_type = gr.Radio(label='Type', choices=flags.ip_list, value=flags.default_ip, container=False) # ip_types.append(ip_type) # ip_ctrls.append(ip_type)
# ip_type.change(lambda x: flags.default_parameters[x], inputs=[ip_type], outputs=[ip_stop, ip_weight], queue=False, show_progress=False) # ip_ad_cols.append(ad_col) # ip_advanced = gr.Checkbox(label='Advanced', value=False, container=False) # 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>')
# def ip_advance_checked(x): # return [gr.update(visible=x)] * len(ip_ad_cols) + \ # [flags.default_ip] * len(ip_types) + \ # [flags.default_parameters[flags.default_ip][0]] * len(ip_stops) + \ # [flags.default_parameters[flags.default_ip][1]] * len(ip_weights)
# ip_advanced.change(ip_advance_checked, inputs=ip_advanced, # outputs=ip_ad_cols + ip_types + ip_stops + ip_weights, # queue=False, show_progress=False) # with gr.TabItem(label='Inpaint or Outpaint') as inpaint_tab: # with gr.Row(): # 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') # inpaint_mask_image = grh.Image(label='Mask Upload', source='upload', type='numpy', height=500, visible=False)
# with gr.Row(): # inpaint_additional_prompt = gr.Textbox(placeholder="Describe what you want to inpaint.", elem_id='inpaint_additional_prompt', label='Inpaint Additional Prompt', visible=False) # outpaint_selections = gr.CheckboxGroup(choices=['Left', 'Right', 'Top', 'Bottom'], value=[], label='Outpaint Direction') # inpaint_mode = gr.Dropdown(choices=modules.flags.inpaint_options, value=modules.flags.inpaint_option_default, label='Method') # example_inpaint_prompts = gr.Dataset(samples=modules.config.example_inpaint_prompts, label='Additional Prompt Quick List', components=[inpaint_additional_prompt], visible=False) # gr.HTML('* Powered by Fooocus Inpaint Engine <a href="https://github.com/lllyasviel/Fooocus/discussions/414" target="_blank">\U0001F4D4 Document</a>') # example_inpaint_prompts.click(lambda x: x[0], inputs=example_inpaint_prompts, outputs=inpaint_additional_prompt, show_progress=False, queue=False) with gr.TabItem(label='Describe') as desc_tab: with gr.Row(): with gr.Column(): desc_input_image = grh.Image(label='Drag any image to here', source='upload', type='numpy') with gr.Column(): # with gr.Row(elem_classes='type_row'): with gr.Row(): prompt = gr.Textbox(label="Output", show_label=True, elem_id='positive_prompt', container=True, autofocus=True, show_copy_button=True, interactive=True)
default_prompt = modules.config.default_prompt if isinstance(default_prompt, str) and default_prompt != '': shared.gradio_root.load(lambda: default_prompt, outputs=prompt)
# with gr.Column(scale=3, min_width=0): # generate_button = gr.Button(label="Generate", value="Generate", elem_classes='type_row', elem_id='generate_button', visible=True) # load_parameter_button = gr.Button(label="Load Parameters", value="Load Parameters", elem_classes='type_row', elem_id='load_parameter_button', visible=False) # skip_button = gr.Button(label="Skip", value="Skip", elem_classes='type_row_half', visible=False) # stop_button = gr.Button(label="Stop", value="Stop", elem_classes='type_row_half', elem_id='stop_button', visible=False)
# def stop_clicked(currentTask): # import ldm_patched.modules.model_management as model_management # currentTask.last_stop = 'stop' # if (currentTask.processing): # model_management.interrupt_current_processing() # return currentTask
# def skip_clicked(currentTask): # import ldm_patched.modules.model_management as model_management # currentTask.last_stop = 'skip' # if (currentTask.processing): # model_management.interrupt_current_processing() # return currentTask
# stop_button.click(stop_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False, _js='cancelGenerateForever') # skip_button.click(skip_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False) # with gr.Row(elem_classes='advanced_check_row'): # # input_image_checkbox = gr.Checkbox(label='Input Image', value=False, container=False, elem_classes='min_check') # advanced_checkbox = gr.Checkbox(label='Advanced', value=modules.config.default_advanced_checkbox, container=False, elem_classes='min_check') with gr.Row(): desc_method = gr.Radio( label='Content Type', choices=[flags.desc_type_photo, flags.desc_type_anime], value=flags.desc_type_photo) desc_btn = gr.Button(value='Describe this Image into Prompt') # gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/1363" target="_blank">\U0001F4D4 Document</a>') # with gr.TabItem(label='Metadata') as load_tab: # with gr.Column(): # metadata_input_image = grh.Image(label='Drag any image generated by Fooocus here', source='upload', type='filepath') # metadata_json = gr.JSON(label='Metadata') # metadata_import_button = gr.Button(value='Apply Metadata')
# def trigger_metadata_preview(filepath): # parameters, metadata_scheme = modules.meta_parser.read_info_from_image(filepath)
# results = {} # if parameters is not None: # results['parameters'] = parameters
# if isinstance(metadata_scheme, flags.MetadataScheme): # results['metadata_scheme'] = metadata_scheme.value
# return results
# metadata_input_image.upload(trigger_metadata_preview, inputs=metadata_input_image, # outputs=metadata_json, queue=False, show_progress=True)
switch_js = "(x) => {if(x){viewer_to_bottom(100);viewer_to_bottom(500);}else{viewer_to_top();} return x;}" down_js = "() => {viewer_to_bottom();}"
# input_image_checkbox.change(lambda x: gr.update(visible=x), inputs=input_image_checkbox, # outputs=image_input_panel, queue=False, show_progress=False, _js=switch_js) # ip_advanced.change(lambda: None, queue=False, show_progress=False, _js=down_js)
# current_tab = gr.Textbox(value='desc', visible=False) # # uov_tab.select(lambda: 'uov', outputs=current_tab, queue=False, _js=down_js, show_progress=False) # # inpaint_tab.select(lambda: 'inpaint', outputs=current_tab, queue=False, _js=down_js, show_progress=False) # # ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False) # desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
# with gr.Column(scale=1, visible=modules.config.default_advanced_checkbox) as advanced_column: # with gr.Tab(label='Setting'): # performance_selection = gr.Radio(label='Performance', # choices=modules.flags.performance_selections, # value=modules.config.default_performance) # aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios, # value=modules.config.default_aspect_ratio, info='width × height', # elem_classes='aspect_ratios') # image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number)
# output_format = gr.Radio(label='Output Format', # choices=modules.flags.output_formats, # value=modules.config.default_output_format)
# negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.", # info='Describing what you do not want to see.', lines=2, # elem_id='negative_prompt', # value=modules.config.default_prompt_negative) # seed_random = gr.Checkbox(label='Random', value=True) # image_seed = gr.Textbox(label='Seed', value=0, max_lines=1, visible=False) # workaround for https://github.com/gradio-app/gradio/issues/5354
# def random_checked(r): # return gr.update(visible=not r)
# def refresh_seed(r, seed_string): # if r: # return random.randint(constants.MIN_SEED, constants.MAX_SEED) # else: # try: # seed_value = int(seed_string) # if constants.MIN_SEED <= seed_value <= constants.MAX_SEED: # return seed_value # except ValueError: # pass # return random.randint(constants.MIN_SEED, constants.MAX_SEED)
# seed_random.change(random_checked, inputs=[seed_random], outputs=[image_seed], # queue=False, show_progress=False)
# def update_history_link(): # if args_manager.args.disable_image_log: # return gr.update(value='') # return gr.update(value=f'<a href="file={get_current_html_path(output_format)}" target="_blank">\U0001F4DA History Log</a>')
# history_link = gr.HTML() # shared.gradio_root.load(update_history_link, outputs=history_link, queue=False, show_progress=False)
# with gr.Tab(label='Style'): # style_sorter.try_load_sorted_styles( # style_names=legal_style_names, # default_selected=modules.config.default_styles)
# style_search_bar = gr.Textbox(show_label=False, container=False, # placeholder="\U0001F50E Type here to search styles ...", # value="", # label='Search Styles') # style_selections = gr.CheckboxGroup(show_label=False, container=False, # choices=copy.deepcopy(style_sorter.all_styles), # value=copy.deepcopy(modules.config.default_styles), # label='Selected Styles', # elem_classes=['style_selections']) # gradio_receiver_style_selections = gr.Textbox(elem_id='gradio_receiver_style_selections', visible=False)
# shared.gradio_root.load(lambda: gr.update(choices=copy.deepcopy(style_sorter.all_styles)), # outputs=style_selections)
# style_search_bar.change(style_sorter.search_styles, # inputs=[style_selections, style_search_bar], # outputs=style_selections, # queue=False, # show_progress=False).then( # lambda: None, _js='()=>{refresh_style_localization();}')
# gradio_receiver_style_selections.input(style_sorter.sort_styles, # inputs=style_selections, # outputs=style_selections, # queue=False, # show_progress=False).then( # lambda: None, _js='()=>{refresh_style_localization();}')
# with gr.Tab(label='Model'): # with gr.Group(): # with gr.Row(): # base_model = gr.Dropdown(label='Base Model (SDXL only)', choices=modules.config.model_filenames, value=modules.config.default_base_model_name, show_label=True) # 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)
# refiner_switch = gr.Slider(label='Refiner Switch At', minimum=0.1, maximum=1.0, step=0.0001, # info='Use 0.4 for SD1.5 realistic models; ' # 'or 0.667 for SD1.5 anime models; ' # 'or 0.8 for XL-refiners; ' # 'or any value for switching two SDXL models.', # value=modules.config.default_refiner_switch, # visible=modules.config.default_refiner_model_name != 'None')
# refiner_model.change(lambda x: gr.update(visible=x != 'None'), # inputs=refiner_model, outputs=refiner_switch, show_progress=False, queue=False)
# with gr.Group(): # lora_ctrls = []
# for i, (n, v) in enumerate(modules.config.default_loras): # with gr.Row(): # lora_enabled = gr.Checkbox(label='Enable', value=True, # elem_classes=['lora_enable', 'min_check'], scale=1) # lora_model = gr.Dropdown(label=f'LoRA {i + 1}', # choices=['None'] + modules.config.lora_filenames, value=n, # elem_classes='lora_model', scale=5) # lora_weight = gr.Slider(label='Weight', minimum=modules.config.default_loras_min_weight, # maximum=modules.config.default_loras_max_weight, step=0.01, value=v, # elem_classes='lora_weight', scale=5) # lora_ctrls += [lora_enabled, lora_model, lora_weight]
# with gr.Row(): # model_refresh = gr.Button(label='Refresh', value='\U0001f504 Refresh All Files', variant='secondary', elem_classes='refresh_button') # with gr.Tab(label='Advanced'): # guidance_scale = gr.Slider(label='Guidance Scale', minimum=1.0, maximum=30.0, step=0.01, # value=modules.config.default_cfg_scale, # info='Higher value means style is cleaner, vivider, and more artistic.') # sharpness = gr.Slider(label='Image Sharpness', minimum=0.0, maximum=30.0, step=0.001, # value=modules.config.default_sample_sharpness, # info='Higher value means image and texture are sharper.') # gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/117" target="_blank">\U0001F4D4 Document</a>') # dev_mode = gr.Checkbox(label='Developer Debug Mode', value=False, container=False)
# with gr.Column(visible=False) as dev_tools: # with gr.Tab(label='Debug Tools'): # adm_scaler_positive = gr.Slider(label='Positive ADM Guidance Scaler', minimum=0.1, maximum=3.0, # step=0.001, value=1.5, info='The scaler multiplied to positive ADM (use 1.0 to disable). ') # adm_scaler_negative = gr.Slider(label='Negative ADM Guidance Scaler', minimum=0.1, maximum=3.0, # step=0.001, value=0.8, info='The scaler multiplied to negative ADM (use 1.0 to disable). ') # adm_scaler_end = gr.Slider(label='ADM Guidance End At Step', minimum=0.0, maximum=1.0, # step=0.001, value=0.3, # info='When to end the guidance from positive/negative ADM. ')
# refiner_swap_method = gr.Dropdown(label='Refiner swap method', value=flags.refiner_swap_method, # choices=['joint', 'separate', 'vae'])
# adaptive_cfg = gr.Slider(label='CFG Mimicking from TSNR', minimum=1.0, maximum=30.0, step=0.01, # value=modules.config.default_cfg_tsnr, # info='Enabling Fooocus\'s implementation of CFG mimicking for TSNR ' # '(effective when real CFG > mimicked CFG).') # sampler_name = gr.Dropdown(label='Sampler', choices=flags.sampler_list, # value=modules.config.default_sampler) # scheduler_name = gr.Dropdown(label='Scheduler', choices=flags.scheduler_list, # value=modules.config.default_scheduler)
# generate_image_grid = gr.Checkbox(label='Generate Image Grid for Each Batch', # info='(Experimental) This may cause performance problems on some computers and certain internet conditions.', # value=False)
# overwrite_step = gr.Slider(label='Forced Overwrite of Sampling Step', # minimum=-1, maximum=200, step=1, # value=modules.config.default_overwrite_step, # info='Set as -1 to disable. For developer debugging.') # overwrite_switch = gr.Slider(label='Forced Overwrite of Refiner Switch Step', # minimum=-1, maximum=200, step=1, # value=modules.config.default_overwrite_switch, # info='Set as -1 to disable. For developer debugging.') # overwrite_width = gr.Slider(label='Forced Overwrite of Generating Width', # minimum=-1, maximum=2048, step=1, value=-1, # info='Set as -1 to disable. For developer debugging. ' # 'Results will be worse for non-standard numbers that SDXL is not trained on.') # overwrite_height = gr.Slider(label='Forced Overwrite of Generating Height', # minimum=-1, maximum=2048, step=1, value=-1, # info='Set as -1 to disable. For developer debugging. ' # 'Results will be worse for non-standard numbers that SDXL is not trained on.') # overwrite_vary_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Vary"', # minimum=-1, maximum=1.0, step=0.001, value=-1, # info='Set as negative number to disable. For developer debugging.') # overwrite_upscale_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Upscale"', # minimum=-1, maximum=1.0, step=0.001, value=-1, # info='Set as negative number to disable. For developer debugging.') # disable_preview = gr.Checkbox(label='Disable Preview', value=False, # info='Disable preview during generation.') # disable_intermediate_results = gr.Checkbox(label='Disable Intermediate Results', # value=modules.config.default_performance == 'Extreme Speed', # interactive=modules.config.default_performance != 'Extreme Speed', # info='Disable intermediate results during generation, only show final gallery.') # disable_seed_increment = gr.Checkbox(label='Disable seed increment', # info='Disable automatic seed increment when image number is > 1.', # value=False)
# # if not args_manager.args.disable_metadata: # # save_metadata_to_images = gr.Checkbox(label='Save Metadata to Images', value=modules.config.default_save_metadata_to_images, # # info='Adds parameters to generated images allowing manual regeneration.') # # metadata_scheme = gr.Radio(label='Metadata Scheme', choices=flags.metadata_scheme, value=modules.config.default_metadata_scheme, # # info='Image Prompt parameters are not included. Use png and a1111 for compatibility with Civitai.', # # visible=modules.config.default_save_metadata_to_images)
# # save_metadata_to_images.change(lambda x: gr.update(visible=x), inputs=[save_metadata_to_images], outputs=[metadata_scheme], # # queue=False, show_progress=False)
# # with gr.Tab(label='Control'): # # debugging_cn_preprocessor = gr.Checkbox(label='Debug Preprocessors', value=False, # # info='See the results from preprocessors.') # # skipping_cn_preprocessor = gr.Checkbox(label='Skip Preprocessors', value=False, # # info='Do not preprocess images. (Inputs are already canny/depth/cropped-face/etc.)')
# # mixing_image_prompt_and_vary_upscale = gr.Checkbox(label='Mixing Image Prompt and Vary/Upscale', # # value=False) # # mixing_image_prompt_and_inpaint = gr.Checkbox(label='Mixing Image Prompt and Inpaint', # # value=False)
# # controlnet_softness = gr.Slider(label='Softness of ControlNet', minimum=0.0, maximum=1.0, # # step=0.001, value=0.25, # # info='Similar to the Control Mode in A1111 (use 0.0 to disable). ')
# # with gr.Tab(label='Canny'): # # canny_low_threshold = gr.Slider(label='Canny Low Threshold', minimum=1, maximum=255, # # step=1, value=64) # # canny_high_threshold = gr.Slider(label='Canny High Threshold', minimum=1, maximum=255, # # step=1, value=128)
# # with gr.Tab(label='Inpaint'): # # debugging_inpaint_preprocessor = gr.Checkbox(label='Debug Inpaint Preprocessing', value=False) # # inpaint_disable_initial_latent = gr.Checkbox(label='Disable initial latent in inpaint', value=False) # # inpaint_engine = gr.Dropdown(label='Inpaint Engine', # # value=modules.config.default_inpaint_engine_version, # # choices=flags.inpaint_engine_versions, # # info='Version of Fooocus inpaint model') # # inpaint_strength = gr.Slider(label='Inpaint Denoising Strength', # # minimum=0.0, maximum=1.0, step=0.001, value=1.0, # # info='Same as the denoising strength in A1111 inpaint. ' # # 'Only used in inpaint, not used in outpaint. ' # # '(Outpaint always use 1.0)') # # inpaint_respective_field = gr.Slider(label='Inpaint Respective Field', # # minimum=0.0, maximum=1.0, step=0.001, value=0.618, # # info='The area to inpaint. ' # # 'Value 0 is same as "Only Masked" in A1111. ' # # 'Value 1 is same as "Whole Image" in A1111. ' # # 'Only used in inpaint, not used in outpaint. ' # # '(Outpaint always use 1.0)') # # inpaint_erode_or_dilate = gr.Slider(label='Mask Erode or Dilate', # # minimum=-64, maximum=64, step=1, value=0, # # info='Positive value will make white area in the mask larger, ' # # 'negative value will make white area smaller.' # # '(default is 0, always process before any mask invert)') # # inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=False) # # invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False)
# # inpaint_ctrls = [debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine, # # inpaint_strength, inpaint_respective_field, # # inpaint_mask_upload_checkbox, invert_mask_checkbox, inpaint_erode_or_dilate]
# # inpaint_mask_upload_checkbox.change(lambda x: gr.update(visible=x), # # inputs=inpaint_mask_upload_checkbox, # # outputs=inpaint_mask_image, queue=False, show_progress=False)
# with gr.Tab(label='FreeU'): # freeu_enabled = gr.Checkbox(label='Enabled', value=False) # freeu_b1 = gr.Slider(label='B1', minimum=0, maximum=2, step=0.01, value=1.01) # freeu_b2 = gr.Slider(label='B2', minimum=0, maximum=2, step=0.01, value=1.02) # freeu_s1 = gr.Slider(label='S1', minimum=0, maximum=4, step=0.01, value=0.99) # freeu_s2 = gr.Slider(label='S2', minimum=0, maximum=4, step=0.01, value=0.95) # freeu_ctrls = [freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2]
# def dev_mode_checked(r): # return gr.update(visible=r)
# dev_mode.change(dev_mode_checked, inputs=[dev_mode], outputs=[dev_tools], # queue=False, show_progress=False)
# def model_refresh_clicked(): # modules.config.update_all_model_names() # results = [gr.update(choices=modules.config.model_filenames)] # results += [gr.update(choices=['None'] + modules.config.model_filenames)] # for i in range(modules.config.default_max_lora_number): # results += [gr.update(interactive=True), gr.update(choices=['None'] + modules.config.lora_filenames), gr.update()] # return results
# model_refresh.click(model_refresh_clicked, [], [base_model, refiner_model] + lora_ctrls, # queue=False, show_progress=False)
# performance_selection.change(lambda x: [gr.update(interactive=x != 'Extreme Speed')] * 11 + # [gr.update(visible=x != 'Extreme Speed')] * 1 + # [gr.update(interactive=x != 'Extreme Speed', value=x == 'Extreme Speed', )] * 1, # inputs=performance_selection, # outputs=[ # guidance_scale, sharpness, adm_scaler_end, adm_scaler_positive, # adm_scaler_negative, refiner_switch, refiner_model, sampler_name, # scheduler_name, adaptive_cfg, refiner_swap_method, negative_prompt, disable_intermediate_results # ], queue=False, show_progress=False) # output_format.input(lambda x: gr.update(output_format=x), inputs=output_format) # advanced_checkbox.change(lambda x: gr.update(visible=x), advanced_checkbox, advanced_column, # queue=False, show_progress=False) \ # .then(fn=lambda: None, _js='refresh_grid_delayed', queue=False, show_progress=False)
# def inpaint_mode_change(mode): # assert mode in modules.flags.inpaint_options
# # inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts, # # inpaint_disable_initial_latent, inpaint_engine, # # inpaint_strength, inpaint_respective_field
# if mode == modules.flags.inpaint_option_detail: # return [ # gr.update(visible=True), gr.update(visible=False, value=[]), # gr.Dataset.update(visible=True, samples=modules.config.example_inpaint_prompts), # False, 'None', 0.5, 0.0 # ]
# if mode == modules.flags.inpaint_option_modify: # return [ # gr.update(visible=True), gr.update(visible=False, value=[]), # gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts), # True, modules.config.default_inpaint_engine_version, 1.0, 0.0 # ]
# return [ # gr.update(visible=False, value=''), gr.update(visible=True), # gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts), # False, modules.config.default_inpaint_engine_version, 1.0, 0.618 # ]
# inpaint_mode.input(inpaint_mode_change, inputs=inpaint_mode, outputs=[ # inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts, # inpaint_disable_initial_latent, inpaint_engine, # inpaint_strength, inpaint_respective_field # ], show_progress=False, queue=False)
# ctrls = [currentTask, generate_image_grid] # ctrls += [ # prompt, negative_prompt, style_selections, # performance_selection, aspect_ratios_selection, image_number, output_format, image_seed, sharpness, guidance_scale # ]
# ctrls += [base_model, refiner_model, refiner_switch] + lora_ctrls # # ctrls += [input_image_checkbox, current_tab] # # ctrls += [uov_method, uov_input_image] # # ctrls += [outpaint_selections, inpaint_input_image, inpaint_additional_prompt, inpaint_mask_image] # ctrls += [disable_preview, disable_intermediate_results, disable_seed_increment] # ctrls += [adm_scaler_positive, adm_scaler_negative, adm_scaler_end, adaptive_cfg] # ctrls += [sampler_name, scheduler_name] # ctrls += [overwrite_step, overwrite_switch, overwrite_width, overwrite_height, overwrite_vary_strength] # ctrls += [overwrite_upscale_strength, mixing_image_prompt_and_vary_upscale, mixing_image_prompt_and_inpaint] # ctrls += [debugging_cn_preprocessor, skipping_cn_preprocessor, canny_low_threshold, canny_high_threshold] # ctrls += [refiner_swap_method, controlnet_softness] # ctrls += freeu_ctrls # ctrls += inpaint_ctrls
# if not args_manager.args.disable_metadata: # ctrls += [save_metadata_to_images, metadata_scheme]
# ctrls += ip_ctrls
# state_is_generating = gr.State(False)
# def parse_meta(raw_prompt_txt, is_generating): # loaded_json = None # if is_json(raw_prompt_txt): # loaded_json = json.loads(raw_prompt_txt)
# if loaded_json is None: # if is_generating: # return gr.update(), gr.update(), gr.update() # else: # return gr.update(), gr.update(visible=True), gr.update(visible=False)
# return json.dumps(loaded_json), gr.update(visible=False), gr.update(visible=True)
# prompt.input(parse_meta, inputs=[prompt, state_is_generating], outputs=[prompt, generate_button, load_parameter_button], queue=False, show_progress=False)
# load_data_outputs = [advanced_checkbox, image_number, prompt, negative_prompt, style_selections, # performance_selection, overwrite_step, overwrite_switch, aspect_ratios_selection, # overwrite_width, overwrite_height, guidance_scale, sharpness, adm_scaler_positive, # adm_scaler_negative, adm_scaler_end, refiner_swap_method, adaptive_cfg, base_model, # refiner_model, refiner_switch, sampler_name, scheduler_name, seed_random, image_seed, # generate_button, load_parameter_button] + freeu_ctrls + lora_ctrls
# 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)
# # def trigger_metadata_import(filepath, state_is_generating): # # parameters, metadata_scheme = modules.meta_parser.read_info_from_image(filepath) # # if parameters is None: # # print('Could not find metadata in the image!') # # parsed_parameters = {} # # else: # # metadata_parser = modules.meta_parser.get_metadata_parser(metadata_scheme) # # parsed_parameters = metadata_parser.parse_json(parameters)
# # return modules.meta_parser.load_parameter_button_click(parsed_parameters, state_is_generating)
# # metadata_import_button.click(trigger_metadata_import, inputs=[metadata_input_image, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=True) \ # # .then(style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False)
# generate_button.click(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), [], True), # outputs=[stop_button, skip_button, generate_button, gallery, state_is_generating]) \ # .then(fn=refresh_seed, inputs=[seed_random, image_seed], outputs=image_seed) \ # .then(fn=get_task, inputs=ctrls, outputs=currentTask) \ # .then(fn=generate_clicked, inputs=currentTask, outputs=[progress_html, progress_window, progress_gallery, gallery]) \ # .then(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), gr.update(visible=False, interactive=False), False), # outputs=[generate_button, stop_button, skip_button, state_is_generating]) \ # .then(fn=update_history_link, outputs=history_link) \ # .then(fn=lambda: None, _js='playNotification').then(fn=lambda: None, _js='refresh_grid_delayed')
for notification_file in ['notification.ogg', 'notification.mp3']: if os.path.exists(notification_file): gr.Audio(interactive=False, value=notification_file, elem_id='audio_notification', visible=False) break
def trigger_describe(mode, img): if mode == flags.desc_type_photo: from extras.interrogate import default_interrogator as default_interrogator_photo return default_interrogator_photo(img), ["Fooocus V2", "Fooocus Enhance", "Fooocus Sharp"] if mode == flags.desc_type_anime: from extras.wd14tagger import default_interrogator as default_interrogator_anime return default_interrogator_anime(img), ["Fooocus V2", "Fooocus Masterpiece"] return mode, ["Fooocus V2"]
desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image], outputs=prompt, show_progress=True, queue=True)
def dump_default_english_config(): from modules.localization import dump_english_config dump_english_config(grh.all_components)
# dump_default_english_config()
shared.gradio_root.launch( inbrowser=args_manager.args.in_browser, server_name=args_manager.args.listen, server_port=args_manager.args.port, share=args_manager.args.share, auth=check_auth if (args_manager.args.share or args_manager.args.listen) and auth_enabled else None, allowed_paths=[modules.config.path_outputs], blocked_paths=[constants.AUTH_FILENAME])123456<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/4.21.0/gradio.js"></script>
<gradio-app src="https://Adityadn-test.hf.space"></gradio-app>12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import ldm_patched.modules.args_parser as args_parserimport os
from tempfile import gettempdir
args_parser.parser.add_argument("--share", action='store_true', help="Set whether to share on Gradio.")args_parser.parser.add_argument("--preset", type=str, default=None, help="Apply specified UI preset.")
args_parser.parser.add_argument("--language", type=str, default='default', help="Translate UI using json files in [language] folder. " "For example, [--language example] will use [language/example.json] for translation.")
# For example, https://github.com/lllyasviel/Fooocus/issues/849args_parser.parser.add_argument("--disable-offload-from-vram", action="store_true", help="Force loading models to vram when the unload can be avoided. " "Some Mac users may need this.")
args_parser.parser.add_argument("--theme", type=str, help="launches the UI with light or dark theme", default=None)args_parser.parser.add_argument("--disable-image-log", action='store_true', help="Prevent writing images and logs to hard drive.")
args_parser.parser.add_argument("--disable-analytics", action='store_true', help="Disables analytics for Gradio.")
args_parser.parser.add_argument("--disable-metadata", action='store_true', help="Disables saving metadata to images.")
args_parser.parser.add_argument("--disable-preset-download", action='store_true', help="Disables downloading models for presets", default=False)
args_parser.parser.add_argument("--always-download-new-model", action='store_true', help="Always download newer models ", default=False)
args_parser.parser.set_defaults( disable_cuda_malloc=True, in_browser=True, port=None)
args_parser.args = args_parser.parser.parse_args()
# (Disable by default because of issues like https://github.com/lllyasviel/Fooocus/issues/724)args_parser.args.always_offload_from_vram = not args_parser.args.disable_offload_from_vram
if args_parser.args.disable_analytics: import os os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
if args_parser.args.disable_in_browser: args_parser.args.in_browser = False
if args_parser.args.temp_path is None: args_parser.args.temp_path = os.path.join(gettempdir(), 'Fooocus')
args = args_parser.args123456[ { "user": "sitting-duck-1", "pass": "very-bad-publicly-known-password-change-it" }]1234567891011121314151617181920212223242526import os
win32_root = os.path.dirname(os.path.dirname(__file__))python_embeded_path = os.path.join(win32_root, 'python_embeded')
is_win32_standalone_build = os.path.exists(python_embeded_path) and os.path.isdir(python_embeded_path)
win32_cmd = '''.\python_embeded\python.exe -s Fooocus\entry_with_update.py {cmds} %*pause'''
def build_launcher(): if not is_win32_standalone_build: return
presets = [None, 'anime', 'realistic']
for preset in presets: win32_cmd_preset = win32_cmd.replace('{cmds}', '' if preset is None else f'--preset {preset}') bat_path = os.path.join(win32_root, 'run.bat' if preset is None else f'run_{preset}.bat') if not os.path.exists(bat_path): with open(bat_path, "w", encoding="utf-8") as f: f.write(win32_cmd_preset) return12345678910111213141516{ "path_checkpoints": [ "models\\checkpoints" ], "path_loras": [ "models\\loras" ], "path_embeddings": "models\\embeddings", "path_vae_approx": "models\\vae_approx", "path_upscale_models": "models\\upscale_models", "path_inpaint": "models\\inpaint", "path_controlnet": "models\\controlnet", "path_clip_vision": "models\\clip_vision", "path_fooocus_expansion": "models\\prompt_expansion\\fooocus_expansion", "path_outputs": "outputs"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123You 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.Do not modify this file. Modifications in this file will not take effect.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.Remember to split the paths with "\\" rather than "\", and there is no "," before the last "}".
{ "path_checkpoints": [ "models\\checkpoints" ], "path_loras": [ "models\\loras" ], "path_embeddings": "models\\embeddings", "path_vae_approx": "models\\vae_approx", "path_upscale_models": "models\\upscale_models", "path_inpaint": "models\\inpaint", "path_controlnet": "models\\controlnet", "path_clip_vision": "models\\clip_vision", "path_fooocus_expansion": "models\\prompt_expansion\\fooocus_expansion", "path_outputs": "outputs", "default_model": "juggernautXL_v8Rundiffusion.safetensors", "previous_default_models": [ "juggernautXL_version8Rundiffusion.safetensors", "juggernautXL_version7Rundiffusion.safetensors", "juggernautXL_v7Rundiffusion.safetensors", "juggernautXL_version6Rundiffusion.safetensors", "juggernautXL_v6Rundiffusion.safetensors" ], "default_refiner": "None", "default_refiner_switch": 0.5, "default_loras_min_weight": -2, "default_loras_max_weight": 2, "default_loras": [ [ "sd_xl_offset_example-lora_1.0.safetensors", 0.1 ], [ "None", 1.0 ], [ "None", 1.0 ], [ "None", 1.0 ], [ "None", 1.0 ] ], "default_max_lora_number": 5, "default_cfg_scale": 4.0, "default_sample_sharpness": 2.0, "default_sampler": "dpmpp_2m_sde_gpu", "default_scheduler": "karras", "default_styles": [ "Fooocus V2", "Fooocus Enhance", "Fooocus Sharp" ], "default_prompt_negative": "", "default_prompt": "", "default_performance": "Speed", "default_advanced_checkbox": false, "default_max_image_number": 32, "default_output_format": "png", "default_image_number": 2, "checkpoint_downloads": { "juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors" }, "lora_downloads": { "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" }, "embeddings_downloads": {}, "available_aspect_ratios": [ "704*1408", "704*1344", "768*1344", "768*1280", "832*1216", "832*1152", "896*1152", "896*1088", "960*1088", "960*1024", "1024*1024", "1024*960", "1088*960", "1088*896", "1152*896", "1152*832", "1216*832", "1280*768", "1344*768", "1344*704", "1408*704", "1472*704", "1536*640", "1600*640", "1664*576", "1728*576" ], "default_aspect_ratio": "1152*896", "default_inpaint_engine_version": "v2.6", "default_cfg_tsnr": 7.0, "default_overwrite_step": -1, "default_overwrite_switch": -1, "example_inpaint_prompts": [ "highly detailed face", "detailed girl face", "detailed man face", "detailed hand", "beautiful eyes" ], "default_save_metadata_to_images": false, "default_metadata_scheme": "fooocus", "metadata_created_by": ""}1234567891011121314151617181920212223242526272829303132333435363738version: '3.9'
volumes: fooocus-data:
services: app: build: . image: fooocus ports: - "7865:7865" environment: - CMDARGS=--listen # Arguments for launch.py. - DATADIR=/content/data # Directory which stores models, outputs dir - config_path=/content/data/config.txt - config_example_path=/content/data/config_modification_tutorial.txt - path_checkpoints=/content/data/models/checkpoints/ - path_loras=/content/data/models/loras/ - path_embeddings=/content/data/models/embeddings/ - path_vae_approx=/content/data/models/vae_approx/ - path_upscale_models=/content/data/models/upscale_models/ - path_inpaint=/content/data/models/inpaint/ - path_controlnet=/content/data/models/controlnet/ - path_clip_vision=/content/data/models/clip_vision/ - path_fooocus_expansion=/content/data/models/prompt_expansion/fooocus_expansion/ - path_outputs=/content/app/outputs/ # Warning: If it is not located under '/content/app', you can't see history log! volumes: - fooocus-data:/content/data #- ./models:/import/models # Once you import files, you don't need to mount again. #- ./outputs:/import/outputs # Once you import files, you don't need to mount again. tty: true deploy: resources: reservations: devices: - driver: nvidia device_ids: ['0'] capabilities: [compute, utility]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566# Fooocus on Docker
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.
## Quick start
**This is just an easy way for testing. Please find more information in the [notes](#notes).**
1. Clone this repository2. Build the image with `docker compose build`3. Run the docker container with `docker compose up`. Building the image takes some time.
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.
Your models and outputs are stored in the `fooocus-data` volume, which, depending on OS, is stored in `/var/lib/docker/volumes`.
## Details
### Update the container manually
When you are using `docker compose up` continuously, the container is not updated to the latest version of Fooocus automatically.Run `git pull` before executing `docker compose build --no-cache` to build an image with the latest Fooocus version.You can then start it with `docker compose up`
### Import models, outputsIf 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):```#- ./models:/import/models # Once you import files, you don't need to mount again.#- ./outputs:/import/outputs # Once you import files, you don't need to mount again.```After running `docker compose up`, your files will be copied into `/content/data/models` and `/content/data/outputs`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.
### Paths inside the container
|Path|Details||-|-||/content/app|The application stored folder||/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.) ||/content/data|Persistent volume mount point||/content/data/models|The folder is symlinked to '/content/app/models'||/content/data/outputs|The folder is symlinked to '/content/app/outputs'|
### Environments
You can change `config.txt` parameters by using environment variables.**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`**
Docker specified environments are there. They are used by 'entrypoint.sh'|Environment|Details||-|-||DATADIR|'/content/data' location.||CMDARGS|Arguments for [entry_with_update.py](entry_with_update.py) which is called by [entrypoint.sh](entrypoint.sh)||config_path|'config.txt' location||config_example_path|'config_modification_tutorial.txt' location|
You can also use the same json key names and values explained in the 'config_modification_tutorial.txt' as the environments.See examples in the [docker-compose.yml](docker-compose.yml)
## Notes
- Please keep 'path_outputs' under '/content/app'. Otherwise, you may get an error when you open the history log.- 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".- 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- 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.12345678910111213141516171819202122232425262728293031323334353637383940414243444546import osimport sys
root = os.path.dirname(os.path.abspath(__file__))sys.path.append(root)os.chdir(root)
try: import pygit2 pygit2.option(pygit2.GIT_OPT_SET_OWNER_VALIDATION, 0)
repo = pygit2.Repository(os.path.abspath(os.path.dirname(__file__)))
branch_name = repo.head.shorthand
remote_name = 'origin' remote = repo.remotes[remote_name]
remote.fetch()
local_branch_ref = f'refs/heads/{branch_name}' local_branch = repo.lookup_reference(local_branch_ref)
remote_reference = f'refs/remotes/{remote_name}/{branch_name}' remote_commit = repo.revparse_single(remote_reference)
merge_result, _ = repo.merge_analysis(remote_commit.id)
if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE: print("Already up-to-date") elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD: local_branch.set_target(remote_commit.id) repo.head.set_target(remote_commit.id) repo.checkout_tree(repo.get(remote_commit.id)) repo.reset(local_branch.target, pygit2.GIT_RESET_HARD) print("Fast-forward merge") elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL: print("Update failed - Did you modify any file?")except Exception as e: print('Update failed.') print(str(e))
print('Update succeeded.')from aiDescUI import *123456789101112131415161718192021222324252627282930313233#!/bin/bash
ORIGINALDIR=/content/app# Use predefined DATADIR if it is defined[[ x"${DATADIR}" == "x" ]] && DATADIR=/content/data
# Make persistent dir from original dirfunction mklink () { mkdir -p $DATADIR/$1 ln -s $DATADIR/$1 $ORIGINALDIR}
# Copy old files from import dirfunction import () { (test -d /import/$1 && cd /import/$1 && cp -Rpn . $DATADIR/$1/)}
cd $ORIGINALDIR
# modelsmklink models# Copy original files(cd $ORIGINALDIR/models.org && cp -Rpn . $ORIGINALDIR/models/)# Import old filesimport models
# outputsmklink outputs# Import old filesimport outputs
# Start applicationpython launch.py $*1234567name: fooocuschannels: - defaultsdependencies: - python=3.10 - pip=23.0 - packaging12345678from modules.expansion import FooocusExpansion
expansion = FooocusExpansion()
text = 'a handsome man'
for i in range(64): print(expansion(text, seed=i))1234567import cv2import extras.face_crop as cropper
img = cv2.imread('lena.png')result = cropper.crop_image(img)cv2.imwrite('lena_result.png', result)12345678import cv2from extras.interrogate import default_interrogator as default_interrogator_photofrom extras.wd14tagger import default_interrogator as default_interrogator_anime
img = cv2.imread('./test_imgs/red_box.jpg')[:, :, ::-1].copy()print(default_interrogator_photo(img))img = cv2.imread('./test_imgs/miku.jpg')[:, :, ::-1].copy()print(default_interrogator_anime(img))1234567891011121314151617181920212223242526272829303132333435{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "id": "VjYy0F2gZIPR" }, "outputs": [], "source": [ "!pip install pygit2==1.12.2\n", "%cd /content\n", "!git clone https://github.com/lllyasviel/Fooocus.git\n", "%cd /content/Fooocus\n", "!python entry_with_update.py --share\n" ] } ], "metadata": { "accelerator": "GPU", "colab": { "gpuType": "T4", "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 0}1version = '2.2.1'123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127import osimport sysimport ssl
print('[System ARGV] ' + str(sys.argv))
root = os.path.dirname(os.path.abspath(__file__))sys.path.append(root)os.chdir(root)
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"os.environ["PYTORCH_MPS_HIGH_WATERMARK_RATIO"] = "0.0"if "GRADIO_SERVER_PORT" not in os.environ: os.environ["GRADIO_SERVER_PORT"] = "7865"
ssl._create_default_https_context = ssl._create_unverified_context
import platformimport fooocus_version
from build_launcher import build_launcherfrom modules.launch_util import is_installed, run, python, run_pip, requirements_metfrom modules.model_loader import load_file_from_url
REINSTALL_ALL = FalseTRY_INSTALL_XFORMERS = False
def prepare_environment(): torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu121") torch_command = os.environ.get('TORCH_COMMAND', f"pip install torch==2.1.0 torchvision==0.16.0 --extra-index-url {torch_index_url}") requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt")
print(f"Python {sys.version}") print(f"Fooocus version: {fooocus_version.version}")
if REINSTALL_ALL or not is_installed("torch") or not is_installed("torchvision"): run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
if TRY_INSTALL_XFORMERS: if REINSTALL_ALL or not is_installed("xformers"): xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.23') if platform.system() == "Windows": if platform.python_version().startswith("3.10"): run_pip(f"install -U -I --no-deps {xformers_package}", "xformers", live=True) else: print("Installation of xformers is not supported in this version of Python.") print( "You can also check this and build manually: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Xformers#building-xformers-on-windows-by-duckness") if not is_installed("xformers"): exit(0) elif platform.system() == "Linux": run_pip(f"install -U -I --no-deps {xformers_package}", "xformers")
if REINSTALL_ALL or not requirements_met(requirements_file): run_pip(f"install -r \"{requirements_file}\"", "requirements")
return
vae_approx_filenames = [ ('xlvaeapp.pth', 'https://huggingface.co/lllyasviel/misc/resolve/main/xlvaeapp.pth'), ('vaeapp_sd15.pth', 'https://huggingface.co/lllyasviel/misc/resolve/main/vaeapp_sd15.pt'), ('xl-to-v1_interposer-v3.1.safetensors', 'https://huggingface.co/lllyasviel/misc/resolve/main/xl-to-v1_interposer-v3.1.safetensors')]
def ini_args(): from args_manager import args return args
prepare_environment()build_launcher()args = ini_args()
if args.gpu_device_id is not None: os.environ['CUDA_VISIBLE_DEVICES'] = str(args.gpu_device_id) print("Set device to:", args.gpu_device_id)
from modules import config
def download_models(): for file_name, url in vae_approx_filenames: load_file_from_url(url=url, model_dir=config.path_vae_approx, file_name=file_name)
load_file_from_url( url='https://huggingface.co/lllyasviel/misc/resolve/main/fooocus_expansion.bin', model_dir=config.path_fooocus_expansion, file_name='pytorch_model.bin' )
if args.disable_preset_download: print('Skipped model download.') return
if not args.always_download_new_model: if not os.path.exists(os.path.join(config.paths_checkpoints[0], config.default_base_model_name)): for alternative_model_name in config.previous_default_models: if os.path.exists(os.path.join(config.paths_checkpoints[0], alternative_model_name)): print(f'You do not have [{config.default_base_model_name}] but you have [{alternative_model_name}].') print(f'Fooocus will use [{alternative_model_name}] to avoid downloading new models, ' f'but you are not using latest models.') print('Use --always-download-new-model to avoid fallback and always get new models.') config.checkpoint_downloads = {} config.default_base_model_name = alternative_model_name break
for file_name, url in config.checkpoint_downloads.items(): load_file_from_url(url=url, model_dir=config.paths_checkpoints[0], file_name=file_name) for file_name, url in config.embeddings_downloads.items(): load_file_from_url(url=url, model_dir=config.path_embeddings, file_name=file_name) for file_name, url in config.lora_downloads.items(): load_file_from_url(url=url, model_dir=config.paths_loras[0], file_name=file_name)
return
download_models()
from webui import *123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438<div align=center><img src="https://github.com/lllyasviel/Fooocus/assets/19834515/483fb86d-c9a2-4c20-997c-46dafc124f25">
**Non-cherry-picked** random batch by just typing two words "forest elf",
without any parameter tweaking, without any strange prompt tags.
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).
In the entire open source community, only Fooocus can achieve this level of **non-cherry-picked** quality.
</div>
# Fooocus
Fooocus is an image generating software (based on [Gradio](https://www.gradio.app/)).
Fooocus is a rethinking of Stable Diffusion and Midjourney’s designs:
* Learned from Stable Diffusion, the software is offline, open source, and free.
* Learned from Midjourney, the manual tweaking is not needed, and users only need to focus on the prompts and images.
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]`.
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).
`[1]` David Holz, 2019.
**Recently many fake websites exist on Google when you search “fooocus”. Do not trust those – here is the only official source of Fooocus.**
## [Installing Fooocus](#download)
# Moving from Midjourney to Fooocus
Using Fooocus is as easy as (probably easier than) Midjourney – but this does not mean we lack functionality. Below are the details.
| Midjourney | Fooocus || - | - || 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) || V1 V2 V3 V4 | Input Image -> Upscale or Variation -> Vary (Subtle) / Vary (Strong)|| U1 U2 U3 U4 | Input Image -> Upscale or Variation -> Upscale (1.5x) / Upscale (2x) || 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) || 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) || --style | Advanced -> Style || --stylize | Advanced -> Advanced -> Guidance || --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) || --quality | Advanced -> Quality || --repeat | Advanced -> Image Number || Multi Prompts (::) | Just use multiple lines of prompts || 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)" || --no | Advanced -> Negative Prompt || --ar | Advanced -> Aspect Ratios || InsightFace | Input Image -> Image Prompt -> Advanced -> FaceSwap || Describe | Input Image -> Describe |
We also have a few things borrowed from the best parts of LeonardoAI:
| LeonardoAI | Fooocus || - | - || Prompt Magic | Advanced -> Style -> Fooocus V2 || Advanced Sampler Parameters (like Contrast/Sharpness/etc) | Advanced -> Advanced -> Sampling Sharpness / etc || User-friendly ControlNets | Input Image -> Image Prompt -> Advanced |
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)
# Download
### Windows
You can directly download Fooocus with:
**[>>> Click here to download <<<](https://github.com/lllyasviel/Fooocus/releases/download/release/Fooocus_win64_2-1-831.7z)**
After you download the file, please uncompress it and then run the "run.bat".

The first time you launch the software, it will automatically download models:
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.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).
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).

If you already have these files, you can copy them to the above locations to speed up installation.
Note that if you see **"MetadataIncompleteBuffer" or "PytorchStreamReader"**, then your model files are corrupted. Please download models again.
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.

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/).
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:
<details><summary>Click here to see the image instructions. </summary>

**And make sure that you have at least 40GB free space on each drive if you still see "RuntimeError: CPUAllocator" !**
</details>
Please open an issue if you use similar devices but still cannot achieve acceptable performances.
Note that the [minimal requirement](#minimal-requirement) for different platforms is different.
See also the common problems and troubleshoots [here](troubleshoot.md).
### Colab
(Last tested - 2023 Dec 12)
| Colab | Info| --- | --- |[](https://colab.research.google.com/github/lllyasviel/Fooocus/blob/main/fooocus_colab.ipynb) | Fooocus Official
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.
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.
Thanks to [camenduru](https://github.com/camenduru)!
### Linux (Using Anaconda)
If you want to use Anaconda/Miniconda, you can
git clone https://github.com/lllyasviel/Fooocus.git cd Fooocus conda env create -f environment.yaml conda activate fooocus pip install -r requirements_versions.txt
Then download the models: download [default models](#models) to the folder "Fooocus\models\checkpoints". **Or let Fooocus automatically download the models** using the launcher:
conda activate fooocus python entry_with_update.py
Or, if you want to open a remote port, use
conda activate fooocus python entry_with_update.py --listen
Use `python entry_with_update.py --preset anime` or `python entry_with_update.py --preset realistic` for Fooocus Anime/Realistic Edition.
### Linux (Using Python Venv)
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
git clone https://github.com/lllyasviel/Fooocus.git cd Fooocus python3 -m venv fooocus_env source fooocus_env/bin/activate pip install -r requirements_versions.txt
See the above sections for model downloads. You can launch the software with:
source fooocus_env/bin/activate python entry_with_update.py
Or, if you want to open a remote port, use
source fooocus_env/bin/activate python entry_with_update.py --listen
Use `python entry_with_update.py --preset anime` or `python entry_with_update.py --preset realistic` for Fooocus Anime/Realistic Edition.
### Linux (Using native system Python)
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
git clone https://github.com/lllyasviel/Fooocus.git cd Fooocus pip3 install -r requirements_versions.txt
See the above sections for model downloads. You can launch the software with:
python3 entry_with_update.py
Or, if you want to open a remote port, use
python3 entry_with_update.py --listen
Use `python entry_with_update.py --preset anime` or `python entry_with_update.py --preset realistic` for Fooocus Anime/Realistic Edition.
### Linux (AMD GPUs)
Note that the [minimal requirement](#minimal-requirement) for different platforms is different.
Same with the above instructions. You need to change torch to the AMD version
pip uninstall torch torchvision torchaudio torchtext functorch xformers pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.6
AMD is not intensively tested, however. The AMD support is in beta.
Use `python entry_with_update.py --preset anime` or `python entry_with_update.py --preset realistic` for Fooocus Anime/Realistic Edition.
### Windows (AMD GPUs)
Note that the [minimal requirement](#minimal-requirement) for different platforms is different.
Same with Windows. Download the software and edit the content of `run.bat` as:
.\python_embeded\python.exe -m pip uninstall torch torchvision torchaudio torchtext functorch xformers -y .\python_embeded\python.exe -m pip install torch-directml .\python_embeded\python.exe -s Fooocus\entry_with_update.py --directml pause
Then run the `run.bat`.
AMD is not intensively tested, however. The AMD support is in beta.
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.
### Mac
Note that the [minimal requirement](#minimal-requirement) for different platforms is different.
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).
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.
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.1. Open the macOS Terminal app and clone this repository with `git clone https://github.com/lllyasviel/Fooocus.git`.1. Change to the new Fooocus directory, `cd Fooocus`.1. Create a new conda environment, `conda env create -f environment.yaml`.1. Activate your new conda environment, `conda activate fooocus`.1. Install the packages required by Fooocus, `pip install -r requirements_versions.txt`.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.
Use `python entry_with_update.py --preset anime` or `python entry_with_update.py --preset realistic` for Fooocus Anime/Realistic Edition.
### Docker
See [docker.md](docker.md)
### Download Previous Version
See the guidelines [here](https://github.com/lllyasviel/Fooocus/discussions/1405).
## Minimal Requirement
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.)
| Operating System | GPU | Minimal GPU Memory | Minimal System Memory | [System Swap](troubleshoot.md) | Note ||-------------------|------------------------------|------------------------------|---------------------------|--------------------------------|----------------------------------------------------------------------------|| Windows/Linux | Nvidia RTX 4XXX | 4GB | 8GB | Required | fastest || Windows/Linux | Nvidia RTX 3XXX | 4GB | 8GB | Required | usually faster than RTX 2XXX || Windows/Linux | Nvidia RTX 2XXX | 4GB | 8GB | Required | usually faster than GTX 1XXX || Windows/Linux | Nvidia GTX 1XXX | 8GB (* 6GB uncertain) | 8GB | Required | only marginally faster than CPU || Windows/Linux | Nvidia GTX 9XX | 8GB | 8GB | Required | faster or slower than CPU || Windows/Linux | Nvidia GTX < 9XX | Not supported | / | / | / || Windows | AMD GPU | 8GB (updated 2023 Dec 30) | 8GB | Required | via DirectML (* ROCm is on hold), about 3x slower than Nvidia RTX 3XXX || Linux | AMD GPU | 8GB | 8GB | Required | via ROCm, about 1.5x slower than Nvidia RTX 3XXX || Mac | M1/M2 MPS | Shared | Shared | Shared | about 9x slower than Nvidia RTX 3XXX || Windows/Linux/Mac | only use CPU | 0GB | 32GB | Required | about 17x slower than Nvidia RTX 3XXX |
* AMD GPU ROCm (on hold): The AMD is still working on supporting ROCm on Windows.
* Nvidia GTX 1XXX 6GB uncertain: Some people report 6GB success on GTX 10XX, but some other people report failure cases.
*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.*
## Troubleshoot
See the common problems [here](troubleshoot.md).
## Default Models<a name="models"></a>
Given different goals, the default models and configs of Fooocus are different:
| Task | Windows | Linux args | Main Model | Refiner | Config || --- | --- | --- | --- | --- |--------------------------------------------------------------------------------|| General | run.bat | | juggernautXL_v8Rundiffusion | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/default.json) || Realistic | run_realistic.bat | --preset realistic | realisticStockPhoto_v20 | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/realistic.json) || Anime | run_anime.bat | --preset anime | animaPencilXL_v100 | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/anime.json) |
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.
## UI Access and AuthenticationIn addition to running on localhost, Fooocus can also expose its UI in two ways: * Local UI listener: use `--listen` (specify port e.g. with `--port 8888`). * API access: use `--share` (registers an endpoint at `.gradio.live`).
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)).
## List of "Hidden" Tricks<a name="tech_list"></a>
The below things are already inside the software, and **users do not need to do anything about these**.
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).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!)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!)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.)5. We modified the style templates a bit and added the "cinematic-default".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.7. The parameters of samplers are carefully tuned.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.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.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.11. A carefully designed system for balancing multiple styles as well as prompt expansion.12. Using automatic1111's method to normalize prompt emphasizing. This significantly improves results when users directly copy prompts from civitai.13. The joint swap system of the refiner now also supports img2img and upscale in a seamless way.14. CFG Scale and TSNR correction (tuned for SDXL) when CFG is bigger than 10.
## Customization
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.
For example, an edited `Fooocus\config.txt` (this file will be generated after the first launch) may look like this:
```json{ "path_checkpoints": "D:\\Fooocus\\models\\checkpoints", "path_loras": "D:\\Fooocus\\models\\loras", "path_embeddings": "D:\\Fooocus\\models\\embeddings", "path_vae_approx": "D:\\Fooocus\\models\\vae_approx", "path_upscale_models": "D:\\Fooocus\\models\\upscale_models", "path_inpaint": "D:\\Fooocus\\models\\inpaint", "path_controlnet": "D:\\Fooocus\\models\\controlnet", "path_clip_vision": "D:\\Fooocus\\models\\clip_vision", "path_fooocus_expansion": "D:\\Fooocus\\models\\prompt_expansion\\fooocus_expansion", "path_outputs": "D:\\Fooocus\\outputs", "default_model": "realisticStockPhoto_v10.safetensors", "default_refiner": "", "default_loras": [["lora_filename_1.safetensors", 0.5], ["lora_filename_2.safetensors", 0.5]], "default_cfg_scale": 3.0, "default_sampler": "dpmpp_2m", "default_scheduler": "karras", "default_negative_prompt": "low quality", "default_positive_prompt": "", "default_styles": [ "Fooocus V2", "Fooocus Photograph", "Fooocus Negative" ]}```
Many other keys, formats, and examples are in `Fooocus\config_modification_tutorial.txt` (this file will be generated after the first launch).
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.
A safer way is just to try "run_anime.bat" or "run_realistic.bat" - they should already be good enough for different tasks.
~Note that `user_path_config.txt` is deprecated and will be removed soon.~ (Edit: it is already removed.)
### All CMD Flags
```entry_with_update.py [-h] [--listen [IP]] [--port PORT] [--disable-header-check [ORIGIN]] [--web-upload-size WEB_UPLOAD_SIZE] [--external-working-path PATH [PATH ...]] [--output-path OUTPUT_PATH] [--temp-path TEMP_PATH] [--cache-path CACHE_PATH] [--in-browser] [--disable-in-browser] [--gpu-device-id DEVICE_ID] [--async-cuda-allocation | --disable-async-cuda-allocation] [--disable-attention-upcast] [--all-in-fp32 | --all-in-fp16] [--unet-in-bf16 | --unet-in-fp16 | --unet-in-fp8-e4m3fn | --unet-in-fp8-e5m2] [--vae-in-fp16 | --vae-in-fp32 | --vae-in-bf16] [--clip-in-fp8-e4m3fn | --clip-in-fp8-e5m2 | --clip-in-fp16 | --clip-in-fp32] [--directml [DIRECTML_DEVICE]] [--disable-ipex-hijack] [--preview-option [none,auto,fast,taesd]] [--attention-split | --attention-quad | --attention-pytorch] [--disable-xformers] [--always-gpu | --always-high-vram | --always-normal-vram | --always-low-vram | --always-no-vram | --always-cpu [CPU_NUM_THREADS]] [--always-offload-from-vram] [--disable-server-log] [--debug-mode] [--is-windows-embedded-python] [--disable-server-info] [--share] [--preset PRESET] [--language LANGUAGE] [--disable-offload-from-vram] [--theme THEME] [--disable-image-log]```
## Advanced Features
[Click here to browse the advanced features.](https://github.com/lllyasviel/Fooocus/discussions/117)
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!
| Fooocus' forks || - || [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 ... |
See also [About Forking and Promotion of Forks](https://github.com/lllyasviel/Fooocus/discussions/699).
## Thanks
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!
## Update Log
The log is [here](update_log.md).
## Localization/Translation/I18N
**We need your help!** Please help translate Fooocus into international languages.
You can put json files in the `language` folder to translate the user interface.
For example, below is the content of `Fooocus/language/example.json`:
```json{ "Generate": "生成", "Input Image": "入力画像", "Advanced": "고급", "SAI 3D Model": "SAI 3D Modèle"}```
If you add `--language example` arg, Fooocus will read `Fooocus/language/example.json` to translate the UI.
For example, you can edit the ending line of Windows `run.bat` as
.\python_embeded\python.exe -s Fooocus\entry_with_update.py --language example
Or `run_anime.bat` as
.\python_embeded\python.exe -s Fooocus\entry_with_update.py --language example --preset anime
Or `run_realistic.bat` as
.\python_embeded\python.exe -s Fooocus\entry_with_update.py --language example --preset realistic
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!**
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.12345torch==2.0.1torchvision==0.15.2torchaudio==2.0.2torchtext==0.15.2torchdata==0.6.1123456789101112131415161718torchsde==0.2.5einops==0.4.1transformers==4.30.2safetensors==0.3.1accelerate==0.21.0pyyaml==6.0Pillow==9.2.0scipy==1.9.3tqdm==4.64.1psutil==5.9.5pytorch_lightning==1.9.4omegaconf==2.2.3gradio==3.41.2pygit2==1.12.2opencv-contrib-python==4.8.0.74httpx==0.24.1onnxruntime==1.16.3timm==0.9.21gradio_root = None123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279[ "Fooocus V2", "Fooocus Enhance", "Fooocus Sharp", "AI V2", "Fooocus Masterpiece", "Fooocus Photograph", "Fooocus Negative", "Fooocus Cinematic", "SAI 3D Model", "SAI Analog Film", "SAI Anime", "SAI Cinematic", "SAI Comic Book", "SAI Craft Clay", "SAI Digital Art", "SAI Enhance", "SAI Fantasy Art", "SAI Isometric", "SAI Line Art", "SAI Lowpoly", "SAI Neonpunk", "SAI Origami", "SAI Photographic", "SAI Pixel Art", "SAI Texture", "MRE Cinematic Dynamic", "MRE Spontaneous Picture", "MRE Artistic Vision", "MRE Dark Dream", "MRE Gloomy Art", "MRE Bad Dream", "MRE Underground", "MRE Surreal Painting", "MRE Dynamic Illustration", "MRE Undead Art", "MRE Elemental Art", "MRE Space Art", "MRE Ancient Illustration", "MRE Brave Art", "MRE Heroic Fantasy", "MRE Dark Cyberpunk", "MRE Lyrical Geometry", "MRE Sumi E Symbolic", "MRE Sumi E Detailed", "MRE Manga", "MRE Anime", "MRE Comic", "Ads Advertising", "Ads Automotive", "Ads Corporate", "Ads Fashion Editorial", "Ads Food Photography", "Ads Gourmet Food Photography", "Ads Luxury", "Ads Real Estate", "Ads Retail", "Artstyle Abstract", "Artstyle Abstract Expressionism", "Artstyle Art Deco", "Artstyle Art Nouveau", "Artstyle Constructivist", "Artstyle Cubist", "Artstyle Expressionist", "Artstyle Graffiti", "Artstyle Hyperrealism", "Artstyle Impressionist", "Artstyle Pointillism", "Artstyle Pop Art", "Artstyle Psychedelic", "Artstyle Renaissance", "Artstyle Steampunk", "Artstyle Surrealist", "Artstyle Typography", "Artstyle Watercolor", "Futuristic Biomechanical", "Futuristic Biomechanical Cyberpunk", "Futuristic Cybernetic", "Futuristic Cybernetic Robot", "Futuristic Cyberpunk Cityscape", "Futuristic Futuristic", "Futuristic Retro Cyberpunk", "Futuristic Retro Futurism", "Futuristic Sci Fi", "Futuristic Vaporwave", "Game Bubble Bobble", "Game Cyberpunk Game", "Game Fighting Game", "Game Gta", "Game Mario", "Game Minecraft", "Game Pokemon", "Game Retro Arcade", "Game Retro Game", "Game Rpg Fantasy Game", "Game Strategy Game", "Game Streetfighter", "Game Zelda", "Misc Architectural", "Misc Disco", "Misc Dreamscape", "Misc Dystopian", "Misc Fairy Tale", "Misc Gothic", "Misc Grunge", "Misc Horror", "Misc Kawaii", "Misc Lovecraftian", "Misc Macabre", "Misc Manga", "Misc Metropolis", "Misc Minimalist", "Misc Monochrome", "Misc Nautical", "Misc Space", "Misc Stained Glass", "Misc Techwear Fashion", "Misc Tribal", "Misc Zentangle", "Papercraft Collage", "Papercraft Flat Papercut", "Papercraft Kirigami", "Papercraft Paper Mache", "Papercraft Paper Quilling", "Papercraft Papercut Collage", "Papercraft Papercut Shadow Box", "Papercraft Stacked Papercut", "Papercraft Thick Layered Papercut", "Photo Alien", "Photo Film Noir", "Photo Glamour", "Photo Hdr", "Photo Iphone Photographic", "Photo Long Exposure", "Photo Neon Noir", "Photo Silhouette", "Photo Tilt Shift", "Cinematic Diva", "Abstract Expressionism", "Academia", "Action Figure", "Adorable 3D Character", "Adorable Kawaii", "Art Deco", "Art Nouveau", "Astral Aura", "Avant Garde", "Baroque", "Bauhaus Style Poster", "Blueprint Schematic Drawing", "Caricature", "Cel Shaded Art", "Character Design Sheet", "Classicism Art", "Color Field Painting", "Colored Pencil Art", "Conceptual Art", "Constructivism", "Cubism", "Dadaism", "Dark Fantasy", "Dark Moody Atmosphere", "Dmt Art Style", "Doodle Art", "Double Exposure", "Dripping Paint Splatter Art", "Expressionism", "Faded Polaroid Photo", "Fauvism", "Flat 2d Art", "Fortnite Art Style", "Futurism", "Glitchcore", "Glo Fi", "Googie Art Style", "Graffiti Art", "Harlem Renaissance Art", "High Fashion", "Idyllic", "Impressionism", "Infographic Drawing", "Ink Dripping Drawing", "Japanese Ink Drawing", "Knolling Photography", "Light Cheery Atmosphere", "Logo Design", "Luxurious Elegance", "Macro Photography", "Mandola Art", "Marker Drawing", "Medievalism", "Minimalism", "Neo Baroque", "Neo Byzantine", "Neo Futurism", "Neo Impressionism", "Neo Rococo", "Neoclassicism", "Op Art", "Ornate And Intricate", "Pencil Sketch Drawing", "Pop Art 2", "Rococo", "Silhouette Art", "Simple Vector Art", "Sketchup", "Steampunk 2", "Surrealism", "Suprematism", "Terragen", "Tranquil Relaxing Atmosphere", "Sticker Designs", "Vibrant Rim Light", "Volumetric Lighting", "Watercolor 2", "Whimsical And Playful", "Mk Chromolithography", "Mk Cross Processing Print", "Mk Dufaycolor Photograph", "Mk Herbarium", "Mk Punk Collage", "Mk Mosaic", "Mk Van Gogh", "Mk Coloring Book", "Mk Singer Sargent", "Mk Pollock", "Mk Basquiat", "Mk Andy Warhol", "Mk Halftone Print", "Mk Gond Painting", "Mk Albumen Print", "Mk Aquatint Print", "Mk Anthotype Print", "Mk Inuit Carving", "Mk Bromoil Print", "Mk Calotype Print", "Mk Color Sketchnote", "Mk Cibulak Porcelain", "Mk Alcohol Ink Art", "Mk One Line Art", "Mk Blacklight Paint", "Mk Carnival Glass", "Mk Cyanotype Print", "Mk Cross Stitching", "Mk Encaustic Paint", "Mk Embroidery", "Mk Gyotaku", "Mk Luminogram", "Mk Lite Brite Art", "Mk Mokume Gane", "Pebble Art", "Mk Palekh", "Mk Suminagashi", "Mk Scrimshaw", "Mk Shibori", "Mk Vitreous Enamel", "Mk Ukiyo E", "Mk Vintage Airline Poster", "Mk Vintage Travel Poster", "Mk Bauhaus Style", "Mk Afrofuturism", "Mk Atompunk", "Mk Constructivism", "Mk Chicano Art", "Mk De Stijl", "Mk Dayak Art", "Mk Fayum Portrait", "Mk Illuminated Manuscript", "Mk Kalighat Painting", "Mk Madhubani Painting", "Mk Pictorialism", "Mk Pichwai Painting", "Mk Patachitra Painting", "Mk Samoan Art Inspired", "Mk Tlingit Art", "Mk Adnate Style", "Mk Ron English Style", "Mk Shepard Fairey Style"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178Below are many common problems that people encountered:
### RuntimeError: CPUAllocator
See also the section: **System Swap**
### Model loaded, then paused, then nothing happens
See also the section: **System Swap**
### Segmentation Fault
See also the section: **System Swap**
### Aborted
See also the section: **System Swap**
### core dumped
See also the section: **System Swap**
### Killed
See also the section: **System Swap**
### ^C, then quit
See also the section: **System Swap**
### adm 2816, then stuck
See also the section: **System Swap**
### Connection errored out
See also the section: **System Swap**
### Error 1006
See also the section: **System Swap**
### WinError 10060
See also the section: **System Swap**
### Read timed out
See also the section: **System Swap**
### No error, but the console close in a flash. Cannot find any error.
See also the section: **System Swap**
### Model loading is extremely slow (more than 1 minute)
See also the section: **System Swap**
### System Swap
All above problems are caused by the fact that you do not have enough System Swap.
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.
(If you have more than 64GB RAM, then *perhaps* you do not need any System Swap, but we are not exactly sure about this.)
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.
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.
If you are using Windows, you can set Swap here:

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.
**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.
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.
Finally, note that you need to restart computer to activate any changes in system swap.
### MetadataIncompleteBuffer
See also the section: **Model corrupted**
### PytorchStreamReader failed
See also the section: **Model corrupted**
### Model corrupted
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.
### UserWarning: The operator 'aten::std_mean.correction' is not currently supported on the DML
This is a warning that you can ignore.
### Torch not compiled with CUDA enabled
You are not following the official installation guide.
Please do not trust those wrong tutorials on the internet, and please only trust the official installation guide.
### subprocess-exited-with-error
Please use python 3.10
Also, you are not following the official installation guide.
Please do not trust those wrong tutorials on the internet, and please only trust the official installation guide.
### SSL: CERTIFICATE_VERIFY_FAILED
Are you living in China? If yes, please consider turn off VPN, and/or try to download models manually.
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.
### CUDA kernel errors might be asynchronously reported at some other API call
A very small amount of devices does have this problem. The cause can be complicated but usually can be resolved after following these steps:
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.)2. Upgrade your Nvidia driver to the latest version. (Usually the version of your Nvidia driver should be 53X, not 3XX or 4XX.)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.4. If it still does not work, please open an issue for us to take a look.
### Found no NVIDIA driver on your system
Please upgrade your Nvidia Driver.
If you are using AMD, please follow official installation guide.
### NVIDIA driver too old
Please upgrade your Nvidia Driver.
### I am using Mac, the speed is very slow.
Some MAC users may need `--disable-offload-from-vram` to speed up model loading.
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.
### I am using Nvidia with 8GB VRAM, I get CUDA Out Of Memory
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).
### I am using Nvidia with 6GB VRAM, I get CUDA Out Of Memory
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).
### I am using Nvidia with 4GB VRAM with Float16 support, like RTX 3050, I get CUDA Out Of Memory
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).
### I am using Nvidia with 4GB VRAM without Float16 support, like GTX 960, I get CUDA Out Of Memory
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).
### I am using AMD GPU on Windows, I get CUDA Out Of Memory
Current AMD support is very experimental for Windows. If you see this, then perhaps you cannot use Fooocus on this device on Windows.
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.
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).
### I am using AMD GPU on Linux, I get CUDA Out Of Memory
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).
### I tried flags like --lowvram or --gpu-only or --bf16 or so on, and things are not getting any better?
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.
### Fooocus suddenly becomes very slow and I have not changed anything
Are you accidentally running two Fooocus at the same time?123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632# [2.2.1](https://github.com/lllyasviel/Fooocus/releases/tag/2.2.1)
* Fix some small bugs (e.g. image grid, upscale fast 2x, LoRA weight width in Firefox)* Allow prompt weights in array syntax* Add steps override and metadata scheme to history log
# [2.2.0](https://github.com/lllyasviel/Fooocus/releases/tag/2.2.0)
* Isolate every image generation to truly allow multi-user usage* Add array support, changes the main prompt when increasing the image number. Syntax: `[[red, green, blue]] flower` * Add optional metadata to images, allowing you to regenerate and modify them later with the same parameters * Now supports native PNG, JPG and WEBP image generation* Add Docker support
# [2.1.865](https://github.com/lllyasviel/Fooocus/releases/tag/2.1.865)
* Various bugfixes* Add authentication to --listen
# 2.1.864
* New model list. See also discussions.
# 2.1.861 (requested update)
(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.
* Show image preview in Style when mouse hover.
# 2.1.860 (requested update)
* Allow upload inpaint mask in developer mode.
# 2.1.857 (requested update)
* Begin to support 8GB AMD GPU on Windows.
# 2.1.854
* Add a button to copy parameters to clipboard in log.* Allow users to load parameters directly by pasting parameters to prompt.
# 2.1.853
* Add Marc K3nt3L's styles. Thanks [Marc K3nt3L](https://github.com/K3nt3L)!
# 2.1.852
* 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).
# 2.1.846
* 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.
# 2.1.843
* Many improvements to Canvas. Thanks CanvasZoom author!
# 2.1.841
* Backend maintain.* Fix some potential frozen after model mismatch.* Fix crash when cfg=1 when using anime preset.* Added some guidelines for troubleshoot the "CUDA kernel errors asynchronously" problem.* Fix inpaint device problem in `--always-gpu` mode.
# 2.1.839
* Maintained some computation codes in backend for efficiency.* Added a note about Seed Breaking Change.
**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).
# 2.1.837
* Fix some precision-related problems.
# 2.1.836
* Avoid blip tokenizer download from torch hub
# 2.1.831
* Input Image -> Describe (Midjourney Describe)
# 2.1.830
* SegmindVega support.
# 2.1.829
* Change SDE tree to CPU on AMD/DirectMl to avoid potential problems.
# 2.1.828
* Allow to disable gradio analytics.* Use html table in log.* fix some SSL problems.
# 2.1.826
* New backend.* FP8 support (see also the new cmd flag list in Readme, eg, --unet-in-fp8-e4m3fn and --unet-in-fp8-e5m2).* Fix some MPS problems.* GLoRA support.* Turbo scheduler.
# 2.1.823
(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.
* Fix some potential problem when LoRAs has clip keys and user want to load those LoRAs to refiners.
# 2.1.822
* New inpaint system (inpaint beta test ends).
# 2.1.821
* New UI for LoRAs.* Improved preset system: normalized preset keys and file names.* Improved session system: now multiple users can use one Fooocus at the same time without seeing others' results.* Improved some computation related to model precision.* Improved config loading system with user-friendly prints.
# 2.1.820
* support "--disable-image-log" to prevent writing images and logs to hard drive.
# 2.1.819
* Allow disabling preview in dev tools.
# 2.1.818
* Fix preset lora failed to load when the weight is exactly one.
# 2.1.817
* support "--theme dark" and "--theme light".* 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.
# 2.1.815
* Multiple loras in preset.
# 2.1.814
* 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.)
# 2.1.813
* Allow preset to set default inpaint engine.
# 2.1.812
* Allow preset to set default performance.* heunpp2 sampler.
# 2.1.810
* Added hints to config_modification_tutorial.txt* Removed user hacked aspect ratios in I18N english templates, but it will still be read like before.* fix some style sorting problem again (perhaps should try Gradio 4.0 later).* Refreshed I18N english templates with more keys.
# 2.1.809
* fix some sorting problem.
# 2.1.808
* Aspect ratios now show aspect ratios.* Added style search.* Added style sorting/ordering/favorites.
# 2.1.807
* Click on image to see it in full screen.
# 2.1.806
* Fix some lora problems related to clip.
# 2.1.805
* Responsive UI for small screens.* Added skip preprocessor in dev tools.
# 2.1.802
* Default inpaint engine changed to v2.6. You can still use inpaint engine v1 in dev tools.* Fix some VRAM problems.
# 2.1.799
* Added 'Extreme Speed' performance mode (based on LCM). The previous complicated settings are not needed now.
# 2.1.798
* 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.
# 2.1.797
* fixed some dependency problems with facexlib and filterpy.
# 2.1.793
* Added many javascripts to improve user experience. Now users with small screen will always see full canvas without needing to scroll.
# 2.1.790
* Face swap (in line with Midjourney InsightFace): Input Image -> Image Prompt -> Advanced -> FaceSwap* The performance is super high. Use it carefully and never use it in any illegal things!* 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.)
# 2.1.788
* Fixed some math problems in previous versions.* Inpaint engine v2.6 join the beta test of Fooocus inpaint models. Use it in dev tools -> inpaint engine -> v2.6 .
# 2.1.785
* 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.* The paths in `user_path_config.txt` will still be loaded in recent versions, but it will be removed soon.* 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.* The new `config.txt` will never save default values so the default value changes in scripts will not be prevented by old config files.
# 2.1.782
2.1.782 is mainly an update for a new LoRA system that supports both SDXL loras and SD1.5 loras.
Now when you load a lora, the following things will happen:
1. try to load the lora to the base model, if failed (model mismatch), then try to load the lora to refiner.2. try to load the lora to refiner, if failed (model mismatch) then do nothing.
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.
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.
# 2.1.781
(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.
* Disable refiner to speed up when new users mistakenly set same model to base and refiner.
# 2.1.779
* 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.
# 2.1.776
* Support Ctrl+Up/Down Arrow to change prompt emphasizing weights.
# 2.1.750
* New UI: now you can get each image during generating.
# 2.1.743
* Improved GPT2 by removing some tokens that may corrupt styles.
# 2.1.741
Style Updates:
* "Default (Slightly Cinematic)" as renamed to "Fooocus Cinematic".* "Default (Slightly Cinematic)" is canceled from default style selections. * Added "Fooocus Sharp". This style combines many CivitAI prompts that reduces SDXL blurry and improves sharpness in a relatively natural way.* 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.* "Fooocus Sharp" and "Fooocus Enhance" and "Fooocus V2" becomes the new default set of styles.* Removed the default text in the "negative prompt" input area since it is not necessary now.* You can reproduce previous results by using "Fooocus Cinematic".* "Fooocus Sharp" and "Fooocus Enhance" may undergo minor revision in future updates.
# 2.1.739
* Added support for authentication in --share mode (via auth.json).
# 2.1.737
* Allowed customizing resolutions in config.
Modifying this will make results worse if you do not understand how Positional Encoding works.
You have been warned.
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.
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.
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.
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.
Again, if you do not understand how Positional Encoding works, just do not change the resolution numbers.
# 2.1.735
* Fixed many problems related to torch autocast.
# 2.1.733
* Increased allowed random seed range.
# 2.1.728
* Fixed some potential numerical problems since 2.1.723
# 2.1.723
* Improve Fooocus Anime a bit by using better SD1.5 refining formulation.
# 2.1.722
* Now it is possible to translate 100% all texts in the UI.
# 2.1.721
* Added language/en.json to make translation easier.
# 2.1.720
* Added Canvas Zoom to inpaint canvas* Fixed the problem that image will be cropped in UI when the uploaded image is too wide.
# 2.1.719
* I18N
# 2.1.718
* Corrected handling dash in wildcard names, more wildcards (extended-color).
# 2.1.717
* Corrected displaying multi-line prompts in Private Log.
# 2.1.716
* Added support for nested wildcards, more wildcards (flower, color_flower).
# 2.1.714
* Fixed resolution problems.
# 2.1.712
* Cleaned up Private Log (most users won't need information about raw prompts).
# 2.1.711
* Added more information about prompts in Private Log.* Made wildcards in negative prompt use different seed.
# 2.1.710
* Added information about wildcards usage in console log.
# 2.1.709
* Allowed changing default values of advanced checkbox and image number.
# 2.1.707
* Updated Gradio to v3.41.2.
# 2.1.703
* Fixed many previous problems related to inpaint.
# 2.1.702
* Corrected reading empty negative prompt from config (it shouldn't turn into None).
# 2.1.701
* Updated FreeU node to v2 (gives less overcooked results).
# 2.1.699
* Disabled smart memory management (solves some memory issues).
# 2.1.698
* Added support for loading model files from subfolders.
# 2.1.696
* Improved wildcards implementation (using same wildcard multiple times will now return different values).
**(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.**
# 2.1.695 (requested emergency bug fix)
* Reduced 3.4GB RAM use when swapping base model.* Reduced 372MB VRAM use in VAE decoding after using control model in image prompt.* 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.
(2023 Oct 17) Announcement of update being paused.
# 2.1.693
* Putting custom styles before pre-defined styles.* 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).* Fixed some minor bugs in Fooocus Anime preset's prompt emphasizing of commas.* Supported and documented embedding grammar (and wildcards grammar). * This release is a relative stable version and many features are determined now.
# 2.1.687
* Added support for wildcards (using files from wildcards folder - try prompts like `__color__ sports car` with different seeds).
# 2.1.682
* Added support for custom styles (loaded from JSON files placed in sdxl_styles folder).
# 2.1.681
* Added support for generate hotkey (CTRL+ENTER).* Added support for generate forever (RMB on Generate button).* Added support for playing sound when generation is finished ('notification.ogg' or 'notification.mp3').
# 2.1.62
* Preset system. Added anime and realistic support.
# 2.1.52
* removed pygit2 dependency (expect auto update) so that people will never have permission denied problems.
# 2.1.50
* 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.
# 2.1.25
AMD support on Linux and Windows.
# 2.1.0
* Image Prompt* Finished the "Moving from Midjourney" Table
# 2.0.85
* Speed Up Again
# 2.0.80
* Improved the scheduling of ADM guidance and CFG mimicking for better visual quality in high frequency domain and small objects.
# 2.0.80
* Rework many patches and some UI details.* Speed up processing.* Move Colab to independent branch.* Implemented CFG Scale and TSNR correction when CFG is bigger than 10.* Implemented Developer Mode with more options to debug.
### 2.0.72
(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.
### 2.0.72
* Allow users to choose path of models.
### 2.0.65
* Inpaint model released.
### 2.0.50
* Variation/Upscale (Midjourney Toolbar) implemented.
### 2.0.16
* 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.* 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. * 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.
### 2.0.0
* V2 released.* completely rewrite text processing pipeline (higher image quality and prompt understanding).* support multi-style.* In 100 tests (prompts written by ChatGPT), V2 default results outperform V1 default results in 87 cases, evaluated by two human.* 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.* Because the above number is above 80%, we view this as a major update and directly jump to 2.0.0.* Some other things are renamed.
### 1.0.67
* Use dynamic weighting and lower weights for prompt expansion.
### 1.0.64
* Fixed a small OOM problem.
### 1.0.62
* Change prompt expansion to suffix mode for better balance of semantic and style (and debugging).
### 1.0.60
* Tune the balance between style and Prompt Expansion.
### 1.0.56
* Begin to use magic split.
### 1.0.55
* Minor changes of Prompt Expansion.
### 1.0.52
* Reduce the semantic corruption of Prompt Expansion.
### 1.0.51
* Speed up Prompt Expansion a bit.
### 1.0.50
* Prompt expansion and a "Raw mode" to turn it off (similar to Midjourney's "raw").
### 1.0.45
* Reworked SAG, removed unnecessary patch* Reworked anisotropic filters for faster compute.* Replaced with guided anisotropic filter for less distortion.
### 1.0.41
(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)
### 1.0.40
* 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.
### 1.0.39
* Reverted unstable changes between 1.0.37 and 1.0.38 .* Increased refiner steps to half of sampling steps.
### 1.0.36
* Change gaussian kernel to anisotropic kernel.
### 1.0.34
* Random seed restoring.
### 1.0.33
* Hide items in log when images are removed.
### 1.0.32
* Fooocus private log
### 1.0.31
* Fix typo and UI.
### 1.0.29
* Added "Advanced->Advanced->Advanced" block for future development.
### 1.0.29
* Fix overcook problem in 1.0.28
### 1.0.28
* SAG implemented
### 1.0.27
* Fix small problem in textbox css
### 1.0.25
* support sys.argv --listen --share --port
### 1.0.24
* Taller input textbox.
### 1.0.23
* Added some hints on linux after UI start so users know the App does not fail.
### 1.0.20
* Support linux.
### 1.0.20
* Speed-up text encoder.
### 1.0.20
* Re-write UI to use async codes: (1) for faster start, and (2) for better live preview.* Removed opencv dependency* Plan to support Linux soon
### 1.0.19
* Unlock to allow changing model.
### 1.0.17
* 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.)
### 1.0.16
* Implemented "Fooocus/outputs" folder for saving user results.* Ignored cv2 errors when preview fails.* Mentioned future AMD support in Readme.* Created this log.
### 1.0.15
Publicly available.
### 1.0.0
Initial Version.1234567891011121314{ "builds": [ { "src": "app.py", "use": "@vercel/python" } ], "routes": [ { "src": "./", "dest": "app.py" } ]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688import gradio as grimport randomimport osimport jsonimport timeimport sharedimport modules.configimport fooocus_versionimport modules.htmlimport modules.async_worker as workerimport modules.constants as constantsimport modules.flags as flagsimport modules.gradio_hijack as grhimport modules.style_sorter as style_sorterimport modules.meta_parserimport args_managerimport copy
from modules.sdxl_styles import legal_style_namesfrom modules.private_logger import get_current_html_pathfrom modules.ui_gradio_extensions import reload_javascriptfrom modules.auth import auth_enabled, check_authfrom modules.util import is_json
def get_task(*args): args = list(args) args.pop(0)
return worker.AsyncTask(args=args)
def generate_clicked(task): import ldm_patched.modules.model_management as model_management
with model_management.interrupt_processing_mutex: model_management.interrupt_processing = False # outputs=[progress_html, progress_window, progress_gallery, gallery] execution_start_time = time.perf_counter() finished = False
yield gr.update(visible=True, value=modules.html.make_progress_html(1, 'Waiting for task to start ...')), \ gr.update(visible=True, value=None), \ gr.update(visible=False, value=None), \ gr.update(visible=False)
worker.async_tasks.append(task)
while not finished: time.sleep(0.01) if len(task.yields) > 0: flag, product = task.yields.pop(0) if flag == 'preview':
# help bad internet connection by skipping duplicated preview if len(task.yields) > 0: # if we have the next item if task.yields[0][0] == 'preview': # if the next item is also a preview # print('Skipped one preview for better internet connection.') continue
percentage, title, image = product yield gr.update(visible=True, value=modules.html.make_progress_html(percentage, title)), \ gr.update(visible=True, value=image) if image is not None else gr.update(), \ gr.update(), \ gr.update(visible=False) if flag == 'results': yield gr.update(visible=True), \ gr.update(visible=True), \ gr.update(visible=True, value=product), \ gr.update(visible=False) if flag == 'finish': yield gr.update(visible=False), \ gr.update(visible=False), \ gr.update(visible=False), \ gr.update(visible=True, value=product) finished = True
# delete Fooocus temp images, only keep gradio temp images if args_manager.args.disable_image_log: for filepath in product: if isinstance(filepath, str) and os.path.exists(filepath): os.remove(filepath)
execution_time = time.perf_counter() - execution_start_time print(f'Total time: {execution_time:.2f} seconds') return
reload_javascript()
title = f'Fooocus {fooocus_version.version}'
if isinstance(args_manager.args.preset, str): title += ' ' + args_manager.args.preset
shared.gradio_root = gr.Blocks( title=title, css=modules.html.css).queue()
with shared.gradio_root: currentTask = gr.State(worker.AsyncTask(args=[])) with gr.Row(): with gr.Column(scale=2): with gr.Row(): progress_window = grh.Image(label='Preview', show_label=True, visible=False, height=768, elem_classes=['main_view']) progress_gallery = gr.Gallery(label='Finished Images', show_label=True, object_fit='contain', height=768, visible=False, elem_classes=['main_view', 'image_gallery']) progress_html = gr.HTML(value=modules.html.make_progress_html(32, 'Progress 32%'), visible=False, elem_id='progress-bar', elem_classes='progress-bar') gallery = gr.Gallery(label='Gallery', show_label=False, object_fit='contain', visible=True, height=768, elem_classes=['resizable_area', 'main_view', 'final_gallery', 'image_gallery'], elem_id='final_gallery') with gr.Row(elem_classes='type_row'): with gr.Column(scale=17): prompt = gr.Textbox(show_label=False, placeholder="Type prompt here or paste parameters.", elem_id='positive_prompt', container=False, autofocus=True, elem_classes='type_row', lines=1024)
default_prompt = modules.config.default_prompt if isinstance(default_prompt, str) and default_prompt != '': shared.gradio_root.load(lambda: default_prompt, outputs=prompt)
with gr.Column(scale=3, min_width=0): generate_button = gr.Button(label="Generate", value="Generate", elem_classes='type_row', elem_id='generate_button', visible=True) load_parameter_button = gr.Button(label="Load Parameters", value="Load Parameters", elem_classes='type_row', elem_id='load_parameter_button', visible=False) skip_button = gr.Button(label="Skip", value="Skip", elem_classes='type_row_half', visible=False) stop_button = gr.Button(label="Stop", value="Stop", elem_classes='type_row_half', elem_id='stop_button', visible=False)
def stop_clicked(currentTask): import ldm_patched.modules.model_management as model_management currentTask.last_stop = 'stop' if (currentTask.processing): model_management.interrupt_current_processing() return currentTask
def skip_clicked(currentTask): import ldm_patched.modules.model_management as model_management currentTask.last_stop = 'skip' if (currentTask.processing): model_management.interrupt_current_processing() return currentTask
stop_button.click(stop_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False, _js='cancelGenerateForever') skip_button.click(skip_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False) with gr.Row(elem_classes='advanced_check_row'): input_image_checkbox = gr.Checkbox(label='Input Image', value=False, container=False, elem_classes='min_check') advanced_checkbox = gr.Checkbox(label='Advanced', value=modules.config.default_advanced_checkbox, container=False, elem_classes='min_check') with gr.Row(visible=False) as image_input_panel: with gr.Tabs(): with gr.TabItem(label='Upscale or Variation') as uov_tab: with gr.Row(): with gr.Column(): uov_input_image = grh.Image(label='Drag above image to here', source='upload', type='numpy') with gr.Column(): uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list, value=flags.disabled) gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/390" target="_blank">\U0001F4D4 Document</a>') with gr.TabItem(label='Image Prompt') as ip_tab: with gr.Row(): ip_images = [] ip_types = [] ip_stops = [] ip_weights = [] ip_ctrls = [] ip_ad_cols = [] for _ in range(flags.controlnet_image_count): with gr.Column(): ip_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False, height=300) ip_images.append(ip_image) ip_ctrls.append(ip_image) with gr.Column(visible=False) as ad_col: with gr.Row(): default_end, default_weight = flags.default_parameters[flags.default_ip]
ip_stop = gr.Slider(label='Stop At', minimum=0.0, maximum=1.0, step=0.001, value=default_end) ip_stops.append(ip_stop) ip_ctrls.append(ip_stop)
ip_weight = gr.Slider(label='Weight', minimum=0.0, maximum=2.0, step=0.001, value=default_weight) ip_weights.append(ip_weight) ip_ctrls.append(ip_weight)
ip_type = gr.Radio(label='Type', choices=flags.ip_list, value=flags.default_ip, container=False) ip_types.append(ip_type) ip_ctrls.append(ip_type)
ip_type.change(lambda x: flags.default_parameters[x], inputs=[ip_type], outputs=[ip_stop, ip_weight], queue=False, show_progress=False) ip_ad_cols.append(ad_col) ip_advanced = gr.Checkbox(label='Advanced', value=False, container=False) 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>')
def ip_advance_checked(x): return [gr.update(visible=x)] * len(ip_ad_cols) + \ [flags.default_ip] * len(ip_types) + \ [flags.default_parameters[flags.default_ip][0]] * len(ip_stops) + \ [flags.default_parameters[flags.default_ip][1]] * len(ip_weights)
ip_advanced.change(ip_advance_checked, inputs=ip_advanced, outputs=ip_ad_cols + ip_types + ip_stops + ip_weights, queue=False, show_progress=False) with gr.TabItem(label='Inpaint or Outpaint') as inpaint_tab: with gr.Row(): 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') inpaint_mask_image = grh.Image(label='Mask Upload', source='upload', type='numpy', height=500, visible=False)
with gr.Row(): inpaint_additional_prompt = gr.Textbox(placeholder="Describe what you want to inpaint.", elem_id='inpaint_additional_prompt', label='Inpaint Additional Prompt', visible=False) outpaint_selections = gr.CheckboxGroup(choices=['Left', 'Right', 'Top', 'Bottom'], value=[], label='Outpaint Direction') inpaint_mode = gr.Dropdown(choices=modules.flags.inpaint_options, value=modules.flags.inpaint_option_default, label='Method') example_inpaint_prompts = gr.Dataset(samples=modules.config.example_inpaint_prompts, label='Additional Prompt Quick List', components=[inpaint_additional_prompt], visible=False) gr.HTML('* Powered by Fooocus Inpaint Engine <a href="https://github.com/lllyasviel/Fooocus/discussions/414" target="_blank">\U0001F4D4 Document</a>') example_inpaint_prompts.click(lambda x: x[0], inputs=example_inpaint_prompts, outputs=inpaint_additional_prompt, show_progress=False, queue=False) with gr.TabItem(label='Describe') as desc_tab: with gr.Row(): with gr.Column(): desc_input_image = grh.Image(label='Drag any image to here', source='upload', type='numpy') with gr.Column(): desc_method = gr.Radio( label='Content Type', choices=[flags.desc_type_photo, flags.desc_type_anime], value=flags.desc_type_photo) desc_btn = gr.Button(value='Describe this Image into Prompt') gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/1363" target="_blank">\U0001F4D4 Document</a>') with gr.TabItem(label='Metadata') as load_tab: with gr.Column(): metadata_input_image = grh.Image(label='Drag any image generated by Fooocus here', source='upload', type='filepath') metadata_json = gr.JSON(label='Metadata') metadata_import_button = gr.Button(value='Apply Metadata')
def trigger_metadata_preview(filepath): parameters, metadata_scheme = modules.meta_parser.read_info_from_image(filepath)
results = {} if parameters is not None: results['parameters'] = parameters
if isinstance(metadata_scheme, flags.MetadataScheme): results['metadata_scheme'] = metadata_scheme.value
return results
metadata_input_image.upload(trigger_metadata_preview, inputs=metadata_input_image, outputs=metadata_json, queue=False, show_progress=True)
switch_js = "(x) => {if(x){viewer_to_bottom(100);viewer_to_bottom(500);}else{viewer_to_top();} return x;}" down_js = "() => {viewer_to_bottom();}"
input_image_checkbox.change(lambda x: gr.update(visible=x), inputs=input_image_checkbox, outputs=image_input_panel, queue=False, show_progress=False, _js=switch_js) ip_advanced.change(lambda: None, queue=False, show_progress=False, _js=down_js)
current_tab = gr.Textbox(value='uov', visible=False) uov_tab.select(lambda: 'uov', outputs=current_tab, queue=False, _js=down_js, show_progress=False) inpaint_tab.select(lambda: 'inpaint', outputs=current_tab, queue=False, _js=down_js, show_progress=False) ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False) desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
with gr.Column(scale=1, visible=modules.config.default_advanced_checkbox) as advanced_column: with gr.Tab(label='Setting'): performance_selection = gr.Radio(label='Performance', choices=modules.flags.performance_selections, value=modules.config.default_performance) aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios, value=modules.config.default_aspect_ratio, info='width × height', elem_classes='aspect_ratios') image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number)
output_format = gr.Radio(label='Output Format', choices=modules.flags.output_formats, value=modules.config.default_output_format)
negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.", info='Describing what you do not want to see.', lines=2, elem_id='negative_prompt', value=modules.config.default_prompt_negative) seed_random = gr.Checkbox(label='Random', value=True) image_seed = gr.Textbox(label='Seed', value=0, max_lines=1, visible=False) # workaround for https://github.com/gradio-app/gradio/issues/5354
def random_checked(r): return gr.update(visible=not r)
def refresh_seed(r, seed_string): if r: return random.randint(constants.MIN_SEED, constants.MAX_SEED) else: try: seed_value = int(seed_string) if constants.MIN_SEED <= seed_value <= constants.MAX_SEED: return seed_value except ValueError: pass return random.randint(constants.MIN_SEED, constants.MAX_SEED)
seed_random.change(random_checked, inputs=[seed_random], outputs=[image_seed], queue=False, show_progress=False)
def update_history_link(): if args_manager.args.disable_image_log: return gr.update(value='') return gr.update(value=f'<a href="file={get_current_html_path(output_format)}" target="_blank">\U0001F4DA History Log</a>')
history_link = gr.HTML() shared.gradio_root.load(update_history_link, outputs=history_link, queue=False, show_progress=False)
with gr.Tab(label='Style'): style_sorter.try_load_sorted_styles( style_names=legal_style_names, default_selected=modules.config.default_styles)
style_search_bar = gr.Textbox(show_label=False, container=False, placeholder="\U0001F50E Type here to search styles ...", value="", label='Search Styles') style_selections = gr.CheckboxGroup(show_label=False, container=False, choices=copy.deepcopy(style_sorter.all_styles), value=copy.deepcopy(modules.config.default_styles), label='Selected Styles', elem_classes=['style_selections']) gradio_receiver_style_selections = gr.Textbox(elem_id='gradio_receiver_style_selections', visible=False)
shared.gradio_root.load(lambda: gr.update(choices=copy.deepcopy(style_sorter.all_styles)), outputs=style_selections)
style_search_bar.change(style_sorter.search_styles, inputs=[style_selections, style_search_bar], outputs=style_selections, queue=False, show_progress=False).then( lambda: None, _js='()=>{refresh_style_localization();}')
gradio_receiver_style_selections.input(style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False).then( lambda: None, _js='()=>{refresh_style_localization();}')
with gr.Tab(label='Model'): with gr.Group(): with gr.Row(): base_model = gr.Dropdown(label='Base Model (SDXL only)', choices=modules.config.model_filenames, value=modules.config.default_base_model_name, show_label=True) 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)
refiner_switch = gr.Slider(label='Refiner Switch At', minimum=0.1, maximum=1.0, step=0.0001, info='Use 0.4 for SD1.5 realistic models; ' 'or 0.667 for SD1.5 anime models; ' 'or 0.8 for XL-refiners; ' 'or any value for switching two SDXL models.', value=modules.config.default_refiner_switch, visible=modules.config.default_refiner_model_name != 'None')
refiner_model.change(lambda x: gr.update(visible=x != 'None'), inputs=refiner_model, outputs=refiner_switch, show_progress=False, queue=False)
with gr.Group(): lora_ctrls = []
for i, (n, v) in enumerate(modules.config.default_loras): with gr.Row(): lora_enabled = gr.Checkbox(label='Enable', value=True, elem_classes=['lora_enable', 'min_check'], scale=1) lora_model = gr.Dropdown(label=f'LoRA {i + 1}', choices=['None'] + modules.config.lora_filenames, value=n, elem_classes='lora_model', scale=5) lora_weight = gr.Slider(label='Weight', minimum=modules.config.default_loras_min_weight, maximum=modules.config.default_loras_max_weight, step=0.01, value=v, elem_classes='lora_weight', scale=5) lora_ctrls += [lora_enabled, lora_model, lora_weight]
with gr.Row(): model_refresh = gr.Button(label='Refresh', value='\U0001f504 Refresh All Files', variant='secondary', elem_classes='refresh_button') with gr.Tab(label='Advanced'): guidance_scale = gr.Slider(label='Guidance Scale', minimum=1.0, maximum=30.0, step=0.01, value=modules.config.default_cfg_scale, info='Higher value means style is cleaner, vivider, and more artistic.') sharpness = gr.Slider(label='Image Sharpness', minimum=0.0, maximum=30.0, step=0.001, value=modules.config.default_sample_sharpness, info='Higher value means image and texture are sharper.') gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/117" target="_blank">\U0001F4D4 Document</a>') dev_mode = gr.Checkbox(label='Developer Debug Mode', value=False, container=False)
with gr.Column(visible=False) as dev_tools: with gr.Tab(label='Debug Tools'): adm_scaler_positive = gr.Slider(label='Positive ADM Guidance Scaler', minimum=0.1, maximum=3.0, step=0.001, value=1.5, info='The scaler multiplied to positive ADM (use 1.0 to disable). ') adm_scaler_negative = gr.Slider(label='Negative ADM Guidance Scaler', minimum=0.1, maximum=3.0, step=0.001, value=0.8, info='The scaler multiplied to negative ADM (use 1.0 to disable). ') adm_scaler_end = gr.Slider(label='ADM Guidance End At Step', minimum=0.0, maximum=1.0, step=0.001, value=0.3, info='When to end the guidance from positive/negative ADM. ')
refiner_swap_method = gr.Dropdown(label='Refiner swap method', value=flags.refiner_swap_method, choices=['joint', 'separate', 'vae'])
adaptive_cfg = gr.Slider(label='CFG Mimicking from TSNR', minimum=1.0, maximum=30.0, step=0.01, value=modules.config.default_cfg_tsnr, info='Enabling Fooocus\'s implementation of CFG mimicking for TSNR ' '(effective when real CFG > mimicked CFG).') sampler_name = gr.Dropdown(label='Sampler', choices=flags.sampler_list, value=modules.config.default_sampler) scheduler_name = gr.Dropdown(label='Scheduler', choices=flags.scheduler_list, value=modules.config.default_scheduler)
generate_image_grid = gr.Checkbox(label='Generate Image Grid for Each Batch', info='(Experimental) This may cause performance problems on some computers and certain internet conditions.', value=False)
overwrite_step = gr.Slider(label='Forced Overwrite of Sampling Step', minimum=-1, maximum=200, step=1, value=modules.config.default_overwrite_step, info='Set as -1 to disable. For developer debugging.') overwrite_switch = gr.Slider(label='Forced Overwrite of Refiner Switch Step', minimum=-1, maximum=200, step=1, value=modules.config.default_overwrite_switch, info='Set as -1 to disable. For developer debugging.') overwrite_width = gr.Slider(label='Forced Overwrite of Generating Width', minimum=-1, maximum=2048, step=1, value=-1, info='Set as -1 to disable. For developer debugging. ' 'Results will be worse for non-standard numbers that SDXL is not trained on.') overwrite_height = gr.Slider(label='Forced Overwrite of Generating Height', minimum=-1, maximum=2048, step=1, value=-1, info='Set as -1 to disable. For developer debugging. ' 'Results will be worse for non-standard numbers that SDXL is not trained on.') overwrite_vary_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Vary"', minimum=-1, maximum=1.0, step=0.001, value=-1, info='Set as negative number to disable. For developer debugging.') overwrite_upscale_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Upscale"', minimum=-1, maximum=1.0, step=0.001, value=-1, info='Set as negative number to disable. For developer debugging.') disable_preview = gr.Checkbox(label='Disable Preview', value=False, info='Disable preview during generation.') disable_intermediate_results = gr.Checkbox(label='Disable Intermediate Results', value=modules.config.default_performance == 'Extreme Speed', interactive=modules.config.default_performance != 'Extreme Speed', info='Disable intermediate results during generation, only show final gallery.') disable_seed_increment = gr.Checkbox(label='Disable seed increment', info='Disable automatic seed increment when image number is > 1.', value=False)
if not args_manager.args.disable_metadata: save_metadata_to_images = gr.Checkbox(label='Save Metadata to Images', value=modules.config.default_save_metadata_to_images, info='Adds parameters to generated images allowing manual regeneration.') metadata_scheme = gr.Radio(label='Metadata Scheme', choices=flags.metadata_scheme, value=modules.config.default_metadata_scheme, info='Image Prompt parameters are not included. Use png and a1111 for compatibility with Civitai.', visible=modules.config.default_save_metadata_to_images)
save_metadata_to_images.change(lambda x: gr.update(visible=x), inputs=[save_metadata_to_images], outputs=[metadata_scheme], queue=False, show_progress=False)
with gr.Tab(label='Control'): debugging_cn_preprocessor = gr.Checkbox(label='Debug Preprocessors', value=False, info='See the results from preprocessors.') skipping_cn_preprocessor = gr.Checkbox(label='Skip Preprocessors', value=False, info='Do not preprocess images. (Inputs are already canny/depth/cropped-face/etc.)')
mixing_image_prompt_and_vary_upscale = gr.Checkbox(label='Mixing Image Prompt and Vary/Upscale', value=False) mixing_image_prompt_and_inpaint = gr.Checkbox(label='Mixing Image Prompt and Inpaint', value=False)
controlnet_softness = gr.Slider(label='Softness of ControlNet', minimum=0.0, maximum=1.0, step=0.001, value=0.25, info='Similar to the Control Mode in A1111 (use 0.0 to disable). ')
with gr.Tab(label='Canny'): canny_low_threshold = gr.Slider(label='Canny Low Threshold', minimum=1, maximum=255, step=1, value=64) canny_high_threshold = gr.Slider(label='Canny High Threshold', minimum=1, maximum=255, step=1, value=128)
with gr.Tab(label='Inpaint'): debugging_inpaint_preprocessor = gr.Checkbox(label='Debug Inpaint Preprocessing', value=False) inpaint_disable_initial_latent = gr.Checkbox(label='Disable initial latent in inpaint', value=False) inpaint_engine = gr.Dropdown(label='Inpaint Engine', value=modules.config.default_inpaint_engine_version, choices=flags.inpaint_engine_versions, info='Version of Fooocus inpaint model') inpaint_strength = gr.Slider(label='Inpaint Denoising Strength', minimum=0.0, maximum=1.0, step=0.001, value=1.0, info='Same as the denoising strength in A1111 inpaint. ' 'Only used in inpaint, not used in outpaint. ' '(Outpaint always use 1.0)') inpaint_respective_field = gr.Slider(label='Inpaint Respective Field', minimum=0.0, maximum=1.0, step=0.001, value=0.618, info='The area to inpaint. ' 'Value 0 is same as "Only Masked" in A1111. ' 'Value 1 is same as "Whole Image" in A1111. ' 'Only used in inpaint, not used in outpaint. ' '(Outpaint always use 1.0)') inpaint_erode_or_dilate = gr.Slider(label='Mask Erode or Dilate', minimum=-64, maximum=64, step=1, value=0, info='Positive value will make white area in the mask larger, ' 'negative value will make white area smaller.' '(default is 0, always process before any mask invert)') inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=False) invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False)
inpaint_ctrls = [debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine, inpaint_strength, inpaint_respective_field, inpaint_mask_upload_checkbox, invert_mask_checkbox, inpaint_erode_or_dilate]
inpaint_mask_upload_checkbox.change(lambda x: gr.update(visible=x), inputs=inpaint_mask_upload_checkbox, outputs=inpaint_mask_image, queue=False, show_progress=False)
with gr.Tab(label='FreeU'): freeu_enabled = gr.Checkbox(label='Enabled', value=False) freeu_b1 = gr.Slider(label='B1', minimum=0, maximum=2, step=0.01, value=1.01) freeu_b2 = gr.Slider(label='B2', minimum=0, maximum=2, step=0.01, value=1.02) freeu_s1 = gr.Slider(label='S1', minimum=0, maximum=4, step=0.01, value=0.99) freeu_s2 = gr.Slider(label='S2', minimum=0, maximum=4, step=0.01, value=0.95) freeu_ctrls = [freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2]
def dev_mode_checked(r): return gr.update(visible=r)
dev_mode.change(dev_mode_checked, inputs=[dev_mode], outputs=[dev_tools], queue=False, show_progress=False)
def model_refresh_clicked(): modules.config.update_all_model_names() results = [gr.update(choices=modules.config.model_filenames)] results += [gr.update(choices=['None'] + modules.config.model_filenames)] for i in range(modules.config.default_max_lora_number): results += [gr.update(interactive=True), gr.update(choices=['None'] + modules.config.lora_filenames), gr.update()] return results
model_refresh.click(model_refresh_clicked, [], [base_model, refiner_model] + lora_ctrls, queue=False, show_progress=False)
performance_selection.change(lambda x: [gr.update(interactive=x != 'Extreme Speed')] * 11 + [gr.update(visible=x != 'Extreme Speed')] * 1 + [gr.update(interactive=x != 'Extreme Speed', value=x == 'Extreme Speed', )] * 1, inputs=performance_selection, outputs=[ guidance_scale, sharpness, adm_scaler_end, adm_scaler_positive, adm_scaler_negative, refiner_switch, refiner_model, sampler_name, scheduler_name, adaptive_cfg, refiner_swap_method, negative_prompt, disable_intermediate_results ], queue=False, show_progress=False) output_format.input(lambda x: gr.update(output_format=x), inputs=output_format) advanced_checkbox.change(lambda x: gr.update(visible=x), advanced_checkbox, advanced_column, queue=False, show_progress=False) \ .then(fn=lambda: None, _js='refresh_grid_delayed', queue=False, show_progress=False)
def inpaint_mode_change(mode): assert mode in modules.flags.inpaint_options
# inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts, # inpaint_disable_initial_latent, inpaint_engine, # inpaint_strength, inpaint_respective_field
if mode == modules.flags.inpaint_option_detail: return [ gr.update(visible=True), gr.update(visible=False, value=[]), gr.Dataset.update(visible=True, samples=modules.config.example_inpaint_prompts), False, 'None', 0.5, 0.0 ]
if mode == modules.flags.inpaint_option_modify: return [ gr.update(visible=True), gr.update(visible=False, value=[]), gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts), True, modules.config.default_inpaint_engine_version, 1.0, 0.0 ]
return [ gr.update(visible=False, value=''), gr.update(visible=True), gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts), False, modules.config.default_inpaint_engine_version, 1.0, 0.618 ]
inpaint_mode.input(inpaint_mode_change, inputs=inpaint_mode, outputs=[ inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts, inpaint_disable_initial_latent, inpaint_engine, inpaint_strength, inpaint_respective_field ], show_progress=False, queue=False)
ctrls = [currentTask, generate_image_grid] ctrls += [ prompt, negative_prompt, style_selections, performance_selection, aspect_ratios_selection, image_number, output_format, image_seed, sharpness, guidance_scale ]
ctrls += [base_model, refiner_model, refiner_switch] + lora_ctrls ctrls += [input_image_checkbox, current_tab] ctrls += [uov_method, uov_input_image] ctrls += [outpaint_selections, inpaint_input_image, inpaint_additional_prompt, inpaint_mask_image] ctrls += [disable_preview, disable_intermediate_results, disable_seed_increment] ctrls += [adm_scaler_positive, adm_scaler_negative, adm_scaler_end, adaptive_cfg] ctrls += [sampler_name, scheduler_name] ctrls += [overwrite_step, overwrite_switch, overwrite_width, overwrite_height, overwrite_vary_strength] ctrls += [overwrite_upscale_strength, mixing_image_prompt_and_vary_upscale, mixing_image_prompt_and_inpaint] ctrls += [debugging_cn_preprocessor, skipping_cn_preprocessor, canny_low_threshold, canny_high_threshold] ctrls += [refiner_swap_method, controlnet_softness] ctrls += freeu_ctrls ctrls += inpaint_ctrls
if not args_manager.args.disable_metadata: ctrls += [save_metadata_to_images, metadata_scheme]
ctrls += ip_ctrls
state_is_generating = gr.State(False)
def parse_meta(raw_prompt_txt, is_generating): loaded_json = None if is_json(raw_prompt_txt): loaded_json = json.loads(raw_prompt_txt)
if loaded_json is None: if is_generating: return gr.update(), gr.update(), gr.update() else: return gr.update(), gr.update(visible=True), gr.update(visible=False)
return json.dumps(loaded_json), gr.update(visible=False), gr.update(visible=True)
prompt.input(parse_meta, inputs=[prompt, state_is_generating], outputs=[prompt, generate_button, load_parameter_button], queue=False, show_progress=False)
load_data_outputs = [advanced_checkbox, image_number, prompt, negative_prompt, style_selections, performance_selection, overwrite_step, overwrite_switch, aspect_ratios_selection, overwrite_width, overwrite_height, guidance_scale, sharpness, adm_scaler_positive, adm_scaler_negative, adm_scaler_end, refiner_swap_method, adaptive_cfg, base_model, refiner_model, refiner_switch, sampler_name, scheduler_name, seed_random, image_seed, generate_button, load_parameter_button] + freeu_ctrls + lora_ctrls
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)
def trigger_metadata_import(filepath, state_is_generating): parameters, metadata_scheme = modules.meta_parser.read_info_from_image(filepath) if parameters is None: print('Could not find metadata in the image!') parsed_parameters = {} else: metadata_parser = modules.meta_parser.get_metadata_parser(metadata_scheme) parsed_parameters = metadata_parser.parse_json(parameters)
return modules.meta_parser.load_parameter_button_click(parsed_parameters, state_is_generating)
metadata_import_button.click(trigger_metadata_import, inputs=[metadata_input_image, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=True) \ .then(style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False)
generate_button.click(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), [], True), outputs=[stop_button, skip_button, generate_button, gallery, state_is_generating]) \ .then(fn=refresh_seed, inputs=[seed_random, image_seed], outputs=image_seed) \ .then(fn=get_task, inputs=ctrls, outputs=currentTask) \ .then(fn=generate_clicked, inputs=currentTask, outputs=[progress_html, progress_window, progress_gallery, gallery]) \ .then(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), gr.update(visible=False, interactive=False), False), outputs=[generate_button, stop_button, skip_button, state_is_generating]) \ .then(fn=update_history_link, outputs=history_link) \ .then(fn=lambda: None, _js='playNotification').then(fn=lambda: None, _js='refresh_grid_delayed')
for notification_file in ['notification.ogg', 'notification.mp3']: if os.path.exists(notification_file): gr.Audio(interactive=False, value=notification_file, elem_id='audio_notification', visible=False) break
def trigger_describe(mode, img): if mode == flags.desc_type_photo: from extras.interrogate import default_interrogator as default_interrogator_photo return default_interrogator_photo(img), ["Fooocus V2", "Fooocus Enhance", "Fooocus Sharp"] if mode == flags.desc_type_anime: from extras.wd14tagger import default_interrogator as default_interrogator_anime return default_interrogator_anime(img), ["Fooocus V2", "Fooocus Masterpiece"] return mode, ["Fooocus V2"]
desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image], outputs=[prompt, style_selections], show_progress=True, queue=True)
def dump_default_english_config(): from modules.localization import dump_english_config dump_english_config(grh.all_components)
# dump_default_english_config()
shared.gradio_root.launch( inbrowser=args_manager.args.in_browser, server_name=args_manager.args.listen, server_port=args_manager.args.port, share=args_manager.args.share, auth=check_auth if (args_manager.args.share or args_manager.args.listen) and auth_enabled else None, allowed_paths=[modules.config.path_outputs], blocked_paths=[constants.AUTH_FILENAME]).dockerignoreAdded+1
.gitignoreAdded+54
.run anime.batAdded+2
.run default.batAdded+2
.run lcm.batAdded+2
.run realistic.batAdded+2
.run sai.batAdded+2
.run.batAdded+2
DockerfileAdded+29
LICENSEAdded+674
aiDescTerminal.pyAdded+90
aiDescUI.pyAdded+688
app.htmlAdded+6
args_manager.pyAdded+55
auth-example.jsonAdded+6
build_launcher.pyAdded+26
config.txtAdded+16
config_modification_tutorial.txtAdded+123
docker-compose.ymlAdded+38
docker.mdAdded+66
entry_with_update.pyAdded+46
entrypoint.shAdded+33
environment.yamlAdded+7
experiments_expansion.pyAdded+8
experiments_face.pyAdded+7
experiments_interrogate.pyAdded+8
fooocus_colab.ipynbAdded+35
fooocus_version.pyAdded+1
launch.pyAdded+127
notification-example.oggAdded
readme.mdAdded+438
requirements_docker.txtAdded+5
requirements_versions.txtAdded+18
shared.pyAdded+1
sorted_styles.jsonAdded+279
troubleshoot.mdAdded+178
update_log.mdAdded+632
vercel.jsonAdded+14
webui.pyAdded+688