Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- sage2/.github/workflows/publish.yml +21 -0
- sage2/.gitignore +5 -0
- sage2/LICENSE +674 -0
- sage2/README.md +124 -0
- sage2/__init__.py +42 -0
- sage2/mat/__init__.py +16 -0
- sage2/mat/arch/LICENSE +161 -0
- sage2/mat/arch/MAT.py +1612 -0
- sage2/mat/arch/utils.py +697 -0
- sage2/media/inpaint.png +3 -0
- sage2/media/preprocess-blur-17.png +0 -0
- sage2/media/preprocess-blur-65.png +0 -0
- sage2/media/preprocess-input.png +0 -0
- sage2/media/preprocess-lama.png +0 -0
- sage2/media/preprocess-mat.png +0 -0
- sage2/media/preprocess-navier-stokes.png +0 -0
- sage2/media/preprocess-neutral.png +0 -0
- sage2/media/preprocess-telea.png +0 -0
- sage2/nodes.py +425 -0
- sage2/pyproject.toml +17 -0
- sage2/util.py +105 -0
- sage2/workflows/inpaint-preprocess.json +1483 -0
- sage2/workflows/inpaint-promptless.json +1638 -0
- sage2/workflows/inpaint-refine.json +696 -0
- sage2/workflows/inpaint-simple.json +609 -0
- sage2/workflows/outpaint.json +878 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
sage2/media/inpaint.png filter=lfs diff=lfs merge=lfs -text
|
sage2/.github/workflows/publish.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Publish to Comfy registry
|
| 2 |
+
on:
|
| 3 |
+
workflow_dispatch:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- main
|
| 7 |
+
paths:
|
| 8 |
+
- "pyproject.toml"
|
| 9 |
+
|
| 10 |
+
jobs:
|
| 11 |
+
publish-node:
|
| 12 |
+
name: Publish Custom Node to registry
|
| 13 |
+
runs-on: ubuntu-latest
|
| 14 |
+
steps:
|
| 15 |
+
- name: Check out code
|
| 16 |
+
uses: actions/checkout@v4
|
| 17 |
+
- name: Publish Custom Node
|
| 18 |
+
uses: Comfy-Org/publish-node-action@main
|
| 19 |
+
with:
|
| 20 |
+
## Add your own personal access token to your Github Repository secrets and reference it here.
|
| 21 |
+
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
sage2/.gitignore
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.vscode
|
| 2 |
+
.env
|
| 3 |
+
.dev
|
| 4 |
+
__pycache__
|
| 5 |
+
node.tar.gz
|
sage2/LICENSE
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GNU GENERAL PUBLIC LICENSE
|
| 2 |
+
Version 3, 29 June 2007
|
| 3 |
+
|
| 4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
| 5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
| 6 |
+
of this license document, but changing it is not allowed.
|
| 7 |
+
|
| 8 |
+
Preamble
|
| 9 |
+
|
| 10 |
+
The GNU General Public License is a free, copyleft license for
|
| 11 |
+
software and other kinds of works.
|
| 12 |
+
|
| 13 |
+
The licenses for most software and other practical works are designed
|
| 14 |
+
to take away your freedom to share and change the works. By contrast,
|
| 15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
| 16 |
+
share and change all versions of a program--to make sure it remains free
|
| 17 |
+
software for all its users. We, the Free Software Foundation, use the
|
| 18 |
+
GNU General Public License for most of our software; it applies also to
|
| 19 |
+
any other work released this way by its authors. You can apply it to
|
| 20 |
+
your programs, too.
|
| 21 |
+
|
| 22 |
+
When we speak of free software, we are referring to freedom, not
|
| 23 |
+
price. Our General Public Licenses are designed to make sure that you
|
| 24 |
+
have the freedom to distribute copies of free software (and charge for
|
| 25 |
+
them if you wish), that you receive source code or can get it if you
|
| 26 |
+
want it, that you can change the software or use pieces of it in new
|
| 27 |
+
free programs, and that you know you can do these things.
|
| 28 |
+
|
| 29 |
+
To protect your rights, we need to prevent others from denying you
|
| 30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
| 31 |
+
certain responsibilities if you distribute copies of the software, or if
|
| 32 |
+
you modify it: responsibilities to respect the freedom of others.
|
| 33 |
+
|
| 34 |
+
For example, if you distribute copies of such a program, whether
|
| 35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
| 36 |
+
freedoms that you received. You must make sure that they, too, receive
|
| 37 |
+
or can get the source code. And you must show them these terms so they
|
| 38 |
+
know their rights.
|
| 39 |
+
|
| 40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
| 41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
| 42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
| 43 |
+
|
| 44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
| 45 |
+
that there is no warranty for this free software. For both users' and
|
| 46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
| 47 |
+
changed, so that their problems will not be attributed erroneously to
|
| 48 |
+
authors of previous versions.
|
| 49 |
+
|
| 50 |
+
Some devices are designed to deny users access to install or run
|
| 51 |
+
modified versions of the software inside them, although the manufacturer
|
| 52 |
+
can do so. This is fundamentally incompatible with the aim of
|
| 53 |
+
protecting users' freedom to change the software. The systematic
|
| 54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
| 55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
| 56 |
+
have designed this version of the GPL to prohibit the practice for those
|
| 57 |
+
products. If such problems arise substantially in other domains, we
|
| 58 |
+
stand ready to extend this provision to those domains in future versions
|
| 59 |
+
of the GPL, as needed to protect the freedom of users.
|
| 60 |
+
|
| 61 |
+
Finally, every program is threatened constantly by software patents.
|
| 62 |
+
States should not allow patents to restrict development and use of
|
| 63 |
+
software on general-purpose computers, but in those that do, we wish to
|
| 64 |
+
avoid the special danger that patents applied to a free program could
|
| 65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
| 66 |
+
patents cannot be used to render the program non-free.
|
| 67 |
+
|
| 68 |
+
The precise terms and conditions for copying, distribution and
|
| 69 |
+
modification follow.
|
| 70 |
+
|
| 71 |
+
TERMS AND CONDITIONS
|
| 72 |
+
|
| 73 |
+
0. Definitions.
|
| 74 |
+
|
| 75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
| 76 |
+
|
| 77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
| 78 |
+
works, such as semiconductor masks.
|
| 79 |
+
|
| 80 |
+
"The Program" refers to any copyrightable work licensed under this
|
| 81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
| 82 |
+
"recipients" may be individuals or organizations.
|
| 83 |
+
|
| 84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
| 85 |
+
in a fashion requiring copyright permission, other than the making of an
|
| 86 |
+
exact copy. The resulting work is called a "modified version" of the
|
| 87 |
+
earlier work or a work "based on" the earlier work.
|
| 88 |
+
|
| 89 |
+
A "covered work" means either the unmodified Program or a work based
|
| 90 |
+
on the Program.
|
| 91 |
+
|
| 92 |
+
To "propagate" a work means to do anything with it that, without
|
| 93 |
+
permission, would make you directly or secondarily liable for
|
| 94 |
+
infringement under applicable copyright law, except executing it on a
|
| 95 |
+
computer or modifying a private copy. Propagation includes copying,
|
| 96 |
+
distribution (with or without modification), making available to the
|
| 97 |
+
public, and in some countries other activities as well.
|
| 98 |
+
|
| 99 |
+
To "convey" a work means any kind of propagation that enables other
|
| 100 |
+
parties to make or receive copies. Mere interaction with a user through
|
| 101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
| 102 |
+
|
| 103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
| 104 |
+
to the extent that it includes a convenient and prominently visible
|
| 105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
| 106 |
+
tells the user that there is no warranty for the work (except to the
|
| 107 |
+
extent that warranties are provided), that licensees may convey the
|
| 108 |
+
work under this License, and how to view a copy of this License. If
|
| 109 |
+
the interface presents a list of user commands or options, such as a
|
| 110 |
+
menu, a prominent item in the list meets this criterion.
|
| 111 |
+
|
| 112 |
+
1. Source Code.
|
| 113 |
+
|
| 114 |
+
The "source code" for a work means the preferred form of the work
|
| 115 |
+
for making modifications to it. "Object code" means any non-source
|
| 116 |
+
form of a work.
|
| 117 |
+
|
| 118 |
+
A "Standard Interface" means an interface that either is an official
|
| 119 |
+
standard defined by a recognized standards body, or, in the case of
|
| 120 |
+
interfaces specified for a particular programming language, one that
|
| 121 |
+
is widely used among developers working in that language.
|
| 122 |
+
|
| 123 |
+
The "System Libraries" of an executable work include anything, other
|
| 124 |
+
than the work as a whole, that (a) is included in the normal form of
|
| 125 |
+
packaging a Major Component, but which is not part of that Major
|
| 126 |
+
Component, and (b) serves only to enable use of the work with that
|
| 127 |
+
Major Component, or to implement a Standard Interface for which an
|
| 128 |
+
implementation is available to the public in source code form. A
|
| 129 |
+
"Major Component", in this context, means a major essential component
|
| 130 |
+
(kernel, window system, and so on) of the specific operating system
|
| 131 |
+
(if any) on which the executable work runs, or a compiler used to
|
| 132 |
+
produce the work, or an object code interpreter used to run it.
|
| 133 |
+
|
| 134 |
+
The "Corresponding Source" for a work in object code form means all
|
| 135 |
+
the source code needed to generate, install, and (for an executable
|
| 136 |
+
work) run the object code and to modify the work, including scripts to
|
| 137 |
+
control those activities. However, it does not include the work's
|
| 138 |
+
System Libraries, or general-purpose tools or generally available free
|
| 139 |
+
programs which are used unmodified in performing those activities but
|
| 140 |
+
which are not part of the work. For example, Corresponding Source
|
| 141 |
+
includes interface definition files associated with source files for
|
| 142 |
+
the work, and the source code for shared libraries and dynamically
|
| 143 |
+
linked subprograms that the work is specifically designed to require,
|
| 144 |
+
such as by intimate data communication or control flow between those
|
| 145 |
+
subprograms and other parts of the work.
|
| 146 |
+
|
| 147 |
+
The Corresponding Source need not include anything that users
|
| 148 |
+
can regenerate automatically from other parts of the Corresponding
|
| 149 |
+
Source.
|
| 150 |
+
|
| 151 |
+
The Corresponding Source for a work in source code form is that
|
| 152 |
+
same work.
|
| 153 |
+
|
| 154 |
+
2. Basic Permissions.
|
| 155 |
+
|
| 156 |
+
All rights granted under this License are granted for the term of
|
| 157 |
+
copyright on the Program, and are irrevocable provided the stated
|
| 158 |
+
conditions are met. This License explicitly affirms your unlimited
|
| 159 |
+
permission to run the unmodified Program. The output from running a
|
| 160 |
+
covered work is covered by this License only if the output, given its
|
| 161 |
+
content, constitutes a covered work. This License acknowledges your
|
| 162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
| 163 |
+
|
| 164 |
+
You may make, run and propagate covered works that you do not
|
| 165 |
+
convey, without conditions so long as your license otherwise remains
|
| 166 |
+
in force. You may convey covered works to others for the sole purpose
|
| 167 |
+
of having them make modifications exclusively for you, or provide you
|
| 168 |
+
with facilities for running those works, provided that you comply with
|
| 169 |
+
the terms of this License in conveying all material for which you do
|
| 170 |
+
not control copyright. Those thus making or running the covered works
|
| 171 |
+
for you must do so exclusively on your behalf, under your direction
|
| 172 |
+
and control, on terms that prohibit them from making any copies of
|
| 173 |
+
your copyrighted material outside their relationship with you.
|
| 174 |
+
|
| 175 |
+
Conveying under any other circumstances is permitted solely under
|
| 176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
| 177 |
+
makes it unnecessary.
|
| 178 |
+
|
| 179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
| 180 |
+
|
| 181 |
+
No covered work shall be deemed part of an effective technological
|
| 182 |
+
measure under any applicable law fulfilling obligations under article
|
| 183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
| 184 |
+
similar laws prohibiting or restricting circumvention of such
|
| 185 |
+
measures.
|
| 186 |
+
|
| 187 |
+
When you convey a covered work, you waive any legal power to forbid
|
| 188 |
+
circumvention of technological measures to the extent such circumvention
|
| 189 |
+
is effected by exercising rights under this License with respect to
|
| 190 |
+
the covered work, and you disclaim any intention to limit operation or
|
| 191 |
+
modification of the work as a means of enforcing, against the work's
|
| 192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
| 193 |
+
technological measures.
|
| 194 |
+
|
| 195 |
+
4. Conveying Verbatim Copies.
|
| 196 |
+
|
| 197 |
+
You may convey verbatim copies of the Program's source code as you
|
| 198 |
+
receive it, in any medium, provided that you conspicuously and
|
| 199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
| 200 |
+
keep intact all notices stating that this License and any
|
| 201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
| 202 |
+
keep intact all notices of the absence of any warranty; and give all
|
| 203 |
+
recipients a copy of this License along with the Program.
|
| 204 |
+
|
| 205 |
+
You may charge any price or no price for each copy that you convey,
|
| 206 |
+
and you may offer support or warranty protection for a fee.
|
| 207 |
+
|
| 208 |
+
5. Conveying Modified Source Versions.
|
| 209 |
+
|
| 210 |
+
You may convey a work based on the Program, or the modifications to
|
| 211 |
+
produce it from the Program, in the form of source code under the
|
| 212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
| 213 |
+
|
| 214 |
+
a) The work must carry prominent notices stating that you modified
|
| 215 |
+
it, and giving a relevant date.
|
| 216 |
+
|
| 217 |
+
b) The work must carry prominent notices stating that it is
|
| 218 |
+
released under this License and any conditions added under section
|
| 219 |
+
7. This requirement modifies the requirement in section 4 to
|
| 220 |
+
"keep intact all notices".
|
| 221 |
+
|
| 222 |
+
c) You must license the entire work, as a whole, under this
|
| 223 |
+
License to anyone who comes into possession of a copy. This
|
| 224 |
+
License will therefore apply, along with any applicable section 7
|
| 225 |
+
additional terms, to the whole of the work, and all its parts,
|
| 226 |
+
regardless of how they are packaged. This License gives no
|
| 227 |
+
permission to license the work in any other way, but it does not
|
| 228 |
+
invalidate such permission if you have separately received it.
|
| 229 |
+
|
| 230 |
+
d) If the work has interactive user interfaces, each must display
|
| 231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
| 232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
| 233 |
+
work need not make them do so.
|
| 234 |
+
|
| 235 |
+
A compilation of a covered work with other separate and independent
|
| 236 |
+
works, which are not by their nature extensions of the covered work,
|
| 237 |
+
and which are not combined with it such as to form a larger program,
|
| 238 |
+
in or on a volume of a storage or distribution medium, is called an
|
| 239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
| 240 |
+
used to limit the access or legal rights of the compilation's users
|
| 241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
| 242 |
+
in an aggregate does not cause this License to apply to the other
|
| 243 |
+
parts of the aggregate.
|
| 244 |
+
|
| 245 |
+
6. Conveying Non-Source Forms.
|
| 246 |
+
|
| 247 |
+
You may convey a covered work in object code form under the terms
|
| 248 |
+
of sections 4 and 5, provided that you also convey the
|
| 249 |
+
machine-readable Corresponding Source under the terms of this License,
|
| 250 |
+
in one of these ways:
|
| 251 |
+
|
| 252 |
+
a) Convey the object code in, or embodied in, a physical product
|
| 253 |
+
(including a physical distribution medium), accompanied by the
|
| 254 |
+
Corresponding Source fixed on a durable physical medium
|
| 255 |
+
customarily used for software interchange.
|
| 256 |
+
|
| 257 |
+
b) Convey the object code in, or embodied in, a physical product
|
| 258 |
+
(including a physical distribution medium), accompanied by a
|
| 259 |
+
written offer, valid for at least three years and valid for as
|
| 260 |
+
long as you offer spare parts or customer support for that product
|
| 261 |
+
model, to give anyone who possesses the object code either (1) a
|
| 262 |
+
copy of the Corresponding Source for all the software in the
|
| 263 |
+
product that is covered by this License, on a durable physical
|
| 264 |
+
medium customarily used for software interchange, for a price no
|
| 265 |
+
more than your reasonable cost of physically performing this
|
| 266 |
+
conveying of source, or (2) access to copy the
|
| 267 |
+
Corresponding Source from a network server at no charge.
|
| 268 |
+
|
| 269 |
+
c) Convey individual copies of the object code with a copy of the
|
| 270 |
+
written offer to provide the Corresponding Source. This
|
| 271 |
+
alternative is allowed only occasionally and noncommercially, and
|
| 272 |
+
only if you received the object code with such an offer, in accord
|
| 273 |
+
with subsection 6b.
|
| 274 |
+
|
| 275 |
+
d) Convey the object code by offering access from a designated
|
| 276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
| 277 |
+
Corresponding Source in the same way through the same place at no
|
| 278 |
+
further charge. You need not require recipients to copy the
|
| 279 |
+
Corresponding Source along with the object code. If the place to
|
| 280 |
+
copy the object code is a network server, the Corresponding Source
|
| 281 |
+
may be on a different server (operated by you or a third party)
|
| 282 |
+
that supports equivalent copying facilities, provided you maintain
|
| 283 |
+
clear directions next to the object code saying where to find the
|
| 284 |
+
Corresponding Source. Regardless of what server hosts the
|
| 285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
| 286 |
+
available for as long as needed to satisfy these requirements.
|
| 287 |
+
|
| 288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
| 289 |
+
you inform other peers where the object code and Corresponding
|
| 290 |
+
Source of the work are being offered to the general public at no
|
| 291 |
+
charge under subsection 6d.
|
| 292 |
+
|
| 293 |
+
A separable portion of the object code, whose source code is excluded
|
| 294 |
+
from the Corresponding Source as a System Library, need not be
|
| 295 |
+
included in conveying the object code work.
|
| 296 |
+
|
| 297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
| 298 |
+
tangible personal property which is normally used for personal, family,
|
| 299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
| 300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
| 301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
| 302 |
+
product received by a particular user, "normally used" refers to a
|
| 303 |
+
typical or common use of that class of product, regardless of the status
|
| 304 |
+
of the particular user or of the way in which the particular user
|
| 305 |
+
actually uses, or expects or is expected to use, the product. A product
|
| 306 |
+
is a consumer product regardless of whether the product has substantial
|
| 307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
| 308 |
+
the only significant mode of use of the product.
|
| 309 |
+
|
| 310 |
+
"Installation Information" for a User Product means any methods,
|
| 311 |
+
procedures, authorization keys, or other information required to install
|
| 312 |
+
and execute modified versions of a covered work in that User Product from
|
| 313 |
+
a modified version of its Corresponding Source. The information must
|
| 314 |
+
suffice to ensure that the continued functioning of the modified object
|
| 315 |
+
code is in no case prevented or interfered with solely because
|
| 316 |
+
modification has been made.
|
| 317 |
+
|
| 318 |
+
If you convey an object code work under this section in, or with, or
|
| 319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
| 320 |
+
part of a transaction in which the right of possession and use of the
|
| 321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
| 322 |
+
fixed term (regardless of how the transaction is characterized), the
|
| 323 |
+
Corresponding Source conveyed under this section must be accompanied
|
| 324 |
+
by the Installation Information. But this requirement does not apply
|
| 325 |
+
if neither you nor any third party retains the ability to install
|
| 326 |
+
modified object code on the User Product (for example, the work has
|
| 327 |
+
been installed in ROM).
|
| 328 |
+
|
| 329 |
+
The requirement to provide Installation Information does not include a
|
| 330 |
+
requirement to continue to provide support service, warranty, or updates
|
| 331 |
+
for a work that has been modified or installed by the recipient, or for
|
| 332 |
+
the User Product in which it has been modified or installed. Access to a
|
| 333 |
+
network may be denied when the modification itself materially and
|
| 334 |
+
adversely affects the operation of the network or violates the rules and
|
| 335 |
+
protocols for communication across the network.
|
| 336 |
+
|
| 337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
| 338 |
+
in accord with this section must be in a format that is publicly
|
| 339 |
+
documented (and with an implementation available to the public in
|
| 340 |
+
source code form), and must require no special password or key for
|
| 341 |
+
unpacking, reading or copying.
|
| 342 |
+
|
| 343 |
+
7. Additional Terms.
|
| 344 |
+
|
| 345 |
+
"Additional permissions" are terms that supplement the terms of this
|
| 346 |
+
License by making exceptions from one or more of its conditions.
|
| 347 |
+
Additional permissions that are applicable to the entire Program shall
|
| 348 |
+
be treated as though they were included in this License, to the extent
|
| 349 |
+
that they are valid under applicable law. If additional permissions
|
| 350 |
+
apply only to part of the Program, that part may be used separately
|
| 351 |
+
under those permissions, but the entire Program remains governed by
|
| 352 |
+
this License without regard to the additional permissions.
|
| 353 |
+
|
| 354 |
+
When you convey a copy of a covered work, you may at your option
|
| 355 |
+
remove any additional permissions from that copy, or from any part of
|
| 356 |
+
it. (Additional permissions may be written to require their own
|
| 357 |
+
removal in certain cases when you modify the work.) You may place
|
| 358 |
+
additional permissions on material, added by you to a covered work,
|
| 359 |
+
for which you have or can give appropriate copyright permission.
|
| 360 |
+
|
| 361 |
+
Notwithstanding any other provision of this License, for material you
|
| 362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
| 363 |
+
that material) supplement the terms of this License with terms:
|
| 364 |
+
|
| 365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
| 366 |
+
terms of sections 15 and 16 of this License; or
|
| 367 |
+
|
| 368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
| 369 |
+
author attributions in that material or in the Appropriate Legal
|
| 370 |
+
Notices displayed by works containing it; or
|
| 371 |
+
|
| 372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
| 373 |
+
requiring that modified versions of such material be marked in
|
| 374 |
+
reasonable ways as different from the original version; or
|
| 375 |
+
|
| 376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
| 377 |
+
authors of the material; or
|
| 378 |
+
|
| 379 |
+
e) Declining to grant rights under trademark law for use of some
|
| 380 |
+
trade names, trademarks, or service marks; or
|
| 381 |
+
|
| 382 |
+
f) Requiring indemnification of licensors and authors of that
|
| 383 |
+
material by anyone who conveys the material (or modified versions of
|
| 384 |
+
it) with contractual assumptions of liability to the recipient, for
|
| 385 |
+
any liability that these contractual assumptions directly impose on
|
| 386 |
+
those licensors and authors.
|
| 387 |
+
|
| 388 |
+
All other non-permissive additional terms are considered "further
|
| 389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
| 390 |
+
received it, or any part of it, contains a notice stating that it is
|
| 391 |
+
governed by this License along with a term that is a further
|
| 392 |
+
restriction, you may remove that term. If a license document contains
|
| 393 |
+
a further restriction but permits relicensing or conveying under this
|
| 394 |
+
License, you may add to a covered work material governed by the terms
|
| 395 |
+
of that license document, provided that the further restriction does
|
| 396 |
+
not survive such relicensing or conveying.
|
| 397 |
+
|
| 398 |
+
If you add terms to a covered work in accord with this section, you
|
| 399 |
+
must place, in the relevant source files, a statement of the
|
| 400 |
+
additional terms that apply to those files, or a notice indicating
|
| 401 |
+
where to find the applicable terms.
|
| 402 |
+
|
| 403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
| 404 |
+
form of a separately written license, or stated as exceptions;
|
| 405 |
+
the above requirements apply either way.
|
| 406 |
+
|
| 407 |
+
8. Termination.
|
| 408 |
+
|
| 409 |
+
You may not propagate or modify a covered work except as expressly
|
| 410 |
+
provided under this License. Any attempt otherwise to propagate or
|
| 411 |
+
modify it is void, and will automatically terminate your rights under
|
| 412 |
+
this License (including any patent licenses granted under the third
|
| 413 |
+
paragraph of section 11).
|
| 414 |
+
|
| 415 |
+
However, if you cease all violation of this License, then your
|
| 416 |
+
license from a particular copyright holder is reinstated (a)
|
| 417 |
+
provisionally, unless and until the copyright holder explicitly and
|
| 418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
| 419 |
+
holder fails to notify you of the violation by some reasonable means
|
| 420 |
+
prior to 60 days after the cessation.
|
| 421 |
+
|
| 422 |
+
Moreover, your license from a particular copyright holder is
|
| 423 |
+
reinstated permanently if the copyright holder notifies you of the
|
| 424 |
+
violation by some reasonable means, this is the first time you have
|
| 425 |
+
received notice of violation of this License (for any work) from that
|
| 426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
| 427 |
+
your receipt of the notice.
|
| 428 |
+
|
| 429 |
+
Termination of your rights under this section does not terminate the
|
| 430 |
+
licenses of parties who have received copies or rights from you under
|
| 431 |
+
this License. If your rights have been terminated and not permanently
|
| 432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
| 433 |
+
material under section 10.
|
| 434 |
+
|
| 435 |
+
9. Acceptance Not Required for Having Copies.
|
| 436 |
+
|
| 437 |
+
You are not required to accept this License in order to receive or
|
| 438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
| 439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
| 440 |
+
to receive a copy likewise does not require acceptance. However,
|
| 441 |
+
nothing other than this License grants you permission to propagate or
|
| 442 |
+
modify any covered work. These actions infringe copyright if you do
|
| 443 |
+
not accept this License. Therefore, by modifying or propagating a
|
| 444 |
+
covered work, you indicate your acceptance of this License to do so.
|
| 445 |
+
|
| 446 |
+
10. Automatic Licensing of Downstream Recipients.
|
| 447 |
+
|
| 448 |
+
Each time you convey a covered work, the recipient automatically
|
| 449 |
+
receives a license from the original licensors, to run, modify and
|
| 450 |
+
propagate that work, subject to this License. You are not responsible
|
| 451 |
+
for enforcing compliance by third parties with this License.
|
| 452 |
+
|
| 453 |
+
An "entity transaction" is a transaction transferring control of an
|
| 454 |
+
organization, or substantially all assets of one, or subdividing an
|
| 455 |
+
organization, or merging organizations. If propagation of a covered
|
| 456 |
+
work results from an entity transaction, each party to that
|
| 457 |
+
transaction who receives a copy of the work also receives whatever
|
| 458 |
+
licenses to the work the party's predecessor in interest had or could
|
| 459 |
+
give under the previous paragraph, plus a right to possession of the
|
| 460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
| 461 |
+
the predecessor has it or can get it with reasonable efforts.
|
| 462 |
+
|
| 463 |
+
You may not impose any further restrictions on the exercise of the
|
| 464 |
+
rights granted or affirmed under this License. For example, you may
|
| 465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
| 466 |
+
rights granted under this License, and you may not initiate litigation
|
| 467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
| 468 |
+
any patent claim is infringed by making, using, selling, offering for
|
| 469 |
+
sale, or importing the Program or any portion of it.
|
| 470 |
+
|
| 471 |
+
11. Patents.
|
| 472 |
+
|
| 473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
| 474 |
+
License of the Program or a work on which the Program is based. The
|
| 475 |
+
work thus licensed is called the contributor's "contributor version".
|
| 476 |
+
|
| 477 |
+
A contributor's "essential patent claims" are all patent claims
|
| 478 |
+
owned or controlled by the contributor, whether already acquired or
|
| 479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
| 480 |
+
by this License, of making, using, or selling its contributor version,
|
| 481 |
+
but do not include claims that would be infringed only as a
|
| 482 |
+
consequence of further modification of the contributor version. For
|
| 483 |
+
purposes of this definition, "control" includes the right to grant
|
| 484 |
+
patent sublicenses in a manner consistent with the requirements of
|
| 485 |
+
this License.
|
| 486 |
+
|
| 487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
| 488 |
+
patent license under the contributor's essential patent claims, to
|
| 489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
| 490 |
+
propagate the contents of its contributor version.
|
| 491 |
+
|
| 492 |
+
In the following three paragraphs, a "patent license" is any express
|
| 493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
| 494 |
+
(such as an express permission to practice a patent or covenant not to
|
| 495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
| 496 |
+
party means to make such an agreement or commitment not to enforce a
|
| 497 |
+
patent against the party.
|
| 498 |
+
|
| 499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
| 500 |
+
and the Corresponding Source of the work is not available for anyone
|
| 501 |
+
to copy, free of charge and under the terms of this License, through a
|
| 502 |
+
publicly available network server or other readily accessible means,
|
| 503 |
+
then you must either (1) cause the Corresponding Source to be so
|
| 504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
| 505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
| 506 |
+
consistent with the requirements of this License, to extend the patent
|
| 507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
| 508 |
+
actual knowledge that, but for the patent license, your conveying the
|
| 509 |
+
covered work in a country, or your recipient's use of the covered work
|
| 510 |
+
in a country, would infringe one or more identifiable patents in that
|
| 511 |
+
country that you have reason to believe are valid.
|
| 512 |
+
|
| 513 |
+
If, pursuant to or in connection with a single transaction or
|
| 514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
| 515 |
+
covered work, and grant a patent license to some of the parties
|
| 516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
| 517 |
+
or convey a specific copy of the covered work, then the patent license
|
| 518 |
+
you grant is automatically extended to all recipients of the covered
|
| 519 |
+
work and works based on it.
|
| 520 |
+
|
| 521 |
+
A patent license is "discriminatory" if it does not include within
|
| 522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
| 523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
| 524 |
+
specifically granted under this License. You may not convey a covered
|
| 525 |
+
work if you are a party to an arrangement with a third party that is
|
| 526 |
+
in the business of distributing software, under which you make payment
|
| 527 |
+
to the third party based on the extent of your activity of conveying
|
| 528 |
+
the work, and under which the third party grants, to any of the
|
| 529 |
+
parties who would receive the covered work from you, a discriminatory
|
| 530 |
+
patent license (a) in connection with copies of the covered work
|
| 531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
| 532 |
+
for and in connection with specific products or compilations that
|
| 533 |
+
contain the covered work, unless you entered into that arrangement,
|
| 534 |
+
or that patent license was granted, prior to 28 March 2007.
|
| 535 |
+
|
| 536 |
+
Nothing in this License shall be construed as excluding or limiting
|
| 537 |
+
any implied license or other defenses to infringement that may
|
| 538 |
+
otherwise be available to you under applicable patent law.
|
| 539 |
+
|
| 540 |
+
12. No Surrender of Others' Freedom.
|
| 541 |
+
|
| 542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
| 543 |
+
otherwise) that contradict the conditions of this License, they do not
|
| 544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
| 545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
| 546 |
+
License and any other pertinent obligations, then as a consequence you may
|
| 547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
| 548 |
+
to collect a royalty for further conveying from those to whom you convey
|
| 549 |
+
the Program, the only way you could satisfy both those terms and this
|
| 550 |
+
License would be to refrain entirely from conveying the Program.
|
| 551 |
+
|
| 552 |
+
13. Use with the GNU Affero General Public License.
|
| 553 |
+
|
| 554 |
+
Notwithstanding any other provision of this License, you have
|
| 555 |
+
permission to link or combine any covered work with a work licensed
|
| 556 |
+
under version 3 of the GNU Affero General Public License into a single
|
| 557 |
+
combined work, and to convey the resulting work. The terms of this
|
| 558 |
+
License will continue to apply to the part which is the covered work,
|
| 559 |
+
but the special requirements of the GNU Affero General Public License,
|
| 560 |
+
section 13, concerning interaction through a network will apply to the
|
| 561 |
+
combination as such.
|
| 562 |
+
|
| 563 |
+
14. Revised Versions of this License.
|
| 564 |
+
|
| 565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
| 566 |
+
the GNU General Public License from time to time. Such new versions will
|
| 567 |
+
be similar in spirit to the present version, but may differ in detail to
|
| 568 |
+
address new problems or concerns.
|
| 569 |
+
|
| 570 |
+
Each version is given a distinguishing version number. If the
|
| 571 |
+
Program specifies that a certain numbered version of the GNU General
|
| 572 |
+
Public License "or any later version" applies to it, you have the
|
| 573 |
+
option of following the terms and conditions either of that numbered
|
| 574 |
+
version or of any later version published by the Free Software
|
| 575 |
+
Foundation. If the Program does not specify a version number of the
|
| 576 |
+
GNU General Public License, you may choose any version ever published
|
| 577 |
+
by the Free Software Foundation.
|
| 578 |
+
|
| 579 |
+
If the Program specifies that a proxy can decide which future
|
| 580 |
+
versions of the GNU General Public License can be used, that proxy's
|
| 581 |
+
public statement of acceptance of a version permanently authorizes you
|
| 582 |
+
to choose that version for the Program.
|
| 583 |
+
|
| 584 |
+
Later license versions may give you additional or different
|
| 585 |
+
permissions. However, no additional obligations are imposed on any
|
| 586 |
+
author or copyright holder as a result of your choosing to follow a
|
| 587 |
+
later version.
|
| 588 |
+
|
| 589 |
+
15. Disclaimer of Warranty.
|
| 590 |
+
|
| 591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
| 592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
| 593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
| 594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
| 595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
| 596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
| 597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
| 598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
| 599 |
+
|
| 600 |
+
16. Limitation of Liability.
|
| 601 |
+
|
| 602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
| 603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
| 604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
| 605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
| 606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
| 607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
| 608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
| 609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
| 610 |
+
SUCH DAMAGES.
|
| 611 |
+
|
| 612 |
+
17. Interpretation of Sections 15 and 16.
|
| 613 |
+
|
| 614 |
+
If the disclaimer of warranty and limitation of liability provided
|
| 615 |
+
above cannot be given local legal effect according to their terms,
|
| 616 |
+
reviewing courts shall apply local law that most closely approximates
|
| 617 |
+
an absolute waiver of all civil liability in connection with the
|
| 618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
| 619 |
+
copy of the Program in return for a fee.
|
| 620 |
+
|
| 621 |
+
END OF TERMS AND CONDITIONS
|
| 622 |
+
|
| 623 |
+
How to Apply These Terms to Your New Programs
|
| 624 |
+
|
| 625 |
+
If you develop a new program, and you want it to be of the greatest
|
| 626 |
+
possible use to the public, the best way to achieve this is to make it
|
| 627 |
+
free software which everyone can redistribute and change under these terms.
|
| 628 |
+
|
| 629 |
+
To do so, attach the following notices to the program. It is safest
|
| 630 |
+
to attach them to the start of each source file to most effectively
|
| 631 |
+
state the exclusion of warranty; and each file should have at least
|
| 632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
| 633 |
+
|
| 634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
| 635 |
+
Copyright (C) <year> <name of author>
|
| 636 |
+
|
| 637 |
+
This program is free software: you can redistribute it and/or modify
|
| 638 |
+
it under the terms of the GNU General Public License as published by
|
| 639 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 640 |
+
(at your option) any later version.
|
| 641 |
+
|
| 642 |
+
This program is distributed in the hope that it will be useful,
|
| 643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 645 |
+
GNU General Public License for more details.
|
| 646 |
+
|
| 647 |
+
You should have received a copy of the GNU General Public License
|
| 648 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 649 |
+
|
| 650 |
+
Also add information on how to contact you by electronic and paper mail.
|
| 651 |
+
|
| 652 |
+
If the program does terminal interaction, make it output a short
|
| 653 |
+
notice like this when it starts in an interactive mode:
|
| 654 |
+
|
| 655 |
+
<program> Copyright (C) <year> <name of author>
|
| 656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
| 657 |
+
This is free software, and you are welcome to redistribute it
|
| 658 |
+
under certain conditions; type `show c' for details.
|
| 659 |
+
|
| 660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
| 661 |
+
parts of the General Public License. Of course, your program's commands
|
| 662 |
+
might be different; for a GUI interface, you would use an "about box".
|
| 663 |
+
|
| 664 |
+
You should also get your employer (if you work as a programmer) or school,
|
| 665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
| 666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
| 667 |
+
<https://www.gnu.org/licenses/>.
|
| 668 |
+
|
| 669 |
+
The GNU General Public License does not permit incorporating your program
|
| 670 |
+
into proprietary programs. If your program is a subroutine library, you
|
| 671 |
+
may consider it more useful to permit linking proprietary applications with
|
| 672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
| 673 |
+
Public License instead of this License. But first, please read
|
| 674 |
+
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
sage2/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ComfyUI Inpaint Nodes
|
| 2 |
+
|
| 3 |
+
Nodes for better inpainting with ComfyUI: Fooocus inpaint model for SDXL, LaMa, MAT,
|
| 4 |
+
and various other tools for pre-filling inpaint & outpaint areas.
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
## Fooocus Inpaint
|
| 8 |
+
|
| 9 |
+
Adds two nodes which allow using [Fooocus](https://github.com/lllyasviel/Fooocus) inpaint model.
|
| 10 |
+
It's a small and flexible patch which can be applied to _any **SDXL** checkpoint_ and will transform
|
| 11 |
+
it into an inpaint model. This model can then be used like other inpaint models, and provides the
|
| 12 |
+
same benefits. [Read more](https://github.com/lllyasviel/Fooocus/discussions/414)
|
| 13 |
+
|
| 14 |
+
Download models from [lllyasviel/fooocus_inpaint](https://huggingface.co/lllyasviel/fooocus_inpaint/tree/main) to `ComfyUI/models/inpaint`.
|
| 15 |
+
|
| 16 |
+

|
| 17 |
+
|
| 18 |
+
Note: Implementation is somewhat hacky as it monkey-patches ComfyUI's `ModelPatcher` to support
|
| 19 |
+
the custom Lora format which the model is using.
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
## Inpaint Conditioning
|
| 23 |
+
|
| 24 |
+
Fooocus inpaint can be used with ComfyUI's _VAE Encode (for Inpainting)_ directly. However this does
|
| 25 |
+
not allow existing content in the masked area, denoise strength must be 1.0.
|
| 26 |
+
|
| 27 |
+
_InpaintModelConditioning_ can be used to combine inpaint models with existing content. The resulting
|
| 28 |
+
latent can however _not_ be used directly to patch the model using _Apply Fooocus Inpaint_. This repository
|
| 29 |
+
adds a new node **VAE Encode & Inpaint Conditioning** which provides two outputs: `latent_inpaint` (connect
|
| 30 |
+
this to _Apply Fooocus Inpaint_) and `latent_samples` (connect this to _KSampler_).
|
| 31 |
+
|
| 32 |
+
It's the same as using both _VAE Encode (for Inpainting)_ and _InpaintModelConditioning_, but less overhead
|
| 33 |
+
because it avoids VAE-encoding the image twice. [Example workflow](workflows/inpaint-refine.json)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
## Inpaint Pre-processing
|
| 37 |
+
|
| 38 |
+
Several nodes are available to fill the masked area prior to inpainting. They avoid seams as long as the
|
| 39 |
+
input mask is large enough.
|
| 40 |
+
|
| 41 |
+
### Fill Masked
|
| 42 |
+
|
| 43 |
+
This fills the masked area, with a smooth transition at the border. It has 3 modes:
|
| 44 |
+
* `neutral`: fills with grey, good for adding entirely new content
|
| 45 |
+
* `telea`: fills with colors from surrounding border (based on algorithm by Alexandru Telea)
|
| 46 |
+
* `navier-stokes`: fills with colors from surrounding border (based on fluid dynamics described by Navier-Stokes)
|
| 47 |
+
|
| 48 |
+
| Input | Neutral | Telea | Navier-Stokes |
|
| 49 |
+
|-|-|-|-|
|
| 50 |
+
|  |  |  | 
|
| 51 |
+
|
| 52 |
+
### Blur Masked
|
| 53 |
+
|
| 54 |
+
This blurs the image into the masked area. The blur is less strong at the borders of the mask.
|
| 55 |
+
Good for keeping the general colors the same.
|
| 56 |
+
|
| 57 |
+
| Input | Blur radius 17 | Blur radius 65 |
|
| 58 |
+
|-|-|-|
|
| 59 |
+
|  |  |  |
|
| 60 |
+
|
| 61 |
+
### Inpaint Models (LaMA, MAT)
|
| 62 |
+
|
| 63 |
+
This runs a small, fast inpaint model on the masked area. Models can be loaded with **Load Inpaint Model**
|
| 64 |
+
and are applied with the **Inpaint (using Model)** node. This works well for outpainting or object removal.
|
| 65 |
+
|
| 66 |
+
The following inpaint models are supported, place them in `ComfyUI/models/inpaint`:
|
| 67 |
+
- [LaMa](https://github.com/advimman/lama) | [Model download](https://github.com/Sanster/models/releases/download/add_big_lama/big-lama.pt)
|
| 68 |
+
- [MAT](https://github.com/fenglinglwb/MAT) | [Model download](https://github.com/Sanster/models/releases/download/add_mat/Places_512_FullData_G.pth) | [Model download (fp16 safetensors)](https://huggingface.co/Acly/MAT/resolve/main/MAT_Places512_G_fp16.safetensors)
|
| 69 |
+
|
| 70 |
+
| Input | LaMa | MAT |
|
| 71 |
+
|-|-|-|
|
| 72 |
+
|  |  |  |
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
## Inpaint Post-processing
|
| 76 |
+
|
| 77 |
+
### Denoise to Compositing Mask
|
| 78 |
+
|
| 79 |
+
Takes a _mask_, an _offset_ (default 0.1) and a _threshold_ (default 0.2).
|
| 80 |
+
Maps mask values in the range of \[_offset_ → _threshold_\] to \[0 → 1\].
|
| 81 |
+
Values below offset are clamped to 0, values above threshold to 1.
|
| 82 |
+
|
| 83 |
+
This is particularly useful in combination with ComfyUI's "Differential Diffusion" node, which allows to use a mask as per-pixel denoise strength.
|
| 84 |
+
Using the same mask for compositing (alpha blending) defeats the purpose, but no blending at all degrades quality in regions with zero or very low strength. This node creates a mask suitable for blending from the denoise-mask.
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
## Example Workflows
|
| 88 |
+
|
| 89 |
+
Example workflows can be found in [workflows](workflows).
|
| 90 |
+
|
| 91 |
+
* **[Simple](https://raw.githubusercontent.com/Acly/comfyui-inpaint-nodes/main/workflows/inpaint-simple.json):** basic workflow, ignore previous content, 100% replacement
|
| 92 |
+
* **[Refine](https://raw.githubusercontent.com/Acly/comfyui-inpaint-nodes/main/workflows/inpaint-refine.json):** advanced workflow, refine existing content, 1-100% denoise strength
|
| 93 |
+
* **[Outpaint](https://raw.githubusercontent.com/Acly/comfyui-inpaint-nodes/main/workflows/outpaint.json):** workflow for outpainting with pre-processing
|
| 94 |
+
* **[Pre-process](https://raw.githubusercontent.com/Acly/comfyui-inpaint-nodes/main/workflows/inpaint-preprocess.json):** complex workflow for experimenting with pre-processors
|
| 95 |
+
* **[Promptless](https://raw.githubusercontent.com/Acly/comfyui-inpaint-nodes/main/workflows/inpaint-promptless.json):** same as above but without text prompt, requires [IP-Adapter](https://github.com/cubiq/ComfyUI_IPAdapter_plus)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
## Installation
|
| 99 |
+
|
| 100 |
+
Use [ComfyUI Manager](https://github.com/ltdrdata/ComfyUI-Manager) and search for "ComfyUI Inpaint Nodes".
|
| 101 |
+
|
| 102 |
+
_**or**_ download the repository and put the folder into `ComfyUI/custom_nodes`.
|
| 103 |
+
|
| 104 |
+
_**or**_ use GIT:
|
| 105 |
+
```
|
| 106 |
+
cd ComfyUI/custom_nodes
|
| 107 |
+
git clone https://github.com/Acly/comfyui-inpaint-nodes.git
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
Restart ComfyUI after installing!
|
| 111 |
+
|
| 112 |
+
---
|
| 113 |
+
|
| 114 |
+
OpenCV is required for _telea_ and _navier-stokes_ fill mode:
|
| 115 |
+
```
|
| 116 |
+
pip install opencv-python
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
## Acknowledgements
|
| 120 |
+
|
| 121 |
+
* Fooocus Inpaint: [lllyasviel/Fooocus](https://github.com/lllyasviel/Fooocus)
|
| 122 |
+
* LaMa: [advimman/lama](https://github.com/advimman/lama)
|
| 123 |
+
* MAT: [fenglinglwb/MAT](https://github.com/fenglinglwb/MAT)
|
| 124 |
+
* LaMa/MAT implementation: [chaiNNer-org/spandrel](https://github.com/chaiNNer-org/spandrel)
|
sage2/__init__.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import folder_paths
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def _add_folder_path(folder_name: str, extensions: list):
|
| 6 |
+
path = os.path.join(folder_paths.models_dir, folder_name)
|
| 7 |
+
_, current_extensions = folder_paths.folder_names_and_paths.setdefault(
|
| 8 |
+
folder_name, ([path], set())
|
| 9 |
+
)
|
| 10 |
+
if isinstance(current_extensions, set):
|
| 11 |
+
current_extensions.update(extensions)
|
| 12 |
+
elif isinstance(current_extensions, list):
|
| 13 |
+
current_extensions.extend(extensions)
|
| 14 |
+
else:
|
| 15 |
+
e = f"Failed to register models/inpaint folder. Found existing value: {current_extensions}"
|
| 16 |
+
raise Exception(e)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
_add_folder_path("inpaint", [".pt", ".pth", ".safetensors", ".patch"])
|
| 20 |
+
|
| 21 |
+
from . import nodes
|
| 22 |
+
|
| 23 |
+
NODE_CLASS_MAPPINGS = {
|
| 24 |
+
"INPAINT_LoadFooocusInpaint": nodes.LoadFooocusInpaint,
|
| 25 |
+
"INPAINT_ApplyFooocusInpaint": nodes.ApplyFooocusInpaint,
|
| 26 |
+
"INPAINT_VAEEncodeInpaintConditioning": nodes.VAEEncodeInpaintConditioning,
|
| 27 |
+
"INPAINT_MaskedFill": nodes.MaskedFill,
|
| 28 |
+
"INPAINT_MaskedBlur": nodes.MaskedBlur,
|
| 29 |
+
"INPAINT_LoadInpaintModel": nodes.LoadInpaintModel,
|
| 30 |
+
"INPAINT_InpaintWithModel": nodes.InpaintWithModel,
|
| 31 |
+
"INPAINT_DenoiseToCompositingMask": nodes.DenoiseToCompositingMask,
|
| 32 |
+
}
|
| 33 |
+
NODE_DISPLAY_NAME_MAPPINGS = {
|
| 34 |
+
"INPAINT_LoadFooocusInpaint": "Load Fooocus Inpaint",
|
| 35 |
+
"INPAINT_ApplyFooocusInpaint": "Apply Fooocus Inpaint",
|
| 36 |
+
"INPAINT_VAEEncodeInpaintConditioning": "VAE Encode & Inpaint Conditioning",
|
| 37 |
+
"INPAINT_MaskedFill": "Fill Masked Area",
|
| 38 |
+
"INPAINT_MaskedBlur": "Blur Masked Area",
|
| 39 |
+
"INPAINT_LoadInpaintModel": "Load Inpaint Model",
|
| 40 |
+
"INPAINT_InpaintWithModel": "Inpaint (using Model)",
|
| 41 |
+
"INPAINT_DenoiseToCompositingMask": "Denoise to Compositing Mask",
|
| 42 |
+
}
|
sage2/mat/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# From https://github.com/chaiNNer-org/spandrel
|
| 2 |
+
# This extends what ComfyUI copied out of chaiNNer's codebase.
|
| 3 |
+
# (until such time as it just uses spandrel as depndency)
|
| 4 |
+
|
| 5 |
+
from .arch.MAT import MAT
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def load(state_dict):
|
| 9 |
+
state = {
|
| 10 |
+
k.replace("synthesis", "model.synthesis").replace("mapping", "model.mapping"): v
|
| 11 |
+
for k, v in state_dict.items()
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
model = MAT()
|
| 15 |
+
model.load_state_dict(state)
|
| 16 |
+
return model
|
sage2/mat/arch/LICENSE
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## creative commons
|
| 2 |
+
|
| 3 |
+
# Attribution-NonCommercial 4.0 International
|
| 4 |
+
|
| 5 |
+
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
|
| 6 |
+
|
| 7 |
+
### Using Creative Commons Public Licenses
|
| 8 |
+
|
| 9 |
+
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
|
| 10 |
+
|
| 11 |
+
* __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors).
|
| 12 |
+
|
| 13 |
+
* __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees).
|
| 14 |
+
|
| 15 |
+
## Creative Commons Attribution-NonCommercial 4.0 International Public License
|
| 16 |
+
|
| 17 |
+
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
| 18 |
+
|
| 19 |
+
### Section 1 – Definitions.
|
| 20 |
+
|
| 21 |
+
a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
| 22 |
+
|
| 23 |
+
b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
|
| 24 |
+
|
| 25 |
+
c. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
| 26 |
+
|
| 27 |
+
d. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
| 28 |
+
|
| 29 |
+
e. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
| 30 |
+
|
| 31 |
+
f. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
| 32 |
+
|
| 33 |
+
g. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
| 34 |
+
|
| 35 |
+
h. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License.
|
| 36 |
+
|
| 37 |
+
i. __NonCommercial__ means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
|
| 38 |
+
|
| 39 |
+
j. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
| 40 |
+
|
| 41 |
+
k. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
| 42 |
+
|
| 43 |
+
l. __You__ means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
|
| 44 |
+
|
| 45 |
+
### Section 2 – Scope.
|
| 46 |
+
|
| 47 |
+
a. ___License grant.___
|
| 48 |
+
|
| 49 |
+
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
| 50 |
+
|
| 51 |
+
A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
|
| 52 |
+
|
| 53 |
+
B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
|
| 54 |
+
|
| 55 |
+
2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
| 56 |
+
|
| 57 |
+
3. __Term.__ The term of this Public License is specified in Section 6(a).
|
| 58 |
+
|
| 59 |
+
4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
| 60 |
+
|
| 61 |
+
5. __Downstream recipients.__
|
| 62 |
+
|
| 63 |
+
A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
|
| 64 |
+
|
| 65 |
+
B. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
| 66 |
+
|
| 67 |
+
6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
|
| 68 |
+
|
| 69 |
+
b. ___Other rights.___
|
| 70 |
+
|
| 71 |
+
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
| 72 |
+
|
| 73 |
+
2. Patent and trademark rights are not licensed under this Public License.
|
| 74 |
+
|
| 75 |
+
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
|
| 76 |
+
|
| 77 |
+
### Section 3 – License Conditions.
|
| 78 |
+
|
| 79 |
+
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
| 80 |
+
|
| 81 |
+
a. ___Attribution.___
|
| 82 |
+
|
| 83 |
+
1. If You Share the Licensed Material (including in modified form), You must:
|
| 84 |
+
|
| 85 |
+
A. retain the following if it is supplied by the Licensor with the Licensed Material:
|
| 86 |
+
|
| 87 |
+
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
| 88 |
+
|
| 89 |
+
ii. a copyright notice;
|
| 90 |
+
|
| 91 |
+
iii. a notice that refers to this Public License;
|
| 92 |
+
|
| 93 |
+
iv. a notice that refers to the disclaimer of warranties;
|
| 94 |
+
|
| 95 |
+
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
| 96 |
+
|
| 97 |
+
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
| 98 |
+
|
| 99 |
+
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
| 100 |
+
|
| 101 |
+
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
| 102 |
+
|
| 103 |
+
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
|
| 104 |
+
|
| 105 |
+
4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
|
| 106 |
+
|
| 107 |
+
### Section 4 – Sui Generis Database Rights.
|
| 108 |
+
|
| 109 |
+
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
| 110 |
+
|
| 111 |
+
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
|
| 112 |
+
|
| 113 |
+
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
|
| 114 |
+
|
| 115 |
+
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
| 116 |
+
|
| 117 |
+
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
| 118 |
+
|
| 119 |
+
### Section 5 – Disclaimer of Warranties and Limitation of Liability.
|
| 120 |
+
|
| 121 |
+
a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__
|
| 122 |
+
|
| 123 |
+
b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__
|
| 124 |
+
|
| 125 |
+
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
| 126 |
+
|
| 127 |
+
### Section 6 – Term and Termination.
|
| 128 |
+
|
| 129 |
+
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
| 130 |
+
|
| 131 |
+
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
| 132 |
+
|
| 133 |
+
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
| 134 |
+
|
| 135 |
+
2. upon express reinstatement by the Licensor.
|
| 136 |
+
|
| 137 |
+
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
| 138 |
+
|
| 139 |
+
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
| 140 |
+
|
| 141 |
+
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
| 142 |
+
|
| 143 |
+
### Section 7 – Other Terms and Conditions.
|
| 144 |
+
|
| 145 |
+
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
| 146 |
+
|
| 147 |
+
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
| 148 |
+
|
| 149 |
+
### Section 8 – Interpretation.
|
| 150 |
+
|
| 151 |
+
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
| 152 |
+
|
| 153 |
+
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
| 154 |
+
|
| 155 |
+
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
| 156 |
+
|
| 157 |
+
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
| 158 |
+
|
| 159 |
+
> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
|
| 160 |
+
>
|
| 161 |
+
> Creative Commons may be contacted at creativecommons.org
|
sage2/mat/arch/MAT.py
ADDED
|
@@ -0,0 +1,1612 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# type: ignore
|
| 2 |
+
"""Original MAT project is copyright of fenglingwb: https://github.com/fenglinglwb/MAT
|
| 3 |
+
Code used for this implementation of MAT is modified from lama-cleaner,
|
| 4 |
+
copyright of Sanster: https://github.com/fenglinglwb/MAT"""
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
import torch
|
| 9 |
+
import torch.nn as nn
|
| 10 |
+
import torch.nn.functional as F
|
| 11 |
+
import torch.utils.checkpoint as checkpoint
|
| 12 |
+
|
| 13 |
+
from .utils import (
|
| 14 |
+
Conv2dLayer,
|
| 15 |
+
FullyConnectedLayer,
|
| 16 |
+
activation_funcs,
|
| 17 |
+
bias_act,
|
| 18 |
+
conv2d_resample,
|
| 19 |
+
normalize_2nd_moment,
|
| 20 |
+
setup_filter,
|
| 21 |
+
to_2tuple,
|
| 22 |
+
upsample2d,
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class ModulatedConv2d(nn.Module):
|
| 27 |
+
def __init__(
|
| 28 |
+
self,
|
| 29 |
+
in_channels, # Number of input channels.
|
| 30 |
+
out_channels, # Number of output channels.
|
| 31 |
+
kernel_size, # Width and height of the convolution kernel.
|
| 32 |
+
style_dim, # dimension of the style code
|
| 33 |
+
demodulate=True, # perfrom demodulation
|
| 34 |
+
up=1, # Integer upsampling factor.
|
| 35 |
+
down=1, # Integer downsampling factor.
|
| 36 |
+
resample_filter=[
|
| 37 |
+
1,
|
| 38 |
+
3,
|
| 39 |
+
3,
|
| 40 |
+
1,
|
| 41 |
+
], # Low-pass filter to apply when resampling activations.
|
| 42 |
+
conv_clamp=None, # Clamp the output to +-X, None = disable clamping.
|
| 43 |
+
):
|
| 44 |
+
super().__init__()
|
| 45 |
+
self.demodulate = demodulate
|
| 46 |
+
|
| 47 |
+
self.weight = torch.nn.Parameter(
|
| 48 |
+
torch.randn([1, out_channels, in_channels, kernel_size, kernel_size])
|
| 49 |
+
)
|
| 50 |
+
self.out_channels = out_channels
|
| 51 |
+
self.kernel_size = kernel_size
|
| 52 |
+
self.weight_gain = 1 / np.sqrt(in_channels * (kernel_size**2))
|
| 53 |
+
self.padding = self.kernel_size // 2
|
| 54 |
+
self.up = up
|
| 55 |
+
self.down = down
|
| 56 |
+
self.register_buffer("resample_filter", setup_filter(resample_filter))
|
| 57 |
+
self.conv_clamp = conv_clamp
|
| 58 |
+
|
| 59 |
+
self.affine = FullyConnectedLayer(style_dim, in_channels, bias_init=1)
|
| 60 |
+
|
| 61 |
+
def forward(self, x, style):
|
| 62 |
+
batch, in_channels, height, width = x.shape
|
| 63 |
+
style = self.affine(style).view(batch, 1, in_channels, 1, 1).to(x.device)
|
| 64 |
+
weight = self.weight.to(x.device) * self.weight_gain * style
|
| 65 |
+
|
| 66 |
+
if self.demodulate:
|
| 67 |
+
decoefs = (weight.pow(2).sum(dim=[2, 3, 4]) + 1e-8).rsqrt()
|
| 68 |
+
weight = weight * decoefs.view(batch, self.out_channels, 1, 1, 1)
|
| 69 |
+
|
| 70 |
+
weight = weight.view(
|
| 71 |
+
batch * self.out_channels, in_channels, self.kernel_size, self.kernel_size
|
| 72 |
+
)
|
| 73 |
+
x = x.view(1, batch * in_channels, height, width)
|
| 74 |
+
x = conv2d_resample(
|
| 75 |
+
x=x,
|
| 76 |
+
w=weight,
|
| 77 |
+
f=self.resample_filter,
|
| 78 |
+
up=self.up,
|
| 79 |
+
down=self.down,
|
| 80 |
+
padding=self.padding,
|
| 81 |
+
groups=batch,
|
| 82 |
+
)
|
| 83 |
+
out = x.view(batch, self.out_channels, *x.shape[2:])
|
| 84 |
+
|
| 85 |
+
return out
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class StyleConv(torch.nn.Module):
|
| 89 |
+
def __init__(
|
| 90 |
+
self,
|
| 91 |
+
in_channels, # Number of input channels.
|
| 92 |
+
out_channels, # Number of output channels.
|
| 93 |
+
style_dim, # Intermediate latent (W) dimensionality.
|
| 94 |
+
resolution, # Resolution of this layer.
|
| 95 |
+
kernel_size=3, # Convolution kernel size.
|
| 96 |
+
up=1, # Integer upsampling factor.
|
| 97 |
+
use_noise=False, # Enable noise input?
|
| 98 |
+
activation="lrelu", # Activation function: 'relu', 'lrelu', etc.
|
| 99 |
+
resample_filter=[
|
| 100 |
+
1,
|
| 101 |
+
3,
|
| 102 |
+
3,
|
| 103 |
+
1,
|
| 104 |
+
], # Low-pass filter to apply when resampling activations.
|
| 105 |
+
conv_clamp=None, # Clamp the output of convolution layers to +-X, None = disable clamping.
|
| 106 |
+
demodulate=True, # perform demodulation
|
| 107 |
+
):
|
| 108 |
+
super().__init__()
|
| 109 |
+
|
| 110 |
+
self.conv = ModulatedConv2d(
|
| 111 |
+
in_channels=in_channels,
|
| 112 |
+
out_channels=out_channels,
|
| 113 |
+
kernel_size=kernel_size,
|
| 114 |
+
style_dim=style_dim,
|
| 115 |
+
demodulate=demodulate,
|
| 116 |
+
up=up,
|
| 117 |
+
resample_filter=resample_filter,
|
| 118 |
+
conv_clamp=conv_clamp,
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
self.use_noise = use_noise
|
| 122 |
+
self.resolution = resolution
|
| 123 |
+
if use_noise:
|
| 124 |
+
self.register_buffer("noise_const", torch.randn([resolution, resolution]))
|
| 125 |
+
self.noise_strength = torch.nn.Parameter(torch.zeros([]))
|
| 126 |
+
|
| 127 |
+
self.bias = torch.nn.Parameter(torch.zeros([out_channels]))
|
| 128 |
+
self.activation = activation
|
| 129 |
+
self.act_gain = activation_funcs[activation].def_gain
|
| 130 |
+
self.conv_clamp = conv_clamp
|
| 131 |
+
|
| 132 |
+
def forward(self, x, style, noise_mode="random", gain=1):
|
| 133 |
+
x = self.conv(x, style)
|
| 134 |
+
|
| 135 |
+
assert noise_mode in ["random", "const", "none"]
|
| 136 |
+
|
| 137 |
+
if self.use_noise:
|
| 138 |
+
if noise_mode == "random":
|
| 139 |
+
xh, xw = x.size()[-2:]
|
| 140 |
+
noise = (
|
| 141 |
+
torch.randn([x.shape[0], 1, xh, xw], device=x.device)
|
| 142 |
+
* self.noise_strength
|
| 143 |
+
)
|
| 144 |
+
if noise_mode == "const":
|
| 145 |
+
noise = self.noise_const * self.noise_strength
|
| 146 |
+
x = x + noise
|
| 147 |
+
|
| 148 |
+
act_gain = self.act_gain * gain
|
| 149 |
+
act_clamp = self.conv_clamp * gain if self.conv_clamp is not None else None
|
| 150 |
+
out = bias_act(
|
| 151 |
+
x, self.bias, act=self.activation, gain=act_gain, clamp=act_clamp
|
| 152 |
+
)
|
| 153 |
+
|
| 154 |
+
return out
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
class ToRGB(torch.nn.Module):
|
| 158 |
+
def __init__(
|
| 159 |
+
self,
|
| 160 |
+
in_channels,
|
| 161 |
+
out_channels,
|
| 162 |
+
style_dim,
|
| 163 |
+
kernel_size=1,
|
| 164 |
+
resample_filter=[1, 3, 3, 1],
|
| 165 |
+
conv_clamp=None,
|
| 166 |
+
demodulate=False,
|
| 167 |
+
):
|
| 168 |
+
super().__init__()
|
| 169 |
+
|
| 170 |
+
self.conv = ModulatedConv2d(
|
| 171 |
+
in_channels=in_channels,
|
| 172 |
+
out_channels=out_channels,
|
| 173 |
+
kernel_size=kernel_size,
|
| 174 |
+
style_dim=style_dim,
|
| 175 |
+
demodulate=demodulate,
|
| 176 |
+
resample_filter=resample_filter,
|
| 177 |
+
conv_clamp=conv_clamp,
|
| 178 |
+
)
|
| 179 |
+
self.bias = torch.nn.Parameter(torch.zeros([out_channels]))
|
| 180 |
+
self.register_buffer("resample_filter", setup_filter(resample_filter))
|
| 181 |
+
self.conv_clamp = conv_clamp
|
| 182 |
+
|
| 183 |
+
def forward(self, x, style, skip=None):
|
| 184 |
+
x = self.conv(x, style)
|
| 185 |
+
out = bias_act(x, self.bias, clamp=self.conv_clamp)
|
| 186 |
+
|
| 187 |
+
if skip is not None:
|
| 188 |
+
if skip.shape != out.shape:
|
| 189 |
+
skip = upsample2d(skip, self.resample_filter)
|
| 190 |
+
out = out + skip
|
| 191 |
+
|
| 192 |
+
return out
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def get_style_code(a, b):
|
| 196 |
+
return torch.cat([a, b.to(a.device)], dim=1)
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
class DecBlockFirst(nn.Module):
|
| 200 |
+
def __init__(
|
| 201 |
+
self,
|
| 202 |
+
in_channels,
|
| 203 |
+
out_channels,
|
| 204 |
+
activation,
|
| 205 |
+
style_dim,
|
| 206 |
+
use_noise,
|
| 207 |
+
demodulate,
|
| 208 |
+
img_channels,
|
| 209 |
+
):
|
| 210 |
+
super().__init__()
|
| 211 |
+
self.fc = FullyConnectedLayer(
|
| 212 |
+
in_features=in_channels * 2,
|
| 213 |
+
out_features=in_channels * 4**2,
|
| 214 |
+
activation=activation,
|
| 215 |
+
)
|
| 216 |
+
self.conv = StyleConv(
|
| 217 |
+
in_channels=in_channels,
|
| 218 |
+
out_channels=out_channels,
|
| 219 |
+
style_dim=style_dim,
|
| 220 |
+
resolution=4,
|
| 221 |
+
kernel_size=3,
|
| 222 |
+
use_noise=use_noise,
|
| 223 |
+
activation=activation,
|
| 224 |
+
demodulate=demodulate,
|
| 225 |
+
)
|
| 226 |
+
self.toRGB = ToRGB(
|
| 227 |
+
in_channels=out_channels,
|
| 228 |
+
out_channels=img_channels,
|
| 229 |
+
style_dim=style_dim,
|
| 230 |
+
kernel_size=1,
|
| 231 |
+
demodulate=False,
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
def forward(self, x, ws, gs, E_features, noise_mode="random"):
|
| 235 |
+
x = self.fc(x).view(x.shape[0], -1, 4, 4)
|
| 236 |
+
x = x + E_features[2]
|
| 237 |
+
style = get_style_code(ws[:, 0], gs)
|
| 238 |
+
x = self.conv(x, style, noise_mode=noise_mode)
|
| 239 |
+
style = get_style_code(ws[:, 1], gs)
|
| 240 |
+
img = self.toRGB(x, style, skip=None)
|
| 241 |
+
|
| 242 |
+
return x, img
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
class MappingNet(torch.nn.Module):
|
| 246 |
+
def __init__(
|
| 247 |
+
self,
|
| 248 |
+
z_dim, # Input latent (Z) dimensionality, 0 = no latent.
|
| 249 |
+
c_dim, # Conditioning label (C) dimensionality, 0 = no label.
|
| 250 |
+
w_dim, # Intermediate latent (W) dimensionality.
|
| 251 |
+
num_ws, # Number of intermediate latents to output, None = do not broadcast.
|
| 252 |
+
num_layers=8, # Number of mapping layers.
|
| 253 |
+
embed_features=None, # Label embedding dimensionality, None = same as w_dim.
|
| 254 |
+
layer_features=None, # Number of intermediate features in the mapping layers, None = same as w_dim.
|
| 255 |
+
activation="lrelu", # Activation function: 'relu', 'lrelu', etc.
|
| 256 |
+
lr_multiplier=0.01, # Learning rate multiplier for the mapping layers.
|
| 257 |
+
w_avg_beta=0.995, # Decay for tracking the moving average of W during training, None = do not track.
|
| 258 |
+
):
|
| 259 |
+
super().__init__()
|
| 260 |
+
self.z_dim = z_dim
|
| 261 |
+
self.c_dim = c_dim
|
| 262 |
+
self.w_dim = w_dim
|
| 263 |
+
self.num_ws = num_ws
|
| 264 |
+
self.num_layers = num_layers
|
| 265 |
+
self.w_avg_beta = w_avg_beta
|
| 266 |
+
|
| 267 |
+
if embed_features is None:
|
| 268 |
+
embed_features = w_dim
|
| 269 |
+
if c_dim == 0:
|
| 270 |
+
embed_features = 0
|
| 271 |
+
if layer_features is None:
|
| 272 |
+
layer_features = w_dim
|
| 273 |
+
features_list = (
|
| 274 |
+
[z_dim + embed_features] + [layer_features] * (num_layers - 1) + [w_dim]
|
| 275 |
+
)
|
| 276 |
+
|
| 277 |
+
if c_dim > 0:
|
| 278 |
+
self.embed = FullyConnectedLayer(c_dim, embed_features)
|
| 279 |
+
for idx in range(num_layers):
|
| 280 |
+
in_features = features_list[idx]
|
| 281 |
+
out_features = features_list[idx + 1]
|
| 282 |
+
layer = FullyConnectedLayer(
|
| 283 |
+
in_features,
|
| 284 |
+
out_features,
|
| 285 |
+
activation=activation,
|
| 286 |
+
lr_multiplier=lr_multiplier,
|
| 287 |
+
)
|
| 288 |
+
setattr(self, f"fc{idx}", layer)
|
| 289 |
+
|
| 290 |
+
if num_ws is not None and w_avg_beta is not None:
|
| 291 |
+
self.register_buffer("w_avg", torch.zeros([w_dim]))
|
| 292 |
+
|
| 293 |
+
def forward(
|
| 294 |
+
self, z, c, truncation_psi=1, truncation_cutoff=None, skip_w_avg_update=False
|
| 295 |
+
):
|
| 296 |
+
# Embed, normalize, and concat inputs.
|
| 297 |
+
x = None
|
| 298 |
+
with torch.autograd.profiler.record_function("input"):
|
| 299 |
+
if self.z_dim > 0:
|
| 300 |
+
x = normalize_2nd_moment(z.to(torch.float32))
|
| 301 |
+
if self.c_dim > 0:
|
| 302 |
+
y = normalize_2nd_moment(self.embed(c.to(torch.float32)))
|
| 303 |
+
x = torch.cat([x, y], dim=1) if x is not None else y
|
| 304 |
+
|
| 305 |
+
# Main layers.
|
| 306 |
+
for idx in range(self.num_layers):
|
| 307 |
+
layer = getattr(self, f"fc{idx}")
|
| 308 |
+
x = layer(x)
|
| 309 |
+
|
| 310 |
+
# Update moving average of W.
|
| 311 |
+
if self.w_avg_beta is not None and self.training and not skip_w_avg_update:
|
| 312 |
+
with torch.autograd.profiler.record_function("update_w_avg"):
|
| 313 |
+
self.w_avg.copy_(
|
| 314 |
+
x.detach().mean(dim=0).lerp(self.w_avg, self.w_avg_beta)
|
| 315 |
+
)
|
| 316 |
+
|
| 317 |
+
# Broadcast.
|
| 318 |
+
if self.num_ws is not None:
|
| 319 |
+
with torch.autograd.profiler.record_function("broadcast"):
|
| 320 |
+
x = x.unsqueeze(1).repeat([1, self.num_ws, 1])
|
| 321 |
+
|
| 322 |
+
# Apply truncation.
|
| 323 |
+
if truncation_psi != 1:
|
| 324 |
+
with torch.autograd.profiler.record_function("truncate"):
|
| 325 |
+
assert self.w_avg_beta is not None
|
| 326 |
+
if self.num_ws is None or truncation_cutoff is None:
|
| 327 |
+
x = self.w_avg.lerp(x, truncation_psi)
|
| 328 |
+
else:
|
| 329 |
+
x[:, :truncation_cutoff] = self.w_avg.lerp(
|
| 330 |
+
x[:, :truncation_cutoff], truncation_psi
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
return x
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
class DisFromRGB(nn.Module):
|
| 337 |
+
def __init__(
|
| 338 |
+
self, in_channels, out_channels, activation
|
| 339 |
+
): # res = 2, ..., resolution_log2
|
| 340 |
+
super().__init__()
|
| 341 |
+
self.conv = Conv2dLayer(
|
| 342 |
+
in_channels=in_channels,
|
| 343 |
+
out_channels=out_channels,
|
| 344 |
+
kernel_size=1,
|
| 345 |
+
activation=activation,
|
| 346 |
+
)
|
| 347 |
+
|
| 348 |
+
def forward(self, x):
|
| 349 |
+
return self.conv(x)
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
class DisBlock(nn.Module):
|
| 353 |
+
def __init__(
|
| 354 |
+
self, in_channels, out_channels, activation
|
| 355 |
+
): # res = 2, ..., resolution_log2
|
| 356 |
+
super().__init__()
|
| 357 |
+
self.conv0 = Conv2dLayer(
|
| 358 |
+
in_channels=in_channels,
|
| 359 |
+
out_channels=in_channels,
|
| 360 |
+
kernel_size=3,
|
| 361 |
+
activation=activation,
|
| 362 |
+
)
|
| 363 |
+
self.conv1 = Conv2dLayer(
|
| 364 |
+
in_channels=in_channels,
|
| 365 |
+
out_channels=out_channels,
|
| 366 |
+
kernel_size=3,
|
| 367 |
+
down=2,
|
| 368 |
+
activation=activation,
|
| 369 |
+
)
|
| 370 |
+
self.skip = Conv2dLayer(
|
| 371 |
+
in_channels=in_channels,
|
| 372 |
+
out_channels=out_channels,
|
| 373 |
+
kernel_size=1,
|
| 374 |
+
down=2,
|
| 375 |
+
bias=False,
|
| 376 |
+
)
|
| 377 |
+
|
| 378 |
+
def forward(self, x):
|
| 379 |
+
skip = self.skip(x, gain=np.sqrt(0.5))
|
| 380 |
+
x = self.conv0(x)
|
| 381 |
+
x = self.conv1(x, gain=np.sqrt(0.5))
|
| 382 |
+
out = skip + x
|
| 383 |
+
|
| 384 |
+
return out
|
| 385 |
+
|
| 386 |
+
|
| 387 |
+
def nf(stage, channel_base=32768, channel_decay=1.0, channel_max=512):
|
| 388 |
+
NF = {512: 64, 256: 128, 128: 256, 64: 512, 32: 512, 16: 512, 8: 512, 4: 512}
|
| 389 |
+
return NF[2**stage]
|
| 390 |
+
|
| 391 |
+
|
| 392 |
+
class Mlp(nn.Module):
|
| 393 |
+
def __init__(
|
| 394 |
+
self,
|
| 395 |
+
in_features,
|
| 396 |
+
hidden_features=None,
|
| 397 |
+
out_features=None,
|
| 398 |
+
act_layer=nn.GELU,
|
| 399 |
+
drop=0.0,
|
| 400 |
+
):
|
| 401 |
+
super().__init__()
|
| 402 |
+
out_features = out_features or in_features
|
| 403 |
+
hidden_features = hidden_features or in_features
|
| 404 |
+
self.fc1 = FullyConnectedLayer(
|
| 405 |
+
in_features=in_features, out_features=hidden_features, activation="lrelu"
|
| 406 |
+
)
|
| 407 |
+
self.fc2 = FullyConnectedLayer(
|
| 408 |
+
in_features=hidden_features, out_features=out_features
|
| 409 |
+
)
|
| 410 |
+
|
| 411 |
+
def forward(self, x):
|
| 412 |
+
x = self.fc1(x)
|
| 413 |
+
x = self.fc2(x)
|
| 414 |
+
return x
|
| 415 |
+
|
| 416 |
+
|
| 417 |
+
def window_partition(x, window_size):
|
| 418 |
+
"""
|
| 419 |
+
Args:
|
| 420 |
+
x: (B, H, W, C)
|
| 421 |
+
window_size (int): window size
|
| 422 |
+
Returns:
|
| 423 |
+
windows: (num_windows*B, window_size, window_size, C)
|
| 424 |
+
"""
|
| 425 |
+
B, H, W, C = x.shape
|
| 426 |
+
x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)
|
| 427 |
+
windows = (
|
| 428 |
+
x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)
|
| 429 |
+
)
|
| 430 |
+
return windows
|
| 431 |
+
|
| 432 |
+
|
| 433 |
+
def window_reverse(windows, window_size: int, H: int, W: int):
|
| 434 |
+
"""
|
| 435 |
+
Args:
|
| 436 |
+
windows: (num_windows*B, window_size, window_size, C)
|
| 437 |
+
window_size (int): Window size
|
| 438 |
+
H (int): Height of image
|
| 439 |
+
W (int): Width of image
|
| 440 |
+
Returns:
|
| 441 |
+
x: (B, H, W, C)
|
| 442 |
+
"""
|
| 443 |
+
B = int(windows.shape[0] / (H * W / window_size / window_size))
|
| 444 |
+
# B = windows.shape[0] / (H * W / window_size / window_size)
|
| 445 |
+
x = windows.view(
|
| 446 |
+
B, H // window_size, W // window_size, window_size, window_size, -1
|
| 447 |
+
)
|
| 448 |
+
x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)
|
| 449 |
+
return x
|
| 450 |
+
|
| 451 |
+
|
| 452 |
+
class Conv2dLayerPartial(nn.Module):
|
| 453 |
+
def __init__(
|
| 454 |
+
self,
|
| 455 |
+
in_channels, # Number of input channels.
|
| 456 |
+
out_channels, # Number of output channels.
|
| 457 |
+
kernel_size, # Width and height of the convolution kernel.
|
| 458 |
+
bias=True, # Apply additive bias before the activation function?
|
| 459 |
+
activation="linear", # Activation function: 'relu', 'lrelu', etc.
|
| 460 |
+
up=1, # Integer upsampling factor.
|
| 461 |
+
down=1, # Integer downsampling factor.
|
| 462 |
+
resample_filter=[
|
| 463 |
+
1,
|
| 464 |
+
3,
|
| 465 |
+
3,
|
| 466 |
+
1,
|
| 467 |
+
], # Low-pass filter to apply when resampling activations.
|
| 468 |
+
conv_clamp=None, # Clamp the output to +-X, None = disable clamping.
|
| 469 |
+
trainable=True, # Update the weights of this layer during training?
|
| 470 |
+
):
|
| 471 |
+
super().__init__()
|
| 472 |
+
self.conv = Conv2dLayer(
|
| 473 |
+
in_channels,
|
| 474 |
+
out_channels,
|
| 475 |
+
kernel_size,
|
| 476 |
+
bias,
|
| 477 |
+
activation,
|
| 478 |
+
up,
|
| 479 |
+
down,
|
| 480 |
+
resample_filter,
|
| 481 |
+
conv_clamp,
|
| 482 |
+
trainable,
|
| 483 |
+
)
|
| 484 |
+
|
| 485 |
+
self.weight_maskUpdater = torch.ones(1, 1, kernel_size, kernel_size)
|
| 486 |
+
self.slide_winsize = kernel_size**2
|
| 487 |
+
self.stride = down
|
| 488 |
+
self.padding = kernel_size // 2 if kernel_size % 2 == 1 else 0
|
| 489 |
+
|
| 490 |
+
def forward(self, x, mask=None):
|
| 491 |
+
if mask is not None:
|
| 492 |
+
with torch.no_grad():
|
| 493 |
+
if self.weight_maskUpdater.type() != x.type():
|
| 494 |
+
self.weight_maskUpdater = self.weight_maskUpdater.to(x)
|
| 495 |
+
update_mask = F.conv2d(
|
| 496 |
+
mask,
|
| 497 |
+
self.weight_maskUpdater,
|
| 498 |
+
bias=None,
|
| 499 |
+
stride=self.stride,
|
| 500 |
+
padding=self.padding,
|
| 501 |
+
)
|
| 502 |
+
mask_ratio = self.slide_winsize / (update_mask + 1e-8)
|
| 503 |
+
update_mask = torch.clamp(update_mask, 0, 1) # 0 or 1
|
| 504 |
+
mask_ratio = torch.mul(mask_ratio, update_mask)
|
| 505 |
+
x = self.conv(x)
|
| 506 |
+
x = torch.mul(x, mask_ratio)
|
| 507 |
+
return x, update_mask
|
| 508 |
+
else:
|
| 509 |
+
x = self.conv(x)
|
| 510 |
+
return x, None
|
| 511 |
+
|
| 512 |
+
|
| 513 |
+
class WindowAttention(nn.Module):
|
| 514 |
+
r"""Window based multi-head self attention (W-MSA) module with relative position bias.
|
| 515 |
+
It supports both of shifted and non-shifted window.
|
| 516 |
+
Args:
|
| 517 |
+
dim (int): Number of input channels.
|
| 518 |
+
window_size (tuple[int]): The height and width of the window.
|
| 519 |
+
num_heads (int): Number of attention heads.
|
| 520 |
+
qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
|
| 521 |
+
qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set
|
| 522 |
+
attn_drop (float, optional): Dropout ratio of attention weight. Default: 0.0
|
| 523 |
+
proj_drop (float, optional): Dropout ratio of output. Default: 0.0
|
| 524 |
+
"""
|
| 525 |
+
|
| 526 |
+
def __init__(
|
| 527 |
+
self,
|
| 528 |
+
dim,
|
| 529 |
+
window_size,
|
| 530 |
+
num_heads,
|
| 531 |
+
down_ratio=1,
|
| 532 |
+
qkv_bias=True,
|
| 533 |
+
qk_scale=None,
|
| 534 |
+
attn_drop=0.0,
|
| 535 |
+
proj_drop=0.0,
|
| 536 |
+
):
|
| 537 |
+
super().__init__()
|
| 538 |
+
self.dim = dim
|
| 539 |
+
self.window_size = window_size # Wh, Ww
|
| 540 |
+
self.num_heads = num_heads
|
| 541 |
+
head_dim = dim // num_heads
|
| 542 |
+
self.scale = qk_scale or head_dim**-0.5
|
| 543 |
+
|
| 544 |
+
self.q = FullyConnectedLayer(in_features=dim, out_features=dim)
|
| 545 |
+
self.k = FullyConnectedLayer(in_features=dim, out_features=dim)
|
| 546 |
+
self.v = FullyConnectedLayer(in_features=dim, out_features=dim)
|
| 547 |
+
self.proj = FullyConnectedLayer(in_features=dim, out_features=dim)
|
| 548 |
+
|
| 549 |
+
self.softmax = nn.Softmax(dim=-1)
|
| 550 |
+
|
| 551 |
+
def forward(self, x, mask_windows=None, mask=None):
|
| 552 |
+
"""
|
| 553 |
+
Args:
|
| 554 |
+
x: input features with shape of (num_windows*B, N, C)
|
| 555 |
+
mask: (0/-inf) mask with shape of (num_windows, Wh*Ww, Wh*Ww) or None
|
| 556 |
+
"""
|
| 557 |
+
B_, N, C = x.shape
|
| 558 |
+
norm_x = F.normalize(x, p=2.0, dim=-1)
|
| 559 |
+
q = (
|
| 560 |
+
self.q(norm_x)
|
| 561 |
+
.reshape(B_, N, self.num_heads, C // self.num_heads)
|
| 562 |
+
.permute(0, 2, 1, 3)
|
| 563 |
+
)
|
| 564 |
+
k = (
|
| 565 |
+
self.k(norm_x)
|
| 566 |
+
.view(B_, -1, self.num_heads, C // self.num_heads)
|
| 567 |
+
.permute(0, 2, 3, 1)
|
| 568 |
+
)
|
| 569 |
+
v = (
|
| 570 |
+
self.v(x)
|
| 571 |
+
.view(B_, -1, self.num_heads, C // self.num_heads)
|
| 572 |
+
.permute(0, 2, 1, 3)
|
| 573 |
+
)
|
| 574 |
+
|
| 575 |
+
attn = (q @ k) * self.scale
|
| 576 |
+
|
| 577 |
+
if mask is not None:
|
| 578 |
+
nW = mask.shape[0]
|
| 579 |
+
attn = attn.view(B_ // nW, nW, self.num_heads, N, N) + mask.unsqueeze(
|
| 580 |
+
1
|
| 581 |
+
).unsqueeze(0)
|
| 582 |
+
attn = attn.view(-1, self.num_heads, N, N)
|
| 583 |
+
|
| 584 |
+
if mask_windows is not None:
|
| 585 |
+
attn_mask_windows = mask_windows.squeeze(-1).unsqueeze(1).unsqueeze(1)
|
| 586 |
+
attn = attn + attn_mask_windows.masked_fill(
|
| 587 |
+
attn_mask_windows == 0, float(-100.0)
|
| 588 |
+
).masked_fill(attn_mask_windows == 1, 0.0)
|
| 589 |
+
with torch.no_grad():
|
| 590 |
+
mask_windows = torch.clamp(
|
| 591 |
+
torch.sum(mask_windows, dim=1, keepdim=True), 0, 1
|
| 592 |
+
).repeat(1, N, 1)
|
| 593 |
+
|
| 594 |
+
attn = self.softmax(attn)
|
| 595 |
+
|
| 596 |
+
x = (attn @ v).transpose(1, 2).reshape(B_, N, C)
|
| 597 |
+
x = self.proj(x)
|
| 598 |
+
return x, mask_windows
|
| 599 |
+
|
| 600 |
+
|
| 601 |
+
class SwinTransformerBlock(nn.Module):
|
| 602 |
+
r"""Swin Transformer Block.
|
| 603 |
+
Args:
|
| 604 |
+
dim (int): Number of input channels.
|
| 605 |
+
input_resolution (tuple[int]): Input resulotion.
|
| 606 |
+
num_heads (int): Number of attention heads.
|
| 607 |
+
window_size (int): Window size.
|
| 608 |
+
shift_size (int): Shift size for SW-MSA.
|
| 609 |
+
mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
|
| 610 |
+
qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
|
| 611 |
+
qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set.
|
| 612 |
+
drop (float, optional): Dropout rate. Default: 0.0
|
| 613 |
+
attn_drop (float, optional): Attention dropout rate. Default: 0.0
|
| 614 |
+
drop_path (float, optional): Stochastic depth rate. Default: 0.0
|
| 615 |
+
act_layer (nn.Module, optional): Activation layer. Default: nn.GELU
|
| 616 |
+
norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm
|
| 617 |
+
"""
|
| 618 |
+
|
| 619 |
+
def __init__(
|
| 620 |
+
self,
|
| 621 |
+
dim,
|
| 622 |
+
input_resolution,
|
| 623 |
+
num_heads,
|
| 624 |
+
down_ratio=1,
|
| 625 |
+
window_size=7,
|
| 626 |
+
shift_size=0,
|
| 627 |
+
mlp_ratio=4.0,
|
| 628 |
+
qkv_bias=True,
|
| 629 |
+
qk_scale=None,
|
| 630 |
+
drop=0.0,
|
| 631 |
+
attn_drop=0.0,
|
| 632 |
+
drop_path=0.0,
|
| 633 |
+
act_layer=nn.GELU,
|
| 634 |
+
norm_layer=nn.LayerNorm,
|
| 635 |
+
):
|
| 636 |
+
super().__init__()
|
| 637 |
+
self.dim = dim
|
| 638 |
+
self.input_resolution = input_resolution
|
| 639 |
+
self.num_heads = num_heads
|
| 640 |
+
self.window_size = window_size
|
| 641 |
+
self.shift_size = shift_size
|
| 642 |
+
self.mlp_ratio = mlp_ratio
|
| 643 |
+
if min(self.input_resolution) <= self.window_size:
|
| 644 |
+
# if window size is larger than input resolution, we don't partition windows
|
| 645 |
+
self.shift_size = 0
|
| 646 |
+
self.window_size = min(self.input_resolution)
|
| 647 |
+
assert (
|
| 648 |
+
0 <= self.shift_size < self.window_size
|
| 649 |
+
), "shift_size must in 0-window_size"
|
| 650 |
+
|
| 651 |
+
if self.shift_size > 0:
|
| 652 |
+
down_ratio = 1
|
| 653 |
+
self.attn = WindowAttention(
|
| 654 |
+
dim,
|
| 655 |
+
window_size=to_2tuple(self.window_size),
|
| 656 |
+
num_heads=num_heads,
|
| 657 |
+
down_ratio=down_ratio,
|
| 658 |
+
qkv_bias=qkv_bias,
|
| 659 |
+
qk_scale=qk_scale,
|
| 660 |
+
attn_drop=attn_drop,
|
| 661 |
+
proj_drop=drop,
|
| 662 |
+
)
|
| 663 |
+
|
| 664 |
+
self.fuse = FullyConnectedLayer(
|
| 665 |
+
in_features=dim * 2, out_features=dim, activation="lrelu"
|
| 666 |
+
)
|
| 667 |
+
|
| 668 |
+
mlp_hidden_dim = int(dim * mlp_ratio)
|
| 669 |
+
self.mlp = Mlp(
|
| 670 |
+
in_features=dim,
|
| 671 |
+
hidden_features=mlp_hidden_dim,
|
| 672 |
+
act_layer=act_layer,
|
| 673 |
+
drop=drop,
|
| 674 |
+
)
|
| 675 |
+
|
| 676 |
+
if self.shift_size > 0:
|
| 677 |
+
attn_mask = self.calculate_mask(self.input_resolution)
|
| 678 |
+
else:
|
| 679 |
+
attn_mask = None
|
| 680 |
+
|
| 681 |
+
self.register_buffer("attn_mask", attn_mask)
|
| 682 |
+
|
| 683 |
+
def calculate_mask(self, x_size):
|
| 684 |
+
# calculate attention mask for SW-MSA
|
| 685 |
+
H, W = x_size
|
| 686 |
+
img_mask = torch.zeros((1, H, W, 1)) # 1 H W 1
|
| 687 |
+
h_slices = (
|
| 688 |
+
slice(0, -self.window_size),
|
| 689 |
+
slice(-self.window_size, -self.shift_size),
|
| 690 |
+
slice(-self.shift_size, None),
|
| 691 |
+
)
|
| 692 |
+
w_slices = (
|
| 693 |
+
slice(0, -self.window_size),
|
| 694 |
+
slice(-self.window_size, -self.shift_size),
|
| 695 |
+
slice(-self.shift_size, None),
|
| 696 |
+
)
|
| 697 |
+
cnt = 0
|
| 698 |
+
for h in h_slices:
|
| 699 |
+
for w in w_slices:
|
| 700 |
+
img_mask[:, h, w, :] = cnt
|
| 701 |
+
cnt += 1
|
| 702 |
+
|
| 703 |
+
mask_windows = window_partition(
|
| 704 |
+
img_mask, self.window_size
|
| 705 |
+
) # nW, window_size, window_size, 1
|
| 706 |
+
mask_windows = mask_windows.view(-1, self.window_size * self.window_size)
|
| 707 |
+
attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2)
|
| 708 |
+
attn_mask = attn_mask.masked_fill(attn_mask != 0, float(-100.0)).masked_fill(
|
| 709 |
+
attn_mask == 0, 0.0
|
| 710 |
+
)
|
| 711 |
+
|
| 712 |
+
return attn_mask
|
| 713 |
+
|
| 714 |
+
def forward(self, x, x_size, mask=None):
|
| 715 |
+
# H, W = self.input_resolution
|
| 716 |
+
H, W = x_size
|
| 717 |
+
B, _, C = x.shape
|
| 718 |
+
# assert L == H * W, "input feature has wrong size"
|
| 719 |
+
|
| 720 |
+
shortcut = x
|
| 721 |
+
x = x.view(B, H, W, C)
|
| 722 |
+
if mask is not None:
|
| 723 |
+
mask = mask.view(B, H, W, 1)
|
| 724 |
+
|
| 725 |
+
# cyclic shift
|
| 726 |
+
if self.shift_size > 0:
|
| 727 |
+
shifted_x = torch.roll(
|
| 728 |
+
x, shifts=(-self.shift_size, -self.shift_size), dims=(1, 2)
|
| 729 |
+
)
|
| 730 |
+
if mask is not None:
|
| 731 |
+
shifted_mask = torch.roll(
|
| 732 |
+
mask, shifts=(-self.shift_size, -self.shift_size), dims=(1, 2)
|
| 733 |
+
)
|
| 734 |
+
else:
|
| 735 |
+
shifted_x = x
|
| 736 |
+
if mask is not None:
|
| 737 |
+
shifted_mask = mask
|
| 738 |
+
|
| 739 |
+
# partition windows
|
| 740 |
+
x_windows = window_partition(
|
| 741 |
+
shifted_x, self.window_size
|
| 742 |
+
) # nW*B, window_size, window_size, C
|
| 743 |
+
x_windows = x_windows.view(
|
| 744 |
+
-1, self.window_size * self.window_size, C
|
| 745 |
+
) # nW*B, window_size*window_size, C
|
| 746 |
+
if mask is not None:
|
| 747 |
+
mask_windows = window_partition(shifted_mask, self.window_size)
|
| 748 |
+
mask_windows = mask_windows.view(-1, self.window_size * self.window_size, 1)
|
| 749 |
+
else:
|
| 750 |
+
mask_windows = None
|
| 751 |
+
|
| 752 |
+
# W-MSA/SW-MSA (to be compatible for testing on images whose shapes are the multiple of window size
|
| 753 |
+
if self.input_resolution == x_size:
|
| 754 |
+
attn_windows, mask_windows = self.attn(
|
| 755 |
+
x_windows, mask_windows, mask=self.attn_mask
|
| 756 |
+
) # nW*B, window_size*window_size, C
|
| 757 |
+
else:
|
| 758 |
+
attn_windows, mask_windows = self.attn(
|
| 759 |
+
x_windows, mask_windows, mask=self.calculate_mask(x_size).to(x.device)
|
| 760 |
+
) # nW*B, window_size*window_size, C
|
| 761 |
+
|
| 762 |
+
# merge windows
|
| 763 |
+
attn_windows = attn_windows.view(-1, self.window_size, self.window_size, C)
|
| 764 |
+
shifted_x = window_reverse(attn_windows, self.window_size, H, W) # B H' W' C
|
| 765 |
+
if mask is not None:
|
| 766 |
+
mask_windows = mask_windows.view(-1, self.window_size, self.window_size, 1)
|
| 767 |
+
shifted_mask = window_reverse(mask_windows, self.window_size, H, W)
|
| 768 |
+
|
| 769 |
+
# reverse cyclic shift
|
| 770 |
+
if self.shift_size > 0:
|
| 771 |
+
x = torch.roll(
|
| 772 |
+
shifted_x, shifts=(self.shift_size, self.shift_size), dims=(1, 2)
|
| 773 |
+
)
|
| 774 |
+
if mask is not None:
|
| 775 |
+
mask = torch.roll(
|
| 776 |
+
shifted_mask, shifts=(self.shift_size, self.shift_size), dims=(1, 2)
|
| 777 |
+
)
|
| 778 |
+
else:
|
| 779 |
+
x = shifted_x
|
| 780 |
+
if mask is not None:
|
| 781 |
+
mask = shifted_mask
|
| 782 |
+
x = x.view(B, H * W, C)
|
| 783 |
+
if mask is not None:
|
| 784 |
+
mask = mask.view(B, H * W, 1)
|
| 785 |
+
|
| 786 |
+
# FFN
|
| 787 |
+
x = self.fuse(torch.cat([shortcut, x], dim=-1))
|
| 788 |
+
x = self.mlp(x)
|
| 789 |
+
|
| 790 |
+
return x, mask
|
| 791 |
+
|
| 792 |
+
|
| 793 |
+
class PatchMerging(nn.Module):
|
| 794 |
+
def __init__(self, in_channels, out_channels, down=2):
|
| 795 |
+
super().__init__()
|
| 796 |
+
self.conv = Conv2dLayerPartial(
|
| 797 |
+
in_channels=in_channels,
|
| 798 |
+
out_channels=out_channels,
|
| 799 |
+
kernel_size=3,
|
| 800 |
+
activation="lrelu",
|
| 801 |
+
down=down,
|
| 802 |
+
)
|
| 803 |
+
self.down = down
|
| 804 |
+
|
| 805 |
+
def forward(self, x, x_size, mask=None):
|
| 806 |
+
x = token2feature(x, x_size)
|
| 807 |
+
if mask is not None:
|
| 808 |
+
mask = token2feature(mask, x_size)
|
| 809 |
+
x, mask = self.conv(x, mask)
|
| 810 |
+
if self.down != 1:
|
| 811 |
+
ratio = 1 / self.down
|
| 812 |
+
x_size = (int(x_size[0] * ratio), int(x_size[1] * ratio))
|
| 813 |
+
x = feature2token(x)
|
| 814 |
+
if mask is not None:
|
| 815 |
+
mask = feature2token(mask)
|
| 816 |
+
return x, x_size, mask
|
| 817 |
+
|
| 818 |
+
|
| 819 |
+
class PatchUpsampling(nn.Module):
|
| 820 |
+
def __init__(self, in_channels, out_channels, up=2):
|
| 821 |
+
super().__init__()
|
| 822 |
+
self.conv = Conv2dLayerPartial(
|
| 823 |
+
in_channels=in_channels,
|
| 824 |
+
out_channels=out_channels,
|
| 825 |
+
kernel_size=3,
|
| 826 |
+
activation="lrelu",
|
| 827 |
+
up=up,
|
| 828 |
+
)
|
| 829 |
+
self.up = up
|
| 830 |
+
|
| 831 |
+
def forward(self, x, x_size, mask=None):
|
| 832 |
+
x = token2feature(x, x_size)
|
| 833 |
+
if mask is not None:
|
| 834 |
+
mask = token2feature(mask, x_size)
|
| 835 |
+
x, mask = self.conv(x, mask)
|
| 836 |
+
if self.up != 1:
|
| 837 |
+
x_size = (int(x_size[0] * self.up), int(x_size[1] * self.up))
|
| 838 |
+
x = feature2token(x)
|
| 839 |
+
if mask is not None:
|
| 840 |
+
mask = feature2token(mask)
|
| 841 |
+
return x, x_size, mask
|
| 842 |
+
|
| 843 |
+
|
| 844 |
+
class BasicLayer(nn.Module):
|
| 845 |
+
"""A basic Swin Transformer layer for one stage.
|
| 846 |
+
Args:
|
| 847 |
+
dim (int): Number of input channels.
|
| 848 |
+
input_resolution (tuple[int]): Input resolution.
|
| 849 |
+
depth (int): Number of blocks.
|
| 850 |
+
num_heads (int): Number of attention heads.
|
| 851 |
+
window_size (int): Local window size.
|
| 852 |
+
mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
|
| 853 |
+
qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
|
| 854 |
+
qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set.
|
| 855 |
+
drop (float, optional): Dropout rate. Default: 0.0
|
| 856 |
+
attn_drop (float, optional): Attention dropout rate. Default: 0.0
|
| 857 |
+
drop_path (float | tuple[float], optional): Stochastic depth rate. Default: 0.0
|
| 858 |
+
norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm
|
| 859 |
+
downsample (nn.Module | None, optional): Downsample layer at the end of the layer. Default: None
|
| 860 |
+
use_checkpoint (bool): Whether to use checkpointing to save memory. Default: False.
|
| 861 |
+
"""
|
| 862 |
+
|
| 863 |
+
def __init__(
|
| 864 |
+
self,
|
| 865 |
+
dim,
|
| 866 |
+
input_resolution,
|
| 867 |
+
depth,
|
| 868 |
+
num_heads,
|
| 869 |
+
window_size,
|
| 870 |
+
down_ratio=1,
|
| 871 |
+
mlp_ratio=2.0,
|
| 872 |
+
qkv_bias=True,
|
| 873 |
+
qk_scale=None,
|
| 874 |
+
drop=0.0,
|
| 875 |
+
attn_drop=0.0,
|
| 876 |
+
drop_path=0.0,
|
| 877 |
+
norm_layer=nn.LayerNorm,
|
| 878 |
+
downsample=None,
|
| 879 |
+
use_checkpoint=False,
|
| 880 |
+
):
|
| 881 |
+
super().__init__()
|
| 882 |
+
self.dim = dim
|
| 883 |
+
self.input_resolution = input_resolution
|
| 884 |
+
self.depth = depth
|
| 885 |
+
self.use_checkpoint = use_checkpoint
|
| 886 |
+
|
| 887 |
+
# patch merging layer
|
| 888 |
+
if downsample is not None:
|
| 889 |
+
# self.downsample = downsample(input_resolution, dim=dim, norm_layer=norm_layer)
|
| 890 |
+
self.downsample = downsample
|
| 891 |
+
else:
|
| 892 |
+
self.downsample = None
|
| 893 |
+
|
| 894 |
+
# build blocks
|
| 895 |
+
self.blocks = nn.ModuleList(
|
| 896 |
+
[
|
| 897 |
+
SwinTransformerBlock(
|
| 898 |
+
dim=dim,
|
| 899 |
+
input_resolution=input_resolution,
|
| 900 |
+
num_heads=num_heads,
|
| 901 |
+
down_ratio=down_ratio,
|
| 902 |
+
window_size=window_size,
|
| 903 |
+
shift_size=0 if (i % 2 == 0) else window_size // 2,
|
| 904 |
+
mlp_ratio=mlp_ratio,
|
| 905 |
+
qkv_bias=qkv_bias,
|
| 906 |
+
qk_scale=qk_scale,
|
| 907 |
+
drop=drop,
|
| 908 |
+
attn_drop=attn_drop,
|
| 909 |
+
drop_path=drop_path[i]
|
| 910 |
+
if isinstance(drop_path, list)
|
| 911 |
+
else drop_path,
|
| 912 |
+
norm_layer=norm_layer,
|
| 913 |
+
)
|
| 914 |
+
for i in range(depth)
|
| 915 |
+
]
|
| 916 |
+
)
|
| 917 |
+
|
| 918 |
+
self.conv = Conv2dLayerPartial(
|
| 919 |
+
in_channels=dim, out_channels=dim, kernel_size=3, activation="lrelu"
|
| 920 |
+
)
|
| 921 |
+
|
| 922 |
+
def forward(self, x, x_size, mask=None):
|
| 923 |
+
if self.downsample is not None:
|
| 924 |
+
x, x_size, mask = self.downsample(x, x_size, mask)
|
| 925 |
+
identity = x
|
| 926 |
+
for blk in self.blocks:
|
| 927 |
+
if self.use_checkpoint:
|
| 928 |
+
x, mask = checkpoint.checkpoint(blk, x, x_size, mask)
|
| 929 |
+
else:
|
| 930 |
+
x, mask = blk(x, x_size, mask)
|
| 931 |
+
if mask is not None:
|
| 932 |
+
mask = token2feature(mask, x_size)
|
| 933 |
+
x, mask = self.conv(token2feature(x, x_size), mask)
|
| 934 |
+
x = feature2token(x) + identity
|
| 935 |
+
if mask is not None:
|
| 936 |
+
mask = feature2token(mask)
|
| 937 |
+
return x, x_size, mask
|
| 938 |
+
|
| 939 |
+
|
| 940 |
+
class ToToken(nn.Module):
|
| 941 |
+
def __init__(self, in_channels=3, dim=128, kernel_size=5, stride=1):
|
| 942 |
+
super().__init__()
|
| 943 |
+
|
| 944 |
+
self.proj = Conv2dLayerPartial(
|
| 945 |
+
in_channels=in_channels,
|
| 946 |
+
out_channels=dim,
|
| 947 |
+
kernel_size=kernel_size,
|
| 948 |
+
activation="lrelu",
|
| 949 |
+
)
|
| 950 |
+
|
| 951 |
+
def forward(self, x, mask):
|
| 952 |
+
x, mask = self.proj(x, mask)
|
| 953 |
+
|
| 954 |
+
return x, mask
|
| 955 |
+
|
| 956 |
+
|
| 957 |
+
class EncFromRGB(nn.Module):
|
| 958 |
+
def __init__(
|
| 959 |
+
self, in_channels, out_channels, activation
|
| 960 |
+
): # res = 2, ..., resolution_log2
|
| 961 |
+
super().__init__()
|
| 962 |
+
self.conv0 = Conv2dLayer(
|
| 963 |
+
in_channels=in_channels,
|
| 964 |
+
out_channels=out_channels,
|
| 965 |
+
kernel_size=1,
|
| 966 |
+
activation=activation,
|
| 967 |
+
)
|
| 968 |
+
self.conv1 = Conv2dLayer(
|
| 969 |
+
in_channels=out_channels,
|
| 970 |
+
out_channels=out_channels,
|
| 971 |
+
kernel_size=3,
|
| 972 |
+
activation=activation,
|
| 973 |
+
)
|
| 974 |
+
|
| 975 |
+
def forward(self, x):
|
| 976 |
+
x = self.conv0(x)
|
| 977 |
+
x = self.conv1(x)
|
| 978 |
+
|
| 979 |
+
return x
|
| 980 |
+
|
| 981 |
+
|
| 982 |
+
class ConvBlockDown(nn.Module):
|
| 983 |
+
def __init__(
|
| 984 |
+
self, in_channels, out_channels, activation
|
| 985 |
+
): # res = 2, ..., resolution_log
|
| 986 |
+
super().__init__()
|
| 987 |
+
|
| 988 |
+
self.conv0 = Conv2dLayer(
|
| 989 |
+
in_channels=in_channels,
|
| 990 |
+
out_channels=out_channels,
|
| 991 |
+
kernel_size=3,
|
| 992 |
+
activation=activation,
|
| 993 |
+
down=2,
|
| 994 |
+
)
|
| 995 |
+
self.conv1 = Conv2dLayer(
|
| 996 |
+
in_channels=out_channels,
|
| 997 |
+
out_channels=out_channels,
|
| 998 |
+
kernel_size=3,
|
| 999 |
+
activation=activation,
|
| 1000 |
+
)
|
| 1001 |
+
|
| 1002 |
+
def forward(self, x):
|
| 1003 |
+
x = self.conv0(x)
|
| 1004 |
+
x = self.conv1(x)
|
| 1005 |
+
|
| 1006 |
+
return x
|
| 1007 |
+
|
| 1008 |
+
|
| 1009 |
+
def token2feature(x, x_size):
|
| 1010 |
+
B, _, C = x.shape
|
| 1011 |
+
h, w = x_size
|
| 1012 |
+
x = x.permute(0, 2, 1).reshape(B, C, h, w)
|
| 1013 |
+
return x
|
| 1014 |
+
|
| 1015 |
+
|
| 1016 |
+
def feature2token(x):
|
| 1017 |
+
B, C, _, _ = x.shape
|
| 1018 |
+
x = x.view(B, C, -1).transpose(1, 2)
|
| 1019 |
+
return x
|
| 1020 |
+
|
| 1021 |
+
|
| 1022 |
+
class Encoder(nn.Module):
|
| 1023 |
+
def __init__(
|
| 1024 |
+
self,
|
| 1025 |
+
res_log2,
|
| 1026 |
+
img_channels,
|
| 1027 |
+
activation,
|
| 1028 |
+
patch_size=5,
|
| 1029 |
+
channels=16,
|
| 1030 |
+
drop_path_rate=0.1,
|
| 1031 |
+
):
|
| 1032 |
+
super().__init__()
|
| 1033 |
+
|
| 1034 |
+
self.resolution = []
|
| 1035 |
+
|
| 1036 |
+
for i in range(res_log2, 3, -1): # from input size to 16x16
|
| 1037 |
+
res = 2**i
|
| 1038 |
+
self.resolution.append(res)
|
| 1039 |
+
if i == res_log2:
|
| 1040 |
+
block = EncFromRGB(img_channels * 2 + 1, nf(i), activation)
|
| 1041 |
+
else:
|
| 1042 |
+
block = ConvBlockDown(nf(i + 1), nf(i), activation)
|
| 1043 |
+
setattr(self, "EncConv_Block_%dx%d" % (res, res), block)
|
| 1044 |
+
|
| 1045 |
+
def forward(self, x):
|
| 1046 |
+
out = {}
|
| 1047 |
+
for res in self.resolution:
|
| 1048 |
+
res_log2 = int(np.log2(res))
|
| 1049 |
+
x = getattr(self, "EncConv_Block_%dx%d" % (res, res))(x)
|
| 1050 |
+
out[res_log2] = x
|
| 1051 |
+
|
| 1052 |
+
return out
|
| 1053 |
+
|
| 1054 |
+
|
| 1055 |
+
class ToStyle(nn.Module):
|
| 1056 |
+
def __init__(self, in_channels, out_channels, activation, drop_rate):
|
| 1057 |
+
super().__init__()
|
| 1058 |
+
self.conv = nn.Sequential(
|
| 1059 |
+
Conv2dLayer(
|
| 1060 |
+
in_channels=in_channels,
|
| 1061 |
+
out_channels=in_channels,
|
| 1062 |
+
kernel_size=3,
|
| 1063 |
+
activation=activation,
|
| 1064 |
+
down=2,
|
| 1065 |
+
),
|
| 1066 |
+
Conv2dLayer(
|
| 1067 |
+
in_channels=in_channels,
|
| 1068 |
+
out_channels=in_channels,
|
| 1069 |
+
kernel_size=3,
|
| 1070 |
+
activation=activation,
|
| 1071 |
+
down=2,
|
| 1072 |
+
),
|
| 1073 |
+
Conv2dLayer(
|
| 1074 |
+
in_channels=in_channels,
|
| 1075 |
+
out_channels=in_channels,
|
| 1076 |
+
kernel_size=3,
|
| 1077 |
+
activation=activation,
|
| 1078 |
+
down=2,
|
| 1079 |
+
),
|
| 1080 |
+
)
|
| 1081 |
+
|
| 1082 |
+
self.pool = nn.AdaptiveAvgPool2d(1)
|
| 1083 |
+
self.fc = FullyConnectedLayer(
|
| 1084 |
+
in_features=in_channels, out_features=out_channels, activation=activation
|
| 1085 |
+
)
|
| 1086 |
+
# self.dropout = nn.Dropout(drop_rate)
|
| 1087 |
+
|
| 1088 |
+
def forward(self, x):
|
| 1089 |
+
x = self.conv(x)
|
| 1090 |
+
x = self.pool(x)
|
| 1091 |
+
x = self.fc(x.flatten(start_dim=1))
|
| 1092 |
+
# x = self.dropout(x)
|
| 1093 |
+
|
| 1094 |
+
return x
|
| 1095 |
+
|
| 1096 |
+
|
| 1097 |
+
class DecBlockFirstV2(nn.Module):
|
| 1098 |
+
def __init__(
|
| 1099 |
+
self,
|
| 1100 |
+
res,
|
| 1101 |
+
in_channels,
|
| 1102 |
+
out_channels,
|
| 1103 |
+
activation,
|
| 1104 |
+
style_dim,
|
| 1105 |
+
use_noise,
|
| 1106 |
+
demodulate,
|
| 1107 |
+
img_channels,
|
| 1108 |
+
):
|
| 1109 |
+
super().__init__()
|
| 1110 |
+
self.res = res
|
| 1111 |
+
|
| 1112 |
+
self.conv0 = Conv2dLayer(
|
| 1113 |
+
in_channels=in_channels,
|
| 1114 |
+
out_channels=in_channels,
|
| 1115 |
+
kernel_size=3,
|
| 1116 |
+
activation=activation,
|
| 1117 |
+
)
|
| 1118 |
+
self.conv1 = StyleConv(
|
| 1119 |
+
in_channels=in_channels,
|
| 1120 |
+
out_channels=out_channels,
|
| 1121 |
+
style_dim=style_dim,
|
| 1122 |
+
resolution=2**res,
|
| 1123 |
+
kernel_size=3,
|
| 1124 |
+
use_noise=use_noise,
|
| 1125 |
+
activation=activation,
|
| 1126 |
+
demodulate=demodulate,
|
| 1127 |
+
)
|
| 1128 |
+
self.toRGB = ToRGB(
|
| 1129 |
+
in_channels=out_channels,
|
| 1130 |
+
out_channels=img_channels,
|
| 1131 |
+
style_dim=style_dim,
|
| 1132 |
+
kernel_size=1,
|
| 1133 |
+
demodulate=False,
|
| 1134 |
+
)
|
| 1135 |
+
|
| 1136 |
+
def forward(self, x, ws, gs, E_features, noise_mode="random"):
|
| 1137 |
+
# x = self.fc(x).view(x.shape[0], -1, 4, 4)
|
| 1138 |
+
x = self.conv0(x)
|
| 1139 |
+
x = x + E_features[self.res]
|
| 1140 |
+
style = get_style_code(ws[:, 0], gs)
|
| 1141 |
+
x = self.conv1(x, style, noise_mode=noise_mode)
|
| 1142 |
+
style = get_style_code(ws[:, 1], gs)
|
| 1143 |
+
img = self.toRGB(x, style, skip=None)
|
| 1144 |
+
|
| 1145 |
+
return x, img
|
| 1146 |
+
|
| 1147 |
+
|
| 1148 |
+
class DecBlock(nn.Module):
|
| 1149 |
+
def __init__(
|
| 1150 |
+
self,
|
| 1151 |
+
res,
|
| 1152 |
+
in_channels,
|
| 1153 |
+
out_channels,
|
| 1154 |
+
activation,
|
| 1155 |
+
style_dim,
|
| 1156 |
+
use_noise,
|
| 1157 |
+
demodulate,
|
| 1158 |
+
img_channels,
|
| 1159 |
+
): # res = 4, ..., resolution_log2
|
| 1160 |
+
super().__init__()
|
| 1161 |
+
self.res = res
|
| 1162 |
+
|
| 1163 |
+
self.conv0 = StyleConv(
|
| 1164 |
+
in_channels=in_channels,
|
| 1165 |
+
out_channels=out_channels,
|
| 1166 |
+
style_dim=style_dim,
|
| 1167 |
+
resolution=2**res,
|
| 1168 |
+
kernel_size=3,
|
| 1169 |
+
up=2,
|
| 1170 |
+
use_noise=use_noise,
|
| 1171 |
+
activation=activation,
|
| 1172 |
+
demodulate=demodulate,
|
| 1173 |
+
)
|
| 1174 |
+
self.conv1 = StyleConv(
|
| 1175 |
+
in_channels=out_channels,
|
| 1176 |
+
out_channels=out_channels,
|
| 1177 |
+
style_dim=style_dim,
|
| 1178 |
+
resolution=2**res,
|
| 1179 |
+
kernel_size=3,
|
| 1180 |
+
use_noise=use_noise,
|
| 1181 |
+
activation=activation,
|
| 1182 |
+
demodulate=demodulate,
|
| 1183 |
+
)
|
| 1184 |
+
self.toRGB = ToRGB(
|
| 1185 |
+
in_channels=out_channels,
|
| 1186 |
+
out_channels=img_channels,
|
| 1187 |
+
style_dim=style_dim,
|
| 1188 |
+
kernel_size=1,
|
| 1189 |
+
demodulate=False,
|
| 1190 |
+
)
|
| 1191 |
+
|
| 1192 |
+
def forward(self, x, img, ws, gs, E_features, noise_mode="random"):
|
| 1193 |
+
style = get_style_code(ws[:, self.res * 2 - 9], gs)
|
| 1194 |
+
x = self.conv0(x, style, noise_mode=noise_mode)
|
| 1195 |
+
x = x + E_features[self.res]
|
| 1196 |
+
style = get_style_code(ws[:, self.res * 2 - 8], gs)
|
| 1197 |
+
x = self.conv1(x, style, noise_mode=noise_mode)
|
| 1198 |
+
style = get_style_code(ws[:, self.res * 2 - 7], gs)
|
| 1199 |
+
img = self.toRGB(x, style, skip=img)
|
| 1200 |
+
|
| 1201 |
+
return x, img
|
| 1202 |
+
|
| 1203 |
+
|
| 1204 |
+
class Decoder(nn.Module):
|
| 1205 |
+
def __init__(
|
| 1206 |
+
self, res_log2, activation, style_dim, use_noise, demodulate, img_channels
|
| 1207 |
+
):
|
| 1208 |
+
super().__init__()
|
| 1209 |
+
self.Dec_16x16 = DecBlockFirstV2(
|
| 1210 |
+
4, nf(4), nf(4), activation, style_dim, use_noise, demodulate, img_channels
|
| 1211 |
+
)
|
| 1212 |
+
for res in range(5, res_log2 + 1):
|
| 1213 |
+
setattr(
|
| 1214 |
+
self,
|
| 1215 |
+
"Dec_%dx%d" % (2**res, 2**res),
|
| 1216 |
+
DecBlock(
|
| 1217 |
+
res,
|
| 1218 |
+
nf(res - 1),
|
| 1219 |
+
nf(res),
|
| 1220 |
+
activation,
|
| 1221 |
+
style_dim,
|
| 1222 |
+
use_noise,
|
| 1223 |
+
demodulate,
|
| 1224 |
+
img_channels,
|
| 1225 |
+
),
|
| 1226 |
+
)
|
| 1227 |
+
self.res_log2 = res_log2
|
| 1228 |
+
|
| 1229 |
+
def forward(self, x, ws, gs, E_features, noise_mode="random"):
|
| 1230 |
+
x, img = self.Dec_16x16(x, ws, gs, E_features, noise_mode=noise_mode)
|
| 1231 |
+
for res in range(5, self.res_log2 + 1):
|
| 1232 |
+
block = getattr(self, "Dec_%dx%d" % (2**res, 2**res))
|
| 1233 |
+
x, img = block(x, img, ws, gs, E_features, noise_mode=noise_mode)
|
| 1234 |
+
|
| 1235 |
+
return img
|
| 1236 |
+
|
| 1237 |
+
|
| 1238 |
+
class DecStyleBlock(nn.Module):
|
| 1239 |
+
def __init__(
|
| 1240 |
+
self,
|
| 1241 |
+
res,
|
| 1242 |
+
in_channels,
|
| 1243 |
+
out_channels,
|
| 1244 |
+
activation,
|
| 1245 |
+
style_dim,
|
| 1246 |
+
use_noise,
|
| 1247 |
+
demodulate,
|
| 1248 |
+
img_channels,
|
| 1249 |
+
):
|
| 1250 |
+
super().__init__()
|
| 1251 |
+
self.res = res
|
| 1252 |
+
|
| 1253 |
+
self.conv0 = StyleConv(
|
| 1254 |
+
in_channels=in_channels,
|
| 1255 |
+
out_channels=out_channels,
|
| 1256 |
+
style_dim=style_dim,
|
| 1257 |
+
resolution=2**res,
|
| 1258 |
+
kernel_size=3,
|
| 1259 |
+
up=2,
|
| 1260 |
+
use_noise=use_noise,
|
| 1261 |
+
activation=activation,
|
| 1262 |
+
demodulate=demodulate,
|
| 1263 |
+
)
|
| 1264 |
+
self.conv1 = StyleConv(
|
| 1265 |
+
in_channels=out_channels,
|
| 1266 |
+
out_channels=out_channels,
|
| 1267 |
+
style_dim=style_dim,
|
| 1268 |
+
resolution=2**res,
|
| 1269 |
+
kernel_size=3,
|
| 1270 |
+
use_noise=use_noise,
|
| 1271 |
+
activation=activation,
|
| 1272 |
+
demodulate=demodulate,
|
| 1273 |
+
)
|
| 1274 |
+
self.toRGB = ToRGB(
|
| 1275 |
+
in_channels=out_channels,
|
| 1276 |
+
out_channels=img_channels,
|
| 1277 |
+
style_dim=style_dim,
|
| 1278 |
+
kernel_size=1,
|
| 1279 |
+
demodulate=False,
|
| 1280 |
+
)
|
| 1281 |
+
|
| 1282 |
+
def forward(self, x, img, style, skip, noise_mode="random"):
|
| 1283 |
+
x = self.conv0(x, style, noise_mode=noise_mode)
|
| 1284 |
+
x = x + skip
|
| 1285 |
+
x = self.conv1(x, style, noise_mode=noise_mode)
|
| 1286 |
+
img = self.toRGB(x, style, skip=img)
|
| 1287 |
+
|
| 1288 |
+
return x, img
|
| 1289 |
+
|
| 1290 |
+
|
| 1291 |
+
class FirstStage(nn.Module):
|
| 1292 |
+
def __init__(
|
| 1293 |
+
self,
|
| 1294 |
+
img_channels,
|
| 1295 |
+
img_resolution=256,
|
| 1296 |
+
dim=180,
|
| 1297 |
+
w_dim=512,
|
| 1298 |
+
use_noise=False,
|
| 1299 |
+
demodulate=True,
|
| 1300 |
+
activation="lrelu",
|
| 1301 |
+
):
|
| 1302 |
+
super().__init__()
|
| 1303 |
+
res = 64
|
| 1304 |
+
|
| 1305 |
+
self.conv_first = Conv2dLayerPartial(
|
| 1306 |
+
in_channels=img_channels + 1,
|
| 1307 |
+
out_channels=dim,
|
| 1308 |
+
kernel_size=3,
|
| 1309 |
+
activation=activation,
|
| 1310 |
+
)
|
| 1311 |
+
self.enc_conv = nn.ModuleList()
|
| 1312 |
+
down_time = int(np.log2(img_resolution // res))
|
| 1313 |
+
# 根据图片尺寸构建 swim transformer 的层数
|
| 1314 |
+
for i in range(down_time): # from input size to 64
|
| 1315 |
+
self.enc_conv.append(
|
| 1316 |
+
Conv2dLayerPartial(
|
| 1317 |
+
in_channels=dim,
|
| 1318 |
+
out_channels=dim,
|
| 1319 |
+
kernel_size=3,
|
| 1320 |
+
down=2,
|
| 1321 |
+
activation=activation,
|
| 1322 |
+
)
|
| 1323 |
+
)
|
| 1324 |
+
|
| 1325 |
+
# from 64 -> 16 -> 64
|
| 1326 |
+
depths = [2, 3, 4, 3, 2]
|
| 1327 |
+
ratios = [1, 1 / 2, 1 / 2, 2, 2]
|
| 1328 |
+
num_heads = 6
|
| 1329 |
+
window_sizes = [8, 16, 16, 16, 8]
|
| 1330 |
+
drop_path_rate = 0.1
|
| 1331 |
+
dpr = [x.item() for x in torch.linspace(0, drop_path_rate, sum(depths))]
|
| 1332 |
+
|
| 1333 |
+
self.tran = nn.ModuleList()
|
| 1334 |
+
for i, depth in enumerate(depths):
|
| 1335 |
+
res = int(res * ratios[i])
|
| 1336 |
+
if ratios[i] < 1:
|
| 1337 |
+
merge = PatchMerging(dim, dim, down=int(1 / ratios[i]))
|
| 1338 |
+
elif ratios[i] > 1:
|
| 1339 |
+
merge = PatchUpsampling(dim, dim, up=ratios[i])
|
| 1340 |
+
else:
|
| 1341 |
+
merge = None
|
| 1342 |
+
self.tran.append(
|
| 1343 |
+
BasicLayer(
|
| 1344 |
+
dim=dim,
|
| 1345 |
+
input_resolution=[res, res],
|
| 1346 |
+
depth=depth,
|
| 1347 |
+
num_heads=num_heads,
|
| 1348 |
+
window_size=window_sizes[i],
|
| 1349 |
+
drop_path=dpr[sum(depths[:i]) : sum(depths[: i + 1])],
|
| 1350 |
+
downsample=merge,
|
| 1351 |
+
)
|
| 1352 |
+
)
|
| 1353 |
+
|
| 1354 |
+
# global style
|
| 1355 |
+
down_conv = []
|
| 1356 |
+
for i in range(int(np.log2(16))):
|
| 1357 |
+
down_conv.append(
|
| 1358 |
+
Conv2dLayer(
|
| 1359 |
+
in_channels=dim,
|
| 1360 |
+
out_channels=dim,
|
| 1361 |
+
kernel_size=3,
|
| 1362 |
+
down=2,
|
| 1363 |
+
activation=activation,
|
| 1364 |
+
)
|
| 1365 |
+
)
|
| 1366 |
+
down_conv.append(nn.AdaptiveAvgPool2d((1, 1)))
|
| 1367 |
+
self.down_conv = nn.Sequential(*down_conv)
|
| 1368 |
+
self.to_style = FullyConnectedLayer(
|
| 1369 |
+
in_features=dim, out_features=dim * 2, activation=activation
|
| 1370 |
+
)
|
| 1371 |
+
self.ws_style = FullyConnectedLayer(
|
| 1372 |
+
in_features=w_dim, out_features=dim, activation=activation
|
| 1373 |
+
)
|
| 1374 |
+
self.to_square = FullyConnectedLayer(
|
| 1375 |
+
in_features=dim, out_features=16 * 16, activation=activation
|
| 1376 |
+
)
|
| 1377 |
+
|
| 1378 |
+
style_dim = dim * 3
|
| 1379 |
+
self.dec_conv = nn.ModuleList()
|
| 1380 |
+
for i in range(down_time): # from 64 to input size
|
| 1381 |
+
res = res * 2
|
| 1382 |
+
self.dec_conv.append(
|
| 1383 |
+
DecStyleBlock(
|
| 1384 |
+
res,
|
| 1385 |
+
dim,
|
| 1386 |
+
dim,
|
| 1387 |
+
activation,
|
| 1388 |
+
style_dim,
|
| 1389 |
+
use_noise,
|
| 1390 |
+
demodulate,
|
| 1391 |
+
img_channels,
|
| 1392 |
+
)
|
| 1393 |
+
)
|
| 1394 |
+
|
| 1395 |
+
def forward(self, images_in, masks_in, ws, noise_mode="random"):
|
| 1396 |
+
x = torch.cat([masks_in - 0.5, images_in * masks_in], dim=1)
|
| 1397 |
+
|
| 1398 |
+
skips = []
|
| 1399 |
+
x, mask = self.conv_first(x, masks_in) # input size
|
| 1400 |
+
skips.append(x)
|
| 1401 |
+
for i, block in enumerate(self.enc_conv): # input size to 64
|
| 1402 |
+
x, mask = block(x, mask)
|
| 1403 |
+
if i != len(self.enc_conv) - 1:
|
| 1404 |
+
skips.append(x)
|
| 1405 |
+
|
| 1406 |
+
x_size = x.size()[-2:]
|
| 1407 |
+
x = feature2token(x)
|
| 1408 |
+
mask = feature2token(mask)
|
| 1409 |
+
mid = len(self.tran) // 2
|
| 1410 |
+
for i, block in enumerate(self.tran): # 64 to 16
|
| 1411 |
+
if i < mid:
|
| 1412 |
+
x, x_size, mask = block(x, x_size, mask)
|
| 1413 |
+
skips.append(x)
|
| 1414 |
+
elif i > mid:
|
| 1415 |
+
x, x_size, mask = block(x, x_size, None)
|
| 1416 |
+
x = x + skips[mid - i]
|
| 1417 |
+
else:
|
| 1418 |
+
x, x_size, mask = block(x, x_size, None)
|
| 1419 |
+
|
| 1420 |
+
mul_map = torch.ones_like(x) * 0.5
|
| 1421 |
+
mul_map = F.dropout(mul_map, training=True).to(x.device)
|
| 1422 |
+
ws = self.ws_style(ws[:, -1]).to(x.device)
|
| 1423 |
+
add_n = self.to_square(ws).unsqueeze(1).to(x.device)
|
| 1424 |
+
add_n = (
|
| 1425 |
+
F.interpolate(
|
| 1426 |
+
add_n, size=x.size(1), mode="linear", align_corners=False
|
| 1427 |
+
)
|
| 1428 |
+
.squeeze(1)
|
| 1429 |
+
.unsqueeze(-1)
|
| 1430 |
+
).to(x.device)
|
| 1431 |
+
x = x * mul_map + add_n * (1 - mul_map)
|
| 1432 |
+
gs = self.to_style(
|
| 1433 |
+
self.down_conv(token2feature(x, x_size)).flatten(start_dim=1)
|
| 1434 |
+
).to(x.device)
|
| 1435 |
+
style = torch.cat([gs, ws], dim=1)
|
| 1436 |
+
|
| 1437 |
+
x = token2feature(x, x_size).contiguous()
|
| 1438 |
+
img = None
|
| 1439 |
+
for i, block in enumerate(self.dec_conv):
|
| 1440 |
+
x, img = block(
|
| 1441 |
+
x, img, style, skips[len(self.dec_conv) - i - 1], noise_mode=noise_mode
|
| 1442 |
+
)
|
| 1443 |
+
|
| 1444 |
+
# ensemble
|
| 1445 |
+
img = img * (1 - masks_in) + images_in * masks_in
|
| 1446 |
+
|
| 1447 |
+
return img
|
| 1448 |
+
|
| 1449 |
+
|
| 1450 |
+
class SynthesisNet(nn.Module):
|
| 1451 |
+
def __init__(
|
| 1452 |
+
self,
|
| 1453 |
+
w_dim, # Intermediate latent (W) dimensionality.
|
| 1454 |
+
img_resolution, # Output image resolution.
|
| 1455 |
+
img_channels=3, # Number of color channels.
|
| 1456 |
+
channel_base=32768, # Overall multiplier for the number of channels.
|
| 1457 |
+
channel_decay=1.0,
|
| 1458 |
+
channel_max=512, # Maximum number of channels in any layer.
|
| 1459 |
+
activation="lrelu", # Activation function: 'relu', 'lrelu', etc.
|
| 1460 |
+
drop_rate=0.5,
|
| 1461 |
+
use_noise=False,
|
| 1462 |
+
demodulate=True,
|
| 1463 |
+
):
|
| 1464 |
+
super().__init__()
|
| 1465 |
+
resolution_log2 = int(np.log2(img_resolution))
|
| 1466 |
+
assert img_resolution == 2**resolution_log2 and img_resolution >= 4
|
| 1467 |
+
|
| 1468 |
+
self.num_layers = resolution_log2 * 2 - 3 * 2
|
| 1469 |
+
self.img_resolution = img_resolution
|
| 1470 |
+
self.resolution_log2 = resolution_log2
|
| 1471 |
+
|
| 1472 |
+
# first stage
|
| 1473 |
+
self.first_stage = FirstStage(
|
| 1474 |
+
img_channels,
|
| 1475 |
+
img_resolution=img_resolution,
|
| 1476 |
+
w_dim=w_dim,
|
| 1477 |
+
use_noise=False,
|
| 1478 |
+
demodulate=demodulate,
|
| 1479 |
+
)
|
| 1480 |
+
|
| 1481 |
+
# second stage
|
| 1482 |
+
self.enc = Encoder(
|
| 1483 |
+
resolution_log2, img_channels, activation, patch_size=5, channels=16
|
| 1484 |
+
)
|
| 1485 |
+
self.to_square = FullyConnectedLayer(
|
| 1486 |
+
in_features=w_dim, out_features=16 * 16, activation=activation
|
| 1487 |
+
)
|
| 1488 |
+
self.to_style = ToStyle(
|
| 1489 |
+
in_channels=nf(4),
|
| 1490 |
+
out_channels=nf(2) * 2,
|
| 1491 |
+
activation=activation,
|
| 1492 |
+
drop_rate=drop_rate,
|
| 1493 |
+
)
|
| 1494 |
+
style_dim = w_dim + nf(2) * 2
|
| 1495 |
+
self.dec = Decoder(
|
| 1496 |
+
resolution_log2, activation, style_dim, use_noise, demodulate, img_channels
|
| 1497 |
+
)
|
| 1498 |
+
|
| 1499 |
+
def forward(self, images_in, masks_in, ws, noise_mode="random", return_stg1=False):
|
| 1500 |
+
out_stg1 = self.first_stage(images_in, masks_in, ws, noise_mode=noise_mode)
|
| 1501 |
+
|
| 1502 |
+
# encoder
|
| 1503 |
+
x = images_in * masks_in + out_stg1 * (1 - masks_in)
|
| 1504 |
+
x = torch.cat([masks_in - 0.5, x, images_in * masks_in], dim=1)
|
| 1505 |
+
E_features = self.enc(x)
|
| 1506 |
+
|
| 1507 |
+
fea_16 = E_features[4].to(x.device)
|
| 1508 |
+
mul_map = torch.ones_like(fea_16) * 0.5
|
| 1509 |
+
mul_map = F.dropout(mul_map, training=True).to(x.device)
|
| 1510 |
+
add_n = self.to_square(ws[:, 0]).view(-1, 16, 16).unsqueeze(1)
|
| 1511 |
+
add_n = F.interpolate(
|
| 1512 |
+
add_n, size=fea_16.size()[-2:], mode="bilinear", align_corners=False
|
| 1513 |
+
).to(x.device)
|
| 1514 |
+
fea_16 = fea_16 * mul_map + add_n * (1 - mul_map)
|
| 1515 |
+
E_features[4] = fea_16
|
| 1516 |
+
|
| 1517 |
+
# style
|
| 1518 |
+
gs = self.to_style(fea_16).to(x.device)
|
| 1519 |
+
|
| 1520 |
+
# decoder
|
| 1521 |
+
img = self.dec(fea_16, ws, gs, E_features, noise_mode=noise_mode).to(x.device)
|
| 1522 |
+
|
| 1523 |
+
# ensemble
|
| 1524 |
+
img = img * (1 - masks_in) + images_in * masks_in
|
| 1525 |
+
|
| 1526 |
+
if not return_stg1:
|
| 1527 |
+
return img
|
| 1528 |
+
else:
|
| 1529 |
+
return img, out_stg1
|
| 1530 |
+
|
| 1531 |
+
|
| 1532 |
+
class Generator(nn.Module):
|
| 1533 |
+
def __init__(
|
| 1534 |
+
self,
|
| 1535 |
+
z_dim, # Input latent (Z) dimensionality, 0 = no latent.
|
| 1536 |
+
c_dim, # Conditioning label (C) dimensionality, 0 = no label.
|
| 1537 |
+
w_dim, # Intermediate latent (W) dimensionality.
|
| 1538 |
+
img_resolution, # resolution of generated image
|
| 1539 |
+
img_channels, # Number of input color channels.
|
| 1540 |
+
synthesis_kwargs={}, # Arguments for SynthesisNetwork.
|
| 1541 |
+
mapping_kwargs={}, # Arguments for MappingNetwork.
|
| 1542 |
+
):
|
| 1543 |
+
super().__init__()
|
| 1544 |
+
self.z_dim = z_dim
|
| 1545 |
+
self.c_dim = c_dim
|
| 1546 |
+
self.w_dim = w_dim
|
| 1547 |
+
self.img_resolution = img_resolution
|
| 1548 |
+
self.img_channels = img_channels
|
| 1549 |
+
|
| 1550 |
+
self.synthesis = SynthesisNet(
|
| 1551 |
+
w_dim=w_dim,
|
| 1552 |
+
img_resolution=img_resolution,
|
| 1553 |
+
img_channels=img_channels,
|
| 1554 |
+
**synthesis_kwargs,
|
| 1555 |
+
)
|
| 1556 |
+
self.mapping = MappingNet(
|
| 1557 |
+
z_dim=z_dim,
|
| 1558 |
+
c_dim=c_dim,
|
| 1559 |
+
w_dim=w_dim,
|
| 1560 |
+
num_ws=self.synthesis.num_layers,
|
| 1561 |
+
**mapping_kwargs,
|
| 1562 |
+
)
|
| 1563 |
+
|
| 1564 |
+
def forward(
|
| 1565 |
+
self,
|
| 1566 |
+
images_in,
|
| 1567 |
+
masks_in,
|
| 1568 |
+
z,
|
| 1569 |
+
c,
|
| 1570 |
+
truncation_psi=1,
|
| 1571 |
+
truncation_cutoff=None,
|
| 1572 |
+
skip_w_avg_update=False,
|
| 1573 |
+
noise_mode="none",
|
| 1574 |
+
return_stg1=False,
|
| 1575 |
+
):
|
| 1576 |
+
ws = self.mapping(
|
| 1577 |
+
z,
|
| 1578 |
+
c,
|
| 1579 |
+
truncation_psi=truncation_psi,
|
| 1580 |
+
truncation_cutoff=truncation_cutoff,
|
| 1581 |
+
skip_w_avg_update=skip_w_avg_update,
|
| 1582 |
+
)
|
| 1583 |
+
img = self.synthesis(images_in, masks_in, ws, noise_mode=noise_mode)
|
| 1584 |
+
return img
|
| 1585 |
+
|
| 1586 |
+
|
| 1587 |
+
class MAT(nn.Module):
|
| 1588 |
+
def __init__(self):
|
| 1589 |
+
super().__init__()
|
| 1590 |
+
self.model_arch = "MAT"
|
| 1591 |
+
|
| 1592 |
+
self.model = Generator(
|
| 1593 |
+
z_dim=512, c_dim=0, w_dim=512, img_resolution=512, img_channels=3
|
| 1594 |
+
)
|
| 1595 |
+
self.z = torch.from_numpy(np.random.randn(1, self.model.z_dim)) # [1., 512]
|
| 1596 |
+
self.label = torch.zeros([1, self.model.c_dim])
|
| 1597 |
+
|
| 1598 |
+
def forward(self, image, mask):
|
| 1599 |
+
"""Input images and output images have same size
|
| 1600 |
+
images: [H, W, C] RGB
|
| 1601 |
+
masks: [H, W] mask area == 255
|
| 1602 |
+
return: BGR IMAGE
|
| 1603 |
+
"""
|
| 1604 |
+
|
| 1605 |
+
image = image * 2 - 1 # [0, 1] -> [-1, 1]
|
| 1606 |
+
mask = 1 - mask
|
| 1607 |
+
|
| 1608 |
+
output = self.model(
|
| 1609 |
+
image, mask, self.z, self.label, truncation_psi=1, noise_mode="none"
|
| 1610 |
+
)
|
| 1611 |
+
|
| 1612 |
+
return output * 0.5 + 0.5
|
sage2/mat/arch/utils.py
ADDED
|
@@ -0,0 +1,697 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# type: ignore
|
| 2 |
+
"""Code used for this implementation of the MAT helper utils is modified from
|
| 3 |
+
lama-cleaner, copyright of Sanster: https://github.com/fenglinglwb/MAT"""
|
| 4 |
+
|
| 5 |
+
import collections
|
| 6 |
+
from itertools import repeat
|
| 7 |
+
from typing import Any
|
| 8 |
+
|
| 9 |
+
import numpy as np
|
| 10 |
+
import torch
|
| 11 |
+
from torch import conv2d, conv_transpose2d
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def normalize_2nd_moment(x, dim=1, eps=1e-8):
|
| 15 |
+
return x * (x.square().mean(dim=dim, keepdim=True) + eps).rsqrt()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class EasyDict(dict):
|
| 19 |
+
"""Convenience class that behaves like a dict but allows access with the attribute syntax."""
|
| 20 |
+
|
| 21 |
+
def __getattr__(self, name: str) -> Any:
|
| 22 |
+
try:
|
| 23 |
+
return self[name]
|
| 24 |
+
except KeyError as ke:
|
| 25 |
+
raise AttributeError(name) from ke
|
| 26 |
+
|
| 27 |
+
def __setattr__(self, name: str, value: Any) -> None:
|
| 28 |
+
self[name] = value
|
| 29 |
+
|
| 30 |
+
def __delattr__(self, name: str) -> None:
|
| 31 |
+
del self[name]
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
activation_funcs = {
|
| 35 |
+
"linear": EasyDict(
|
| 36 |
+
func=lambda x, **_: x,
|
| 37 |
+
def_alpha=0,
|
| 38 |
+
def_gain=1,
|
| 39 |
+
cuda_idx=1,
|
| 40 |
+
ref="",
|
| 41 |
+
has_2nd_grad=False,
|
| 42 |
+
),
|
| 43 |
+
"relu": EasyDict(
|
| 44 |
+
func=lambda x, **_: torch.nn.functional.relu(x),
|
| 45 |
+
def_alpha=0,
|
| 46 |
+
def_gain=np.sqrt(2),
|
| 47 |
+
cuda_idx=2,
|
| 48 |
+
ref="y",
|
| 49 |
+
has_2nd_grad=False,
|
| 50 |
+
),
|
| 51 |
+
"lrelu": EasyDict(
|
| 52 |
+
func=lambda x, alpha, **_: torch.nn.functional.leaky_relu(x, alpha),
|
| 53 |
+
def_alpha=0.2,
|
| 54 |
+
def_gain=np.sqrt(2),
|
| 55 |
+
cuda_idx=3,
|
| 56 |
+
ref="y",
|
| 57 |
+
has_2nd_grad=False,
|
| 58 |
+
),
|
| 59 |
+
"tanh": EasyDict(
|
| 60 |
+
func=lambda x, **_: torch.tanh(x),
|
| 61 |
+
def_alpha=0,
|
| 62 |
+
def_gain=1,
|
| 63 |
+
cuda_idx=4,
|
| 64 |
+
ref="y",
|
| 65 |
+
has_2nd_grad=True,
|
| 66 |
+
),
|
| 67 |
+
"sigmoid": EasyDict(
|
| 68 |
+
func=lambda x, **_: torch.sigmoid(x),
|
| 69 |
+
def_alpha=0,
|
| 70 |
+
def_gain=1,
|
| 71 |
+
cuda_idx=5,
|
| 72 |
+
ref="y",
|
| 73 |
+
has_2nd_grad=True,
|
| 74 |
+
),
|
| 75 |
+
"elu": EasyDict(
|
| 76 |
+
func=lambda x, **_: torch.nn.functional.elu(x),
|
| 77 |
+
def_alpha=0,
|
| 78 |
+
def_gain=1,
|
| 79 |
+
cuda_idx=6,
|
| 80 |
+
ref="y",
|
| 81 |
+
has_2nd_grad=True,
|
| 82 |
+
),
|
| 83 |
+
"selu": EasyDict(
|
| 84 |
+
func=lambda x, **_: torch.nn.functional.selu(x),
|
| 85 |
+
def_alpha=0,
|
| 86 |
+
def_gain=1,
|
| 87 |
+
cuda_idx=7,
|
| 88 |
+
ref="y",
|
| 89 |
+
has_2nd_grad=True,
|
| 90 |
+
),
|
| 91 |
+
"softplus": EasyDict(
|
| 92 |
+
func=lambda x, **_: torch.nn.functional.softplus(x),
|
| 93 |
+
def_alpha=0,
|
| 94 |
+
def_gain=1,
|
| 95 |
+
cuda_idx=8,
|
| 96 |
+
ref="y",
|
| 97 |
+
has_2nd_grad=True,
|
| 98 |
+
),
|
| 99 |
+
"swish": EasyDict(
|
| 100 |
+
func=lambda x, **_: torch.sigmoid(x) * x,
|
| 101 |
+
def_alpha=0,
|
| 102 |
+
def_gain=np.sqrt(2),
|
| 103 |
+
cuda_idx=9,
|
| 104 |
+
ref="x",
|
| 105 |
+
has_2nd_grad=True,
|
| 106 |
+
),
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def _bias_act_ref(x, b=None, dim=1, act="linear", alpha=None, gain=None, clamp=None):
|
| 111 |
+
"""Slow reference implementation of `bias_act()` using standard TensorFlow ops."""
|
| 112 |
+
assert isinstance(x, torch.Tensor)
|
| 113 |
+
assert clamp is None or clamp >= 0
|
| 114 |
+
spec = activation_funcs[act]
|
| 115 |
+
alpha = float(alpha if alpha is not None else spec.def_alpha)
|
| 116 |
+
gain = float(gain if gain is not None else spec.def_gain)
|
| 117 |
+
clamp = float(clamp if clamp is not None else -1)
|
| 118 |
+
|
| 119 |
+
# Add bias.
|
| 120 |
+
if b is not None:
|
| 121 |
+
assert isinstance(b, torch.Tensor) and b.ndim == 1
|
| 122 |
+
assert 0 <= dim < x.ndim
|
| 123 |
+
assert b.shape[0] == x.shape[dim]
|
| 124 |
+
x = x + b.reshape([-1 if i == dim else 1 for i in range(x.ndim)]).to(x.device)
|
| 125 |
+
|
| 126 |
+
# Evaluate activation function.
|
| 127 |
+
alpha = float(alpha)
|
| 128 |
+
x = spec.func(x, alpha=alpha)
|
| 129 |
+
|
| 130 |
+
# Scale by gain.
|
| 131 |
+
gain = float(gain)
|
| 132 |
+
if gain != 1:
|
| 133 |
+
x = x * gain
|
| 134 |
+
|
| 135 |
+
# Clamp.
|
| 136 |
+
if clamp >= 0:
|
| 137 |
+
x = x.clamp(-clamp, clamp) # pylint: disable=invalid-unary-operand-type
|
| 138 |
+
return x
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
def bias_act(
|
| 142 |
+
x, b=None, dim=1, act="linear", alpha=None, gain=None, clamp=None, impl="ref"
|
| 143 |
+
):
|
| 144 |
+
r"""Fused bias and activation function.
|
| 145 |
+
Adds bias `b` to activation tensor `x`, evaluates activation function `act`,
|
| 146 |
+
and scales the result by `gain`. Each of the steps is optional. In most cases,
|
| 147 |
+
the fused op is considerably more efficient than performing the same calculation
|
| 148 |
+
using standard PyTorch ops. It supports first and second order gradients,
|
| 149 |
+
but not third order gradients.
|
| 150 |
+
Args:
|
| 151 |
+
x: Input activation tensor. Can be of any shape.
|
| 152 |
+
b: Bias vector, or `None` to disable. Must be a 1D tensor of the same type
|
| 153 |
+
as `x`. The shape must be known, and it must match the dimension of `x`
|
| 154 |
+
corresponding to `dim`.
|
| 155 |
+
dim: The dimension in `x` corresponding to the elements of `b`.
|
| 156 |
+
The value of `dim` is ignored if `b` is not specified.
|
| 157 |
+
act: Name of the activation function to evaluate, or `"linear"` to disable.
|
| 158 |
+
Can be e.g. `"relu"`, `"lrelu"`, `"tanh"`, `"sigmoid"`, `"swish"`, etc.
|
| 159 |
+
See `activation_funcs` for a full list. `None` is not allowed.
|
| 160 |
+
alpha: Shape parameter for the activation function, or `None` to use the default.
|
| 161 |
+
gain: Scaling factor for the output tensor, or `None` to use default.
|
| 162 |
+
See `activation_funcs` for the default scaling of each activation function.
|
| 163 |
+
If unsure, consider specifying 1.
|
| 164 |
+
clamp: Clamp the output values to `[-clamp, +clamp]`, or `None` to disable
|
| 165 |
+
the clamping (default).
|
| 166 |
+
impl: Name of the implementation to use. Can be `"ref"` or `"cuda"` (default).
|
| 167 |
+
Returns:
|
| 168 |
+
Tensor of the same shape and datatype as `x`.
|
| 169 |
+
"""
|
| 170 |
+
assert isinstance(x, torch.Tensor)
|
| 171 |
+
assert impl in ["ref", "cuda"]
|
| 172 |
+
return _bias_act_ref(
|
| 173 |
+
x=x, b=b, dim=dim, act=act, alpha=alpha, gain=gain, clamp=clamp
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def setup_filter(
|
| 178 |
+
f,
|
| 179 |
+
device=torch.device("cpu"),
|
| 180 |
+
normalize=True,
|
| 181 |
+
flip_filter=False,
|
| 182 |
+
gain=1,
|
| 183 |
+
separable=None,
|
| 184 |
+
):
|
| 185 |
+
r"""Convenience function to setup 2D FIR filter for `upfirdn2d()`.
|
| 186 |
+
Args:
|
| 187 |
+
f: Torch tensor, numpy array, or python list of the shape
|
| 188 |
+
`[filter_height, filter_width]` (non-separable),
|
| 189 |
+
`[filter_taps]` (separable),
|
| 190 |
+
`[]` (impulse), or
|
| 191 |
+
`None` (identity).
|
| 192 |
+
device: Result device (default: cpu).
|
| 193 |
+
normalize: Normalize the filter so that it retains the magnitude
|
| 194 |
+
for constant input signal (DC)? (default: True).
|
| 195 |
+
flip_filter: Flip the filter? (default: False).
|
| 196 |
+
gain: Overall scaling factor for signal magnitude (default: 1).
|
| 197 |
+
separable: Return a separable filter? (default: select automatically).
|
| 198 |
+
Returns:
|
| 199 |
+
Float32 tensor of the shape
|
| 200 |
+
`[filter_height, filter_width]` (non-separable) or
|
| 201 |
+
`[filter_taps]` (separable).
|
| 202 |
+
"""
|
| 203 |
+
# Validate.
|
| 204 |
+
if f is None:
|
| 205 |
+
f = 1
|
| 206 |
+
f = torch.as_tensor(f, dtype=torch.float32)
|
| 207 |
+
assert f.ndim in [0, 1, 2]
|
| 208 |
+
assert f.numel() > 0
|
| 209 |
+
if f.ndim == 0:
|
| 210 |
+
f = f[np.newaxis]
|
| 211 |
+
|
| 212 |
+
# Separable?
|
| 213 |
+
if separable is None:
|
| 214 |
+
separable = f.ndim == 1 and f.numel() >= 8
|
| 215 |
+
if f.ndim == 1 and not separable:
|
| 216 |
+
f = f.ger(f)
|
| 217 |
+
assert f.ndim == (1 if separable else 2)
|
| 218 |
+
|
| 219 |
+
# Apply normalize, flip, gain, and device.
|
| 220 |
+
if normalize:
|
| 221 |
+
f /= f.sum()
|
| 222 |
+
if flip_filter:
|
| 223 |
+
f = f.flip(list(range(f.ndim)))
|
| 224 |
+
f = f * (gain ** (f.ndim / 2))
|
| 225 |
+
f = f.to(device=device)
|
| 226 |
+
return f
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
def _get_filter_size(f):
|
| 230 |
+
if f is None:
|
| 231 |
+
return 1, 1
|
| 232 |
+
|
| 233 |
+
assert isinstance(f, torch.Tensor) and f.ndim in [1, 2]
|
| 234 |
+
fw = f.shape[-1]
|
| 235 |
+
fh = f.shape[0]
|
| 236 |
+
|
| 237 |
+
fw = int(fw)
|
| 238 |
+
fh = int(fh)
|
| 239 |
+
assert fw >= 1 and fh >= 1
|
| 240 |
+
return fw, fh
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
def _get_weight_shape(w):
|
| 244 |
+
shape = [int(sz) for sz in w.shape]
|
| 245 |
+
return shape
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
def _parse_scaling(scaling):
|
| 249 |
+
if isinstance(scaling, int):
|
| 250 |
+
scaling = [scaling, scaling]
|
| 251 |
+
assert isinstance(scaling, (list, tuple))
|
| 252 |
+
assert all(isinstance(x, int) for x in scaling)
|
| 253 |
+
sx, sy = scaling
|
| 254 |
+
assert sx >= 1 and sy >= 1
|
| 255 |
+
return sx, sy
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
def _parse_padding(padding):
|
| 259 |
+
if isinstance(padding, int):
|
| 260 |
+
padding = [padding, padding]
|
| 261 |
+
assert isinstance(padding, (list, tuple))
|
| 262 |
+
assert all(isinstance(x, int) for x in padding)
|
| 263 |
+
if len(padding) == 2:
|
| 264 |
+
padx, pady = padding
|
| 265 |
+
padding = [padx, padx, pady, pady]
|
| 266 |
+
padx0, padx1, pady0, pady1 = padding
|
| 267 |
+
return padx0, padx1, pady0, pady1
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
def _ntuple(n):
|
| 271 |
+
def parse(x):
|
| 272 |
+
if isinstance(x, collections.abc.Iterable):
|
| 273 |
+
return x
|
| 274 |
+
return tuple(repeat(x, n))
|
| 275 |
+
|
| 276 |
+
return parse
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
to_2tuple = _ntuple(2)
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
def _upfirdn2d_ref(x, f, up=1, down=1, padding=0, flip_filter=False, gain=1):
|
| 283 |
+
"""Slow reference implementation of `upfirdn2d()` using standard PyTorch ops."""
|
| 284 |
+
# Validate arguments.
|
| 285 |
+
assert isinstance(x, torch.Tensor) and x.ndim == 4
|
| 286 |
+
if f is None:
|
| 287 |
+
f = torch.ones([1, 1], dtype=torch.float32, device=x.device)
|
| 288 |
+
assert isinstance(f, torch.Tensor) and f.ndim in [1, 2]
|
| 289 |
+
assert f.dtype == torch.float32 and not f.requires_grad
|
| 290 |
+
batch_size, num_channels, in_height, in_width = x.shape
|
| 291 |
+
# upx, upy = _parse_scaling(up)
|
| 292 |
+
# downx, downy = _parse_scaling(down)
|
| 293 |
+
|
| 294 |
+
upx, upy = up, up
|
| 295 |
+
downx, downy = down, down
|
| 296 |
+
|
| 297 |
+
# padx0, padx1, pady0, pady1 = _parse_padding(padding)
|
| 298 |
+
padx0, padx1, pady0, pady1 = padding[0], padding[1], padding[2], padding[3]
|
| 299 |
+
|
| 300 |
+
# Upsample by inserting zeros.
|
| 301 |
+
x = x.reshape([batch_size, num_channels, in_height, 1, in_width, 1])
|
| 302 |
+
x = torch.nn.functional.pad(x, [0, upx - 1, 0, 0, 0, upy - 1])
|
| 303 |
+
x = x.reshape([batch_size, num_channels, in_height * upy, in_width * upx])
|
| 304 |
+
|
| 305 |
+
# Pad or crop.
|
| 306 |
+
x = torch.nn.functional.pad(
|
| 307 |
+
x, [max(padx0, 0), max(padx1, 0), max(pady0, 0), max(pady1, 0)]
|
| 308 |
+
)
|
| 309 |
+
x = x[
|
| 310 |
+
:,
|
| 311 |
+
:,
|
| 312 |
+
max(-pady0, 0) : x.shape[2] - max(-pady1, 0),
|
| 313 |
+
max(-padx0, 0) : x.shape[3] - max(-padx1, 0),
|
| 314 |
+
]
|
| 315 |
+
|
| 316 |
+
# Setup filter.
|
| 317 |
+
f = f * (gain ** (f.ndim / 2))
|
| 318 |
+
f = f.to(x.dtype)
|
| 319 |
+
if not flip_filter:
|
| 320 |
+
f = f.flip(list(range(f.ndim)))
|
| 321 |
+
|
| 322 |
+
# Convolve with the filter.
|
| 323 |
+
f = f[np.newaxis, np.newaxis].repeat([num_channels, 1] + [1] * f.ndim)
|
| 324 |
+
if f.ndim == 4:
|
| 325 |
+
x = conv2d(input=x, weight=f, groups=num_channels)
|
| 326 |
+
else:
|
| 327 |
+
x = conv2d(input=x, weight=f.unsqueeze(2), groups=num_channels)
|
| 328 |
+
x = conv2d(input=x, weight=f.unsqueeze(3), groups=num_channels)
|
| 329 |
+
|
| 330 |
+
# Downsample by throwing away pixels.
|
| 331 |
+
x = x[:, :, ::downy, ::downx]
|
| 332 |
+
return x
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
def upfirdn2d(x, f, up=1, down=1, padding=0, flip_filter=False, gain=1, impl="cuda"):
|
| 336 |
+
r"""Pad, upsample, filter, and downsample a batch of 2D images.
|
| 337 |
+
Performs the following sequence of operations for each channel:
|
| 338 |
+
1. Upsample the image by inserting N-1 zeros after each pixel (`up`).
|
| 339 |
+
2. Pad the image with the specified number of zeros on each side (`padding`).
|
| 340 |
+
Negative padding corresponds to cropping the image.
|
| 341 |
+
3. Convolve the image with the specified 2D FIR filter (`f`), shrinking it
|
| 342 |
+
so that the footprint of all output pixels lies within the input image.
|
| 343 |
+
4. Downsample the image by keeping every Nth pixel (`down`).
|
| 344 |
+
This sequence of operations bears close resemblance to scipy.signal.upfirdn().
|
| 345 |
+
The fused op is considerably more efficient than performing the same calculation
|
| 346 |
+
using standard PyTorch ops. It supports gradients of arbitrary order.
|
| 347 |
+
Args:
|
| 348 |
+
x: Float32/float64/float16 input tensor of the shape
|
| 349 |
+
`[batch_size, num_channels, in_height, in_width]`.
|
| 350 |
+
f: Float32 FIR filter of the shape
|
| 351 |
+
`[filter_height, filter_width]` (non-separable),
|
| 352 |
+
`[filter_taps]` (separable), or
|
| 353 |
+
`None` (identity).
|
| 354 |
+
up: Integer upsampling factor. Can be a single int or a list/tuple
|
| 355 |
+
`[x, y]` (default: 1).
|
| 356 |
+
down: Integer downsampling factor. Can be a single int or a list/tuple
|
| 357 |
+
`[x, y]` (default: 1).
|
| 358 |
+
padding: Padding with respect to the upsampled image. Can be a single number
|
| 359 |
+
or a list/tuple `[x, y]` or `[x_before, x_after, y_before, y_after]`
|
| 360 |
+
(default: 0).
|
| 361 |
+
flip_filter: False = convolution, True = correlation (default: False).
|
| 362 |
+
gain: Overall scaling factor for signal magnitude (default: 1).
|
| 363 |
+
impl: Implementation to use. Can be `'ref'` or `'cuda'` (default: `'cuda'`).
|
| 364 |
+
Returns:
|
| 365 |
+
Tensor of the shape `[batch_size, num_channels, out_height, out_width]`.
|
| 366 |
+
"""
|
| 367 |
+
# assert isinstance(x, torch.Tensor)
|
| 368 |
+
# assert impl in ['ref', 'cuda']
|
| 369 |
+
return _upfirdn2d_ref(
|
| 370 |
+
x, f, up=up, down=down, padding=padding, flip_filter=flip_filter, gain=gain
|
| 371 |
+
)
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
def upsample2d(x, f, up=2, padding=0, flip_filter=False, gain=1, impl="cuda"):
|
| 375 |
+
r"""Upsample a batch of 2D images using the given 2D FIR filter.
|
| 376 |
+
By default, the result is padded so that its shape is a multiple of the input.
|
| 377 |
+
User-specified padding is applied on top of that, with negative values
|
| 378 |
+
indicating cropping. Pixels outside the image are assumed to be zero.
|
| 379 |
+
Args:
|
| 380 |
+
x: Float32/float64/float16 input tensor of the shape
|
| 381 |
+
`[batch_size, num_channels, in_height, in_width]`.
|
| 382 |
+
f: Float32 FIR filter of the shape
|
| 383 |
+
`[filter_height, filter_width]` (non-separable),
|
| 384 |
+
`[filter_taps]` (separable), or
|
| 385 |
+
`None` (identity).
|
| 386 |
+
up: Integer upsampling factor. Can be a single int or a list/tuple
|
| 387 |
+
`[x, y]` (default: 1).
|
| 388 |
+
padding: Padding with respect to the output. Can be a single number or a
|
| 389 |
+
list/tuple `[x, y]` or `[x_before, x_after, y_before, y_after]`
|
| 390 |
+
(default: 0).
|
| 391 |
+
flip_filter: False = convolution, True = correlation (default: False).
|
| 392 |
+
gain: Overall scaling factor for signal magnitude (default: 1).
|
| 393 |
+
impl: Implementation to use. Can be `'ref'` or `'cuda'` (default: `'cuda'`).
|
| 394 |
+
Returns:
|
| 395 |
+
Tensor of the shape `[batch_size, num_channels, out_height, out_width]`.
|
| 396 |
+
"""
|
| 397 |
+
upx, upy = _parse_scaling(up)
|
| 398 |
+
# upx, upy = up, up
|
| 399 |
+
padx0, padx1, pady0, pady1 = _parse_padding(padding)
|
| 400 |
+
# padx0, padx1, pady0, pady1 = padding, padding, padding, padding
|
| 401 |
+
fw, fh = _get_filter_size(f)
|
| 402 |
+
p = [
|
| 403 |
+
padx0 + (fw + upx - 1) // 2,
|
| 404 |
+
padx1 + (fw - upx) // 2,
|
| 405 |
+
pady0 + (fh + upy - 1) // 2,
|
| 406 |
+
pady1 + (fh - upy) // 2,
|
| 407 |
+
]
|
| 408 |
+
return upfirdn2d(
|
| 409 |
+
x,
|
| 410 |
+
f,
|
| 411 |
+
up=up,
|
| 412 |
+
padding=p,
|
| 413 |
+
flip_filter=flip_filter,
|
| 414 |
+
gain=gain * upx * upy,
|
| 415 |
+
impl=impl,
|
| 416 |
+
)
|
| 417 |
+
|
| 418 |
+
|
| 419 |
+
class FullyConnectedLayer(torch.nn.Module):
|
| 420 |
+
def __init__(
|
| 421 |
+
self,
|
| 422 |
+
in_features, # Number of input features.
|
| 423 |
+
out_features, # Number of output features.
|
| 424 |
+
bias=True, # Apply additive bias before the activation function?
|
| 425 |
+
activation="linear", # Activation function: 'relu', 'lrelu', etc.
|
| 426 |
+
lr_multiplier=1, # Learning rate multiplier.
|
| 427 |
+
bias_init=0, # Initial value for the additive bias.
|
| 428 |
+
):
|
| 429 |
+
super().__init__()
|
| 430 |
+
self.weight = torch.nn.Parameter(
|
| 431 |
+
torch.randn([out_features, in_features]) / lr_multiplier
|
| 432 |
+
)
|
| 433 |
+
self.bias = (
|
| 434 |
+
torch.nn.Parameter(torch.full([out_features], np.float32(bias_init)))
|
| 435 |
+
if bias
|
| 436 |
+
else None
|
| 437 |
+
)
|
| 438 |
+
self.activation = activation
|
| 439 |
+
|
| 440 |
+
self.weight_gain = lr_multiplier / np.sqrt(in_features)
|
| 441 |
+
self.bias_gain = lr_multiplier
|
| 442 |
+
|
| 443 |
+
def forward(self, x):
|
| 444 |
+
w = self.weight * self.weight_gain
|
| 445 |
+
b = self.bias
|
| 446 |
+
if b is not None and self.bias_gain != 1:
|
| 447 |
+
b = b * self.bias_gain
|
| 448 |
+
|
| 449 |
+
if self.activation == "linear" and b is not None:
|
| 450 |
+
# out = torch.addmm(b.unsqueeze(0), x, w.t())
|
| 451 |
+
x = x.matmul(w.t().to(x.device))
|
| 452 |
+
out = x + b.reshape(
|
| 453 |
+
[-1 if i == x.ndim - 1 else 1 for i in range(x.ndim)]
|
| 454 |
+
).to(x.device)
|
| 455 |
+
else:
|
| 456 |
+
x = x.matmul(w.t().to(x.device))
|
| 457 |
+
out = bias_act(x, b, act=self.activation, dim=x.ndim - 1).to(x.device)
|
| 458 |
+
return out
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
def _conv2d_wrapper(
|
| 462 |
+
x, w, stride=1, padding=0, groups=1, transpose=False, flip_weight=True
|
| 463 |
+
):
|
| 464 |
+
"""Wrapper for the underlying `conv2d()` and `conv_transpose2d()` implementations."""
|
| 465 |
+
out_channels, in_channels_per_group, kh, kw = _get_weight_shape(w)
|
| 466 |
+
|
| 467 |
+
# Flip weight if requested.
|
| 468 |
+
if not flip_weight: # conv2d() actually performs correlation (flip_weight=True) not convolution (flip_weight=False).
|
| 469 |
+
w = w.flip([2, 3])
|
| 470 |
+
|
| 471 |
+
# Workaround performance pitfall in cuDNN 8.0.5, triggered when using
|
| 472 |
+
# 1x1 kernel + memory_format=channels_last + less than 64 channels.
|
| 473 |
+
if (
|
| 474 |
+
kw == 1
|
| 475 |
+
and kh == 1
|
| 476 |
+
and stride == 1
|
| 477 |
+
and padding in [0, [0, 0], (0, 0)]
|
| 478 |
+
and not transpose
|
| 479 |
+
):
|
| 480 |
+
if x.stride()[1] == 1 and min(out_channels, in_channels_per_group) < 64:
|
| 481 |
+
if out_channels <= 4 and groups == 1:
|
| 482 |
+
in_shape = x.shape
|
| 483 |
+
x = w.squeeze(3).squeeze(2) @ x.reshape(
|
| 484 |
+
[in_shape[0], in_channels_per_group, -1]
|
| 485 |
+
)
|
| 486 |
+
x = x.reshape([in_shape[0], out_channels, in_shape[2], in_shape[3]])
|
| 487 |
+
else:
|
| 488 |
+
x = x.to(memory_format=torch.contiguous_format)
|
| 489 |
+
w = w.to(memory_format=torch.contiguous_format)
|
| 490 |
+
x = conv2d(x, w, groups=groups)
|
| 491 |
+
return x.to(memory_format=torch.channels_last)
|
| 492 |
+
|
| 493 |
+
# Otherwise => execute using conv2d_gradfix.
|
| 494 |
+
op = conv_transpose2d if transpose else conv2d
|
| 495 |
+
return op(x, w, stride=stride, padding=padding, groups=groups)
|
| 496 |
+
|
| 497 |
+
|
| 498 |
+
def conv2d_resample(
|
| 499 |
+
x, w, f=None, up=1, down=1, padding=0, groups=1, flip_weight=True, flip_filter=False
|
| 500 |
+
):
|
| 501 |
+
r"""2D convolution with optional up/downsampling.
|
| 502 |
+
Padding is performed only once at the beginning, not between the operations.
|
| 503 |
+
Args:
|
| 504 |
+
x: Input tensor of shape
|
| 505 |
+
`[batch_size, in_channels, in_height, in_width]`.
|
| 506 |
+
w: Weight tensor of shape
|
| 507 |
+
`[out_channels, in_channels//groups, kernel_height, kernel_width]`.
|
| 508 |
+
f: Low-pass filter for up/downsampling. Must be prepared beforehand by
|
| 509 |
+
calling setup_filter(). None = identity (default).
|
| 510 |
+
up: Integer upsampling factor (default: 1).
|
| 511 |
+
down: Integer downsampling factor (default: 1).
|
| 512 |
+
padding: Padding with respect to the upsampled image. Can be a single number
|
| 513 |
+
or a list/tuple `[x, y]` or `[x_before, x_after, y_before, y_after]`
|
| 514 |
+
(default: 0).
|
| 515 |
+
groups: Split input channels into N groups (default: 1).
|
| 516 |
+
flip_weight: False = convolution, True = correlation (default: True).
|
| 517 |
+
flip_filter: False = convolution, True = correlation (default: False).
|
| 518 |
+
Returns:
|
| 519 |
+
Tensor of the shape `[batch_size, num_channels, out_height, out_width]`.
|
| 520 |
+
"""
|
| 521 |
+
# Validate arguments.
|
| 522 |
+
assert isinstance(x, torch.Tensor) and (x.ndim == 4)
|
| 523 |
+
assert isinstance(w, torch.Tensor) and (w.ndim == 4) and (w.dtype == x.dtype)
|
| 524 |
+
assert f is None or (
|
| 525 |
+
isinstance(f, torch.Tensor) and f.ndim in [1, 2] and f.dtype == torch.float32
|
| 526 |
+
)
|
| 527 |
+
assert isinstance(up, int) and (up >= 1)
|
| 528 |
+
assert isinstance(down, int) and (down >= 1)
|
| 529 |
+
# assert isinstance(groups, int) and (groups >= 1), f"!!!!!! groups: {groups} isinstance(groups, int) {isinstance(groups, int)} {type(groups)}"
|
| 530 |
+
out_channels, in_channels_per_group, kh, kw = _get_weight_shape(w)
|
| 531 |
+
fw, fh = _get_filter_size(f)
|
| 532 |
+
# px0, px1, py0, py1 = _parse_padding(padding)
|
| 533 |
+
px0, px1, py0, py1 = padding, padding, padding, padding
|
| 534 |
+
|
| 535 |
+
# Adjust padding to account for up/downsampling.
|
| 536 |
+
if up > 1:
|
| 537 |
+
px0 += (fw + up - 1) // 2
|
| 538 |
+
px1 += (fw - up) // 2
|
| 539 |
+
py0 += (fh + up - 1) // 2
|
| 540 |
+
py1 += (fh - up) // 2
|
| 541 |
+
if down > 1:
|
| 542 |
+
px0 += (fw - down + 1) // 2
|
| 543 |
+
px1 += (fw - down) // 2
|
| 544 |
+
py0 += (fh - down + 1) // 2
|
| 545 |
+
py1 += (fh - down) // 2
|
| 546 |
+
|
| 547 |
+
# Fast path: 1x1 convolution with downsampling only => downsample first, then convolve.
|
| 548 |
+
if kw == 1 and kh == 1 and (down > 1 and up == 1):
|
| 549 |
+
x = upfirdn2d(
|
| 550 |
+
x=x, f=f, down=down, padding=[px0, px1, py0, py1], flip_filter=flip_filter
|
| 551 |
+
)
|
| 552 |
+
x = _conv2d_wrapper(x=x, w=w, groups=groups, flip_weight=flip_weight)
|
| 553 |
+
return x
|
| 554 |
+
|
| 555 |
+
# Fast path: 1x1 convolution with upsampling only => convolve first, then upsample.
|
| 556 |
+
if kw == 1 and kh == 1 and (up > 1 and down == 1):
|
| 557 |
+
x = _conv2d_wrapper(x=x, w=w, groups=groups, flip_weight=flip_weight)
|
| 558 |
+
x = upfirdn2d(
|
| 559 |
+
x=x,
|
| 560 |
+
f=f,
|
| 561 |
+
up=up,
|
| 562 |
+
padding=[px0, px1, py0, py1],
|
| 563 |
+
gain=up**2,
|
| 564 |
+
flip_filter=flip_filter,
|
| 565 |
+
)
|
| 566 |
+
return x
|
| 567 |
+
|
| 568 |
+
# Fast path: downsampling only => use strided convolution.
|
| 569 |
+
if down > 1 and up == 1:
|
| 570 |
+
x = upfirdn2d(x=x, f=f, padding=[px0, px1, py0, py1], flip_filter=flip_filter)
|
| 571 |
+
x = _conv2d_wrapper(
|
| 572 |
+
x=x, w=w, stride=down, groups=groups, flip_weight=flip_weight
|
| 573 |
+
)
|
| 574 |
+
return x
|
| 575 |
+
|
| 576 |
+
# Fast path: upsampling with optional downsampling => use transpose strided convolution.
|
| 577 |
+
if up > 1:
|
| 578 |
+
if groups == 1:
|
| 579 |
+
w = w.transpose(0, 1)
|
| 580 |
+
else:
|
| 581 |
+
w = w.reshape(groups, out_channels // groups, in_channels_per_group, kh, kw)
|
| 582 |
+
w = w.transpose(1, 2)
|
| 583 |
+
w = w.reshape(
|
| 584 |
+
groups * in_channels_per_group, out_channels // groups, kh, kw
|
| 585 |
+
)
|
| 586 |
+
px0 -= kw - 1
|
| 587 |
+
px1 -= kw - up
|
| 588 |
+
py0 -= kh - 1
|
| 589 |
+
py1 -= kh - up
|
| 590 |
+
pxt = max(min(-px0, -px1), 0)
|
| 591 |
+
pyt = max(min(-py0, -py1), 0)
|
| 592 |
+
x = _conv2d_wrapper(
|
| 593 |
+
x=x,
|
| 594 |
+
w=w,
|
| 595 |
+
stride=up,
|
| 596 |
+
padding=[pyt, pxt],
|
| 597 |
+
groups=groups,
|
| 598 |
+
transpose=True,
|
| 599 |
+
flip_weight=(not flip_weight),
|
| 600 |
+
)
|
| 601 |
+
x = upfirdn2d(
|
| 602 |
+
x=x,
|
| 603 |
+
f=f,
|
| 604 |
+
padding=[px0 + pxt, px1 + pxt, py0 + pyt, py1 + pyt],
|
| 605 |
+
gain=up**2,
|
| 606 |
+
flip_filter=flip_filter,
|
| 607 |
+
)
|
| 608 |
+
if down > 1:
|
| 609 |
+
x = upfirdn2d(x=x, f=f, down=down, flip_filter=flip_filter)
|
| 610 |
+
return x
|
| 611 |
+
|
| 612 |
+
# Fast path: no up/downsampling, padding supported by the underlying implementation => use plain conv2d.
|
| 613 |
+
if up == 1 and down == 1:
|
| 614 |
+
if px0 == px1 and py0 == py1 and px0 >= 0 and py0 >= 0:
|
| 615 |
+
return _conv2d_wrapper(
|
| 616 |
+
x=x, w=w, padding=[py0, px0], groups=groups, flip_weight=flip_weight
|
| 617 |
+
)
|
| 618 |
+
|
| 619 |
+
# Fallback: Generic reference implementation.
|
| 620 |
+
x = upfirdn2d(
|
| 621 |
+
x=x,
|
| 622 |
+
f=(f if up > 1 else None),
|
| 623 |
+
up=up,
|
| 624 |
+
padding=[px0, px1, py0, py1],
|
| 625 |
+
gain=up**2,
|
| 626 |
+
flip_filter=flip_filter,
|
| 627 |
+
)
|
| 628 |
+
x = _conv2d_wrapper(x=x, w=w, groups=groups, flip_weight=flip_weight)
|
| 629 |
+
if down > 1:
|
| 630 |
+
x = upfirdn2d(x=x, f=f, down=down, flip_filter=flip_filter)
|
| 631 |
+
return x
|
| 632 |
+
|
| 633 |
+
|
| 634 |
+
class Conv2dLayer(torch.nn.Module):
|
| 635 |
+
def __init__(
|
| 636 |
+
self,
|
| 637 |
+
in_channels, # Number of input channels.
|
| 638 |
+
out_channels, # Number of output channels.
|
| 639 |
+
kernel_size, # Width and height of the convolution kernel.
|
| 640 |
+
bias=True, # Apply additive bias before the activation function?
|
| 641 |
+
activation="linear", # Activation function: 'relu', 'lrelu', etc.
|
| 642 |
+
up=1, # Integer upsampling factor.
|
| 643 |
+
down=1, # Integer downsampling factor.
|
| 644 |
+
resample_filter=[
|
| 645 |
+
1,
|
| 646 |
+
3,
|
| 647 |
+
3,
|
| 648 |
+
1,
|
| 649 |
+
], # Low-pass filter to apply when resampling activations.
|
| 650 |
+
conv_clamp=None, # Clamp the output to +-X, None = disable clamping.
|
| 651 |
+
channels_last=False, # Expect the input to have memory_format=channels_last?
|
| 652 |
+
trainable=True, # Update the weights of this layer during training?
|
| 653 |
+
):
|
| 654 |
+
super().__init__()
|
| 655 |
+
self.activation = activation
|
| 656 |
+
self.up = up
|
| 657 |
+
self.down = down
|
| 658 |
+
self.register_buffer("resample_filter", setup_filter(resample_filter))
|
| 659 |
+
self.conv_clamp = conv_clamp
|
| 660 |
+
self.padding = kernel_size // 2
|
| 661 |
+
self.weight_gain = 1 / np.sqrt(in_channels * (kernel_size**2))
|
| 662 |
+
self.act_gain = activation_funcs[activation].def_gain
|
| 663 |
+
|
| 664 |
+
memory_format = (
|
| 665 |
+
torch.channels_last if channels_last else torch.contiguous_format
|
| 666 |
+
)
|
| 667 |
+
weight = torch.randn([out_channels, in_channels, kernel_size, kernel_size]).to(
|
| 668 |
+
memory_format=memory_format
|
| 669 |
+
)
|
| 670 |
+
bias = torch.zeros([out_channels]) if bias else None
|
| 671 |
+
if trainable:
|
| 672 |
+
self.weight = torch.nn.Parameter(weight)
|
| 673 |
+
self.bias = torch.nn.Parameter(bias) if bias is not None else None
|
| 674 |
+
else:
|
| 675 |
+
self.register_buffer("weight", weight)
|
| 676 |
+
if bias is not None:
|
| 677 |
+
self.register_buffer("bias", bias)
|
| 678 |
+
else:
|
| 679 |
+
self.bias = None
|
| 680 |
+
|
| 681 |
+
def forward(self, x, gain=1):
|
| 682 |
+
w = self.weight * self.weight_gain
|
| 683 |
+
x = conv2d_resample(
|
| 684 |
+
x=x,
|
| 685 |
+
w=w,
|
| 686 |
+
f=self.resample_filter,
|
| 687 |
+
up=self.up,
|
| 688 |
+
down=self.down,
|
| 689 |
+
padding=self.padding,
|
| 690 |
+
)
|
| 691 |
+
|
| 692 |
+
act_gain = self.act_gain * gain
|
| 693 |
+
act_clamp = self.conv_clamp * gain if self.conv_clamp is not None else None
|
| 694 |
+
out = bias_act(
|
| 695 |
+
x, self.bias, act=self.activation, gain=act_gain, clamp=act_clamp
|
| 696 |
+
)
|
| 697 |
+
return out
|
sage2/media/inpaint.png
ADDED
|
Git LFS Details
|
sage2/media/preprocess-blur-17.png
ADDED
|
sage2/media/preprocess-blur-65.png
ADDED
|
sage2/media/preprocess-input.png
ADDED
|
sage2/media/preprocess-lama.png
ADDED
|
sage2/media/preprocess-mat.png
ADDED
|
sage2/media/preprocess-navier-stokes.png
ADDED
|
sage2/media/preproc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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
from typing import Any
|
| 3 |
+
import numpy as np
|
| 4 |
+
import torch
|
| 5 |
+
import torch.jit
|
| 6 |
+
import torch.nn.functional as F
|
| 7 |
+
from spandrel import ModelLoader, MaskedImageModelDescriptor
|
| 8 |
+
|
| 9 |
+
from torch import Tensor
|
| 10 |
+
from tqdm import trange
|
| 11 |
+
|
| 12 |
+
from comfy.utils import ProgressBar
|
| 13 |
+
from comfy.model_patcher import ModelPatcher
|
| 14 |
+
from comfy.model_base import BaseModel
|
| 15 |
+
from comfy.model_management import cast_to_device, get_torch_device
|
| 16 |
+
import comfy.utils
|
| 17 |
+
import comfy.lora
|
| 18 |
+
import folder_paths
|
| 19 |
+
import nodes
|
| 20 |
+
|
| 21 |
+
from . import mat
|
| 22 |
+
from .util import (
|
| 23 |
+
gaussian_blur,
|
| 24 |
+
binary_erosion,
|
| 25 |
+
make_odd,
|
| 26 |
+
to_torch,
|
| 27 |
+
to_comfy,
|
| 28 |
+
resize_square,
|
| 29 |
+
undo_resize_square,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class InpaintHead(torch.nn.Module):
|
| 34 |
+
def __init__(self, *args, **kwargs):
|
| 35 |
+
super().__init__(*args, **kwargs)
|
| 36 |
+
self.head = torch.nn.Parameter(torch.empty(size=(320, 5, 3, 3), device="cpu"))
|
| 37 |
+
|
| 38 |
+
def __call__(self, x):
|
| 39 |
+
x = F.pad(x, (1, 1, 1, 1), "replicate")
|
| 40 |
+
return F.conv2d(x, weight=self.head)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def load_fooocus_patch(lora: dict, to_load: dict):
|
| 44 |
+
patch_dict = {}
|
| 45 |
+
loaded_keys = set()
|
| 46 |
+
for key in to_load.values():
|
| 47 |
+
if value := lora.get(key, None):
|
| 48 |
+
patch_dict[key] = ("fooocus", value)
|
| 49 |
+
loaded_keys.add(key)
|
| 50 |
+
|
| 51 |
+
not_loaded = sum(1 for x in lora if x not in loaded_keys)
|
| 52 |
+
print(
|
| 53 |
+
f"[ApplyFooocusInpaint] {len(loaded_keys)} Lora keys loaded, {not_loaded} remaining keys not found in model."
|
| 54 |
+
)
|
| 55 |
+
return patch_dict
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
original_calculate_weight = ModelPatcher.calculate_weight
|
| 59 |
+
injected_model_patcher_calculate_weight = False
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def calculate_weight_patched(self: ModelPatcher, patches, weight, key):
|
| 63 |
+
remaining = []
|
| 64 |
+
|
| 65 |
+
for p in patches:
|
| 66 |
+
alpha, v, strength_model = p
|
| 67 |
+
|
| 68 |
+
is_fooocus_patch = isinstance(v, tuple) and len(v) == 2 and v[0] == "fooocus"
|
| 69 |
+
if not is_fooocus_patch:
|
| 70 |
+
remaining.append(p)
|
| 71 |
+
continue
|
| 72 |
+
|
| 73 |
+
if alpha != 0.0:
|
| 74 |
+
v = v[1]
|
| 75 |
+
w1 = cast_to_device(v[0], weight.device, torch.float32)
|
| 76 |
+
if w1.shape == weight.shape:
|
| 77 |
+
w_min = cast_to_device(v[1], weight.device, torch.float32)
|
| 78 |
+
w_max = cast_to_device(v[2], weight.device, torch.float32)
|
| 79 |
+
w1 = (w1 / 255.0) * (w_max - w_min) + w_min
|
| 80 |
+
weight += alpha * cast_to_device(w1, weight.device, weight.dtype)
|
| 81 |
+
else:
|
| 82 |
+
print(
|
| 83 |
+
f"[ApplyFooocusInpaint] Shape mismatch {key}, weight not merged ({w1.shape} != {weight.shape})"
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
if len(remaining) > 0:
|
| 87 |
+
return original_calculate_weight(self, remaining, weight, key)
|
| 88 |
+
return weight
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def inject_patched_calculate_weight():
|
| 92 |
+
global injected_model_patcher_calculate_weight
|
| 93 |
+
if not injected_model_patcher_calculate_weight:
|
| 94 |
+
print(
|
| 95 |
+
"[comfyui-inpaint-nodes] Injecting patched comfy.model_patcher.ModelPatcher.calculate_weight"
|
| 96 |
+
)
|
| 97 |
+
ModelPatcher.calculate_weight = calculate_weight_patched
|
| 98 |
+
injected_model_patcher_calculate_weight = True
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
class LoadFooocusInpaint:
|
| 102 |
+
@classmethod
|
| 103 |
+
def INPUT_TYPES(s):
|
| 104 |
+
return {
|
| 105 |
+
"required": {
|
| 106 |
+
"head": (folder_paths.get_filename_list("inpaint"),),
|
| 107 |
+
"patch": (folder_paths.get_filename_list("inpaint"),),
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
RETURN_TYPES = ("INPAINT_PATCH",)
|
| 112 |
+
CATEGORY = "inpaint"
|
| 113 |
+
FUNCTION = "load"
|
| 114 |
+
|
| 115 |
+
def load(self, head: str, patch: str):
|
| 116 |
+
head_file = folder_paths.get_full_path("inpaint", head)
|
| 117 |
+
inpaint_head_model = InpaintHead()
|
| 118 |
+
sd = torch.load(head_file, map_location="cpu")
|
| 119 |
+
inpaint_head_model.load_state_dict(sd)
|
| 120 |
+
|
| 121 |
+
patch_file = folder_paths.get_full_path("inpaint", patch)
|
| 122 |
+
inpaint_lora = comfy.utils.load_torch_file(patch_file, safe_load=True)
|
| 123 |
+
|
| 124 |
+
return ((inpaint_head_model, inpaint_lora),)
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
class ApplyFooocusInpaint:
|
| 128 |
+
@classmethod
|
| 129 |
+
def INPUT_TYPES(s):
|
| 130 |
+
return {
|
| 131 |
+
"required": {
|
| 132 |
+
"model": ("MODEL",),
|
| 133 |
+
"patch": ("INPAINT_PATCH",),
|
| 134 |
+
"latent": ("LATENT",),
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
RETURN_TYPES = ("MODEL",)
|
| 139 |
+
CATEGORY = "inpaint"
|
| 140 |
+
FUNCTION = "patch"
|
| 141 |
+
|
| 142 |
+
def patch(
|
| 143 |
+
self,
|
| 144 |
+
model: ModelPatcher,
|
| 145 |
+
patch: tuple[InpaintHead, dict[str, Tensor]],
|
| 146 |
+
latent: dict[str, Any],
|
| 147 |
+
):
|
| 148 |
+
base_model: BaseModel = model.model
|
| 149 |
+
latent_pixels = base_model.process_latent_in(latent["samples"])
|
| 150 |
+
noise_mask = latent["noise_mask"].round()
|
| 151 |
+
|
| 152 |
+
latent_mask = F.max_pool2d(noise_mask, (8, 8)).round().to(latent_pixels)
|
| 153 |
+
|
| 154 |
+
inpaint_head_model, inpaint_lora = patch
|
| 155 |
+
feed = torch.cat([latent_mask, latent_pixels], dim=1)
|
| 156 |
+
inpaint_head_model.to(device=feed.device, dtype=feed.dtype)
|
| 157 |
+
inpaint_head_feature = inpaint_head_model(feed)
|
| 158 |
+
|
| 159 |
+
def input_block_patch(h, transformer_options):
|
| 160 |
+
if transformer_options["block"][1] == 0:
|
| 161 |
+
h = h + inpaint_head_feature.to(h)
|
| 162 |
+
return h
|
| 163 |
+
|
| 164 |
+
lora_keys = comfy.lora.model_lora_keys_unet(model.model, {})
|
| 165 |
+
lora_keys.update({x: x for x in base_model.state_dict().keys()})
|
| 166 |
+
loaded_lora = load_fooocus_patch(inpaint_lora, lora_keys)
|
| 167 |
+
|
| 168 |
+
m = model.clone()
|
| 169 |
+
m.set_model_input_block_patch(input_block_patch)
|
| 170 |
+
patched = m.add_patches(loaded_lora, 1.0)
|
| 171 |
+
|
| 172 |
+
not_patched_count = sum(1 for x in loaded_lora if x not in patched)
|
| 173 |
+
if not_patched_count > 0:
|
| 174 |
+
print(f"[ApplyFooocusInpaint] Failed to patch {not_patched_count} keys")
|
| 175 |
+
|
| 176 |
+
inject_patched_calculate_weight()
|
| 177 |
+
return (m,)
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
class VAEEncodeInpaintConditioning:
|
| 181 |
+
@classmethod
|
| 182 |
+
def INPUT_TYPES(s):
|
| 183 |
+
return {
|
| 184 |
+
"required": {
|
| 185 |
+
"positive": ("CONDITIONING",),
|
| 186 |
+
"negative": ("CONDITIONING",),
|
| 187 |
+
"vae": ("VAE",),
|
| 188 |
+
"pixels": ("IMAGE",),
|
| 189 |
+
"mask": ("MASK",),
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
RETURN_TYPES = ("CONDITIONING", "CONDITIONING", "LATENT", "LATENT")
|
| 194 |
+
RETURN_NAMES = ("positive", "negative", "latent_inpaint", "latent_samples")
|
| 195 |
+
FUNCTION = "encode"
|
| 196 |
+
CATEGORY = "inpaint"
|
| 197 |
+
|
| 198 |
+
def encode(self, positive, negative, vae, pixels, mask):
|
| 199 |
+
positive, negative, latent = nodes.InpaintModelConditioning().encode(
|
| 200 |
+
positive, negative, pixels, vae, mask
|
| 201 |
+
)
|
| 202 |
+
latent_inpaint = dict(
|
| 203 |
+
samples=positive[0][1]["concat_latent_image"],
|
| 204 |
+
noise_mask=latent["noise_mask"].round(),
|
| 205 |
+
)
|
| 206 |
+
return (positive, negative, latent_inpaint, latent)
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
class MaskedFill:
|
| 210 |
+
@classmethod
|
| 211 |
+
def INPUT_TYPES(s):
|
| 212 |
+
return {
|
| 213 |
+
"required": {
|
| 214 |
+
"image": ("IMAGE",),
|
| 215 |
+
"mask": ("MASK",),
|
| 216 |
+
"fill": (["neutral", "telea", "navier-stokes"],),
|
| 217 |
+
"falloff": ("INT", {"default": 0, "min": 0, "max": 8191, "step": 1}),
|
| 218 |
+
}
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
RETURN_TYPES = ("IMAGE",)
|
| 222 |
+
CATEGORY = "inpaint"
|
| 223 |
+
FUNCTION = "fill"
|
| 224 |
+
|
| 225 |
+
def fill(self, image: Tensor, mask: Tensor, fill: str, falloff: int):
|
| 226 |
+
image = image.detach().clone()
|
| 227 |
+
alpha = mask.expand(1, *mask.shape[-2:]).floor()
|
| 228 |
+
falloff = make_odd(falloff)
|
| 229 |
+
if falloff > 0:
|
| 230 |
+
erosion = binary_erosion(alpha, falloff)
|
| 231 |
+
alpha = alpha * gaussian_blur(erosion, falloff)
|
| 232 |
+
|
| 233 |
+
if fill == "neutral":
|
| 234 |
+
m = (1.0 - alpha).squeeze(1)
|
| 235 |
+
for i in range(3):
|
| 236 |
+
image[:, :, :, i] -= 0.5
|
| 237 |
+
image[:, :, :, i] *= m
|
| 238 |
+
image[:, :, :, i] += 0.5
|
| 239 |
+
else:
|
| 240 |
+
import cv2
|
| 241 |
+
|
| 242 |
+
method = cv2.INPAINT_TELEA if fill == "telea" else cv2.INPAINT_NS
|
| 243 |
+
alpha_np = alpha.squeeze(0).cpu().numpy()
|
| 244 |
+
alpha_bc = alpha_np.reshape(*alpha_np.shape, 1)
|
| 245 |
+
for slice in image:
|
| 246 |
+
image_np = slice.cpu().numpy()
|
| 247 |
+
filled_np = cv2.inpaint(
|
| 248 |
+
(255.0 * image_np).astype(np.uint8),
|
| 249 |
+
(255.0 * alpha_np).astype(np.uint8),
|
| 250 |
+
3,
|
| 251 |
+
method,
|
| 252 |
+
)
|
| 253 |
+
filled_np = filled_np.astype(np.float32) / 255.0
|
| 254 |
+
filled_np = image_np * (1.0 - alpha_bc) + filled_np * alpha_bc
|
| 255 |
+
slice.copy_(torch.from_numpy(filled_np))
|
| 256 |
+
|
| 257 |
+
return (image,)
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
class MaskedBlur:
|
| 261 |
+
@classmethod
|
| 262 |
+
def INPUT_TYPES(s):
|
| 263 |
+
return {
|
| 264 |
+
"required": {
|
| 265 |
+
"image": ("IMAGE",),
|
| 266 |
+
"mask": ("MASK",),
|
| 267 |
+
"blur": ("INT", {"default": 255, "min": 3, "max": 8191, "step": 1}),
|
| 268 |
+
"falloff": ("INT", {"default": 0, "min": 0, "max": 8191, "step": 1}),
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
RETURN_TYPES = ("IMAGE",)
|
| 273 |
+
CATEGORY = "inpaint"
|
| 274 |
+
FUNCTION = "fill"
|
| 275 |
+
|
| 276 |
+
def fill(self, image: Tensor, mask: Tensor, blur: int, falloff: int):
|
| 277 |
+
blur = make_odd(blur)
|
| 278 |
+
falloff = min(make_odd(falloff), blur - 2)
|
| 279 |
+
image, mask = to_torch(image, mask)
|
| 280 |
+
|
| 281 |
+
original = image.clone()
|
| 282 |
+
alpha = mask.floor()
|
| 283 |
+
if falloff > 0:
|
| 284 |
+
erosion = binary_erosion(alpha, falloff)
|
| 285 |
+
alpha = alpha * gaussian_blur(erosion, falloff)
|
| 286 |
+
alpha = alpha.repeat(1, 3, 1, 1)
|
| 287 |
+
|
| 288 |
+
image = gaussian_blur(image, blur)
|
| 289 |
+
image = original + (image - original) * alpha
|
| 290 |
+
return (to_comfy(image),)
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
class LoadInpaintModel:
|
| 294 |
+
@classmethod
|
| 295 |
+
def INPUT_TYPES(s):
|
| 296 |
+
return {
|
| 297 |
+
"required": {
|
| 298 |
+
"model_name": (folder_paths.get_filename_list("inpaint"),),
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
RETURN_TYPES = ("INPAINT_MODEL",)
|
| 303 |
+
CATEGORY = "inpaint"
|
| 304 |
+
FUNCTION = "load"
|
| 305 |
+
|
| 306 |
+
def load(self, model_name: str):
|
| 307 |
+
model_file = folder_paths.get_full_path("inpaint", model_name)
|
| 308 |
+
if model_file is None:
|
| 309 |
+
raise RuntimeError(f"Model file not found: {model_name}")
|
| 310 |
+
if model_file.endswith(".pt"):
|
| 311 |
+
sd = torch.jit.load(model_file, map_location="cpu").state_dict()
|
| 312 |
+
else:
|
| 313 |
+
sd = comfy.utils.load_torch_file(model_file, safe_load=True)
|
| 314 |
+
|
| 315 |
+
if "synthesis.first_stage.conv_first.conv.resample_filter" in sd: # MAT
|
| 316 |
+
model = mat.load(sd)
|
| 317 |
+
else:
|
| 318 |
+
model = ModelLoader().load_from_state_dict(sd)
|
| 319 |
+
model = model.eval()
|
| 320 |
+
return (model,)
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
class InpaintWithModel:
|
| 324 |
+
@classmethod
|
| 325 |
+
def INPUT_TYPES(s):
|
| 326 |
+
return {
|
| 327 |
+
"required": {
|
| 328 |
+
"inpaint_model": ("INPAINT_MODEL",),
|
| 329 |
+
"image": ("IMAGE",),
|
| 330 |
+
"mask": ("MASK",),
|
| 331 |
+
"seed": ("INT", {"default": 0, "min": 0, "max": 0xFFFFFFFFFFFFFFFF}),
|
| 332 |
+
},
|
| 333 |
+
"optional": {
|
| 334 |
+
"optional_upscale_model": ("UPSCALE_MODEL",),
|
| 335 |
+
},
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
RETURN_TYPES = ("IMAGE",)
|
| 339 |
+
CATEGORY = "inpaint"
|
| 340 |
+
FUNCTION = "inpaint"
|
| 341 |
+
|
| 342 |
+
def inpaint(
|
| 343 |
+
self,
|
| 344 |
+
inpaint_model: MaskedImageModelDescriptor | mat.MAT,
|
| 345 |
+
image: Tensor,
|
| 346 |
+
mask: Tensor,
|
| 347 |
+
seed: int,
|
| 348 |
+
optional_upscale_model=None,
|
| 349 |
+
):
|
| 350 |
+
if isinstance(inpaint_model, mat.MAT):
|
| 351 |
+
required_size = 512
|
| 352 |
+
elif inpaint_model.architecture.id == "LaMa":
|
| 353 |
+
required_size = 256
|
| 354 |
+
else:
|
| 355 |
+
raise ValueError(f"Unknown model_arch {type(inpaint_model)}")
|
| 356 |
+
|
| 357 |
+
if optional_upscale_model != None:
|
| 358 |
+
from comfy_extras.nodes_upscale_model import ImageUpscaleWithModel
|
| 359 |
+
|
| 360 |
+
upscaler = ImageUpscaleWithModel
|
| 361 |
+
|
| 362 |
+
image, mask = to_torch(image, mask)
|
| 363 |
+
batch_size = image.shape[0]
|
| 364 |
+
if mask.shape[0] != batch_size:
|
| 365 |
+
mask = mask[0].unsqueeze(0).repeat(batch_size, 1, 1, 1)
|
| 366 |
+
|
| 367 |
+
image_device = image.device
|
| 368 |
+
device = get_torch_device()
|
| 369 |
+
inpaint_model.to(device)
|
| 370 |
+
batch_image = []
|
| 371 |
+
pbar = ProgressBar(batch_size)
|
| 372 |
+
|
| 373 |
+
for i in trange(batch_size):
|
| 374 |
+
work_image, work_mask = image[i].unsqueeze(0), mask[i].unsqueeze(0)
|
| 375 |
+
work_image, work_mask, original_size = resize_square(
|
| 376 |
+
work_image, work_mask, required_size
|
| 377 |
+
)
|
| 378 |
+
work_mask = work_mask.floor()
|
| 379 |
+
|
| 380 |
+
torch.manual_seed(seed)
|
| 381 |
+
work_image = inpaint_model(work_image.to(device), work_mask.to(device))
|
| 382 |
+
|
| 383 |
+
if optional_upscale_model != None:
|
| 384 |
+
work_image = work_image.movedim(1, -1)
|
| 385 |
+
work_image = upscaler.upscale(upscaler, optional_upscale_model, work_image)
|
| 386 |
+
work_image = work_image[0].movedim(-1, 1)
|
| 387 |
+
|
| 388 |
+
work_image.to(image_device)
|
| 389 |
+
work_image = undo_resize_square(work_image.to(image_device), original_size)
|
| 390 |
+
work_image = image[i] + (work_image - image[i]) * mask[i].floor()
|
| 391 |
+
|
| 392 |
+
batch_image.append(work_image)
|
| 393 |
+
pbar.update(1)
|
| 394 |
+
|
| 395 |
+
inpaint_model.cpu()
|
| 396 |
+
result = torch.cat(batch_image, dim=0)
|
| 397 |
+
return (to_comfy(result),)
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
class DenoiseToCompositingMask:
|
| 401 |
+
@classmethod
|
| 402 |
+
def INPUT_TYPES(cls):
|
| 403 |
+
return {
|
| 404 |
+
"required": {
|
| 405 |
+
"mask": ("MASK",),
|
| 406 |
+
"offset": (
|
| 407 |
+
"FLOAT",
|
| 408 |
+
{"default": 0.1, "min": 0.0, "max": 1.0, "step": 0.01},
|
| 409 |
+
),
|
| 410 |
+
"threshold": (
|
| 411 |
+
"FLOAT",
|
| 412 |
+
{"default": 0.2, "min": 0.01, "max": 1.0, "step": 0.01},
|
| 413 |
+
),
|
| 414 |
+
}
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
RETURN_TYPES = ("MASK",)
|
| 418 |
+
CATEGORY = "inpaint"
|
| 419 |
+
FUNCTION = "convert"
|
| 420 |
+
|
| 421 |
+
def convert(self, mask: Tensor, offset: float, threshold: float):
|
| 422 |
+
assert 0.0 <= offset < threshold <= 1.0, "Threshold must be higher than offset"
|
| 423 |
+
mask = (mask - offset) * (1 / (threshold - offset))
|
| 424 |
+
mask = mask.clamp(0, 1)
|
| 425 |
+
return (mask,)
|
sage2/pyproject.toml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "comfyui-inpaint-nodes"
|
| 3 |
+
description = "Nodes for better inpainting with ComfyUI. Adds various ways to pre-process inpaint areas. Supports the Fooocus inpaint model, a small and flexible patch which can be applied to any SDXL checkpoint and will improve consistency when generating masked areas."
|
| 4 |
+
version = "1.0.1"
|
| 5 |
+
license = "LICENSE"
|
| 6 |
+
|
| 7 |
+
[project.urls]
|
| 8 |
+
Repository = "https://github.com/Acly/comfyui-inpaint-nodes"
|
| 9 |
+
|
| 10 |
+
[tool.black]
|
| 11 |
+
line-length = 100
|
| 12 |
+
preview = true
|
| 13 |
+
|
| 14 |
+
[tool.comfy]
|
| 15 |
+
PublisherId = "acly"
|
| 16 |
+
DisplayName = "comfyui-inpaint-nodes"
|
| 17 |
+
Icon = ""
|
sage2/util.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
import torch
|
| 3 |
+
import torch.nn.functional as F
|
| 4 |
+
import numpy as np
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def to_torch(image: Tensor, mask: Tensor | None = None):
|
| 9 |
+
if len(image.shape) == 3:
|
| 10 |
+
image = image.unsqueeze(0)
|
| 11 |
+
image = image.permute(0, 3, 1, 2) # BHWC -> BCHW
|
| 12 |
+
if mask is not None:
|
| 13 |
+
if len(mask.shape) == 3: # BHW -> B1HW
|
| 14 |
+
mask = mask.unsqueeze(1)
|
| 15 |
+
elif len(mask.shape) == 2: # HW -> B1HW
|
| 16 |
+
mask = mask.unsqueeze(0).unsqueeze(0)
|
| 17 |
+
if image.shape[2:] != mask.shape[2:]:
|
| 18 |
+
raise ValueError(
|
| 19 |
+
f"Image and mask must be the same size. {image.shape[2:]} != {mask.shape[2:]}"
|
| 20 |
+
)
|
| 21 |
+
return image, mask
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def to_comfy(image: Tensor):
|
| 25 |
+
return image.permute(0, 2, 3, 1) # BCHW -> BHWC
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# torch pad does not support padding greater than image size with "reflect" mode
|
| 29 |
+
def pad_reflect_once(x: Tensor, original_padding: tuple[int, int, int, int]):
|
| 30 |
+
_, _, h, w = x.shape
|
| 31 |
+
padding = np.array(original_padding)
|
| 32 |
+
size = np.array([w, w, h, h])
|
| 33 |
+
|
| 34 |
+
initial_padding = np.minimum(padding, size - 1)
|
| 35 |
+
additional_padding = padding - initial_padding
|
| 36 |
+
|
| 37 |
+
x = F.pad(x, tuple(initial_padding), mode="reflect")
|
| 38 |
+
if np.any(additional_padding > 0):
|
| 39 |
+
x = F.pad(x, tuple(additional_padding), mode="constant")
|
| 40 |
+
return x
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def resize_square(image: Tensor, mask: Tensor, size: int):
|
| 44 |
+
_, _, h, w = image.shape
|
| 45 |
+
pad_w, pad_h, prev_size = 0, 0, w
|
| 46 |
+
if w == size and h == size:
|
| 47 |
+
return image, mask, (pad_w, pad_h, prev_size)
|
| 48 |
+
|
| 49 |
+
if w < h:
|
| 50 |
+
pad_w = h - w
|
| 51 |
+
prev_size = h
|
| 52 |
+
elif h < w:
|
| 53 |
+
pad_h = w - h
|
| 54 |
+
prev_size = w
|
| 55 |
+
image = pad_reflect_once(image, (0, pad_w, 0, pad_h))
|
| 56 |
+
mask = pad_reflect_once(mask, (0, pad_w, 0, pad_h))
|
| 57 |
+
|
| 58 |
+
if image.shape[-1] != size:
|
| 59 |
+
image = F.interpolate(image, size=size, mode="nearest-exact")
|
| 60 |
+
mask = F.interpolate(mask, size=size, mode="nearest-exact")
|
| 61 |
+
|
| 62 |
+
return image, mask, (pad_w, pad_h, prev_size)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def undo_resize_square(image: Tensor, original_size: tuple[int, int, int]):
|
| 66 |
+
_, _, h, w = image.shape
|
| 67 |
+
pad_w, pad_h, prev_size = original_size
|
| 68 |
+
if prev_size != w or prev_size != h:
|
| 69 |
+
image = F.interpolate(image, size=prev_size, mode="bilinear")
|
| 70 |
+
return image[:, :, 0 : prev_size - pad_h, 0 : prev_size - pad_w]
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def _gaussian_kernel(radius: int, sigma: float):
|
| 74 |
+
x = torch.linspace(-radius, radius, steps=radius * 2 + 1)
|
| 75 |
+
pdf = torch.exp(-0.5 * (x / sigma).pow(2))
|
| 76 |
+
return pdf / pdf.sum()
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def gaussian_blur(image: Tensor, radius: int, sigma: float = 0):
|
| 80 |
+
c = image.shape[-3]
|
| 81 |
+
if sigma <= 0:
|
| 82 |
+
sigma = 0.3 * (radius - 1) + 0.8
|
| 83 |
+
|
| 84 |
+
kernel = _gaussian_kernel(radius, sigma).to(image.device)
|
| 85 |
+
kernel_x = kernel[..., None, :].repeat(c, 1, 1).unsqueeze(1)
|
| 86 |
+
kernel_y = kernel[..., None].repeat(c, 1, 1).unsqueeze(1)
|
| 87 |
+
|
| 88 |
+
image = F.pad(image, (radius, radius, radius, radius), mode="reflect")
|
| 89 |
+
image = F.conv2d(image, kernel_x, groups=c)
|
| 90 |
+
image = F.conv2d(image, kernel_y, groups=c)
|
| 91 |
+
return image
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def binary_erosion(mask: Tensor, radius: int):
|
| 95 |
+
kernel = torch.ones(1, 1, radius * 2 + 1, radius * 2 + 1, device=mask.device)
|
| 96 |
+
mask = F.pad(mask, (radius, radius, radius, radius), mode="constant", value=1)
|
| 97 |
+
mask = F.conv2d(mask, kernel, groups=1)
|
| 98 |
+
mask = (mask == kernel.numel()).to(mask.dtype)
|
| 99 |
+
return mask
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def make_odd(x):
|
| 103 |
+
if x > 0 and x % 2 == 0:
|
| 104 |
+
return x + 1
|
| 105 |
+
return x
|
sage2/workflows/inpaint-preprocess.json
ADDED
|
@@ -0,0 +1,1483 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"last_node_id": 66,
|
| 3 |
+
"last_link_id": 170,
|
| 4 |
+
"nodes": [
|
| 5 |
+
{
|
| 6 |
+
"id": 19,
|
| 7 |
+
"type": "CheckpointLoaderSimple",
|
| 8 |
+
"pos": [
|
| 9 |
+
-483,
|
| 10 |
+
1110
|
| 11 |
+
],
|
| 12 |
+
"size": {
|
| 13 |
+
"0": 431,
|
| 14 |
+
"1": 98
|
| 15 |
+
},
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 0,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"outputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "MODEL",
|
| 22 |
+
"type": "MODEL",
|
| 23 |
+
"links": [
|
| 24 |
+
60
|
| 25 |
+
],
|
| 26 |
+
"shape": 3,
|
| 27 |
+
"slot_index": 0
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"name": "CLIP",
|
| 31 |
+
"type": "CLIP",
|
| 32 |
+
"links": [
|
| 33 |
+
35,
|
| 34 |
+
88
|
| 35 |
+
],
|
| 36 |
+
"shape": 3,
|
| 37 |
+
"slot_index": 1
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"name": "VAE",
|
| 41 |
+
"type": "VAE",
|
| 42 |
+
"links": [
|
| 43 |
+
43,
|
| 44 |
+
128
|
| 45 |
+
],
|
| 46 |
+
"shape": 3,
|
| 47 |
+
"slot_index": 2
|
| 48 |
+
}
|
| 49 |
+
],
|
| 50 |
+
"properties": {
|
| 51 |
+
"Node name for S&R": "CheckpointLoaderSimple"
|
| 52 |
+
},
|
| 53 |
+
"widgets_values": [
|
| 54 |
+
"juggernautXL_version6Rundiffusion.safetensors"
|
| 55 |
+
]
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"id": 10,
|
| 59 |
+
"type": "CLIPTextEncode",
|
| 60 |
+
"pos": [
|
| 61 |
+
-474,
|
| 62 |
+
1381
|
| 63 |
+
],
|
| 64 |
+
"size": [
|
| 65 |
+
417.5841689221421,
|
| 66 |
+
76
|
| 67 |
+
],
|
| 68 |
+
"flags": {},
|
| 69 |
+
"order": 10,
|
| 70 |
+
"mode": 0,
|
| 71 |
+
"inputs": [
|
| 72 |
+
{
|
| 73 |
+
"name": "clip",
|
| 74 |
+
"type": "CLIP",
|
| 75 |
+
"link": 35
|
| 76 |
+
}
|
| 77 |
+
],
|
| 78 |
+
"outputs": [
|
| 79 |
+
{
|
| 80 |
+
"name": "CONDITIONING",
|
| 81 |
+
"type": "CONDITIONING",
|
| 82 |
+
"links": [
|
| 83 |
+
123
|
| 84 |
+
],
|
| 85 |
+
"shape": 3,
|
| 86 |
+
"slot_index": 0
|
| 87 |
+
}
|
| 88 |
+
],
|
| 89 |
+
"properties": {
|
| 90 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 91 |
+
},
|
| 92 |
+
"widgets_values": [
|
| 93 |
+
"text, watermark"
|
| 94 |
+
],
|
| 95 |
+
"color": "#322",
|
| 96 |
+
"bgcolor": "#533"
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"id": 35,
|
| 100 |
+
"type": "INPAINT_LoadFooocusInpaint",
|
| 101 |
+
"pos": [
|
| 102 |
+
208,
|
| 103 |
+
1200
|
| 104 |
+
],
|
| 105 |
+
"size": [
|
| 106 |
+
276.6825206658291,
|
| 107 |
+
82
|
| 108 |
+
],
|
| 109 |
+
"flags": {},
|
| 110 |
+
"order": 1,
|
| 111 |
+
"mode": 0,
|
| 112 |
+
"outputs": [
|
| 113 |
+
{
|
| 114 |
+
"name": "INPAINT_PATCH",
|
| 115 |
+
"type": "INPAINT_PATCH",
|
| 116 |
+
"links": [
|
| 117 |
+
62
|
| 118 |
+
],
|
| 119 |
+
"shape": 3,
|
| 120 |
+
"slot_index": 0
|
| 121 |
+
}
|
| 122 |
+
],
|
| 123 |
+
"properties": {
|
| 124 |
+
"Node name for S&R": "INPAINT_LoadFooocusInpaint"
|
| 125 |
+
},
|
| 126 |
+
"widgets_values": [
|
| 127 |
+
"fooocus_inpaint_head.pth",
|
| 128 |
+
"inpaint_v26.fooocus.patch"
|
| 129 |
+
],
|
| 130 |
+
"color": "#323",
|
| 131 |
+
"bgcolor": "#535"
|
| 132 |
+
},
|
| 133 |
+
{
|
| 134 |
+
"id": 44,
|
| 135 |
+
"type": "INPAINT_VAEEncodeInpaintConditioning",
|
| 136 |
+
"pos": [
|
| 137 |
+
194,
|
| 138 |
+
1330
|
| 139 |
+
],
|
| 140 |
+
"size": {
|
| 141 |
+
"0": 292.20001220703125,
|
| 142 |
+
"1": 106
|
| 143 |
+
},
|
| 144 |
+
"flags": {},
|
| 145 |
+
"order": 24,
|
| 146 |
+
"mode": 0,
|
| 147 |
+
"inputs": [
|
| 148 |
+
{
|
| 149 |
+
"name": "positive",
|
| 150 |
+
"type": "CONDITIONING",
|
| 151 |
+
"link": 122
|
| 152 |
+
},
|
| 153 |
+
{
|
| 154 |
+
"name": "negative",
|
| 155 |
+
"type": "CONDITIONING",
|
| 156 |
+
"link": 123
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
"name": "vae",
|
| 160 |
+
"type": "VAE",
|
| 161 |
+
"link": 128
|
| 162 |
+
},
|
| 163 |
+
{
|
| 164 |
+
"name": "pixels",
|
| 165 |
+
"type": "IMAGE",
|
| 166 |
+
"link": 140
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
"name": "mask",
|
| 170 |
+
"type": "MASK",
|
| 171 |
+
"link": 138
|
| 172 |
+
}
|
| 173 |
+
],
|
| 174 |
+
"outputs": [
|
| 175 |
+
{
|
| 176 |
+
"name": "positive",
|
| 177 |
+
"type": "CONDITIONING",
|
| 178 |
+
"links": [
|
| 179 |
+
124
|
| 180 |
+
],
|
| 181 |
+
"shape": 3,
|
| 182 |
+
"slot_index": 0
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"name": "negative",
|
| 186 |
+
"type": "CONDITIONING",
|
| 187 |
+
"links": [
|
| 188 |
+
125
|
| 189 |
+
],
|
| 190 |
+
"shape": 3,
|
| 191 |
+
"slot_index": 1
|
| 192 |
+
},
|
| 193 |
+
{
|
| 194 |
+
"name": "latent_inpaint",
|
| 195 |
+
"type": "LATENT",
|
| 196 |
+
"links": [
|
| 197 |
+
127
|
| 198 |
+
],
|
| 199 |
+
"shape": 3,
|
| 200 |
+
"slot_index": 2
|
| 201 |
+
},
|
| 202 |
+
{
|
| 203 |
+
"name": "latent_samples",
|
| 204 |
+
"type": "LATENT",
|
| 205 |
+
"links": [
|
| 206 |
+
126
|
| 207 |
+
],
|
| 208 |
+
"shape": 3,
|
| 209 |
+
"slot_index": 3
|
| 210 |
+
}
|
| 211 |
+
],
|
| 212 |
+
"properties": {
|
| 213 |
+
"Node name for S&R": "INPAINT_VAEEncodeInpaintConditioning"
|
| 214 |
+
},
|
| 215 |
+
"color": "#323",
|
| 216 |
+
"bgcolor": "#535"
|
| 217 |
+
},
|
| 218 |
+
{
|
| 219 |
+
"id": 55,
|
| 220 |
+
"type": "PreviewImage",
|
| 221 |
+
"pos": [
|
| 222 |
+
490,
|
| 223 |
+
800
|
| 224 |
+
],
|
| 225 |
+
"size": [
|
| 226 |
+
210,
|
| 227 |
+
246
|
| 228 |
+
],
|
| 229 |
+
"flags": {},
|
| 230 |
+
"order": 20,
|
| 231 |
+
"mode": 0,
|
| 232 |
+
"inputs": [
|
| 233 |
+
{
|
| 234 |
+
"name": "images",
|
| 235 |
+
"type": "IMAGE",
|
| 236 |
+
"link": 148
|
| 237 |
+
}
|
| 238 |
+
],
|
| 239 |
+
"properties": {
|
| 240 |
+
"Node name for S&R": "PreviewImage"
|
| 241 |
+
}
|
| 242 |
+
},
|
| 243 |
+
{
|
| 244 |
+
"id": 51,
|
| 245 |
+
"type": "Reroute",
|
| 246 |
+
"pos": [
|
| 247 |
+
505,
|
| 248 |
+
1075
|
| 249 |
+
],
|
| 250 |
+
"size": [
|
| 251 |
+
75,
|
| 252 |
+
26
|
| 253 |
+
],
|
| 254 |
+
"flags": {},
|
| 255 |
+
"order": 22,
|
| 256 |
+
"mode": 0,
|
| 257 |
+
"inputs": [
|
| 258 |
+
{
|
| 259 |
+
"name": "",
|
| 260 |
+
"type": "*",
|
| 261 |
+
"link": 167,
|
| 262 |
+
"slot_index": 0
|
| 263 |
+
}
|
| 264 |
+
],
|
| 265 |
+
"outputs": [
|
| 266 |
+
{
|
| 267 |
+
"name": "",
|
| 268 |
+
"type": "IMAGE",
|
| 269 |
+
"links": [
|
| 270 |
+
142
|
| 271 |
+
],
|
| 272 |
+
"slot_index": 0
|
| 273 |
+
}
|
| 274 |
+
],
|
| 275 |
+
"properties": {
|
| 276 |
+
"showOutputText": false,
|
| 277 |
+
"horizontal": false
|
| 278 |
+
}
|
| 279 |
+
},
|
| 280 |
+
{
|
| 281 |
+
"id": 50,
|
| 282 |
+
"type": "Reroute",
|
| 283 |
+
"pos": [
|
| 284 |
+
109,
|
| 285 |
+
1080
|
| 286 |
+
],
|
| 287 |
+
"size": [
|
| 288 |
+
75,
|
| 289 |
+
26
|
| 290 |
+
],
|
| 291 |
+
"flags": {},
|
| 292 |
+
"order": 23,
|
| 293 |
+
"mode": 0,
|
| 294 |
+
"inputs": [
|
| 295 |
+
{
|
| 296 |
+
"name": "",
|
| 297 |
+
"type": "*",
|
| 298 |
+
"link": 142
|
| 299 |
+
}
|
| 300 |
+
],
|
| 301 |
+
"outputs": [
|
| 302 |
+
{
|
| 303 |
+
"name": "",
|
| 304 |
+
"type": "IMAGE",
|
| 305 |
+
"links": [
|
| 306 |
+
140
|
| 307 |
+
],
|
| 308 |
+
"slot_index": 0
|
| 309 |
+
}
|
| 310 |
+
],
|
| 311 |
+
"properties": {
|
| 312 |
+
"showOutputText": false,
|
| 313 |
+
"horizontal": false
|
| 314 |
+
}
|
| 315 |
+
},
|
| 316 |
+
{
|
| 317 |
+
"id": 36,
|
| 318 |
+
"type": "INPAINT_ApplyFooocusInpaint",
|
| 319 |
+
"pos": [
|
| 320 |
+
581,
|
| 321 |
+
1155
|
| 322 |
+
],
|
| 323 |
+
"size": [
|
| 324 |
+
191.45638474692714,
|
| 325 |
+
66
|
| 326 |
+
],
|
| 327 |
+
"flags": {},
|
| 328 |
+
"order": 25,
|
| 329 |
+
"mode": 0,
|
| 330 |
+
"inputs": [
|
| 331 |
+
{
|
| 332 |
+
"name": "model",
|
| 333 |
+
"type": "MODEL",
|
| 334 |
+
"link": 60
|
| 335 |
+
},
|
| 336 |
+
{
|
| 337 |
+
"name": "patch",
|
| 338 |
+
"type": "INPAINT_PATCH",
|
| 339 |
+
"link": 62
|
| 340 |
+
},
|
| 341 |
+
{
|
| 342 |
+
"name": "latent",
|
| 343 |
+
"type": "LATENT",
|
| 344 |
+
"link": 127
|
| 345 |
+
}
|
| 346 |
+
],
|
| 347 |
+
"outputs": [
|
| 348 |
+
{
|
| 349 |
+
"name": "MODEL",
|
| 350 |
+
"type": "MODEL",
|
| 351 |
+
"links": [
|
| 352 |
+
120
|
| 353 |
+
],
|
| 354 |
+
"shape": 3,
|
| 355 |
+
"slot_index": 0
|
| 356 |
+
}
|
| 357 |
+
],
|
| 358 |
+
"properties": {
|
| 359 |
+
"Node name for S&R": "INPAINT_ApplyFooocusInpaint"
|
| 360 |
+
},
|
| 361 |
+
"color": "#323",
|
| 362 |
+
"bgcolor": "#535"
|
| 363 |
+
},
|
| 364 |
+
{
|
| 365 |
+
"id": 47,
|
| 366 |
+
"type": "Reroute",
|
| 367 |
+
"pos": [
|
| 368 |
+
-85.70390089638016,
|
| 369 |
+
451.81675574263164
|
| 370 |
+
],
|
| 371 |
+
"size": [
|
| 372 |
+
75,
|
| 373 |
+
26
|
| 374 |
+
],
|
| 375 |
+
"flags": {},
|
| 376 |
+
"order": 14,
|
| 377 |
+
"mode": 0,
|
| 378 |
+
"inputs": [
|
| 379 |
+
{
|
| 380 |
+
"name": "",
|
| 381 |
+
"type": "*",
|
| 382 |
+
"link": 170
|
| 383 |
+
}
|
| 384 |
+
],
|
| 385 |
+
"outputs": [
|
| 386 |
+
{
|
| 387 |
+
"name": "",
|
| 388 |
+
"type": "MASK",
|
| 389 |
+
"links": [
|
| 390 |
+
137,
|
| 391 |
+
138,
|
| 392 |
+
145,
|
| 393 |
+
151,
|
| 394 |
+
159
|
| 395 |
+
],
|
| 396 |
+
"slot_index": 0
|
| 397 |
+
}
|
| 398 |
+
],
|
| 399 |
+
"properties": {
|
| 400 |
+
"showOutputText": false,
|
| 401 |
+
"horizontal": false
|
| 402 |
+
}
|
| 403 |
+
},
|
| 404 |
+
{
|
| 405 |
+
"id": 46,
|
| 406 |
+
"type": "Reroute",
|
| 407 |
+
"pos": [
|
| 408 |
+
-85.62200405782187,
|
| 409 |
+
401.364032722935
|
| 410 |
+
],
|
| 411 |
+
"size": [
|
| 412 |
+
75,
|
| 413 |
+
26
|
| 414 |
+
],
|
| 415 |
+
"flags": {},
|
| 416 |
+
"order": 13,
|
| 417 |
+
"mode": 0,
|
| 418 |
+
"inputs": [
|
| 419 |
+
{
|
| 420 |
+
"name": "",
|
| 421 |
+
"type": "*",
|
| 422 |
+
"link": 168
|
| 423 |
+
}
|
| 424 |
+
],
|
| 425 |
+
"outputs": [
|
| 426 |
+
{
|
| 427 |
+
"name": "",
|
| 428 |
+
"type": "IMAGE",
|
| 429 |
+
"links": [
|
| 430 |
+
136,
|
| 431 |
+
144,
|
| 432 |
+
150,
|
| 433 |
+
154,
|
| 434 |
+
160
|
| 435 |
+
],
|
| 436 |
+
"slot_index": 0
|
| 437 |
+
}
|
| 438 |
+
],
|
| 439 |
+
"properties": {
|
| 440 |
+
"showOutputText": false,
|
| 441 |
+
"horizontal": false
|
| 442 |
+
}
|
| 443 |
+
},
|
| 444 |
+
{
|
| 445 |
+
"id": 62,
|
| 446 |
+
"type": "Note",
|
| 447 |
+
"pos": [
|
| 448 |
+
281,
|
| 449 |
+
78
|
| 450 |
+
],
|
| 451 |
+
"size": [
|
| 452 |
+
288.36252399942055,
|
| 453 |
+
58
|
| 454 |
+
],
|
| 455 |
+
"flags": {},
|
| 456 |
+
"order": 2,
|
| 457 |
+
"mode": 0,
|
| 458 |
+
"properties": {
|
| 459 |
+
"text": ""
|
| 460 |
+
},
|
| 461 |
+
"widgets_values": [
|
| 462 |
+
"pass-through: for refinement with denoise < 1"
|
| 463 |
+
],
|
| 464 |
+
"color": "#432",
|
| 465 |
+
"bgcolor": "#653"
|
| 466 |
+
},
|
| 467 |
+
{
|
| 468 |
+
"id": 65,
|
| 469 |
+
"type": "ImageCompositeMasked",
|
| 470 |
+
"pos": [
|
| 471 |
+
900.6461852182938,
|
| 472 |
+
863.8659206207312
|
| 473 |
+
],
|
| 474 |
+
"size": {
|
| 475 |
+
"0": 315,
|
| 476 |
+
"1": 146
|
| 477 |
+
},
|
| 478 |
+
"flags": {},
|
| 479 |
+
"order": 28,
|
| 480 |
+
"mode": 0,
|
| 481 |
+
"inputs": [
|
| 482 |
+
{
|
| 483 |
+
"name": "destination",
|
| 484 |
+
"type": "IMAGE",
|
| 485 |
+
"link": 160
|
| 486 |
+
},
|
| 487 |
+
{
|
| 488 |
+
"name": "source",
|
| 489 |
+
"type": "IMAGE",
|
| 490 |
+
"link": 156
|
| 491 |
+
},
|
| 492 |
+
{
|
| 493 |
+
"name": "mask",
|
| 494 |
+
"type": "MASK",
|
| 495 |
+
"link": 159
|
| 496 |
+
}
|
| 497 |
+
],
|
| 498 |
+
"outputs": [
|
| 499 |
+
{
|
| 500 |
+
"name": "IMAGE",
|
| 501 |
+
"type": "IMAGE",
|
| 502 |
+
"links": [
|
| 503 |
+
155
|
| 504 |
+
],
|
| 505 |
+
"shape": 3,
|
| 506 |
+
"slot_index": 0
|
| 507 |
+
}
|
| 508 |
+
],
|
| 509 |
+
"properties": {
|
| 510 |
+
"Node name for S&R": "ImageCompositeMasked"
|
| 511 |
+
},
|
| 512 |
+
"widgets_values": [
|
| 513 |
+
0,
|
| 514 |
+
0,
|
| 515 |
+
false
|
| 516 |
+
]
|
| 517 |
+
},
|
| 518 |
+
{
|
| 519 |
+
"id": 14,
|
| 520 |
+
"type": "VAEDecode",
|
| 521 |
+
"pos": [
|
| 522 |
+
900.6461852182938,
|
| 523 |
+
1063.8659206207312
|
| 524 |
+
],
|
| 525 |
+
"size": [
|
| 526 |
+
280.3295987363324,
|
| 527 |
+
47.345116898486594
|
| 528 |
+
],
|
| 529 |
+
"flags": {},
|
| 530 |
+
"order": 27,
|
| 531 |
+
"mode": 0,
|
| 532 |
+
"inputs": [
|
| 533 |
+
{
|
| 534 |
+
"name": "samples",
|
| 535 |
+
"type": "LATENT",
|
| 536 |
+
"link": 97
|
| 537 |
+
},
|
| 538 |
+
{
|
| 539 |
+
"name": "vae",
|
| 540 |
+
"type": "VAE",
|
| 541 |
+
"link": 43
|
| 542 |
+
}
|
| 543 |
+
],
|
| 544 |
+
"outputs": [
|
| 545 |
+
{
|
| 546 |
+
"name": "IMAGE",
|
| 547 |
+
"type": "IMAGE",
|
| 548 |
+
"links": [
|
| 549 |
+
156
|
| 550 |
+
],
|
| 551 |
+
"shape": 3,
|
| 552 |
+
"slot_index": 0
|
| 553 |
+
}
|
| 554 |
+
],
|
| 555 |
+
"properties": {
|
| 556 |
+
"Node name for S&R": "VAEDecode"
|
| 557 |
+
}
|
| 558 |
+
},
|
| 559 |
+
{
|
| 560 |
+
"id": 59,
|
| 561 |
+
"type": "SaveImage",
|
| 562 |
+
"pos": [
|
| 563 |
+
754,
|
| 564 |
+
76
|
| 565 |
+
],
|
| 566 |
+
"size": [
|
| 567 |
+
490.8734709718178,
|
| 568 |
+
686.078138463666
|
| 569 |
+
],
|
| 570 |
+
"flags": {},
|
| 571 |
+
"order": 29,
|
| 572 |
+
"mode": 0,
|
| 573 |
+
"inputs": [
|
| 574 |
+
{
|
| 575 |
+
"name": "images",
|
| 576 |
+
"type": "IMAGE",
|
| 577 |
+
"link": 155
|
| 578 |
+
}
|
| 579 |
+
],
|
| 580 |
+
"properties": {},
|
| 581 |
+
"widgets_values": [
|
| 582 |
+
"ComfyUI"
|
| 583 |
+
]
|
| 584 |
+
},
|
| 585 |
+
{
|
| 586 |
+
"id": 40,
|
| 587 |
+
"type": "KSampler",
|
| 588 |
+
"pos": [
|
| 589 |
+
912,
|
| 590 |
+
1169
|
| 591 |
+
],
|
| 592 |
+
"size": {
|
| 593 |
+
"0": 315,
|
| 594 |
+
"1": 262
|
| 595 |
+
},
|
| 596 |
+
"flags": {},
|
| 597 |
+
"order": 26,
|
| 598 |
+
"mode": 0,
|
| 599 |
+
"inputs": [
|
| 600 |
+
{
|
| 601 |
+
"name": "model",
|
| 602 |
+
"type": "MODEL",
|
| 603 |
+
"link": 120
|
| 604 |
+
},
|
| 605 |
+
{
|
| 606 |
+
"name": "positive",
|
| 607 |
+
"type": "CONDITIONING",
|
| 608 |
+
"link": 124
|
| 609 |
+
},
|
| 610 |
+
{
|
| 611 |
+
"name": "negative",
|
| 612 |
+
"type": "CONDITIONING",
|
| 613 |
+
"link": 125
|
| 614 |
+
},
|
| 615 |
+
{
|
| 616 |
+
"name": "latent_image",
|
| 617 |
+
"type": "LATENT",
|
| 618 |
+
"link": 126
|
| 619 |
+
}
|
| 620 |
+
],
|
| 621 |
+
"outputs": [
|
| 622 |
+
{
|
| 623 |
+
"name": "LATENT",
|
| 624 |
+
"type": "LATENT",
|
| 625 |
+
"links": [
|
| 626 |
+
97
|
| 627 |
+
],
|
| 628 |
+
"shape": 3,
|
| 629 |
+
"slot_index": 0
|
| 630 |
+
}
|
| 631 |
+
],
|
| 632 |
+
"properties": {
|
| 633 |
+
"Node name for S&R": "KSampler"
|
| 634 |
+
},
|
| 635 |
+
"widgets_values": [
|
| 636 |
+
926268437509169,
|
| 637 |
+
"randomize",
|
| 638 |
+
24,
|
| 639 |
+
5,
|
| 640 |
+
"dpmpp_2m_sde_gpu",
|
| 641 |
+
"karras",
|
| 642 |
+
1
|
| 643 |
+
]
|
| 644 |
+
},
|
| 645 |
+
{
|
| 646 |
+
"id": 43,
|
| 647 |
+
"type": "INPAINT_MaskedBlur",
|
| 648 |
+
"pos": [
|
| 649 |
+
120,
|
| 650 |
+
484
|
| 651 |
+
],
|
| 652 |
+
"size": {
|
| 653 |
+
"0": 315,
|
| 654 |
+
"1": 102
|
| 655 |
+
},
|
| 656 |
+
"flags": {},
|
| 657 |
+
"order": 16,
|
| 658 |
+
"mode": 0,
|
| 659 |
+
"inputs": [
|
| 660 |
+
{
|
| 661 |
+
"name": "image",
|
| 662 |
+
"type": "IMAGE",
|
| 663 |
+
"link": 136
|
| 664 |
+
},
|
| 665 |
+
{
|
| 666 |
+
"name": "mask",
|
| 667 |
+
"type": "MASK",
|
| 668 |
+
"link": 137
|
| 669 |
+
}
|
| 670 |
+
],
|
| 671 |
+
"outputs": [
|
| 672 |
+
{
|
| 673 |
+
"name": "IMAGE",
|
| 674 |
+
"type": "IMAGE",
|
| 675 |
+
"links": [
|
| 676 |
+
147
|
| 677 |
+
],
|
| 678 |
+
"shape": 3,
|
| 679 |
+
"slot_index": 0
|
| 680 |
+
}
|
| 681 |
+
],
|
| 682 |
+
"properties": {
|
| 683 |
+
"Node name for S&R": "INPAINT_MaskedBlur"
|
| 684 |
+
},
|
| 685 |
+
"widgets_values": [
|
| 686 |
+
255,
|
| 687 |
+
11
|
| 688 |
+
]
|
| 689 |
+
},
|
| 690 |
+
{
|
| 691 |
+
"id": 52,
|
| 692 |
+
"type": "INPAINT_LoadInpaintModel",
|
| 693 |
+
"pos": [
|
| 694 |
+
120,
|
| 695 |
+
769
|
| 696 |
+
],
|
| 697 |
+
"size": {
|
| 698 |
+
"0": 315,
|
| 699 |
+
"1": 58
|
| 700 |
+
},
|
| 701 |
+
"flags": {},
|
| 702 |
+
"order": 3,
|
| 703 |
+
"mode": 0,
|
| 704 |
+
"outputs": [
|
| 705 |
+
{
|
| 706 |
+
"name": "INPAINT_MODEL",
|
| 707 |
+
"type": "INPAINT_MODEL",
|
| 708 |
+
"links": [
|
| 709 |
+
143
|
| 710 |
+
],
|
| 711 |
+
"shape": 3,
|
| 712 |
+
"slot_index": 0
|
| 713 |
+
}
|
| 714 |
+
],
|
| 715 |
+
"properties": {
|
| 716 |
+
"Node name for S&R": "INPAINT_LoadInpaintModel"
|
| 717 |
+
},
|
| 718 |
+
"widgets_values": [
|
| 719 |
+
"Places_512_FullData_G.pth"
|
| 720 |
+
]
|
| 721 |
+
},
|
| 722 |
+
{
|
| 723 |
+
"id": 53,
|
| 724 |
+
"type": "PreviewImage",
|
| 725 |
+
"pos": [
|
| 726 |
+
487,
|
| 727 |
+
201
|
| 728 |
+
],
|
| 729 |
+
"size": [
|
| 730 |
+
210,
|
| 731 |
+
246
|
| 732 |
+
],
|
| 733 |
+
"flags": {},
|
| 734 |
+
"order": 21,
|
| 735 |
+
"mode": 0,
|
| 736 |
+
"inputs": [
|
| 737 |
+
{
|
| 738 |
+
"name": "images",
|
| 739 |
+
"type": "IMAGE",
|
| 740 |
+
"link": 146
|
| 741 |
+
}
|
| 742 |
+
],
|
| 743 |
+
"properties": {
|
| 744 |
+
"Node name for S&R": "PreviewImage"
|
| 745 |
+
}
|
| 746 |
+
},
|
| 747 |
+
{
|
| 748 |
+
"id": 54,
|
| 749 |
+
"type": "PreviewImage",
|
| 750 |
+
"pos": [
|
| 751 |
+
489,
|
| 752 |
+
491
|
| 753 |
+
],
|
| 754 |
+
"size": [
|
| 755 |
+
210,
|
| 756 |
+
246
|
| 757 |
+
],
|
| 758 |
+
"flags": {},
|
| 759 |
+
"order": 19,
|
| 760 |
+
"mode": 0,
|
| 761 |
+
"inputs": [
|
| 762 |
+
{
|
| 763 |
+
"name": "images",
|
| 764 |
+
"type": "IMAGE",
|
| 765 |
+
"link": 147
|
| 766 |
+
}
|
| 767 |
+
],
|
| 768 |
+
"properties": {
|
| 769 |
+
"Node name for S&R": "PreviewImage"
|
| 770 |
+
}
|
| 771 |
+
},
|
| 772 |
+
{
|
| 773 |
+
"id": 45,
|
| 774 |
+
"type": "ImagePadForOutpaint",
|
| 775 |
+
"pos": [
|
| 776 |
+
-482,
|
| 777 |
+
887
|
| 778 |
+
],
|
| 779 |
+
"size": {
|
| 780 |
+
"0": 315,
|
| 781 |
+
"1": 174
|
| 782 |
+
},
|
| 783 |
+
"flags": {},
|
| 784 |
+
"order": 12,
|
| 785 |
+
"mode": 0,
|
| 786 |
+
"inputs": [
|
| 787 |
+
{
|
| 788 |
+
"name": "image",
|
| 789 |
+
"type": "IMAGE",
|
| 790 |
+
"link": 133
|
| 791 |
+
}
|
| 792 |
+
],
|
| 793 |
+
"outputs": [
|
| 794 |
+
{
|
| 795 |
+
"name": "IMAGE",
|
| 796 |
+
"type": "IMAGE",
|
| 797 |
+
"links": [],
|
| 798 |
+
"shape": 3,
|
| 799 |
+
"slot_index": 0
|
| 800 |
+
},
|
| 801 |
+
{
|
| 802 |
+
"name": "MASK",
|
| 803 |
+
"type": "MASK",
|
| 804 |
+
"links": [],
|
| 805 |
+
"shape": 3,
|
| 806 |
+
"slot_index": 1
|
| 807 |
+
}
|
| 808 |
+
],
|
| 809 |
+
"properties": {
|
| 810 |
+
"Node name for S&R": "ImagePadForOutpaint"
|
| 811 |
+
},
|
| 812 |
+
"widgets_values": [
|
| 813 |
+
128,
|
| 814 |
+
0,
|
| 815 |
+
128,
|
| 816 |
+
0,
|
| 817 |
+
40
|
| 818 |
+
]
|
| 819 |
+
},
|
| 820 |
+
{
|
| 821 |
+
"id": 66,
|
| 822 |
+
"type": "Note",
|
| 823 |
+
"pos": [
|
| 824 |
+
-466,
|
| 825 |
+
426
|
| 826 |
+
],
|
| 827 |
+
"size": [
|
| 828 |
+
309.2648882293299,
|
| 829 |
+
64.0997455459651
|
| 830 |
+
],
|
| 831 |
+
"flags": {},
|
| 832 |
+
"order": 4,
|
| 833 |
+
"mode": 0,
|
| 834 |
+
"properties": {
|
| 835 |
+
"text": ""
|
| 836 |
+
},
|
| 837 |
+
"widgets_values": [
|
| 838 |
+
"Paint mask into image,\nOR load mask from file,\nOR generate outpainting mask"
|
| 839 |
+
],
|
| 840 |
+
"color": "#2a363b",
|
| 841 |
+
"bgcolor": "#3f5159"
|
| 842 |
+
},
|
| 843 |
+
{
|
| 844 |
+
"id": 49,
|
| 845 |
+
"type": "INPAINT_InpaintWithModel",
|
| 846 |
+
"pos": [
|
| 847 |
+
121,
|
| 848 |
+
871
|
| 849 |
+
],
|
| 850 |
+
"size": [
|
| 851 |
+
311.12821705664123,
|
| 852 |
+
95.89705449489816
|
| 853 |
+
],
|
| 854 |
+
"flags": {},
|
| 855 |
+
"order": 17,
|
| 856 |
+
"mode": 0,
|
| 857 |
+
"inputs": [
|
| 858 |
+
{
|
| 859 |
+
"name": "inpaint_model",
|
| 860 |
+
"type": "INPAINT_MODEL",
|
| 861 |
+
"link": 143
|
| 862 |
+
},
|
| 863 |
+
{
|
| 864 |
+
"name": "image",
|
| 865 |
+
"type": "IMAGE",
|
| 866 |
+
"link": 144
|
| 867 |
+
},
|
| 868 |
+
{
|
| 869 |
+
"name": "mask",
|
| 870 |
+
"type": "MASK",
|
| 871 |
+
"link": 145
|
| 872 |
+
}
|
| 873 |
+
],
|
| 874 |
+
"outputs": [
|
| 875 |
+
{
|
| 876 |
+
"name": "IMAGE",
|
| 877 |
+
"type": "IMAGE",
|
| 878 |
+
"links": [
|
| 879 |
+
148
|
| 880 |
+
],
|
| 881 |
+
"shape": 3,
|
| 882 |
+
"slot_index": 0
|
| 883 |
+
}
|
| 884 |
+
],
|
| 885 |
+
"properties": {
|
| 886 |
+
"Node name for S&R": "INPAINT_InpaintWithModel"
|
| 887 |
+
}
|
| 888 |
+
},
|
| 889 |
+
{
|
| 890 |
+
"id": 61,
|
| 891 |
+
"type": "Reroute",
|
| 892 |
+
"pos": [
|
| 893 |
+
128,
|
| 894 |
+
88
|
| 895 |
+
],
|
| 896 |
+
"size": [
|
| 897 |
+
75,
|
| 898 |
+
26
|
| 899 |
+
],
|
| 900 |
+
"flags": {},
|
| 901 |
+
"order": 15,
|
| 902 |
+
"mode": 0,
|
| 903 |
+
"inputs": [
|
| 904 |
+
{
|
| 905 |
+
"name": "",
|
| 906 |
+
"type": "*",
|
| 907 |
+
"link": 154
|
| 908 |
+
}
|
| 909 |
+
],
|
| 910 |
+
"outputs": [
|
| 911 |
+
{
|
| 912 |
+
"name": "",
|
| 913 |
+
"type": "IMAGE",
|
| 914 |
+
"links": [],
|
| 915 |
+
"slot_index": 0
|
| 916 |
+
}
|
| 917 |
+
],
|
| 918 |
+
"properties": {
|
| 919 |
+
"showOutputText": false,
|
| 920 |
+
"horizontal": false
|
| 921 |
+
}
|
| 922 |
+
},
|
| 923 |
+
{
|
| 924 |
+
"id": 56,
|
| 925 |
+
"type": "Note",
|
| 926 |
+
"pos": [
|
| 927 |
+
120,
|
| 928 |
+
350
|
| 929 |
+
],
|
| 930 |
+
"size": [
|
| 931 |
+
301.34525467611184,
|
| 932 |
+
67.77167938795697
|
| 933 |
+
],
|
| 934 |
+
"flags": {},
|
| 935 |
+
"order": 5,
|
| 936 |
+
"mode": 0,
|
| 937 |
+
"properties": {
|
| 938 |
+
"text": ""
|
| 939 |
+
},
|
| 940 |
+
"widgets_values": [
|
| 941 |
+
"neutral: to add objects / make drastic changes\ntelea/navier-stokes: good for outpainting"
|
| 942 |
+
],
|
| 943 |
+
"color": "#432",
|
| 944 |
+
"bgcolor": "#653"
|
| 945 |
+
},
|
| 946 |
+
{
|
| 947 |
+
"id": 57,
|
| 948 |
+
"type": "Note",
|
| 949 |
+
"pos": [
|
| 950 |
+
127,
|
| 951 |
+
627
|
| 952 |
+
],
|
| 953 |
+
"size": [
|
| 954 |
+
301.4128003846947,
|
| 955 |
+
58
|
| 956 |
+
],
|
| 957 |
+
"flags": {},
|
| 958 |
+
"order": 6,
|
| 959 |
+
"mode": 0,
|
| 960 |
+
"properties": {
|
| 961 |
+
"text": ""
|
| 962 |
+
},
|
| 963 |
+
"widgets_values": [
|
| 964 |
+
"keeps average colors from masked area"
|
| 965 |
+
],
|
| 966 |
+
"color": "#432",
|
| 967 |
+
"bgcolor": "#653"
|
| 968 |
+
},
|
| 969 |
+
{
|
| 970 |
+
"id": 58,
|
| 971 |
+
"type": "Note",
|
| 972 |
+
"pos": [
|
| 973 |
+
121,
|
| 974 |
+
997
|
| 975 |
+
],
|
| 976 |
+
"size": [
|
| 977 |
+
311.85528871597717,
|
| 978 |
+
60.94014246080269
|
| 979 |
+
],
|
| 980 |
+
"flags": {},
|
| 981 |
+
"order": 7,
|
| 982 |
+
"mode": 0,
|
| 983 |
+
"properties": {
|
| 984 |
+
"text": ""
|
| 985 |
+
},
|
| 986 |
+
"widgets_values": [
|
| 987 |
+
"fill with fast inpaint model\ngood for removing objects"
|
| 988 |
+
],
|
| 989 |
+
"color": "#432",
|
| 990 |
+
"bgcolor": "#653"
|
| 991 |
+
},
|
| 992 |
+
{
|
| 993 |
+
"id": 48,
|
| 994 |
+
"type": "INPAINT_MaskedFill",
|
| 995 |
+
"pos": [
|
| 996 |
+
110,
|
| 997 |
+
210
|
| 998 |
+
],
|
| 999 |
+
"size": {
|
| 1000 |
+
"0": 315,
|
| 1001 |
+
"1": 102
|
| 1002 |
+
},
|
| 1003 |
+
"flags": {},
|
| 1004 |
+
"order": 18,
|
| 1005 |
+
"mode": 0,
|
| 1006 |
+
"inputs": [
|
| 1007 |
+
{
|
| 1008 |
+
"name": "image",
|
| 1009 |
+
"type": "IMAGE",
|
| 1010 |
+
"link": 150
|
| 1011 |
+
},
|
| 1012 |
+
{
|
| 1013 |
+
"name": "mask",
|
| 1014 |
+
"type": "MASK",
|
| 1015 |
+
"link": 151
|
| 1016 |
+
}
|
| 1017 |
+
],
|
| 1018 |
+
"outputs": [
|
| 1019 |
+
{
|
| 1020 |
+
"name": "IMAGE",
|
| 1021 |
+
"type": "IMAGE",
|
| 1022 |
+
"links": [
|
| 1023 |
+
146,
|
| 1024 |
+
167
|
| 1025 |
+
],
|
| 1026 |
+
"shape": 3,
|
| 1027 |
+
"slot_index": 0
|
| 1028 |
+
}
|
| 1029 |
+
],
|
| 1030 |
+
"properties": {
|
| 1031 |
+
"Node name for S&R": "INPAINT_MaskedFill"
|
| 1032 |
+
},
|
| 1033 |
+
"widgets_values": [
|
| 1034 |
+
"neutral",
|
| 1035 |
+
11
|
| 1036 |
+
]
|
| 1037 |
+
},
|
| 1038 |
+
{
|
| 1039 |
+
"id": 34,
|
| 1040 |
+
"type": "LoadImageMask",
|
| 1041 |
+
"pos": [
|
| 1042 |
+
-476,
|
| 1043 |
+
534
|
| 1044 |
+
],
|
| 1045 |
+
"size": {
|
| 1046 |
+
"0": 315,
|
| 1047 |
+
"1": 318
|
| 1048 |
+
},
|
| 1049 |
+
"flags": {},
|
| 1050 |
+
"order": 8,
|
| 1051 |
+
"mode": 0,
|
| 1052 |
+
"outputs": [
|
| 1053 |
+
{
|
| 1054 |
+
"name": "MASK",
|
| 1055 |
+
"type": "MASK",
|
| 1056 |
+
"links": [],
|
| 1057 |
+
"shape": 3,
|
| 1058 |
+
"slot_index": 0
|
| 1059 |
+
}
|
| 1060 |
+
],
|
| 1061 |
+
"properties": {
|
| 1062 |
+
"Node name for S&R": "LoadImageMask"
|
| 1063 |
+
},
|
| 1064 |
+
"widgets_values": [
|
| 1065 |
+
"mask.png",
|
| 1066 |
+
"red",
|
| 1067 |
+
"image"
|
| 1068 |
+
]
|
| 1069 |
+
},
|
| 1070 |
+
{
|
| 1071 |
+
"id": 33,
|
| 1072 |
+
"type": "LoadImage",
|
| 1073 |
+
"pos": [
|
| 1074 |
+
-469,
|
| 1075 |
+
71
|
| 1076 |
+
],
|
| 1077 |
+
"size": {
|
| 1078 |
+
"0": 315,
|
| 1079 |
+
"1": 314
|
| 1080 |
+
},
|
| 1081 |
+
"flags": {},
|
| 1082 |
+
"order": 9,
|
| 1083 |
+
"mode": 0,
|
| 1084 |
+
"outputs": [
|
| 1085 |
+
{
|
| 1086 |
+
"name": "IMAGE",
|
| 1087 |
+
"type": "IMAGE",
|
| 1088 |
+
"links": [
|
| 1089 |
+
133,
|
| 1090 |
+
168
|
| 1091 |
+
],
|
| 1092 |
+
"shape": 3,
|
| 1093 |
+
"slot_index": 0
|
| 1094 |
+
},
|
| 1095 |
+
{
|
| 1096 |
+
"name": "MASK",
|
| 1097 |
+
"type": "MASK",
|
| 1098 |
+
"links": [
|
| 1099 |
+
170
|
| 1100 |
+
],
|
| 1101 |
+
"shape": 3,
|
| 1102 |
+
"slot_index": 1
|
| 1103 |
+
}
|
| 1104 |
+
],
|
| 1105 |
+
"properties": {
|
| 1106 |
+
"Node name for S&R": "LoadImage"
|
| 1107 |
+
},
|
| 1108 |
+
"widgets_values": [
|
| 1109 |
+
"base.png",
|
| 1110 |
+
"image"
|
| 1111 |
+
]
|
| 1112 |
+
},
|
| 1113 |
+
{
|
| 1114 |
+
"id": 9,
|
| 1115 |
+
"type": "CLIPTextEncode",
|
| 1116 |
+
"pos": [
|
| 1117 |
+
-476,
|
| 1118 |
+
1249
|
| 1119 |
+
],
|
| 1120 |
+
"size": [
|
| 1121 |
+
421.96778938051466,
|
| 1122 |
+
88.26173063346437
|
| 1123 |
+
],
|
| 1124 |
+
"flags": {},
|
| 1125 |
+
"order": 11,
|
| 1126 |
+
"mode": 0,
|
| 1127 |
+
"inputs": [
|
| 1128 |
+
{
|
| 1129 |
+
"name": "clip",
|
| 1130 |
+
"type": "CLIP",
|
| 1131 |
+
"link": 88
|
| 1132 |
+
}
|
| 1133 |
+
],
|
| 1134 |
+
"outputs": [
|
| 1135 |
+
{
|
| 1136 |
+
"name": "CONDITIONING",
|
| 1137 |
+
"type": "CONDITIONING",
|
| 1138 |
+
"links": [
|
| 1139 |
+
122
|
| 1140 |
+
],
|
| 1141 |
+
"shape": 3,
|
| 1142 |
+
"slot_index": 0
|
| 1143 |
+
}
|
| 1144 |
+
],
|
| 1145 |
+
"properties": {
|
| 1146 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 1147 |
+
},
|
| 1148 |
+
"widgets_values": [
|
| 1149 |
+
"positive prompt"
|
| 1150 |
+
],
|
| 1151 |
+
"color": "#232",
|
| 1152 |
+
"bgcolor": "#353"
|
| 1153 |
+
}
|
| 1154 |
+
],
|
| 1155 |
+
"links": [
|
| 1156 |
+
[
|
| 1157 |
+
35,
|
| 1158 |
+
19,
|
| 1159 |
+
1,
|
| 1160 |
+
10,
|
| 1161 |
+
0,
|
| 1162 |
+
"CLIP"
|
| 1163 |
+
],
|
| 1164 |
+
[
|
| 1165 |
+
43,
|
| 1166 |
+
19,
|
| 1167 |
+
2,
|
| 1168 |
+
14,
|
| 1169 |
+
1,
|
| 1170 |
+
"VAE"
|
| 1171 |
+
],
|
| 1172 |
+
[
|
| 1173 |
+
60,
|
| 1174 |
+
19,
|
| 1175 |
+
0,
|
| 1176 |
+
36,
|
| 1177 |
+
0,
|
| 1178 |
+
"MODEL"
|
| 1179 |
+
],
|
| 1180 |
+
[
|
| 1181 |
+
62,
|
| 1182 |
+
35,
|
| 1183 |
+
0,
|
| 1184 |
+
36,
|
| 1185 |
+
1,
|
| 1186 |
+
"INPAINT_PATCH"
|
| 1187 |
+
],
|
| 1188 |
+
[
|
| 1189 |
+
88,
|
| 1190 |
+
19,
|
| 1191 |
+
1,
|
| 1192 |
+
9,
|
| 1193 |
+
0,
|
| 1194 |
+
"CLIP"
|
| 1195 |
+
],
|
| 1196 |
+
[
|
| 1197 |
+
97,
|
| 1198 |
+
40,
|
| 1199 |
+
0,
|
| 1200 |
+
14,
|
| 1201 |
+
0,
|
| 1202 |
+
"LATENT"
|
| 1203 |
+
],
|
| 1204 |
+
[
|
| 1205 |
+
120,
|
| 1206 |
+
36,
|
| 1207 |
+
0,
|
| 1208 |
+
40,
|
| 1209 |
+
0,
|
| 1210 |
+
"MODEL"
|
| 1211 |
+
],
|
| 1212 |
+
[
|
| 1213 |
+
122,
|
| 1214 |
+
9,
|
| 1215 |
+
0,
|
| 1216 |
+
44,
|
| 1217 |
+
0,
|
| 1218 |
+
"CONDITIONING"
|
| 1219 |
+
],
|
| 1220 |
+
[
|
| 1221 |
+
123,
|
| 1222 |
+
10,
|
| 1223 |
+
0,
|
| 1224 |
+
44,
|
| 1225 |
+
1,
|
| 1226 |
+
"CONDITIONING"
|
| 1227 |
+
],
|
| 1228 |
+
[
|
| 1229 |
+
124,
|
| 1230 |
+
44,
|
| 1231 |
+
0,
|
| 1232 |
+
40,
|
| 1233 |
+
1,
|
| 1234 |
+
"CONDITIONING"
|
| 1235 |
+
],
|
| 1236 |
+
[
|
| 1237 |
+
125,
|
| 1238 |
+
44,
|
| 1239 |
+
1,
|
| 1240 |
+
40,
|
| 1241 |
+
2,
|
| 1242 |
+
"CONDITIONING"
|
| 1243 |
+
],
|
| 1244 |
+
[
|
| 1245 |
+
126,
|
| 1246 |
+
44,
|
| 1247 |
+
3,
|
| 1248 |
+
40,
|
| 1249 |
+
3,
|
| 1250 |
+
"LATENT"
|
| 1251 |
+
],
|
| 1252 |
+
[
|
| 1253 |
+
127,
|
| 1254 |
+
44,
|
| 1255 |
+
2,
|
| 1256 |
+
36,
|
| 1257 |
+
2,
|
| 1258 |
+
"LATENT"
|
| 1259 |
+
],
|
| 1260 |
+
[
|
| 1261 |
+
128,
|
| 1262 |
+
19,
|
| 1263 |
+
2,
|
| 1264 |
+
44,
|
| 1265 |
+
2,
|
| 1266 |
+
"VAE"
|
| 1267 |
+
],
|
| 1268 |
+
[
|
| 1269 |
+
133,
|
| 1270 |
+
33,
|
| 1271 |
+
0,
|
| 1272 |
+
45,
|
| 1273 |
+
0,
|
| 1274 |
+
"IMAGE"
|
| 1275 |
+
],
|
| 1276 |
+
[
|
| 1277 |
+
136,
|
| 1278 |
+
46,
|
| 1279 |
+
0,
|
| 1280 |
+
43,
|
| 1281 |
+
0,
|
| 1282 |
+
"IMAGE"
|
| 1283 |
+
],
|
| 1284 |
+
[
|
| 1285 |
+
137,
|
| 1286 |
+
47,
|
| 1287 |
+
0,
|
| 1288 |
+
43,
|
| 1289 |
+
1,
|
| 1290 |
+
"MASK"
|
| 1291 |
+
],
|
| 1292 |
+
[
|
| 1293 |
+
138,
|
| 1294 |
+
47,
|
| 1295 |
+
0,
|
| 1296 |
+
44,
|
| 1297 |
+
4,
|
| 1298 |
+
"MASK"
|
| 1299 |
+
],
|
| 1300 |
+
[
|
| 1301 |
+
140,
|
| 1302 |
+
50,
|
| 1303 |
+
0,
|
| 1304 |
+
44,
|
| 1305 |
+
3,
|
| 1306 |
+
"IMAGE"
|
| 1307 |
+
],
|
| 1308 |
+
[
|
| 1309 |
+
142,
|
| 1310 |
+
51,
|
| 1311 |
+
0,
|
| 1312 |
+
50,
|
| 1313 |
+
0,
|
| 1314 |
+
"*"
|
| 1315 |
+
],
|
| 1316 |
+
[
|
| 1317 |
+
143,
|
| 1318 |
+
52,
|
| 1319 |
+
0,
|
| 1320 |
+
49,
|
| 1321 |
+
0,
|
| 1322 |
+
"INPAINT_MODEL"
|
| 1323 |
+
],
|
| 1324 |
+
[
|
| 1325 |
+
144,
|
| 1326 |
+
46,
|
| 1327 |
+
0,
|
| 1328 |
+
49,
|
| 1329 |
+
1,
|
| 1330 |
+
"IMAGE"
|
| 1331 |
+
],
|
| 1332 |
+
[
|
| 1333 |
+
145,
|
| 1334 |
+
47,
|
| 1335 |
+
0,
|
| 1336 |
+
49,
|
| 1337 |
+
2,
|
| 1338 |
+
"MASK"
|
| 1339 |
+
],
|
| 1340 |
+
[
|
| 1341 |
+
146,
|
| 1342 |
+
48,
|
| 1343 |
+
0,
|
| 1344 |
+
53,
|
| 1345 |
+
0,
|
| 1346 |
+
"IMAGE"
|
| 1347 |
+
],
|
| 1348 |
+
[
|
| 1349 |
+
147,
|
| 1350 |
+
43,
|
| 1351 |
+
0,
|
| 1352 |
+
54,
|
| 1353 |
+
0,
|
| 1354 |
+
"IMAGE"
|
| 1355 |
+
],
|
| 1356 |
+
[
|
| 1357 |
+
148,
|
| 1358 |
+
49,
|
| 1359 |
+
0,
|
| 1360 |
+
55,
|
| 1361 |
+
0,
|
| 1362 |
+
"IMAGE"
|
| 1363 |
+
],
|
| 1364 |
+
[
|
| 1365 |
+
150,
|
| 1366 |
+
46,
|
| 1367 |
+
0,
|
| 1368 |
+
48,
|
| 1369 |
+
0,
|
| 1370 |
+
"IMAGE"
|
| 1371 |
+
],
|
| 1372 |
+
[
|
| 1373 |
+
151,
|
| 1374 |
+
47,
|
| 1375 |
+
0,
|
| 1376 |
+
48,
|
| 1377 |
+
1,
|
| 1378 |
+
"MASK"
|
| 1379 |
+
],
|
| 1380 |
+
[
|
| 1381 |
+
154,
|
| 1382 |
+
46,
|
| 1383 |
+
0,
|
| 1384 |
+
61,
|
| 1385 |
+
0,
|
| 1386 |
+
"*"
|
| 1387 |
+
],
|
| 1388 |
+
[
|
| 1389 |
+
155,
|
| 1390 |
+
65,
|
| 1391 |
+
0,
|
| 1392 |
+
59,
|
| 1393 |
+
0,
|
| 1394 |
+
"IMAGE"
|
| 1395 |
+
],
|
| 1396 |
+
[
|
| 1397 |
+
156,
|
| 1398 |
+
14,
|
| 1399 |
+
0,
|
| 1400 |
+
65,
|
| 1401 |
+
1,
|
| 1402 |
+
"IMAGE"
|
| 1403 |
+
],
|
| 1404 |
+
[
|
| 1405 |
+
159,
|
| 1406 |
+
47,
|
| 1407 |
+
0,
|
| 1408 |
+
65,
|
| 1409 |
+
2,
|
| 1410 |
+
"MASK"
|
| 1411 |
+
],
|
| 1412 |
+
[
|
| 1413 |
+
160,
|
| 1414 |
+
46,
|
| 1415 |
+
0,
|
| 1416 |
+
65,
|
| 1417 |
+
0,
|
| 1418 |
+
"IMAGE"
|
| 1419 |
+
],
|
| 1420 |
+
[
|
| 1421 |
+
167,
|
| 1422 |
+
48,
|
| 1423 |
+
0,
|
| 1424 |
+
51,
|
| 1425 |
+
0,
|
| 1426 |
+
"*"
|
| 1427 |
+
],
|
| 1428 |
+
[
|
| 1429 |
+
168,
|
| 1430 |
+
33,
|
| 1431 |
+
0,
|
| 1432 |
+
46,
|
| 1433 |
+
0,
|
| 1434 |
+
"*"
|
| 1435 |
+
],
|
| 1436 |
+
[
|
| 1437 |
+
170,
|
| 1438 |
+
33,
|
| 1439 |
+
1,
|
| 1440 |
+
47,
|
| 1441 |
+
0,
|
| 1442 |
+
"*"
|
| 1443 |
+
]
|
| 1444 |
+
],
|
| 1445 |
+
"groups": [
|
| 1446 |
+
{
|
| 1447 |
+
"title": "Input Image and Mask",
|
| 1448 |
+
"bounding": [
|
| 1449 |
+
-496,
|
| 1450 |
+
-2,
|
| 1451 |
+
452,
|
| 1452 |
+
1072
|
| 1453 |
+
],
|
| 1454 |
+
"color": "#3f789e",
|
| 1455 |
+
"font_size": 24
|
| 1456 |
+
},
|
| 1457 |
+
{
|
| 1458 |
+
"title": "Preprocess",
|
| 1459 |
+
"bounding": [
|
| 1460 |
+
93,
|
| 1461 |
+
-2,
|
| 1462 |
+
623,
|
| 1463 |
+
1087
|
| 1464 |
+
],
|
| 1465 |
+
"color": "#b06634",
|
| 1466 |
+
"font_size": 24
|
| 1467 |
+
},
|
| 1468 |
+
{
|
| 1469 |
+
"title": "Postprocess",
|
| 1470 |
+
"bounding": [
|
| 1471 |
+
891,
|
| 1472 |
+
790,
|
| 1473 |
+
335,
|
| 1474 |
+
331
|
| 1475 |
+
],
|
| 1476 |
+
"color": "#8AA",
|
| 1477 |
+
"font_size": 24
|
| 1478 |
+
}
|
| 1479 |
+
],
|
| 1480 |
+
"config": {},
|
| 1481 |
+
"extra": {},
|
| 1482 |
+
"version": 0.4
|
| 1483 |
+
}
|
sage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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"last_node_id": 71,
|
| 3 |
+
"last_link_id": 184,
|
| 4 |
+
"nodes": [
|
| 5 |
+
{
|
| 6 |
+
"id": 55,
|
| 7 |
+
"type": "PreviewImage",
|
| 8 |
+
"pos": [
|
| 9 |
+
490,
|
| 10 |
+
800
|
| 11 |
+
],
|
| 12 |
+
"size": {
|
| 13 |
+
"0": 210,
|
| 14 |
+
"1": 246
|
| 15 |
+
},
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 22,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"inputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "images",
|
| 22 |
+
"type": "IMAGE",
|
| 23 |
+
"link": 148
|
| 24 |
+
}
|
| 25 |
+
],
|
| 26 |
+
"properties": {
|
| 27 |
+
"Node name for S&R": "PreviewImage"
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"id": 47,
|
| 32 |
+
"type": "Reroute",
|
| 33 |
+
"pos": [
|
| 34 |
+
-85.70390089638016,
|
| 35 |
+
451.81675574263164
|
| 36 |
+
],
|
| 37 |
+
"size": [
|
| 38 |
+
75,
|
| 39 |
+
26
|
| 40 |
+
],
|
| 41 |
+
"flags": {},
|
| 42 |
+
"order": 15,
|
| 43 |
+
"mode": 0,
|
| 44 |
+
"inputs": [
|
| 45 |
+
{
|
| 46 |
+
"name": "",
|
| 47 |
+
"type": "*",
|
| 48 |
+
"link": 184
|
| 49 |
+
}
|
| 50 |
+
],
|
| 51 |
+
"outputs": [
|
| 52 |
+
{
|
| 53 |
+
"name": "",
|
| 54 |
+
"type": "MASK",
|
| 55 |
+
"links": [
|
| 56 |
+
137,
|
| 57 |
+
138,
|
| 58 |
+
145,
|
| 59 |
+
151,
|
| 60 |
+
159
|
| 61 |
+
],
|
| 62 |
+
"slot_index": 0
|
| 63 |
+
}
|
| 64 |
+
],
|
| 65 |
+
"properties": {
|
| 66 |
+
"showOutputText": false,
|
| 67 |
+
"horizontal": false
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"id": 62,
|
| 72 |
+
"type": "Note",
|
| 73 |
+
"pos": [
|
| 74 |
+
281,
|
| 75 |
+
78
|
| 76 |
+
],
|
| 77 |
+
"size": {
|
| 78 |
+
"0": 288.3625183105469,
|
| 79 |
+
"1": 58
|
| 80 |
+
},
|
| 81 |
+
"flags": {},
|
| 82 |
+
"order": 0,
|
| 83 |
+
"mode": 0,
|
| 84 |
+
"properties": {
|
| 85 |
+
"text": ""
|
| 86 |
+
},
|
| 87 |
+
"widgets_values": [
|
| 88 |
+
"pass-through: for refinement with denoise < 1"
|
| 89 |
+
],
|
| 90 |
+
"color": "#432",
|
| 91 |
+
"bgcolor": "#653"
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"id": 65,
|
| 95 |
+
"type": "ImageCompositeMasked",
|
| 96 |
+
"pos": [
|
| 97 |
+
900.6461852182938,
|
| 98 |
+
863.8659206207312
|
| 99 |
+
],
|
| 100 |
+
"size": {
|
| 101 |
+
"0": 315,
|
| 102 |
+
"1": 146
|
| 103 |
+
},
|
| 104 |
+
"flags": {},
|
| 105 |
+
"order": 30,
|
| 106 |
+
"mode": 0,
|
| 107 |
+
"inputs": [
|
| 108 |
+
{
|
| 109 |
+
"name": "destination",
|
| 110 |
+
"type": "IMAGE",
|
| 111 |
+
"link": 160
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"name": "source",
|
| 115 |
+
"type": "IMAGE",
|
| 116 |
+
"link": 156
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"name": "mask",
|
| 120 |
+
"type": "MASK",
|
| 121 |
+
"link": 159
|
| 122 |
+
}
|
| 123 |
+
],
|
| 124 |
+
"outputs": [
|
| 125 |
+
{
|
| 126 |
+
"name": "IMAGE",
|
| 127 |
+
"type": "IMAGE",
|
| 128 |
+
"links": [
|
| 129 |
+
155
|
| 130 |
+
],
|
| 131 |
+
"shape": 3,
|
| 132 |
+
"slot_index": 0
|
| 133 |
+
}
|
| 134 |
+
],
|
| 135 |
+
"properties": {
|
| 136 |
+
"Node name for S&R": "ImageCompositeMasked"
|
| 137 |
+
},
|
| 138 |
+
"widgets_values": [
|
| 139 |
+
0,
|
| 140 |
+
0,
|
| 141 |
+
false
|
| 142 |
+
]
|
| 143 |
+
},
|
| 144 |
+
{
|
| 145 |
+
"id": 59,
|
| 146 |
+
"type": "SaveImage",
|
| 147 |
+
"pos": [
|
| 148 |
+
754,
|
| 149 |
+
76
|
| 150 |
+
],
|
| 151 |
+
"size": {
|
| 152 |
+
"0": 490.87347412109375,
|
| 153 |
+
"1": 686.078125
|
| 154 |
+
},
|
| 155 |
+
"flags": {},
|
| 156 |
+
"order": 31,
|
| 157 |
+
"mode": 0,
|
| 158 |
+
"inputs": [
|
| 159 |
+
{
|
| 160 |
+
"name": "images",
|
| 161 |
+
"type": "IMAGE",
|
| 162 |
+
"link": 155
|
| 163 |
+
}
|
| 164 |
+
],
|
| 165 |
+
"properties": {},
|
| 166 |
+
"widgets_values": [
|
| 167 |
+
"ComfyUI"
|
| 168 |
+
]
|
| 169 |
+
},
|
| 170 |
+
{
|
| 171 |
+
"id": 43,
|
| 172 |
+
"type": "INPAINT_MaskedBlur",
|
| 173 |
+
"pos": [
|
| 174 |
+
120,
|
| 175 |
+
484
|
| 176 |
+
],
|
| 177 |
+
"size": {
|
| 178 |
+
"0": 315,
|
| 179 |
+
"1": 102
|
| 180 |
+
},
|
| 181 |
+
"flags": {},
|
| 182 |
+
"order": 18,
|
| 183 |
+
"mode": 0,
|
| 184 |
+
"inputs": [
|
| 185 |
+
{
|
| 186 |
+
"name": "image",
|
| 187 |
+
"type": "IMAGE",
|
| 188 |
+
"link": 136
|
| 189 |
+
},
|
| 190 |
+
{
|
| 191 |
+
"name": "mask",
|
| 192 |
+
"type": "MASK",
|
| 193 |
+
"link": 137
|
| 194 |
+
}
|
| 195 |
+
],
|
| 196 |
+
"outputs": [
|
| 197 |
+
{
|
| 198 |
+
"name": "IMAGE",
|
| 199 |
+
"type": "IMAGE",
|
| 200 |
+
"links": [
|
| 201 |
+
147
|
| 202 |
+
],
|
| 203 |
+
"shape": 3,
|
| 204 |
+
"slot_index": 0
|
| 205 |
+
}
|
| 206 |
+
],
|
| 207 |
+
"properties": {
|
| 208 |
+
"Node name for S&R": "INPAINT_MaskedBlur"
|
| 209 |
+
},
|
| 210 |
+
"widgets_values": [
|
| 211 |
+
255,
|
| 212 |
+
11
|
| 213 |
+
]
|
| 214 |
+
},
|
| 215 |
+
{
|
| 216 |
+
"id": 53,
|
| 217 |
+
"type": "PreviewImage",
|
| 218 |
+
"pos": [
|
| 219 |
+
487,
|
| 220 |
+
201
|
| 221 |
+
],
|
| 222 |
+
"size": {
|
| 223 |
+
"0": 210,
|
| 224 |
+
"1": 246
|
| 225 |
+
},
|
| 226 |
+
"flags": {},
|
| 227 |
+
"order": 23,
|
| 228 |
+
"mode": 0,
|
| 229 |
+
"inputs": [
|
| 230 |
+
{
|
| 231 |
+
"name": "images",
|
| 232 |
+
"type": "IMAGE",
|
| 233 |
+
"link": 146
|
| 234 |
+
}
|
| 235 |
+
],
|
| 236 |
+
"properties": {
|
| 237 |
+
"Node name for S&R": "PreviewImage"
|
| 238 |
+
}
|
| 239 |
+
},
|
| 240 |
+
{
|
| 241 |
+
"id": 54,
|
| 242 |
+
"type": "PreviewImage",
|
| 243 |
+
"pos": [
|
| 244 |
+
489,
|
| 245 |
+
491
|
| 246 |
+
],
|
| 247 |
+
"size": {
|
| 248 |
+
"0": 210,
|
| 249 |
+
"1": 246
|
| 250 |
+
},
|
| 251 |
+
"flags": {},
|
| 252 |
+
"order": 21,
|
| 253 |
+
"mode": 0,
|
| 254 |
+
"inputs": [
|
| 255 |
+
{
|
| 256 |
+
"name": "images",
|
| 257 |
+
"type": "IMAGE",
|
| 258 |
+
"link": 147
|
| 259 |
+
}
|
| 260 |
+
],
|
| 261 |
+
"properties": {
|
| 262 |
+
"Node name for S&R": "PreviewImage"
|
| 263 |
+
}
|
| 264 |
+
},
|
| 265 |
+
{
|
| 266 |
+
"id": 45,
|
| 267 |
+
"type": "ImagePadForOutpaint",
|
| 268 |
+
"pos": [
|
| 269 |
+
-482,
|
| 270 |
+
887
|
| 271 |
+
],
|
| 272 |
+
"size": {
|
| 273 |
+
"0": 315,
|
| 274 |
+
"1": 174
|
| 275 |
+
},
|
| 276 |
+
"flags": {},
|
| 277 |
+
"order": 13,
|
| 278 |
+
"mode": 0,
|
| 279 |
+
"inputs": [
|
| 280 |
+
{
|
| 281 |
+
"name": "image",
|
| 282 |
+
"type": "IMAGE",
|
| 283 |
+
"link": 133
|
| 284 |
+
}
|
| 285 |
+
],
|
| 286 |
+
"outputs": [
|
| 287 |
+
{
|
| 288 |
+
"name": "IMAGE",
|
| 289 |
+
"type": "IMAGE",
|
| 290 |
+
"links": [],
|
| 291 |
+
"shape": 3,
|
| 292 |
+
"slot_index": 0
|
| 293 |
+
},
|
| 294 |
+
{
|
| 295 |
+
"name": "MASK",
|
| 296 |
+
"type": "MASK",
|
| 297 |
+
"links": [],
|
| 298 |
+
"shape": 3,
|
| 299 |
+
"slot_index": 1
|
| 300 |
+
}
|
| 301 |
+
],
|
| 302 |
+
"properties": {
|
| 303 |
+
"Node name for S&R": "ImagePadForOutpaint"
|
| 304 |
+
},
|
| 305 |
+
"widgets_values": [
|
| 306 |
+
128,
|
| 307 |
+
0,
|
| 308 |
+
128,
|
| 309 |
+
0,
|
| 310 |
+
40
|
| 311 |
+
]
|
| 312 |
+
},
|
| 313 |
+
{
|
| 314 |
+
"id": 66,
|
| 315 |
+
"type": "Note",
|
| 316 |
+
"pos": [
|
| 317 |
+
-466,
|
| 318 |
+
426
|
| 319 |
+
],
|
| 320 |
+
"size": {
|
| 321 |
+
"0": 309.264892578125,
|
| 322 |
+
"1": 64.09974670410156
|
| 323 |
+
},
|
| 324 |
+
"flags": {},
|
| 325 |
+
"order": 1,
|
| 326 |
+
"mode": 0,
|
| 327 |
+
"properties": {
|
| 328 |
+
"text": ""
|
| 329 |
+
},
|
| 330 |
+
"widgets_values": [
|
| 331 |
+
"Paint mask into image,\nOR load mask from file,\nOR generate outpainting mask"
|
| 332 |
+
],
|
| 333 |
+
"color": "#2a363b",
|
| 334 |
+
"bgcolor": "#3f5159"
|
| 335 |
+
},
|
| 336 |
+
{
|
| 337 |
+
"id": 61,
|
| 338 |
+
"type": "Reroute",
|
| 339 |
+
"pos": [
|
| 340 |
+
128,
|
| 341 |
+
88
|
| 342 |
+
],
|
| 343 |
+
"size": [
|
| 344 |
+
75,
|
| 345 |
+
26
|
| 346 |
+
],
|
| 347 |
+
"flags": {},
|
| 348 |
+
"order": 16,
|
| 349 |
+
"mode": 0,
|
| 350 |
+
"inputs": [
|
| 351 |
+
{
|
| 352 |
+
"name": "",
|
| 353 |
+
"type": "*",
|
| 354 |
+
"link": 154
|
| 355 |
+
}
|
| 356 |
+
],
|
| 357 |
+
"outputs": [
|
| 358 |
+
{
|
| 359 |
+
"name": "",
|
| 360 |
+
"type": "IMAGE",
|
| 361 |
+
"links": [],
|
| 362 |
+
"slot_index": 0
|
| 363 |
+
}
|
| 364 |
+
],
|
| 365 |
+
"properties": {
|
| 366 |
+
"showOutputText": false,
|
| 367 |
+
"horizontal": false
|
| 368 |
+
}
|
| 369 |
+
},
|
| 370 |
+
{
|
| 371 |
+
"id": 56,
|
| 372 |
+
"type": "Note",
|
| 373 |
+
"pos": [
|
| 374 |
+
120,
|
| 375 |
+
350
|
| 376 |
+
],
|
| 377 |
+
"size": {
|
| 378 |
+
"0": 301.3452453613281,
|
| 379 |
+
"1": 67.77168273925781
|
| 380 |
+
},
|
| 381 |
+
"flags": {},
|
| 382 |
+
"order": 2,
|
| 383 |
+
"mode": 0,
|
| 384 |
+
"properties": {
|
| 385 |
+
"text": ""
|
| 386 |
+
},
|
| 387 |
+
"widgets_values": [
|
| 388 |
+
"neutral: to add objects / make drastic changes\ntelea/navier-stokes: good for outpainting"
|
| 389 |
+
],
|
| 390 |
+
"color": "#432",
|
| 391 |
+
"bgcolor": "#653"
|
| 392 |
+
},
|
| 393 |
+
{
|
| 394 |
+
"id": 57,
|
| 395 |
+
"type": "Note",
|
| 396 |
+
"pos": [
|
| 397 |
+
127,
|
| 398 |
+
627
|
| 399 |
+
],
|
| 400 |
+
"size": {
|
| 401 |
+
"0": 301.4128112792969,
|
| 402 |
+
"1": 58
|
| 403 |
+
},
|
| 404 |
+
"flags": {},
|
| 405 |
+
"order": 3,
|
| 406 |
+
"mode": 0,
|
| 407 |
+
"properties": {
|
| 408 |
+
"text": ""
|
| 409 |
+
},
|
| 410 |
+
"widgets_values": [
|
| 411 |
+
"keeps average colors from masked area"
|
| 412 |
+
],
|
| 413 |
+
"color": "#432",
|
| 414 |
+
"bgcolor": "#653"
|
| 415 |
+
},
|
| 416 |
+
{
|
| 417 |
+
"id": 48,
|
| 418 |
+
"type": "INPAINT_MaskedFill",
|
| 419 |
+
"pos": [
|
| 420 |
+
110,
|
| 421 |
+
210
|
| 422 |
+
],
|
| 423 |
+
"size": {
|
| 424 |
+
"0": 315,
|
| 425 |
+
"1": 102
|
| 426 |
+
},
|
| 427 |
+
"flags": {},
|
| 428 |
+
"order": 20,
|
| 429 |
+
"mode": 0,
|
| 430 |
+
"inputs": [
|
| 431 |
+
{
|
| 432 |
+
"name": "image",
|
| 433 |
+
"type": "IMAGE",
|
| 434 |
+
"link": 150
|
| 435 |
+
},
|
| 436 |
+
{
|
| 437 |
+
"name": "mask",
|
| 438 |
+
"type": "MASK",
|
| 439 |
+
"link": 151
|
| 440 |
+
}
|
| 441 |
+
],
|
| 442 |
+
"outputs": [
|
| 443 |
+
{
|
| 444 |
+
"name": "IMAGE",
|
| 445 |
+
"type": "IMAGE",
|
| 446 |
+
"links": [
|
| 447 |
+
146,
|
| 448 |
+
167
|
| 449 |
+
],
|
| 450 |
+
"shape": 3,
|
| 451 |
+
"slot_index": 0
|
| 452 |
+
}
|
| 453 |
+
],
|
| 454 |
+
"properties": {
|
| 455 |
+
"Node name for S&R": "INPAINT_MaskedFill"
|
| 456 |
+
},
|
| 457 |
+
"widgets_values": [
|
| 458 |
+
"neutral",
|
| 459 |
+
11
|
| 460 |
+
]
|
| 461 |
+
},
|
| 462 |
+
{
|
| 463 |
+
"id": 36,
|
| 464 |
+
"type": "INPAINT_ApplyFooocusInpaint",
|
| 465 |
+
"pos": [
|
| 466 |
+
679,
|
| 467 |
+
1339
|
| 468 |
+
],
|
| 469 |
+
"size": {
|
| 470 |
+
"0": 191.45639038085938,
|
| 471 |
+
"1": 66
|
| 472 |
+
},
|
| 473 |
+
"flags": {},
|
| 474 |
+
"order": 27,
|
| 475 |
+
"mode": 0,
|
| 476 |
+
"inputs": [
|
| 477 |
+
{
|
| 478 |
+
"name": "model",
|
| 479 |
+
"type": "MODEL",
|
| 480 |
+
"link": 181
|
| 481 |
+
},
|
| 482 |
+
{
|
| 483 |
+
"name": "patch",
|
| 484 |
+
"type": "INPAINT_PATCH",
|
| 485 |
+
"link": 62
|
| 486 |
+
},
|
| 487 |
+
{
|
| 488 |
+
"name": "latent",
|
| 489 |
+
"type": "LATENT",
|
| 490 |
+
"link": 127
|
| 491 |
+
}
|
| 492 |
+
],
|
| 493 |
+
"outputs": [
|
| 494 |
+
{
|
| 495 |
+
"name": "MODEL",
|
| 496 |
+
"type": "MODEL",
|
| 497 |
+
"links": [
|
| 498 |
+
120
|
| 499 |
+
],
|
| 500 |
+
"shape": 3,
|
| 501 |
+
"slot_index": 0
|
| 502 |
+
}
|
| 503 |
+
],
|
| 504 |
+
"properties": {
|
| 505 |
+
"Node name for S&R": "INPAINT_ApplyFooocusInpaint"
|
| 506 |
+
},
|
| 507 |
+
"color": "#323",
|
| 508 |
+
"bgcolor": "#535"
|
| 509 |
+
},
|
| 510 |
+
{
|
| 511 |
+
"id": 40,
|
| 512 |
+
"type": "KSampler",
|
| 513 |
+
"pos": [
|
| 514 |
+
907,
|
| 515 |
+
1200
|
| 516 |
+
],
|
| 517 |
+
"size": {
|
| 518 |
+
"0": 321.14495849609375,
|
| 519 |
+
"1": 262
|
| 520 |
+
},
|
| 521 |
+
"flags": {},
|
| 522 |
+
"order": 28,
|
| 523 |
+
"mode": 0,
|
| 524 |
+
"inputs": [
|
| 525 |
+
{
|
| 526 |
+
"name": "model",
|
| 527 |
+
"type": "MODEL",
|
| 528 |
+
"link": 120
|
| 529 |
+
},
|
| 530 |
+
{
|
| 531 |
+
"name": "positive",
|
| 532 |
+
"type": "CONDITIONING",
|
| 533 |
+
"link": 124
|
| 534 |
+
},
|
| 535 |
+
{
|
| 536 |
+
"name": "negative",
|
| 537 |
+
"type": "CONDITIONING",
|
| 538 |
+
"link": 125
|
| 539 |
+
},
|
| 540 |
+
{
|
| 541 |
+
"name": "latent_image",
|
| 542 |
+
"type": "LATENT",
|
| 543 |
+
"link": 126
|
| 544 |
+
}
|
| 545 |
+
],
|
| 546 |
+
"outputs": [
|
| 547 |
+
{
|
| 548 |
+
"name": "LATENT",
|
| 549 |
+
"type": "LATENT",
|
| 550 |
+
"links": [
|
| 551 |
+
97
|
| 552 |
+
],
|
| 553 |
+
"shape": 3,
|
| 554 |
+
"slot_index": 0
|
| 555 |
+
}
|
| 556 |
+
],
|
| 557 |
+
"properties": {
|
| 558 |
+
"Node name for S&R": "KSampler"
|
| 559 |
+
},
|
| 560 |
+
"widgets_values": [
|
| 561 |
+
469445285154282,
|
| 562 |
+
"randomize",
|
| 563 |
+
24,
|
| 564 |
+
5,
|
| 565 |
+
"dpmpp_2m_sde_gpu",
|
| 566 |
+
"karras",
|
| 567 |
+
1
|
| 568 |
+
]
|
| 569 |
+
},
|
| 570 |
+
{
|
| 571 |
+
"id": 19,
|
| 572 |
+
"type": "CheckpointLoaderSimple",
|
| 573 |
+
"pos": [
|
| 574 |
+
-483,
|
| 575 |
+
1110
|
| 576 |
+
],
|
| 577 |
+
"size": {
|
| 578 |
+
"0": 401.11712646484375,
|
| 579 |
+
"1": 98
|
| 580 |
+
},
|
| 581 |
+
"flags": {},
|
| 582 |
+
"order": 4,
|
| 583 |
+
"mode": 0,
|
| 584 |
+
"outputs": [
|
| 585 |
+
{
|
| 586 |
+
"name": "MODEL",
|
| 587 |
+
"type": "MODEL",
|
| 588 |
+
"links": [
|
| 589 |
+
178
|
| 590 |
+
],
|
| 591 |
+
"shape": 3,
|
| 592 |
+
"slot_index": 0
|
| 593 |
+
},
|
| 594 |
+
{
|
| 595 |
+
"name": "CLIP",
|
| 596 |
+
"type": "CLIP",
|
| 597 |
+
"links": [
|
| 598 |
+
35,
|
| 599 |
+
88
|
| 600 |
+
],
|
| 601 |
+
"shape": 3,
|
| 602 |
+
"slot_index": 1
|
| 603 |
+
},
|
| 604 |
+
{
|
| 605 |
+
"name": "VAE",
|
| 606 |
+
"type": "VAE",
|
| 607 |
+
"links": [
|
| 608 |
+
43,
|
| 609 |
+
128
|
| 610 |
+
],
|
| 611 |
+
"shape": 3,
|
| 612 |
+
"slot_index": 2
|
| 613 |
+
}
|
| 614 |
+
],
|
| 615 |
+
"properties": {
|
| 616 |
+
"Node name for S&R": "CheckpointLoaderSimple"
|
| 617 |
+
},
|
| 618 |
+
"widgets_values": [
|
| 619 |
+
"juggernautXL_version6Rundiffusion.safetensors"
|
| 620 |
+
]
|
| 621 |
+
},
|
| 622 |
+
{
|
| 623 |
+
"id": 46,
|
| 624 |
+
"type": "Reroute",
|
| 625 |
+
"pos": [
|
| 626 |
+
-86,
|
| 627 |
+
401
|
| 628 |
+
],
|
| 629 |
+
"size": [
|
| 630 |
+
75,
|
| 631 |
+
26
|
| 632 |
+
],
|
| 633 |
+
"flags": {},
|
| 634 |
+
"order": 14,
|
| 635 |
+
"mode": 0,
|
| 636 |
+
"inputs": [
|
| 637 |
+
{
|
| 638 |
+
"name": "",
|
| 639 |
+
"type": "*",
|
| 640 |
+
"link": 168
|
| 641 |
+
}
|
| 642 |
+
],
|
| 643 |
+
"outputs": [
|
| 644 |
+
{
|
| 645 |
+
"name": "",
|
| 646 |
+
"type": "IMAGE",
|
| 647 |
+
"links": [
|
| 648 |
+
136,
|
| 649 |
+
144,
|
| 650 |
+
150,
|
| 651 |
+
154,
|
| 652 |
+
160,
|
| 653 |
+
180
|
| 654 |
+
],
|
| 655 |
+
"slot_index": 0
|
| 656 |
+
}
|
| 657 |
+
],
|
| 658 |
+
"properties": {
|
| 659 |
+
"showOutputText": false,
|
| 660 |
+
"horizontal": false
|
| 661 |
+
}
|
| 662 |
+
},
|
| 663 |
+
{
|
| 664 |
+
"id": 35,
|
| 665 |
+
"type": "INPAINT_LoadFooocusInpaint",
|
| 666 |
+
"pos": [
|
| 667 |
+
334,
|
| 668 |
+
1391
|
| 669 |
+
],
|
| 670 |
+
"size": {
|
| 671 |
+
"0": 289.209716796875,
|
| 672 |
+
"1": 82
|
| 673 |
+
},
|
| 674 |
+
"flags": {},
|
| 675 |
+
"order": 5,
|
| 676 |
+
"mode": 0,
|
| 677 |
+
"outputs": [
|
| 678 |
+
{
|
| 679 |
+
"name": "INPAINT_PATCH",
|
| 680 |
+
"type": "INPAINT_PATCH",
|
| 681 |
+
"links": [
|
| 682 |
+
62
|
| 683 |
+
],
|
| 684 |
+
"shape": 3,
|
| 685 |
+
"slot_index": 0
|
| 686 |
+
}
|
| 687 |
+
],
|
| 688 |
+
"properties": {
|
| 689 |
+
"Node name for S&R": "INPAINT_LoadFooocusInpaint"
|
| 690 |
+
},
|
| 691 |
+
"widgets_values": [
|
| 692 |
+
"fooocus_inpaint_head.pth",
|
| 693 |
+
"inpaint_v26.fooocus.patch"
|
| 694 |
+
],
|
| 695 |
+
"color": "#323",
|
| 696 |
+
"bgcolor": "#535"
|
| 697 |
+
},
|
| 698 |
+
{
|
| 699 |
+
"id": 34,
|
| 700 |
+
"type": "LoadImageMask",
|
| 701 |
+
"pos": [
|
| 702 |
+
-476,
|
| 703 |
+
534
|
| 704 |
+
],
|
| 705 |
+
"size": {
|
| 706 |
+
"0": 315,
|
| 707 |
+
"1": 318
|
| 708 |
+
},
|
| 709 |
+
"flags": {},
|
| 710 |
+
"order": 6,
|
| 711 |
+
"mode": 0,
|
| 712 |
+
"outputs": [
|
| 713 |
+
{
|
| 714 |
+
"name": "MASK",
|
| 715 |
+
"type": "MASK",
|
| 716 |
+
"links": [],
|
| 717 |
+
"shape": 3,
|
| 718 |
+
"slot_index": 0
|
| 719 |
+
}
|
| 720 |
+
],
|
| 721 |
+
"properties": {
|
| 722 |
+
"Node name for S&R": "LoadImageMask"
|
| 723 |
+
},
|
| 724 |
+
"widgets_values": [
|
| 725 |
+
"mask1024 (1).png",
|
| 726 |
+
"red",
|
| 727 |
+
"image"
|
| 728 |
+
]
|
| 729 |
+
},
|
| 730 |
+
{
|
| 731 |
+
"id": 44,
|
| 732 |
+
"type": "INPAINT_VAEEncodeInpaintConditioning",
|
| 733 |
+
"pos": [
|
| 734 |
+
350,
|
| 735 |
+
1193
|
| 736 |
+
],
|
| 737 |
+
"size": {
|
| 738 |
+
"0": 277.20001220703125,
|
| 739 |
+
"1": 113.80070495605469
|
| 740 |
+
},
|
| 741 |
+
"flags": {},
|
| 742 |
+
"order": 26,
|
| 743 |
+
"mode": 0,
|
| 744 |
+
"inputs": [
|
| 745 |
+
{
|
| 746 |
+
"name": "positive",
|
| 747 |
+
"type": "CONDITIONING",
|
| 748 |
+
"link": 122
|
| 749 |
+
},
|
| 750 |
+
{
|
| 751 |
+
"name": "negative",
|
| 752 |
+
"type": "CONDITIONING",
|
| 753 |
+
"link": 123
|
| 754 |
+
},
|
| 755 |
+
{
|
| 756 |
+
"name": "vae",
|
| 757 |
+
"type": "VAE",
|
| 758 |
+
"link": 128
|
| 759 |
+
},
|
| 760 |
+
{
|
| 761 |
+
"name": "pixels",
|
| 762 |
+
"type": "IMAGE",
|
| 763 |
+
"link": 140
|
| 764 |
+
},
|
| 765 |
+
{
|
| 766 |
+
"name": "mask",
|
| 767 |
+
"type": "MASK",
|
| 768 |
+
"link": 138
|
| 769 |
+
}
|
| 770 |
+
],
|
| 771 |
+
"outputs": [
|
| 772 |
+
{
|
| 773 |
+
"name": "positive",
|
| 774 |
+
"type": "CONDITIONING",
|
| 775 |
+
"links": [
|
| 776 |
+
124
|
| 777 |
+
],
|
| 778 |
+
"shape": 3,
|
| 779 |
+
"slot_index": 0
|
| 780 |
+
},
|
| 781 |
+
{
|
| 782 |
+
"name": "negative",
|
| 783 |
+
"type": "CONDITIONING",
|
| 784 |
+
"links": [
|
| 785 |
+
125
|
| 786 |
+
],
|
| 787 |
+
"shape": 3,
|
| 788 |
+
"slot_index": 1
|
| 789 |
+
},
|
| 790 |
+
{
|
| 791 |
+
"name": "latent_inpaint",
|
| 792 |
+
"type": "LATENT",
|
| 793 |
+
"links": [
|
| 794 |
+
127
|
| 795 |
+
],
|
| 796 |
+
"shape": 3,
|
| 797 |
+
"slot_index": 2
|
| 798 |
+
},
|
| 799 |
+
{
|
| 800 |
+
"name": "latent_samples",
|
| 801 |
+
"type": "LATENT",
|
| 802 |
+
"links": [
|
| 803 |
+
126
|
| 804 |
+
],
|
| 805 |
+
"shape": 3,
|
| 806 |
+
"slot_index": 3
|
| 807 |
+
}
|
| 808 |
+
],
|
| 809 |
+
"properties": {
|
| 810 |
+
"Node name for S&R": "INPAINT_VAEEncodeInpaintConditioning"
|
| 811 |
+
},
|
| 812 |
+
"color": "#323",
|
| 813 |
+
"bgcolor": "#535"
|
| 814 |
+
},
|
| 815 |
+
{
|
| 816 |
+
"id": 58,
|
| 817 |
+
"type": "Note",
|
| 818 |
+
"pos": [
|
| 819 |
+
124,
|
| 820 |
+
1033
|
| 821 |
+
],
|
| 822 |
+
"size": {
|
| 823 |
+
"0": 311.85528564453125,
|
| 824 |
+
"1": 60.94014358520508
|
| 825 |
+
},
|
| 826 |
+
"flags": {},
|
| 827 |
+
"order": 7,
|
| 828 |
+
"mode": 0,
|
| 829 |
+
"properties": {
|
| 830 |
+
"text": ""
|
| 831 |
+
},
|
| 832 |
+
"widgets_values": [
|
| 833 |
+
"fill with fast inpaint model\ngood for removing objects"
|
| 834 |
+
],
|
| 835 |
+
"color": "#432",
|
| 836 |
+
"bgcolor": "#653"
|
| 837 |
+
},
|
| 838 |
+
{
|
| 839 |
+
"id": 10,
|
| 840 |
+
"type": "CLIPTextEncode",
|
| 841 |
+
"pos": [
|
| 842 |
+
0,
|
| 843 |
+
1240
|
| 844 |
+
],
|
| 845 |
+
"size": {
|
| 846 |
+
"0": 417.58416748046875,
|
| 847 |
+
"1": 76
|
| 848 |
+
},
|
| 849 |
+
"flags": {
|
| 850 |
+
"collapsed": true
|
| 851 |
+
},
|
| 852 |
+
"order": 11,
|
| 853 |
+
"mode": 0,
|
| 854 |
+
"inputs": [
|
| 855 |
+
{
|
| 856 |
+
"name": "clip",
|
| 857 |
+
"type": "CLIP",
|
| 858 |
+
"link": 35
|
| 859 |
+
}
|
| 860 |
+
],
|
| 861 |
+
"outputs": [
|
| 862 |
+
{
|
| 863 |
+
"name": "CONDITIONING",
|
| 864 |
+
"type": "CONDITIONING",
|
| 865 |
+
"links": [
|
| 866 |
+
123
|
| 867 |
+
],
|
| 868 |
+
"shape": 3,
|
| 869 |
+
"slot_index": 0
|
| 870 |
+
}
|
| 871 |
+
],
|
| 872 |
+
"properties": {
|
| 873 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 874 |
+
},
|
| 875 |
+
"widgets_values": [
|
| 876 |
+
"text, watermark"
|
| 877 |
+
],
|
| 878 |
+
"color": "#322",
|
| 879 |
+
"bgcolor": "#533"
|
| 880 |
+
},
|
| 881 |
+
{
|
| 882 |
+
"id": 9,
|
| 883 |
+
"type": "CLIPTextEncode",
|
| 884 |
+
"pos": [
|
| 885 |
+
0,
|
| 886 |
+
1193
|
| 887 |
+
],
|
| 888 |
+
"size": {
|
| 889 |
+
"0": 421.9678039550781,
|
| 890 |
+
"1": 88.26173400878906
|
| 891 |
+
},
|
| 892 |
+
"flags": {
|
| 893 |
+
"collapsed": true
|
| 894 |
+
},
|
| 895 |
+
"order": 12,
|
| 896 |
+
"mode": 0,
|
| 897 |
+
"inputs": [
|
| 898 |
+
{
|
| 899 |
+
"name": "clip",
|
| 900 |
+
"type": "CLIP",
|
| 901 |
+
"link": 88
|
| 902 |
+
}
|
| 903 |
+
],
|
| 904 |
+
"outputs": [
|
| 905 |
+
{
|
| 906 |
+
"name": "CONDITIONING",
|
| 907 |
+
"type": "CONDITIONING",
|
| 908 |
+
"links": [
|
| 909 |
+
122
|
| 910 |
+
],
|
| 911 |
+
"shape": 3,
|
| 912 |
+
"slot_index": 0
|
| 913 |
+
}
|
| 914 |
+
],
|
| 915 |
+
"properties": {
|
| 916 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 917 |
+
},
|
| 918 |
+
"widgets_values": [
|
| 919 |
+
""
|
| 920 |
+
],
|
| 921 |
+
"color": "#232",
|
| 922 |
+
"bgcolor": "#353"
|
| 923 |
+
},
|
| 924 |
+
{
|
| 925 |
+
"id": 50,
|
| 926 |
+
"type": "Reroute",
|
| 927 |
+
"pos": [
|
| 928 |
+
127,
|
| 929 |
+
1110
|
| 930 |
+
],
|
| 931 |
+
"size": [
|
| 932 |
+
75,
|
| 933 |
+
26
|
| 934 |
+
],
|
| 935 |
+
"flags": {},
|
| 936 |
+
"order": 25,
|
| 937 |
+
"mode": 0,
|
| 938 |
+
"inputs": [
|
| 939 |
+
{
|
| 940 |
+
"name": "",
|
| 941 |
+
"type": "*",
|
| 942 |
+
"link": 142
|
| 943 |
+
}
|
| 944 |
+
],
|
| 945 |
+
"outputs": [
|
| 946 |
+
{
|
| 947 |
+
"name": "",
|
| 948 |
+
"type": "IMAGE",
|
| 949 |
+
"links": [
|
| 950 |
+
140
|
| 951 |
+
],
|
| 952 |
+
"slot_index": 0
|
| 953 |
+
}
|
| 954 |
+
],
|
| 955 |
+
"properties": {
|
| 956 |
+
"showOutputText": false,
|
| 957 |
+
"horizontal": false
|
| 958 |
+
}
|
| 959 |
+
},
|
| 960 |
+
{
|
| 961 |
+
"id": 14,
|
| 962 |
+
"type": "VAEDecode",
|
| 963 |
+
"pos": [
|
| 964 |
+
917,
|
| 965 |
+
1056
|
| 966 |
+
],
|
| 967 |
+
"size": {
|
| 968 |
+
"0": 280.32958984375,
|
| 969 |
+
"1": 47.345115661621094
|
| 970 |
+
},
|
| 971 |
+
"flags": {},
|
| 972 |
+
"order": 29,
|
| 973 |
+
"mode": 0,
|
| 974 |
+
"inputs": [
|
| 975 |
+
{
|
| 976 |
+
"name": "samples",
|
| 977 |
+
"type": "LATENT",
|
| 978 |
+
"link": 97
|
| 979 |
+
},
|
| 980 |
+
{
|
| 981 |
+
"name": "vae",
|
| 982 |
+
"type": "VAE",
|
| 983 |
+
"link": 43
|
| 984 |
+
}
|
| 985 |
+
],
|
| 986 |
+
"outputs": [
|
| 987 |
+
{
|
| 988 |
+
"name": "IMAGE",
|
| 989 |
+
"type": "IMAGE",
|
| 990 |
+
"links": [
|
| 991 |
+
156
|
| 992 |
+
],
|
| 993 |
+
"shape": 3,
|
| 994 |
+
"slot_index": 0
|
| 995 |
+
}
|
| 996 |
+
],
|
| 997 |
+
"properties": {
|
| 998 |
+
"Node name for S&R": "VAEDecode"
|
| 999 |
+
}
|
| 1000 |
+
},
|
| 1001 |
+
{
|
| 1002 |
+
"id": 51,
|
| 1003 |
+
"type": "Reroute",
|
| 1004 |
+
"pos": [
|
| 1005 |
+
514,
|
| 1006 |
+
1070
|
| 1007 |
+
],
|
| 1008 |
+
"size": [
|
| 1009 |
+
75,
|
| 1010 |
+
26
|
| 1011 |
+
],
|
| 1012 |
+
"flags": {},
|
| 1013 |
+
"order": 24,
|
| 1014 |
+
"mode": 0,
|
| 1015 |
+
"inputs": [
|
| 1016 |
+
{
|
| 1017 |
+
"name": "",
|
| 1018 |
+
"type": "*",
|
| 1019 |
+
"link": 167,
|
| 1020 |
+
"slot_index": 0
|
| 1021 |
+
}
|
| 1022 |
+
],
|
| 1023 |
+
"outputs": [
|
| 1024 |
+
{
|
| 1025 |
+
"name": "",
|
| 1026 |
+
"type": "IMAGE",
|
| 1027 |
+
"links": [
|
| 1028 |
+
142
|
| 1029 |
+
],
|
| 1030 |
+
"slot_index": 0
|
| 1031 |
+
}
|
| 1032 |
+
],
|
| 1033 |
+
"properties": {
|
| 1034 |
+
"showOutputText": false,
|
| 1035 |
+
"horizontal": false
|
| 1036 |
+
}
|
| 1037 |
+
},
|
| 1038 |
+
{
|
| 1039 |
+
"id": 71,
|
| 1040 |
+
"type": "IPAdapter",
|
| 1041 |
+
"pos": [
|
| 1042 |
+
-14,
|
| 1043 |
+
1304
|
| 1044 |
+
],
|
| 1045 |
+
"size": {
|
| 1046 |
+
"0": 315,
|
| 1047 |
+
"1": 166
|
| 1048 |
+
},
|
| 1049 |
+
"flags": {},
|
| 1050 |
+
"order": 17,
|
| 1051 |
+
"mode": 0,
|
| 1052 |
+
"inputs": [
|
| 1053 |
+
{
|
| 1054 |
+
"name": "model",
|
| 1055 |
+
"type": "MODEL",
|
| 1056 |
+
"link": 179
|
| 1057 |
+
},
|
| 1058 |
+
{
|
| 1059 |
+
"name": "ipadapter",
|
| 1060 |
+
"type": "IPADAPTER",
|
| 1061 |
+
"link": 183,
|
| 1062 |
+
"slot_index": 1
|
| 1063 |
+
},
|
| 1064 |
+
{
|
| 1065 |
+
"name": "image",
|
| 1066 |
+
"type": "IMAGE",
|
| 1067 |
+
"link": 180
|
| 1068 |
+
},
|
| 1069 |
+
{
|
| 1070 |
+
"name": "attn_mask",
|
| 1071 |
+
"type": "MASK",
|
| 1072 |
+
"link": null
|
| 1073 |
+
}
|
| 1074 |
+
],
|
| 1075 |
+
"outputs": [
|
| 1076 |
+
{
|
| 1077 |
+
"name": "MODEL",
|
| 1078 |
+
"type": "MODEL",
|
| 1079 |
+
"links": [
|
| 1080 |
+
181
|
| 1081 |
+
],
|
| 1082 |
+
"shape": 3,
|
| 1083 |
+
"slot_index": 0
|
| 1084 |
+
}
|
| 1085 |
+
],
|
| 1086 |
+
"properties": {
|
| 1087 |
+
"Node name for S&R": "IPAdapter"
|
| 1088 |
+
},
|
| 1089 |
+
"widgets_values": [
|
| 1090 |
+
1,
|
| 1091 |
+
0,
|
| 1092 |
+
1
|
| 1093 |
+
]
|
| 1094 |
+
},
|
| 1095 |
+
{
|
| 1096 |
+
"id": 70,
|
| 1097 |
+
"type": "IPAdapterUnifiedLoader",
|
| 1098 |
+
"pos": [
|
| 1099 |
+
-479,
|
| 1100 |
+
1256
|
| 1101 |
+
],
|
| 1102 |
+
"size": [
|
| 1103 |
+
382.11956787109375,
|
| 1104 |
+
78
|
| 1105 |
+
],
|
| 1106 |
+
"flags": {},
|
| 1107 |
+
"order": 10,
|
| 1108 |
+
"mode": 0,
|
| 1109 |
+
"inputs": [
|
| 1110 |
+
{
|
| 1111 |
+
"name": "model",
|
| 1112 |
+
"type": "MODEL",
|
| 1113 |
+
"link": 178
|
| 1114 |
+
},
|
| 1115 |
+
{
|
| 1116 |
+
"name": "ipadapter",
|
| 1117 |
+
"type": "IPADAPTER",
|
| 1118 |
+
"link": null
|
| 1119 |
+
}
|
| 1120 |
+
],
|
| 1121 |
+
"outputs": [
|
| 1122 |
+
{
|
| 1123 |
+
"name": "model",
|
| 1124 |
+
"type": "MODEL",
|
| 1125 |
+
"links": [
|
| 1126 |
+
179
|
| 1127 |
+
],
|
| 1128 |
+
"shape": 3,
|
| 1129 |
+
"slot_index": 0
|
| 1130 |
+
},
|
| 1131 |
+
{
|
| 1132 |
+
"name": "ipadapter",
|
| 1133 |
+
"type": "IPADAPTER",
|
| 1134 |
+
"links": [
|
| 1135 |
+
183
|
| 1136 |
+
],
|
| 1137 |
+
"shape": 3
|
| 1138 |
+
}
|
| 1139 |
+
],
|
| 1140 |
+
"properties": {
|
| 1141 |
+
"Node name for S&R": "IPAdapterUnifiedLoader"
|
| 1142 |
+
},
|
| 1143 |
+
"widgets_values": [
|
| 1144 |
+
"STANDARD (medium strength)"
|
| 1145 |
+
]
|
| 1146 |
+
},
|
| 1147 |
+
{
|
| 1148 |
+
"id": 33,
|
| 1149 |
+
"type": "LoadImage",
|
| 1150 |
+
"pos": [
|
| 1151 |
+
-469,
|
| 1152 |
+
71
|
| 1153 |
+
],
|
| 1154 |
+
"size": {
|
| 1155 |
+
"0": 315,
|
| 1156 |
+
"1": 314
|
| 1157 |
+
},
|
| 1158 |
+
"flags": {},
|
| 1159 |
+
"order": 8,
|
| 1160 |
+
"mode": 0,
|
| 1161 |
+
"outputs": [
|
| 1162 |
+
{
|
| 1163 |
+
"name": "IMAGE",
|
| 1164 |
+
"type": "IMAGE",
|
| 1165 |
+
"links": [
|
| 1166 |
+
133,
|
| 1167 |
+
168
|
| 1168 |
+
],
|
| 1169 |
+
"shape": 3,
|
| 1170 |
+
"slot_index": 0
|
| 1171 |
+
},
|
| 1172 |
+
{
|
| 1173 |
+
"name": "MASK",
|
| 1174 |
+
"type": "MASK",
|
| 1175 |
+
"links": [
|
| 1176 |
+
184
|
| 1177 |
+
],
|
| 1178 |
+
"shape": 3,
|
| 1179 |
+
"slot_index": 1
|
| 1180 |
+
}
|
| 1181 |
+
],
|
| 1182 |
+
"properties": {
|
| 1183 |
+
"Node name for S&R": "LoadImage"
|
| 1184 |
+
},
|
| 1185 |
+
"widgets_values": [
|
| 1186 |
+
"base1024 (1).png",
|
| 1187 |
+
"image"
|
| 1188 |
+
]
|
| 1189 |
+
},
|
| 1190 |
+
{
|
| 1191 |
+
"id": 52,
|
| 1192 |
+
"type": "INPAINT_LoadInpaintModel",
|
| 1193 |
+
"pos": [
|
| 1194 |
+
121,
|
| 1195 |
+
756
|
| 1196 |
+
],
|
| 1197 |
+
"size": {
|
| 1198 |
+
"0": 315,
|
| 1199 |
+
"1": 58
|
| 1200 |
+
},
|
| 1201 |
+
"flags": {},
|
| 1202 |
+
"order": 9,
|
| 1203 |
+
"mode": 0,
|
| 1204 |
+
"outputs": [
|
| 1205 |
+
{
|
| 1206 |
+
"name": "INPAINT_MODEL",
|
| 1207 |
+
"type": "INPAINT_MODEL",
|
| 1208 |
+
"links": [
|
| 1209 |
+
143
|
| 1210 |
+
],
|
| 1211 |
+
"shape": 3,
|
| 1212 |
+
"slot_index": 0
|
| 1213 |
+
}
|
| 1214 |
+
],
|
| 1215 |
+
"properties": {
|
| 1216 |
+
"Node name for S&R": "INPAINT_LoadInpaintModel"
|
| 1217 |
+
},
|
| 1218 |
+
"widgets_values": [
|
| 1219 |
+
"Places_512_FullData_G.pth"
|
| 1220 |
+
]
|
| 1221 |
+
},
|
| 1222 |
+
{
|
| 1223 |
+
"id": 49,
|
| 1224 |
+
"type": "INPAINT_InpaintWithModel",
|
| 1225 |
+
"pos": [
|
| 1226 |
+
125,
|
| 1227 |
+
859
|
| 1228 |
+
],
|
| 1229 |
+
"size": {
|
| 1230 |
+
"0": 311.1282043457031,
|
| 1231 |
+
"1": 142
|
| 1232 |
+
},
|
| 1233 |
+
"flags": {},
|
| 1234 |
+
"order": 19,
|
| 1235 |
+
"mode": 0,
|
| 1236 |
+
"inputs": [
|
| 1237 |
+
{
|
| 1238 |
+
"name": "inpaint_model",
|
| 1239 |
+
"type": "INPAINT_MODEL",
|
| 1240 |
+
"link": 143
|
| 1241 |
+
},
|
| 1242 |
+
{
|
| 1243 |
+
"name": "image",
|
| 1244 |
+
"type": "IMAGE",
|
| 1245 |
+
"link": 144
|
| 1246 |
+
},
|
| 1247 |
+
{
|
| 1248 |
+
"name": "mask",
|
| 1249 |
+
"type": "MASK",
|
| 1250 |
+
"link": 145
|
| 1251 |
+
},
|
| 1252 |
+
{
|
| 1253 |
+
"name": "optional_upscale_model",
|
| 1254 |
+
"type": "UPSCALE_MODEL",
|
| 1255 |
+
"link": null
|
| 1256 |
+
}
|
| 1257 |
+
],
|
| 1258 |
+
"outputs": [
|
| 1259 |
+
{
|
| 1260 |
+
"name": "IMAGE",
|
| 1261 |
+
"type": "IMAGE",
|
| 1262 |
+
"links": [
|
| 1263 |
+
148
|
| 1264 |
+
],
|
| 1265 |
+
"shape": 3,
|
| 1266 |
+
"slot_index": 0
|
| 1267 |
+
}
|
| 1268 |
+
],
|
| 1269 |
+
"properties": {
|
| 1270 |
+
"Node name for S&R": "INPAINT_InpaintWithModel"
|
| 1271 |
+
},
|
| 1272 |
+
"widgets_values": [
|
| 1273 |
+
147163031900914,
|
| 1274 |
+
"randomize"
|
| 1275 |
+
]
|
| 1276 |
+
}
|
| 1277 |
+
],
|
| 1278 |
+
"links": [
|
| 1279 |
+
[
|
| 1280 |
+
35,
|
| 1281 |
+
19,
|
| 1282 |
+
1,
|
| 1283 |
+
10,
|
| 1284 |
+
0,
|
| 1285 |
+
"CLIP"
|
| 1286 |
+
],
|
| 1287 |
+
[
|
| 1288 |
+
43,
|
| 1289 |
+
19,
|
| 1290 |
+
2,
|
| 1291 |
+
14,
|
| 1292 |
+
1,
|
| 1293 |
+
"VAE"
|
| 1294 |
+
],
|
| 1295 |
+
[
|
| 1296 |
+
62,
|
| 1297 |
+
35,
|
| 1298 |
+
0,
|
| 1299 |
+
36,
|
| 1300 |
+
1,
|
| 1301 |
+
"INPAINT_PATCH"
|
| 1302 |
+
],
|
| 1303 |
+
[
|
| 1304 |
+
88,
|
| 1305 |
+
19,
|
| 1306 |
+
1,
|
| 1307 |
+
9,
|
| 1308 |
+
0,
|
| 1309 |
+
"CLIP"
|
| 1310 |
+
],
|
| 1311 |
+
[
|
| 1312 |
+
97,
|
| 1313 |
+
40,
|
| 1314 |
+
0,
|
| 1315 |
+
14,
|
| 1316 |
+
0,
|
| 1317 |
+
"LATENT"
|
| 1318 |
+
],
|
| 1319 |
+
[
|
| 1320 |
+
120,
|
| 1321 |
+
36,
|
| 1322 |
+
0,
|
| 1323 |
+
40,
|
| 1324 |
+
0,
|
| 1325 |
+
"MODEL"
|
| 1326 |
+
],
|
| 1327 |
+
[
|
| 1328 |
+
122,
|
| 1329 |
+
9,
|
| 1330 |
+
0,
|
| 1331 |
+
44,
|
| 1332 |
+
0,
|
| 1333 |
+
"CONDITIONING"
|
| 1334 |
+
],
|
| 1335 |
+
[
|
| 1336 |
+
123,
|
| 1337 |
+
10,
|
| 1338 |
+
0,
|
| 1339 |
+
44,
|
| 1340 |
+
1,
|
| 1341 |
+
"CONDITIONING"
|
| 1342 |
+
],
|
| 1343 |
+
[
|
| 1344 |
+
124,
|
| 1345 |
+
44,
|
| 1346 |
+
0,
|
| 1347 |
+
40,
|
| 1348 |
+
1,
|
| 1349 |
+
"CONDITIONING"
|
| 1350 |
+
],
|
| 1351 |
+
[
|
| 1352 |
+
125,
|
| 1353 |
+
44,
|
| 1354 |
+
1,
|
| 1355 |
+
40,
|
| 1356 |
+
2,
|
| 1357 |
+
"CONDITIONING"
|
| 1358 |
+
],
|
| 1359 |
+
[
|
| 1360 |
+
126,
|
| 1361 |
+
44,
|
| 1362 |
+
3,
|
| 1363 |
+
40,
|
| 1364 |
+
3,
|
| 1365 |
+
"LATENT"
|
| 1366 |
+
],
|
| 1367 |
+
[
|
| 1368 |
+
127,
|
| 1369 |
+
44,
|
| 1370 |
+
2,
|
| 1371 |
+
36,
|
| 1372 |
+
2,
|
| 1373 |
+
"LATENT"
|
| 1374 |
+
],
|
| 1375 |
+
[
|
| 1376 |
+
128,
|
| 1377 |
+
19,
|
| 1378 |
+
2,
|
| 1379 |
+
44,
|
| 1380 |
+
2,
|
| 1381 |
+
"VAE"
|
| 1382 |
+
],
|
| 1383 |
+
[
|
| 1384 |
+
133,
|
| 1385 |
+
33,
|
| 1386 |
+
0,
|
| 1387 |
+
45,
|
| 1388 |
+
0,
|
| 1389 |
+
"IMAGE"
|
| 1390 |
+
],
|
| 1391 |
+
[
|
| 1392 |
+
136,
|
| 1393 |
+
46,
|
| 1394 |
+
0,
|
| 1395 |
+
43,
|
| 1396 |
+
0,
|
| 1397 |
+
"IMAGE"
|
| 1398 |
+
],
|
| 1399 |
+
[
|
| 1400 |
+
137,
|
| 1401 |
+
47,
|
| 1402 |
+
0,
|
| 1403 |
+
43,
|
| 1404 |
+
1,
|
| 1405 |
+
"MASK"
|
| 1406 |
+
],
|
| 1407 |
+
[
|
| 1408 |
+
138,
|
| 1409 |
+
47,
|
| 1410 |
+
0,
|
| 1411 |
+
44,
|
| 1412 |
+
4,
|
| 1413 |
+
"MASK"
|
| 1414 |
+
],
|
| 1415 |
+
[
|
| 1416 |
+
140,
|
| 1417 |
+
50,
|
| 1418 |
+
0,
|
| 1419 |
+
44,
|
| 1420 |
+
3,
|
| 1421 |
+
"IMAGE"
|
| 1422 |
+
],
|
| 1423 |
+
[
|
| 1424 |
+
142,
|
| 1425 |
+
51,
|
| 1426 |
+
0,
|
| 1427 |
+
50,
|
| 1428 |
+
0,
|
| 1429 |
+
"*"
|
| 1430 |
+
],
|
| 1431 |
+
[
|
| 1432 |
+
143,
|
| 1433 |
+
52,
|
| 1434 |
+
0,
|
| 1435 |
+
49,
|
| 1436 |
+
0,
|
| 1437 |
+
"INPAINT_MODEL"
|
| 1438 |
+
],
|
| 1439 |
+
[
|
| 1440 |
+
144,
|
| 1441 |
+
46,
|
| 1442 |
+
0,
|
| 1443 |
+
49,
|
| 1444 |
+
1,
|
| 1445 |
+
"IMAGE"
|
| 1446 |
+
],
|
| 1447 |
+
[
|
| 1448 |
+
145,
|
| 1449 |
+
47,
|
| 1450 |
+
0,
|
| 1451 |
+
49,
|
| 1452 |
+
2,
|
| 1453 |
+
"MASK"
|
| 1454 |
+
],
|
| 1455 |
+
[
|
| 1456 |
+
146,
|
| 1457 |
+
48,
|
| 1458 |
+
0,
|
| 1459 |
+
53,
|
| 1460 |
+
0,
|
| 1461 |
+
"IMAGE"
|
| 1462 |
+
],
|
| 1463 |
+
[
|
| 1464 |
+
147,
|
| 1465 |
+
43,
|
| 1466 |
+
0,
|
| 1467 |
+
54,
|
| 1468 |
+
0,
|
| 1469 |
+
"IMAGE"
|
| 1470 |
+
],
|
| 1471 |
+
[
|
| 1472 |
+
148,
|
| 1473 |
+
49,
|
| 1474 |
+
0,
|
| 1475 |
+
55,
|
| 1476 |
+
0,
|
| 1477 |
+
"IMAGE"
|
| 1478 |
+
],
|
| 1479 |
+
[
|
| 1480 |
+
150,
|
| 1481 |
+
46,
|
| 1482 |
+
0,
|
| 1483 |
+
48,
|
| 1484 |
+
0,
|
| 1485 |
+
"IMAGE"
|
| 1486 |
+
],
|
| 1487 |
+
[
|
| 1488 |
+
151,
|
| 1489 |
+
47,
|
| 1490 |
+
0,
|
| 1491 |
+
48,
|
| 1492 |
+
1,
|
| 1493 |
+
"MASK"
|
| 1494 |
+
],
|
| 1495 |
+
[
|
| 1496 |
+
154,
|
| 1497 |
+
46,
|
| 1498 |
+
0,
|
| 1499 |
+
61,
|
| 1500 |
+
0,
|
| 1501 |
+
"*"
|
| 1502 |
+
],
|
| 1503 |
+
[
|
| 1504 |
+
155,
|
| 1505 |
+
65,
|
| 1506 |
+
0,
|
| 1507 |
+
59,
|
| 1508 |
+
0,
|
| 1509 |
+
"IMAGE"
|
| 1510 |
+
],
|
| 1511 |
+
[
|
| 1512 |
+
156,
|
| 1513 |
+
14,
|
| 1514 |
+
0,
|
| 1515 |
+
65,
|
| 1516 |
+
1,
|
| 1517 |
+
"IMAGE"
|
| 1518 |
+
],
|
| 1519 |
+
[
|
| 1520 |
+
159,
|
| 1521 |
+
47,
|
| 1522 |
+
0,
|
| 1523 |
+
65,
|
| 1524 |
+
2,
|
| 1525 |
+
"MASK"
|
| 1526 |
+
],
|
| 1527 |
+
[
|
| 1528 |
+
160,
|
| 1529 |
+
46,
|
| 1530 |
+
0,
|
| 1531 |
+
65,
|
| 1532 |
+
0,
|
| 1533 |
+
"IMAGE"
|
| 1534 |
+
],
|
| 1535 |
+
[
|
| 1536 |
+
167,
|
| 1537 |
+
48,
|
| 1538 |
+
0,
|
| 1539 |
+
51,
|
| 1540 |
+
0,
|
| 1541 |
+
"*"
|
| 1542 |
+
],
|
| 1543 |
+
[
|
| 1544 |
+
168,
|
| 1545 |
+
33,
|
| 1546 |
+
0,
|
| 1547 |
+
46,
|
| 1548 |
+
0,
|
| 1549 |
+
"*"
|
| 1550 |
+
],
|
| 1551 |
+
[
|
| 1552 |
+
178,
|
| 1553 |
+
19,
|
| 1554 |
+
0,
|
| 1555 |
+
70,
|
| 1556 |
+
0,
|
| 1557 |
+
"MODEL"
|
| 1558 |
+
],
|
| 1559 |
+
[
|
| 1560 |
+
179,
|
| 1561 |
+
70,
|
| 1562 |
+
0,
|
| 1563 |
+
71,
|
| 1564 |
+
0,
|
| 1565 |
+
"MODEL"
|
| 1566 |
+
],
|
| 1567 |
+
[
|
| 1568 |
+
180,
|
| 1569 |
+
46,
|
| 1570 |
+
0,
|
| 1571 |
+
71,
|
| 1572 |
+
2,
|
| 1573 |
+
"IMAGE"
|
| 1574 |
+
],
|
| 1575 |
+
[
|
| 1576 |
+
181,
|
| 1577 |
+
71,
|
| 1578 |
+
0,
|
| 1579 |
+
36,
|
| 1580 |
+
0,
|
| 1581 |
+
"MODEL"
|
| 1582 |
+
],
|
| 1583 |
+
[
|
| 1584 |
+
183,
|
| 1585 |
+
70,
|
| 1586 |
+
1,
|
| 1587 |
+
71,
|
| 1588 |
+
1,
|
| 1589 |
+
"IPADAPTER"
|
| 1590 |
+
],
|
| 1591 |
+
[
|
| 1592 |
+
184,
|
| 1593 |
+
33,
|
| 1594 |
+
1,
|
| 1595 |
+
47,
|
| 1596 |
+
0,
|
| 1597 |
+
"*"
|
| 1598 |
+
]
|
| 1599 |
+
],
|
| 1600 |
+
"groups": [
|
| 1601 |
+
{
|
| 1602 |
+
"title": "Input Image and Mask",
|
| 1603 |
+
"bounding": [
|
| 1604 |
+
-496,
|
| 1605 |
+
-2,
|
| 1606 |
+
452,
|
| 1607 |
+
1072
|
| 1608 |
+
],
|
| 1609 |
+
"color": "#3f789e",
|
| 1610 |
+
"font_size": 24
|
| 1611 |
+
},
|
| 1612 |
+
{
|
| 1613 |
+
"title": "Preprocess",
|
| 1614 |
+
"bounding": [
|
| 1615 |
+
93,
|
| 1616 |
+
-2,
|
| 1617 |
+
631,
|
| 1618 |
+
1126
|
| 1619 |
+
],
|
| 1620 |
+
"color": "#b06634",
|
| 1621 |
+
"font_size": 24
|
| 1622 |
+
},
|
| 1623 |
+
{
|
| 1624 |
+
"title": "Postprocess",
|
| 1625 |
+
"bounding": [
|
| 1626 |
+
891,
|
| 1627 |
+
790,
|
| 1628 |
+
335,
|
| 1629 |
+
331
|
| 1630 |
+
],
|
| 1631 |
+
"color": "#8AA",
|
| 1632 |
+
"font_size": 24
|
| 1633 |
+
}
|
| 1634 |
+
],
|
| 1635 |
+
"config": {},
|
| 1636 |
+
"extra": {},
|
| 1637 |
+
"version": 0.4
|
| 1638 |
+
}
|
sage2/workflows/inpaint-refine.json
ADDED
|
@@ -0,0 +1,696 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"last_node_id": 66,
|
| 3 |
+
"last_link_id": 178,
|
| 4 |
+
"nodes": [
|
| 5 |
+
{
|
| 6 |
+
"id": 10,
|
| 7 |
+
"type": "CLIPTextEncode",
|
| 8 |
+
"pos": [
|
| 9 |
+
-455,
|
| 10 |
+
557
|
| 11 |
+
],
|
| 12 |
+
"size": [
|
| 13 |
+
321.6668823242188,
|
| 14 |
+
76
|
| 15 |
+
],
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 3,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"inputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "clip",
|
| 22 |
+
"type": "CLIP",
|
| 23 |
+
"link": 35
|
| 24 |
+
}
|
| 25 |
+
],
|
| 26 |
+
"outputs": [
|
| 27 |
+
{
|
| 28 |
+
"name": "CONDITIONING",
|
| 29 |
+
"type": "CONDITIONING",
|
| 30 |
+
"links": [
|
| 31 |
+
123
|
| 32 |
+
],
|
| 33 |
+
"shape": 3,
|
| 34 |
+
"slot_index": 0
|
| 35 |
+
}
|
| 36 |
+
],
|
| 37 |
+
"properties": {
|
| 38 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 39 |
+
},
|
| 40 |
+
"widgets_values": [
|
| 41 |
+
"text, watermark"
|
| 42 |
+
],
|
| 43 |
+
"color": "#322",
|
| 44 |
+
"bgcolor": "#533"
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"id": 19,
|
| 48 |
+
"type": "CheckpointLoaderSimple",
|
| 49 |
+
"pos": [
|
| 50 |
+
-452,
|
| 51 |
+
672
|
| 52 |
+
],
|
| 53 |
+
"size": [
|
| 54 |
+
409.4665283203125,
|
| 55 |
+
98
|
| 56 |
+
],
|
| 57 |
+
"flags": {},
|
| 58 |
+
"order": 0,
|
| 59 |
+
"mode": 0,
|
| 60 |
+
"outputs": [
|
| 61 |
+
{
|
| 62 |
+
"name": "MODEL",
|
| 63 |
+
"type": "MODEL",
|
| 64 |
+
"links": [
|
| 65 |
+
60
|
| 66 |
+
],
|
| 67 |
+
"shape": 3,
|
| 68 |
+
"slot_index": 0
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"name": "CLIP",
|
| 72 |
+
"type": "CLIP",
|
| 73 |
+
"links": [
|
| 74 |
+
35,
|
| 75 |
+
88
|
| 76 |
+
],
|
| 77 |
+
"shape": 3,
|
| 78 |
+
"slot_index": 1
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"name": "VAE",
|
| 82 |
+
"type": "VAE",
|
| 83 |
+
"links": [
|
| 84 |
+
43,
|
| 85 |
+
128
|
| 86 |
+
],
|
| 87 |
+
"shape": 3,
|
| 88 |
+
"slot_index": 2
|
| 89 |
+
}
|
| 90 |
+
],
|
| 91 |
+
"properties": {
|
| 92 |
+
"Node name for S&R": "CheckpointLoaderSimple"
|
| 93 |
+
},
|
| 94 |
+
"widgets_values": [
|
| 95 |
+
"juggernautXL_version6Rundiffusion.safetensors"
|
| 96 |
+
]
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"id": 44,
|
| 100 |
+
"type": "INPAINT_VAEEncodeInpaintConditioning",
|
| 101 |
+
"pos": [
|
| 102 |
+
-38,
|
| 103 |
+
250
|
| 104 |
+
],
|
| 105 |
+
"size": {
|
| 106 |
+
"0": 292.20001220703125,
|
| 107 |
+
"1": 106
|
| 108 |
+
},
|
| 109 |
+
"flags": {},
|
| 110 |
+
"order": 5,
|
| 111 |
+
"mode": 0,
|
| 112 |
+
"inputs": [
|
| 113 |
+
{
|
| 114 |
+
"name": "positive",
|
| 115 |
+
"type": "CONDITIONING",
|
| 116 |
+
"link": 122
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"name": "negative",
|
| 120 |
+
"type": "CONDITIONING",
|
| 121 |
+
"link": 123
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"name": "vae",
|
| 125 |
+
"type": "VAE",
|
| 126 |
+
"link": 128
|
| 127 |
+
},
|
| 128 |
+
{
|
| 129 |
+
"name": "pixels",
|
| 130 |
+
"type": "IMAGE",
|
| 131 |
+
"link": 178
|
| 132 |
+
},
|
| 133 |
+
{
|
| 134 |
+
"name": "mask",
|
| 135 |
+
"type": "MASK",
|
| 136 |
+
"link": 177
|
| 137 |
+
}
|
| 138 |
+
],
|
| 139 |
+
"outputs": [
|
| 140 |
+
{
|
| 141 |
+
"name": "positive",
|
| 142 |
+
"type": "CONDITIONING",
|
| 143 |
+
"links": [
|
| 144 |
+
124
|
| 145 |
+
],
|
| 146 |
+
"shape": 3,
|
| 147 |
+
"slot_index": 0
|
| 148 |
+
},
|
| 149 |
+
{
|
| 150 |
+
"name": "negative",
|
| 151 |
+
"type": "CONDITIONING",
|
| 152 |
+
"links": [
|
| 153 |
+
125
|
| 154 |
+
],
|
| 155 |
+
"shape": 3,
|
| 156 |
+
"slot_index": 1
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
"name": "latent_inpaint",
|
| 160 |
+
"type": "LATENT",
|
| 161 |
+
"links": [
|
| 162 |
+
127
|
| 163 |
+
],
|
| 164 |
+
"shape": 3,
|
| 165 |
+
"slot_index": 2
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"name": "latent_samples",
|
| 169 |
+
"type": "LATENT",
|
| 170 |
+
"links": [
|
| 171 |
+
126
|
| 172 |
+
],
|
| 173 |
+
"shape": 3,
|
| 174 |
+
"slot_index": 3
|
| 175 |
+
}
|
| 176 |
+
],
|
| 177 |
+
"properties": {
|
| 178 |
+
"Node name for S&R": "INPAINT_VAEEncodeInpaintConditioning"
|
| 179 |
+
},
|
| 180 |
+
"color": "#323",
|
| 181 |
+
"bgcolor": "#535"
|
| 182 |
+
},
|
| 183 |
+
{
|
| 184 |
+
"id": 35,
|
| 185 |
+
"type": "INPAINT_LoadFooocusInpaint",
|
| 186 |
+
"pos": [
|
| 187 |
+
-29,
|
| 188 |
+
400
|
| 189 |
+
],
|
| 190 |
+
"size": {
|
| 191 |
+
"0": 276.6825256347656,
|
| 192 |
+
"1": 82
|
| 193 |
+
},
|
| 194 |
+
"flags": {},
|
| 195 |
+
"order": 1,
|
| 196 |
+
"mode": 0,
|
| 197 |
+
"outputs": [
|
| 198 |
+
{
|
| 199 |
+
"name": "INPAINT_PATCH",
|
| 200 |
+
"type": "INPAINT_PATCH",
|
| 201 |
+
"links": [
|
| 202 |
+
62
|
| 203 |
+
],
|
| 204 |
+
"shape": 3,
|
| 205 |
+
"slot_index": 0
|
| 206 |
+
}
|
| 207 |
+
],
|
| 208 |
+
"properties": {
|
| 209 |
+
"Node name for S&R": "INPAINT_LoadFooocusInpaint"
|
| 210 |
+
},
|
| 211 |
+
"widgets_values": [
|
| 212 |
+
"fooocus_inpaint_head.pth",
|
| 213 |
+
"inpaint_v26.fooocus.patch"
|
| 214 |
+
],
|
| 215 |
+
"color": "#323",
|
| 216 |
+
"bgcolor": "#535"
|
| 217 |
+
},
|
| 218 |
+
{
|
| 219 |
+
"id": 36,
|
| 220 |
+
"type": "INPAINT_ApplyFooocusInpaint",
|
| 221 |
+
"pos": [
|
| 222 |
+
338,
|
| 223 |
+
509
|
| 224 |
+
],
|
| 225 |
+
"size": {
|
| 226 |
+
"0": 191.45639038085938,
|
| 227 |
+
"1": 66
|
| 228 |
+
},
|
| 229 |
+
"flags": {},
|
| 230 |
+
"order": 6,
|
| 231 |
+
"mode": 0,
|
| 232 |
+
"inputs": [
|
| 233 |
+
{
|
| 234 |
+
"name": "model",
|
| 235 |
+
"type": "MODEL",
|
| 236 |
+
"link": 60
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"name": "patch",
|
| 240 |
+
"type": "INPAINT_PATCH",
|
| 241 |
+
"link": 62
|
| 242 |
+
},
|
| 243 |
+
{
|
| 244 |
+
"name": "latent",
|
| 245 |
+
"type": "LATENT",
|
| 246 |
+
"link": 127
|
| 247 |
+
}
|
| 248 |
+
],
|
| 249 |
+
"outputs": [
|
| 250 |
+
{
|
| 251 |
+
"name": "MODEL",
|
| 252 |
+
"type": "MODEL",
|
| 253 |
+
"links": [
|
| 254 |
+
120
|
| 255 |
+
],
|
| 256 |
+
"shape": 3,
|
| 257 |
+
"slot_index": 0
|
| 258 |
+
}
|
| 259 |
+
],
|
| 260 |
+
"properties": {
|
| 261 |
+
"Node name for S&R": "INPAINT_ApplyFooocusInpaint"
|
| 262 |
+
},
|
| 263 |
+
"color": "#323",
|
| 264 |
+
"bgcolor": "#535"
|
| 265 |
+
},
|
| 266 |
+
{
|
| 267 |
+
"id": 14,
|
| 268 |
+
"type": "VAEDecode",
|
| 269 |
+
"pos": [
|
| 270 |
+
673,
|
| 271 |
+
167
|
| 272 |
+
],
|
| 273 |
+
"size": [
|
| 274 |
+
140,
|
| 275 |
+
49.74785232543945
|
| 276 |
+
],
|
| 277 |
+
"flags": {},
|
| 278 |
+
"order": 8,
|
| 279 |
+
"mode": 0,
|
| 280 |
+
"inputs": [
|
| 281 |
+
{
|
| 282 |
+
"name": "samples",
|
| 283 |
+
"type": "LATENT",
|
| 284 |
+
"link": 97
|
| 285 |
+
},
|
| 286 |
+
{
|
| 287 |
+
"name": "vae",
|
| 288 |
+
"type": "VAE",
|
| 289 |
+
"link": 43
|
| 290 |
+
}
|
| 291 |
+
],
|
| 292 |
+
"outputs": [
|
| 293 |
+
{
|
| 294 |
+
"name": "IMAGE",
|
| 295 |
+
"type": "IMAGE",
|
| 296 |
+
"links": [
|
| 297 |
+
156
|
| 298 |
+
],
|
| 299 |
+
"shape": 3,
|
| 300 |
+
"slot_index": 0
|
| 301 |
+
}
|
| 302 |
+
],
|
| 303 |
+
"properties": {
|
| 304 |
+
"Node name for S&R": "VAEDecode"
|
| 305 |
+
}
|
| 306 |
+
},
|
| 307 |
+
{
|
| 308 |
+
"id": 65,
|
| 309 |
+
"type": "ImageCompositeMasked",
|
| 310 |
+
"pos": [
|
| 311 |
+
840,
|
| 312 |
+
70
|
| 313 |
+
],
|
| 314 |
+
"size": [
|
| 315 |
+
240.56597900390625,
|
| 316 |
+
146
|
| 317 |
+
],
|
| 318 |
+
"flags": {},
|
| 319 |
+
"order": 9,
|
| 320 |
+
"mode": 0,
|
| 321 |
+
"inputs": [
|
| 322 |
+
{
|
| 323 |
+
"name": "destination",
|
| 324 |
+
"type": "IMAGE",
|
| 325 |
+
"link": 174
|
| 326 |
+
},
|
| 327 |
+
{
|
| 328 |
+
"name": "source",
|
| 329 |
+
"type": "IMAGE",
|
| 330 |
+
"link": 156
|
| 331 |
+
},
|
| 332 |
+
{
|
| 333 |
+
"name": "mask",
|
| 334 |
+
"type": "MASK",
|
| 335 |
+
"link": 175
|
| 336 |
+
}
|
| 337 |
+
],
|
| 338 |
+
"outputs": [
|
| 339 |
+
{
|
| 340 |
+
"name": "IMAGE",
|
| 341 |
+
"type": "IMAGE",
|
| 342 |
+
"links": [
|
| 343 |
+
155
|
| 344 |
+
],
|
| 345 |
+
"shape": 3,
|
| 346 |
+
"slot_index": 0
|
| 347 |
+
}
|
| 348 |
+
],
|
| 349 |
+
"properties": {
|
| 350 |
+
"Node name for S&R": "ImageCompositeMasked"
|
| 351 |
+
},
|
| 352 |
+
"widgets_values": [
|
| 353 |
+
0,
|
| 354 |
+
0,
|
| 355 |
+
false
|
| 356 |
+
]
|
| 357 |
+
},
|
| 358 |
+
{
|
| 359 |
+
"id": 59,
|
| 360 |
+
"type": "SaveImage",
|
| 361 |
+
"pos": [
|
| 362 |
+
670,
|
| 363 |
+
280
|
| 364 |
+
],
|
| 365 |
+
"size": [
|
| 366 |
+
420.46597900390634,
|
| 367 |
+
474.3479354858399
|
| 368 |
+
],
|
| 369 |
+
"flags": {},
|
| 370 |
+
"order": 10,
|
| 371 |
+
"mode": 0,
|
| 372 |
+
"inputs": [
|
| 373 |
+
{
|
| 374 |
+
"name": "images",
|
| 375 |
+
"type": "IMAGE",
|
| 376 |
+
"link": 155
|
| 377 |
+
}
|
| 378 |
+
],
|
| 379 |
+
"properties": {},
|
| 380 |
+
"widgets_values": [
|
| 381 |
+
"ComfyUI"
|
| 382 |
+
]
|
| 383 |
+
},
|
| 384 |
+
{
|
| 385 |
+
"id": 9,
|
| 386 |
+
"type": "CLIPTextEncode",
|
| 387 |
+
"pos": [
|
| 388 |
+
-456,
|
| 389 |
+
425
|
| 390 |
+
],
|
| 391 |
+
"size": [
|
| 392 |
+
326.6668823242188,
|
| 393 |
+
95.14787673950195
|
| 394 |
+
],
|
| 395 |
+
"flags": {},
|
| 396 |
+
"order": 4,
|
| 397 |
+
"mode": 0,
|
| 398 |
+
"inputs": [
|
| 399 |
+
{
|
| 400 |
+
"name": "clip",
|
| 401 |
+
"type": "CLIP",
|
| 402 |
+
"link": 88
|
| 403 |
+
}
|
| 404 |
+
],
|
| 405 |
+
"outputs": [
|
| 406 |
+
{
|
| 407 |
+
"name": "CONDITIONING",
|
| 408 |
+
"type": "CONDITIONING",
|
| 409 |
+
"links": [
|
| 410 |
+
122
|
| 411 |
+
],
|
| 412 |
+
"shape": 3,
|
| 413 |
+
"slot_index": 0
|
| 414 |
+
}
|
| 415 |
+
],
|
| 416 |
+
"properties": {
|
| 417 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 418 |
+
},
|
| 419 |
+
"widgets_values": [
|
| 420 |
+
"POSITIVE PROMPT"
|
| 421 |
+
],
|
| 422 |
+
"color": "#232",
|
| 423 |
+
"bgcolor": "#353"
|
| 424 |
+
},
|
| 425 |
+
{
|
| 426 |
+
"id": 33,
|
| 427 |
+
"type": "LoadImage",
|
| 428 |
+
"pos": [
|
| 429 |
+
-460,
|
| 430 |
+
74
|
| 431 |
+
],
|
| 432 |
+
"size": [
|
| 433 |
+
295.56678466796876,
|
| 434 |
+
314
|
| 435 |
+
],
|
| 436 |
+
"flags": {},
|
| 437 |
+
"order": 2,
|
| 438 |
+
"mode": 0,
|
| 439 |
+
"outputs": [
|
| 440 |
+
{
|
| 441 |
+
"name": "IMAGE",
|
| 442 |
+
"type": "IMAGE",
|
| 443 |
+
"links": [
|
| 444 |
+
174,
|
| 445 |
+
178
|
| 446 |
+
],
|
| 447 |
+
"shape": 3,
|
| 448 |
+
"slot_index": 0
|
| 449 |
+
},
|
| 450 |
+
{
|
| 451 |
+
"name": "MASK",
|
| 452 |
+
"type": "MASK",
|
| 453 |
+
"links": [
|
| 454 |
+
175,
|
| 455 |
+
177
|
| 456 |
+
],
|
| 457 |
+
"shape": 3,
|
| 458 |
+
"slot_index": 1
|
| 459 |
+
}
|
| 460 |
+
],
|
| 461 |
+
"properties": {
|
| 462 |
+
"Node name for S&R": "LoadImage"
|
| 463 |
+
},
|
| 464 |
+
"widgets_values": [
|
| 465 |
+
"base1024.png",
|
| 466 |
+
"image"
|
| 467 |
+
]
|
| 468 |
+
},
|
| 469 |
+
{
|
| 470 |
+
"id": 40,
|
| 471 |
+
"type": "KSampler",
|
| 472 |
+
"pos": [
|
| 473 |
+
331,
|
| 474 |
+
177
|
| 475 |
+
],
|
| 476 |
+
"size": {
|
| 477 |
+
"0": 315,
|
| 478 |
+
"1": 262
|
| 479 |
+
},
|
| 480 |
+
"flags": {},
|
| 481 |
+
"order": 7,
|
| 482 |
+
"mode": 0,
|
| 483 |
+
"inputs": [
|
| 484 |
+
{
|
| 485 |
+
"name": "model",
|
| 486 |
+
"type": "MODEL",
|
| 487 |
+
"link": 120
|
| 488 |
+
},
|
| 489 |
+
{
|
| 490 |
+
"name": "positive",
|
| 491 |
+
"type": "CONDITIONING",
|
| 492 |
+
"link": 124
|
| 493 |
+
},
|
| 494 |
+
{
|
| 495 |
+
"name": "negative",
|
| 496 |
+
"type": "CONDITIONING",
|
| 497 |
+
"link": 125
|
| 498 |
+
},
|
| 499 |
+
{
|
| 500 |
+
"name": "latent_image",
|
| 501 |
+
"type": "LATENT",
|
| 502 |
+
"link": 126
|
| 503 |
+
}
|
| 504 |
+
],
|
| 505 |
+
"outputs": [
|
| 506 |
+
{
|
| 507 |
+
"name": "LATENT",
|
| 508 |
+
"type": "LATENT",
|
| 509 |
+
"links": [
|
| 510 |
+
97
|
| 511 |
+
],
|
| 512 |
+
"shape": 3,
|
| 513 |
+
"slot_index": 0
|
| 514 |
+
}
|
| 515 |
+
],
|
| 516 |
+
"properties": {
|
| 517 |
+
"Node name for S&R": "KSampler"
|
| 518 |
+
},
|
| 519 |
+
"widgets_values": [
|
| 520 |
+
949757093954838,
|
| 521 |
+
"randomize",
|
| 522 |
+
20,
|
| 523 |
+
5,
|
| 524 |
+
"dpmpp_2m_sde_gpu",
|
| 525 |
+
"karras",
|
| 526 |
+
0.7000000000000001
|
| 527 |
+
]
|
| 528 |
+
}
|
| 529 |
+
],
|
| 530 |
+
"links": [
|
| 531 |
+
[
|
| 532 |
+
35,
|
| 533 |
+
19,
|
| 534 |
+
1,
|
| 535 |
+
10,
|
| 536 |
+
0,
|
| 537 |
+
"CLIP"
|
| 538 |
+
],
|
| 539 |
+
[
|
| 540 |
+
43,
|
| 541 |
+
19,
|
| 542 |
+
2,
|
| 543 |
+
14,
|
| 544 |
+
1,
|
| 545 |
+
"VAE"
|
| 546 |
+
],
|
| 547 |
+
[
|
| 548 |
+
60,
|
| 549 |
+
19,
|
| 550 |
+
0,
|
| 551 |
+
36,
|
| 552 |
+
0,
|
| 553 |
+
"MODEL"
|
| 554 |
+
],
|
| 555 |
+
[
|
| 556 |
+
62,
|
| 557 |
+
35,
|
| 558 |
+
0,
|
| 559 |
+
36,
|
| 560 |
+
1,
|
| 561 |
+
"INPAINT_PATCH"
|
| 562 |
+
],
|
| 563 |
+
[
|
| 564 |
+
88,
|
| 565 |
+
19,
|
| 566 |
+
1,
|
| 567 |
+
9,
|
| 568 |
+
0,
|
| 569 |
+
"CLIP"
|
| 570 |
+
],
|
| 571 |
+
[
|
| 572 |
+
97,
|
| 573 |
+
40,
|
| 574 |
+
0,
|
| 575 |
+
14,
|
| 576 |
+
0,
|
| 577 |
+
"LATENT"
|
| 578 |
+
],
|
| 579 |
+
[
|
| 580 |
+
120,
|
| 581 |
+
36,
|
| 582 |
+
0,
|
| 583 |
+
40,
|
| 584 |
+
0,
|
| 585 |
+
"MODEL"
|
| 586 |
+
],
|
| 587 |
+
[
|
| 588 |
+
122,
|
| 589 |
+
9,
|
| 590 |
+
0,
|
| 591 |
+
44,
|
| 592 |
+
0,
|
| 593 |
+
"CONDITIONING"
|
| 594 |
+
],
|
| 595 |
+
[
|
| 596 |
+
123,
|
| 597 |
+
10,
|
| 598 |
+
0,
|
| 599 |
+
44,
|
| 600 |
+
1,
|
| 601 |
+
"CONDITIONING"
|
| 602 |
+
],
|
| 603 |
+
[
|
| 604 |
+
124,
|
| 605 |
+
44,
|
| 606 |
+
0,
|
| 607 |
+
40,
|
| 608 |
+
1,
|
| 609 |
+
"CONDITIONING"
|
| 610 |
+
],
|
| 611 |
+
[
|
| 612 |
+
125,
|
| 613 |
+
44,
|
| 614 |
+
1,
|
| 615 |
+
40,
|
| 616 |
+
2,
|
| 617 |
+
"CONDITIONING"
|
| 618 |
+
],
|
| 619 |
+
[
|
| 620 |
+
126,
|
| 621 |
+
44,
|
| 622 |
+
3,
|
| 623 |
+
40,
|
| 624 |
+
3,
|
| 625 |
+
"LATENT"
|
| 626 |
+
],
|
| 627 |
+
[
|
| 628 |
+
127,
|
| 629 |
+
44,
|
| 630 |
+
2,
|
| 631 |
+
36,
|
| 632 |
+
2,
|
| 633 |
+
"LATENT"
|
| 634 |
+
],
|
| 635 |
+
[
|
| 636 |
+
128,
|
| 637 |
+
19,
|
| 638 |
+
2,
|
| 639 |
+
44,
|
| 640 |
+
2,
|
| 641 |
+
"VAE"
|
| 642 |
+
],
|
| 643 |
+
[
|
| 644 |
+
155,
|
| 645 |
+
65,
|
| 646 |
+
0,
|
| 647 |
+
59,
|
| 648 |
+
0,
|
| 649 |
+
"IMAGE"
|
| 650 |
+
],
|
| 651 |
+
[
|
| 652 |
+
156,
|
| 653 |
+
14,
|
| 654 |
+
0,
|
| 655 |
+
65,
|
| 656 |
+
1,
|
| 657 |
+
"IMAGE"
|
| 658 |
+
],
|
| 659 |
+
[
|
| 660 |
+
174,
|
| 661 |
+
33,
|
| 662 |
+
0,
|
| 663 |
+
65,
|
| 664 |
+
0,
|
| 665 |
+
"IMAGE"
|
| 666 |
+
],
|
| 667 |
+
[
|
| 668 |
+
175,
|
| 669 |
+
33,
|
| 670 |
+
1,
|
| 671 |
+
65,
|
| 672 |
+
2,
|
| 673 |
+
"MASK"
|
| 674 |
+
],
|
| 675 |
+
[
|
| 676 |
+
177,
|
| 677 |
+
33,
|
| 678 |
+
1,
|
| 679 |
+
44,
|
| 680 |
+
4,
|
| 681 |
+
"MASK"
|
| 682 |
+
],
|
| 683 |
+
[
|
| 684 |
+
178,
|
| 685 |
+
33,
|
| 686 |
+
0,
|
| 687 |
+
44,
|
| 688 |
+
3,
|
| 689 |
+
"IMAGE"
|
| 690 |
+
]
|
| 691 |
+
],
|
| 692 |
+
"groups": [],
|
| 693 |
+
"config": {},
|
| 694 |
+
"extra": {},
|
| 695 |
+
"version": 0.4
|
| 696 |
+
}
|
sage2/workflows/inpaint-simple.json
ADDED
|
@@ -0,0 +1,609 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"last_node_id": 42,
|
| 3 |
+
"last_link_id": 107,
|
| 4 |
+
"nodes": [
|
| 5 |
+
{
|
| 6 |
+
"id": 33,
|
| 7 |
+
"type": "LoadImage",
|
| 8 |
+
"pos": [
|
| 9 |
+
-325,
|
| 10 |
+
111
|
| 11 |
+
],
|
| 12 |
+
"size": {
|
| 13 |
+
"0": 439.18682861328125,
|
| 14 |
+
"1": 485.00018310546875
|
| 15 |
+
},
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 0,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"outputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "IMAGE",
|
| 22 |
+
"type": "IMAGE",
|
| 23 |
+
"links": [
|
| 24 |
+
79
|
| 25 |
+
],
|
| 26 |
+
"shape": 3,
|
| 27 |
+
"slot_index": 0
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"name": "MASK",
|
| 31 |
+
"type": "MASK",
|
| 32 |
+
"links": [
|
| 33 |
+
99
|
| 34 |
+
],
|
| 35 |
+
"shape": 3,
|
| 36 |
+
"slot_index": 1
|
| 37 |
+
}
|
| 38 |
+
],
|
| 39 |
+
"properties": {
|
| 40 |
+
"Node name for S&R": "LoadImage"
|
| 41 |
+
},
|
| 42 |
+
"widgets_values": [
|
| 43 |
+
"clipspace/clipspace-mask-6116028.100000143.png [input]",
|
| 44 |
+
"image"
|
| 45 |
+
]
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"id": 42,
|
| 49 |
+
"type": "Reroute",
|
| 50 |
+
"pos": [
|
| 51 |
+
168,
|
| 52 |
+
-138
|
| 53 |
+
],
|
| 54 |
+
"size": [
|
| 55 |
+
75,
|
| 56 |
+
26
|
| 57 |
+
],
|
| 58 |
+
"flags": {},
|
| 59 |
+
"order": 6,
|
| 60 |
+
"mode": 0,
|
| 61 |
+
"inputs": [
|
| 62 |
+
{
|
| 63 |
+
"name": "",
|
| 64 |
+
"type": "*",
|
| 65 |
+
"link": 102
|
| 66 |
+
}
|
| 67 |
+
],
|
| 68 |
+
"outputs": [
|
| 69 |
+
{
|
| 70 |
+
"name": "",
|
| 71 |
+
"type": "INPAINT_PATCH",
|
| 72 |
+
"links": [
|
| 73 |
+
101
|
| 74 |
+
],
|
| 75 |
+
"slot_index": 0
|
| 76 |
+
}
|
| 77 |
+
],
|
| 78 |
+
"properties": {
|
| 79 |
+
"showOutputText": false,
|
| 80 |
+
"horizontal": false
|
| 81 |
+
}
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"id": 19,
|
| 85 |
+
"type": "CheckpointLoaderSimple",
|
| 86 |
+
"pos": [
|
| 87 |
+
-326,
|
| 88 |
+
-168
|
| 89 |
+
],
|
| 90 |
+
"size": {
|
| 91 |
+
"0": 431,
|
| 92 |
+
"1": 98
|
| 93 |
+
},
|
| 94 |
+
"flags": {},
|
| 95 |
+
"order": 1,
|
| 96 |
+
"mode": 0,
|
| 97 |
+
"outputs": [
|
| 98 |
+
{
|
| 99 |
+
"name": "MODEL",
|
| 100 |
+
"type": "MODEL",
|
| 101 |
+
"links": [
|
| 102 |
+
60
|
| 103 |
+
],
|
| 104 |
+
"shape": 3,
|
| 105 |
+
"slot_index": 0
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"name": "CLIP",
|
| 109 |
+
"type": "CLIP",
|
| 110 |
+
"links": [
|
| 111 |
+
103,
|
| 112 |
+
104
|
| 113 |
+
],
|
| 114 |
+
"shape": 3,
|
| 115 |
+
"slot_index": 1
|
| 116 |
+
},
|
| 117 |
+
{
|
| 118 |
+
"name": "VAE",
|
| 119 |
+
"type": "VAE",
|
| 120 |
+
"links": [
|
| 121 |
+
81,
|
| 122 |
+
107
|
| 123 |
+
],
|
| 124 |
+
"shape": 3,
|
| 125 |
+
"slot_index": 2
|
| 126 |
+
}
|
| 127 |
+
],
|
| 128 |
+
"properties": {
|
| 129 |
+
"Node name for S&R": "CheckpointLoaderSimple"
|
| 130 |
+
},
|
| 131 |
+
"widgets_values": [
|
| 132 |
+
"juggernautXL_version6Rundiffusion.safetensors"
|
| 133 |
+
]
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"id": 9,
|
| 137 |
+
"type": "CLIPTextEncode",
|
| 138 |
+
"pos": [
|
| 139 |
+
200,
|
| 140 |
+
270
|
| 141 |
+
],
|
| 142 |
+
"size": {
|
| 143 |
+
"0": 400,
|
| 144 |
+
"1": 200
|
| 145 |
+
},
|
| 146 |
+
"flags": {},
|
| 147 |
+
"order": 3,
|
| 148 |
+
"mode": 0,
|
| 149 |
+
"inputs": [
|
| 150 |
+
{
|
| 151 |
+
"name": "clip",
|
| 152 |
+
"type": "CLIP",
|
| 153 |
+
"link": 103
|
| 154 |
+
}
|
| 155 |
+
],
|
| 156 |
+
"outputs": [
|
| 157 |
+
{
|
| 158 |
+
"name": "CONDITIONING",
|
| 159 |
+
"type": "CONDITIONING",
|
| 160 |
+
"links": [
|
| 161 |
+
98
|
| 162 |
+
],
|
| 163 |
+
"shape": 3,
|
| 164 |
+
"slot_index": 0
|
| 165 |
+
}
|
| 166 |
+
],
|
| 167 |
+
"properties": {
|
| 168 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 169 |
+
},
|
| 170 |
+
"widgets_values": [
|
| 171 |
+
"photo of a bear standing in a stony river bed, nature"
|
| 172 |
+
]
|
| 173 |
+
},
|
| 174 |
+
{
|
| 175 |
+
"id": 14,
|
| 176 |
+
"type": "VAEDecode",
|
| 177 |
+
"pos": [
|
| 178 |
+
386,
|
| 179 |
+
171
|
| 180 |
+
],
|
| 181 |
+
"size": {
|
| 182 |
+
"0": 210,
|
| 183 |
+
"1": 46
|
| 184 |
+
},
|
| 185 |
+
"flags": {},
|
| 186 |
+
"order": 9,
|
| 187 |
+
"mode": 0,
|
| 188 |
+
"inputs": [
|
| 189 |
+
{
|
| 190 |
+
"name": "samples",
|
| 191 |
+
"type": "LATENT",
|
| 192 |
+
"link": 97
|
| 193 |
+
},
|
| 194 |
+
{
|
| 195 |
+
"name": "vae",
|
| 196 |
+
"type": "VAE",
|
| 197 |
+
"link": 107,
|
| 198 |
+
"slot_index": 1
|
| 199 |
+
}
|
| 200 |
+
],
|
| 201 |
+
"outputs": [
|
| 202 |
+
{
|
| 203 |
+
"name": "IMAGE",
|
| 204 |
+
"type": "IMAGE",
|
| 205 |
+
"links": [
|
| 206 |
+
46
|
| 207 |
+
],
|
| 208 |
+
"shape": 3,
|
| 209 |
+
"slot_index": 0
|
| 210 |
+
}
|
| 211 |
+
],
|
| 212 |
+
"properties": {
|
| 213 |
+
"Node name for S&R": "VAEDecode"
|
| 214 |
+
}
|
| 215 |
+
},
|
| 216 |
+
{
|
| 217 |
+
"id": 28,
|
| 218 |
+
"type": "PreviewImage",
|
| 219 |
+
"pos": [
|
| 220 |
+
664,
|
| 221 |
+
157
|
| 222 |
+
],
|
| 223 |
+
"size": [
|
| 224 |
+
460,
|
| 225 |
+
430
|
| 226 |
+
],
|
| 227 |
+
"flags": {},
|
| 228 |
+
"order": 10,
|
| 229 |
+
"mode": 0,
|
| 230 |
+
"inputs": [
|
| 231 |
+
{
|
| 232 |
+
"name": "images",
|
| 233 |
+
"type": "IMAGE",
|
| 234 |
+
"link": 46
|
| 235 |
+
}
|
| 236 |
+
],
|
| 237 |
+
"properties": {
|
| 238 |
+
"Node name for S&R": "PreviewImage"
|
| 239 |
+
}
|
| 240 |
+
},
|
| 241 |
+
{
|
| 242 |
+
"id": 10,
|
| 243 |
+
"type": "CLIPTextEncode",
|
| 244 |
+
"pos": [
|
| 245 |
+
204,
|
| 246 |
+
512
|
| 247 |
+
],
|
| 248 |
+
"size": {
|
| 249 |
+
"0": 397.5622253417969,
|
| 250 |
+
"1": 76
|
| 251 |
+
},
|
| 252 |
+
"flags": {},
|
| 253 |
+
"order": 4,
|
| 254 |
+
"mode": 0,
|
| 255 |
+
"inputs": [
|
| 256 |
+
{
|
| 257 |
+
"name": "clip",
|
| 258 |
+
"type": "CLIP",
|
| 259 |
+
"link": 104
|
| 260 |
+
}
|
| 261 |
+
],
|
| 262 |
+
"outputs": [
|
| 263 |
+
{
|
| 264 |
+
"name": "CONDITIONING",
|
| 265 |
+
"type": "CONDITIONING",
|
| 266 |
+
"links": [
|
| 267 |
+
105
|
| 268 |
+
],
|
| 269 |
+
"shape": 3,
|
| 270 |
+
"slot_index": 0
|
| 271 |
+
}
|
| 272 |
+
],
|
| 273 |
+
"properties": {
|
| 274 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 275 |
+
},
|
| 276 |
+
"widgets_values": [
|
| 277 |
+
"text, watermark"
|
| 278 |
+
]
|
| 279 |
+
},
|
| 280 |
+
{
|
| 281 |
+
"id": 38,
|
| 282 |
+
"type": "VAEEncodeForInpaint",
|
| 283 |
+
"pos": [
|
| 284 |
+
187,
|
| 285 |
+
-38
|
| 286 |
+
],
|
| 287 |
+
"size": {
|
| 288 |
+
"0": 315,
|
| 289 |
+
"1": 98
|
| 290 |
+
},
|
| 291 |
+
"flags": {},
|
| 292 |
+
"order": 5,
|
| 293 |
+
"mode": 0,
|
| 294 |
+
"inputs": [
|
| 295 |
+
{
|
| 296 |
+
"name": "pixels",
|
| 297 |
+
"type": "IMAGE",
|
| 298 |
+
"link": 79
|
| 299 |
+
},
|
| 300 |
+
{
|
| 301 |
+
"name": "vae",
|
| 302 |
+
"type": "VAE",
|
| 303 |
+
"link": 81
|
| 304 |
+
},
|
| 305 |
+
{
|
| 306 |
+
"name": "mask",
|
| 307 |
+
"type": "MASK",
|
| 308 |
+
"link": 99
|
| 309 |
+
}
|
| 310 |
+
],
|
| 311 |
+
"outputs": [
|
| 312 |
+
{
|
| 313 |
+
"name": "LATENT",
|
| 314 |
+
"type": "LATENT",
|
| 315 |
+
"links": [
|
| 316 |
+
91,
|
| 317 |
+
106
|
| 318 |
+
],
|
| 319 |
+
"shape": 3,
|
| 320 |
+
"slot_index": 0
|
| 321 |
+
}
|
| 322 |
+
],
|
| 323 |
+
"properties": {
|
| 324 |
+
"Node name for S&R": "VAEEncodeForInpaint"
|
| 325 |
+
},
|
| 326 |
+
"widgets_values": [
|
| 327 |
+
8
|
| 328 |
+
]
|
| 329 |
+
},
|
| 330 |
+
{
|
| 331 |
+
"id": 40,
|
| 332 |
+
"type": "KSampler",
|
| 333 |
+
"pos": [
|
| 334 |
+
805,
|
| 335 |
+
-167
|
| 336 |
+
],
|
| 337 |
+
"size": {
|
| 338 |
+
"0": 315,
|
| 339 |
+
"1": 262
|
| 340 |
+
},
|
| 341 |
+
"flags": {},
|
| 342 |
+
"order": 8,
|
| 343 |
+
"mode": 0,
|
| 344 |
+
"inputs": [
|
| 345 |
+
{
|
| 346 |
+
"name": "model",
|
| 347 |
+
"type": "MODEL",
|
| 348 |
+
"link": 93
|
| 349 |
+
},
|
| 350 |
+
{
|
| 351 |
+
"name": "positive",
|
| 352 |
+
"type": "CONDITIONING",
|
| 353 |
+
"link": 98
|
| 354 |
+
},
|
| 355 |
+
{
|
| 356 |
+
"name": "negative",
|
| 357 |
+
"type": "CONDITIONING",
|
| 358 |
+
"link": 105
|
| 359 |
+
},
|
| 360 |
+
{
|
| 361 |
+
"name": "latent_image",
|
| 362 |
+
"type": "LATENT",
|
| 363 |
+
"link": 106,
|
| 364 |
+
"slot_index": 3
|
| 365 |
+
}
|
| 366 |
+
],
|
| 367 |
+
"outputs": [
|
| 368 |
+
{
|
| 369 |
+
"name": "LATENT",
|
| 370 |
+
"type": "LATENT",
|
| 371 |
+
"links": [
|
| 372 |
+
97
|
| 373 |
+
],
|
| 374 |
+
"shape": 3,
|
| 375 |
+
"slot_index": 0
|
| 376 |
+
}
|
| 377 |
+
],
|
| 378 |
+
"properties": {
|
| 379 |
+
"Node name for S&R": "KSampler"
|
| 380 |
+
},
|
| 381 |
+
"widgets_values": [
|
| 382 |
+
923431948001835,
|
| 383 |
+
"fixed",
|
| 384 |
+
24,
|
| 385 |
+
5,
|
| 386 |
+
"dpmpp_2m_sde_gpu",
|
| 387 |
+
"karras",
|
| 388 |
+
1
|
| 389 |
+
]
|
| 390 |
+
},
|
| 391 |
+
{
|
| 392 |
+
"id": 35,
|
| 393 |
+
"type": "INPAINT_LoadFooocusInpaint",
|
| 394 |
+
"pos": [
|
| 395 |
+
-321,
|
| 396 |
+
-26
|
| 397 |
+
],
|
| 398 |
+
"size": {
|
| 399 |
+
"0": 418.0268249511719,
|
| 400 |
+
"1": 87.3501968383789
|
| 401 |
+
},
|
| 402 |
+
"flags": {},
|
| 403 |
+
"order": 2,
|
| 404 |
+
"mode": 0,
|
| 405 |
+
"outputs": [
|
| 406 |
+
{
|
| 407 |
+
"name": "INPAINT_PATCH",
|
| 408 |
+
"type": "INPAINT_PATCH",
|
| 409 |
+
"links": [
|
| 410 |
+
102
|
| 411 |
+
],
|
| 412 |
+
"shape": 3,
|
| 413 |
+
"slot_index": 0
|
| 414 |
+
}
|
| 415 |
+
],
|
| 416 |
+
"properties": {
|
| 417 |
+
"Node name for S&R": "INPAINT_LoadFooocusInpaint"
|
| 418 |
+
},
|
| 419 |
+
"widgets_values": [
|
| 420 |
+
"fooocus_inpaint_head.pth",
|
| 421 |
+
"inpaint_v26.fooocus.patch"
|
| 422 |
+
],
|
| 423 |
+
"color": "#323",
|
| 424 |
+
"bgcolor": "#535"
|
| 425 |
+
},
|
| 426 |
+
{
|
| 427 |
+
"id": 36,
|
| 428 |
+
"type": "INPAINT_ApplyFooocusInpaint",
|
| 429 |
+
"pos": [
|
| 430 |
+
536,
|
| 431 |
+
-168
|
| 432 |
+
],
|
| 433 |
+
"size": [
|
| 434 |
+
209,
|
| 435 |
+
71
|
| 436 |
+
],
|
| 437 |
+
"flags": {},
|
| 438 |
+
"order": 7,
|
| 439 |
+
"mode": 0,
|
| 440 |
+
"inputs": [
|
| 441 |
+
{
|
| 442 |
+
"name": "model",
|
| 443 |
+
"type": "MODEL",
|
| 444 |
+
"link": 60
|
| 445 |
+
},
|
| 446 |
+
{
|
| 447 |
+
"name": "patch",
|
| 448 |
+
"type": "INPAINT_PATCH",
|
| 449 |
+
"link": 101
|
| 450 |
+
},
|
| 451 |
+
{
|
| 452 |
+
"name": "latent",
|
| 453 |
+
"type": "LATENT",
|
| 454 |
+
"link": 91
|
| 455 |
+
}
|
| 456 |
+
],
|
| 457 |
+
"outputs": [
|
| 458 |
+
{
|
| 459 |
+
"name": "MODEL",
|
| 460 |
+
"type": "MODEL",
|
| 461 |
+
"links": [
|
| 462 |
+
93
|
| 463 |
+
],
|
| 464 |
+
"shape": 3,
|
| 465 |
+
"slot_index": 0
|
| 466 |
+
}
|
| 467 |
+
],
|
| 468 |
+
"properties": {
|
| 469 |
+
"Node name for S&R": "INPAINT_ApplyFooocusInpaint"
|
| 470 |
+
},
|
| 471 |
+
"color": "#323",
|
| 472 |
+
"bgcolor": "#535"
|
| 473 |
+
}
|
| 474 |
+
],
|
| 475 |
+
"links": [
|
| 476 |
+
[
|
| 477 |
+
46,
|
| 478 |
+
14,
|
| 479 |
+
0,
|
| 480 |
+
28,
|
| 481 |
+
0,
|
| 482 |
+
"IMAGE"
|
| 483 |
+
],
|
| 484 |
+
[
|
| 485 |
+
60,
|
| 486 |
+
19,
|
| 487 |
+
0,
|
| 488 |
+
36,
|
| 489 |
+
0,
|
| 490 |
+
"MODEL"
|
| 491 |
+
],
|
| 492 |
+
[
|
| 493 |
+
79,
|
| 494 |
+
33,
|
| 495 |
+
0,
|
| 496 |
+
38,
|
| 497 |
+
0,
|
| 498 |
+
"IMAGE"
|
| 499 |
+
],
|
| 500 |
+
[
|
| 501 |
+
81,
|
| 502 |
+
19,
|
| 503 |
+
2,
|
| 504 |
+
38,
|
| 505 |
+
1,
|
| 506 |
+
"VAE"
|
| 507 |
+
],
|
| 508 |
+
[
|
| 509 |
+
91,
|
| 510 |
+
38,
|
| 511 |
+
0,
|
| 512 |
+
36,
|
| 513 |
+
2,
|
| 514 |
+
"LATENT"
|
| 515 |
+
],
|
| 516 |
+
[
|
| 517 |
+
93,
|
| 518 |
+
36,
|
| 519 |
+
0,
|
| 520 |
+
40,
|
| 521 |
+
0,
|
| 522 |
+
"MODEL"
|
| 523 |
+
],
|
| 524 |
+
[
|
| 525 |
+
97,
|
| 526 |
+
40,
|
| 527 |
+
0,
|
| 528 |
+
14,
|
| 529 |
+
0,
|
| 530 |
+
"LATENT"
|
| 531 |
+
],
|
| 532 |
+
[
|
| 533 |
+
98,
|
| 534 |
+
9,
|
| 535 |
+
0,
|
| 536 |
+
40,
|
| 537 |
+
1,
|
| 538 |
+
"CONDITIONING"
|
| 539 |
+
],
|
| 540 |
+
[
|
| 541 |
+
99,
|
| 542 |
+
33,
|
| 543 |
+
1,
|
| 544 |
+
38,
|
| 545 |
+
2,
|
| 546 |
+
"MASK"
|
| 547 |
+
],
|
| 548 |
+
[
|
| 549 |
+
101,
|
| 550 |
+
42,
|
| 551 |
+
0,
|
| 552 |
+
36,
|
| 553 |
+
1,
|
| 554 |
+
"INPAINT_PATCH"
|
| 555 |
+
],
|
| 556 |
+
[
|
| 557 |
+
102,
|
| 558 |
+
35,
|
| 559 |
+
0,
|
| 560 |
+
42,
|
| 561 |
+
0,
|
| 562 |
+
"*"
|
| 563 |
+
],
|
| 564 |
+
[
|
| 565 |
+
103,
|
| 566 |
+
19,
|
| 567 |
+
1,
|
| 568 |
+
9,
|
| 569 |
+
0,
|
| 570 |
+
"CLIP"
|
| 571 |
+
],
|
| 572 |
+
[
|
| 573 |
+
104,
|
| 574 |
+
19,
|
| 575 |
+
1,
|
| 576 |
+
10,
|
| 577 |
+
0,
|
| 578 |
+
"CLIP"
|
| 579 |
+
],
|
| 580 |
+
[
|
| 581 |
+
105,
|
| 582 |
+
10,
|
| 583 |
+
0,
|
| 584 |
+
40,
|
| 585 |
+
2,
|
| 586 |
+
"CONDITIONING"
|
| 587 |
+
],
|
| 588 |
+
[
|
| 589 |
+
106,
|
| 590 |
+
38,
|
| 591 |
+
0,
|
| 592 |
+
40,
|
| 593 |
+
3,
|
| 594 |
+
"LATENT"
|
| 595 |
+
],
|
| 596 |
+
[
|
| 597 |
+
107,
|
| 598 |
+
19,
|
| 599 |
+
2,
|
| 600 |
+
14,
|
| 601 |
+
1,
|
| 602 |
+
"VAE"
|
| 603 |
+
]
|
| 604 |
+
],
|
| 605 |
+
"groups": [],
|
| 606 |
+
"config": {},
|
| 607 |
+
"extra": {},
|
| 608 |
+
"version": 0.4
|
| 609 |
+
}
|
sage2/workflows/outpaint.json
ADDED
|
@@ -0,0 +1,878 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"last_node_id": 74,
|
| 3 |
+
"last_link_id": 199,
|
| 4 |
+
"nodes": [
|
| 5 |
+
{
|
| 6 |
+
"id": 44,
|
| 7 |
+
"type": "INPAINT_VAEEncodeInpaintConditioning",
|
| 8 |
+
"pos": [
|
| 9 |
+
-24,
|
| 10 |
+
400
|
| 11 |
+
],
|
| 12 |
+
"size": {
|
| 13 |
+
"0": 292.20001220703125,
|
| 14 |
+
"1": 106
|
| 15 |
+
},
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 8,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"inputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "positive",
|
| 22 |
+
"type": "CONDITIONING",
|
| 23 |
+
"link": 122
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"name": "negative",
|
| 27 |
+
"type": "CONDITIONING",
|
| 28 |
+
"link": 123
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"name": "vae",
|
| 32 |
+
"type": "VAE",
|
| 33 |
+
"link": 128
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"name": "pixels",
|
| 37 |
+
"type": "IMAGE",
|
| 38 |
+
"link": 198
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"name": "mask",
|
| 42 |
+
"type": "MASK",
|
| 43 |
+
"link": 193
|
| 44 |
+
}
|
| 45 |
+
],
|
| 46 |
+
"outputs": [
|
| 47 |
+
{
|
| 48 |
+
"name": "positive",
|
| 49 |
+
"type": "CONDITIONING",
|
| 50 |
+
"links": [
|
| 51 |
+
124
|
| 52 |
+
],
|
| 53 |
+
"shape": 3,
|
| 54 |
+
"slot_index": 0
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"name": "negative",
|
| 58 |
+
"type": "CONDITIONING",
|
| 59 |
+
"links": [
|
| 60 |
+
125
|
| 61 |
+
],
|
| 62 |
+
"shape": 3,
|
| 63 |
+
"slot_index": 1
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"name": "latent_inpaint",
|
| 67 |
+
"type": "LATENT",
|
| 68 |
+
"links": [
|
| 69 |
+
127
|
| 70 |
+
],
|
| 71 |
+
"shape": 3,
|
| 72 |
+
"slot_index": 2
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"name": "latent_samples",
|
| 76 |
+
"type": "LATENT",
|
| 77 |
+
"links": [
|
| 78 |
+
126
|
| 79 |
+
],
|
| 80 |
+
"shape": 3,
|
| 81 |
+
"slot_index": 3
|
| 82 |
+
}
|
| 83 |
+
],
|
| 84 |
+
"properties": {
|
| 85 |
+
"Node name for S&R": "INPAINT_VAEEncodeInpaintConditioning"
|
| 86 |
+
},
|
| 87 |
+
"color": "#323",
|
| 88 |
+
"bgcolor": "#535"
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"id": 36,
|
| 92 |
+
"type": "INPAINT_ApplyFooocusInpaint",
|
| 93 |
+
"pos": [
|
| 94 |
+
367,
|
| 95 |
+
665
|
| 96 |
+
],
|
| 97 |
+
"size": {
|
| 98 |
+
"0": 191.45639038085938,
|
| 99 |
+
"1": 66
|
| 100 |
+
},
|
| 101 |
+
"flags": {},
|
| 102 |
+
"order": 9,
|
| 103 |
+
"mode": 0,
|
| 104 |
+
"inputs": [
|
| 105 |
+
{
|
| 106 |
+
"name": "model",
|
| 107 |
+
"type": "MODEL",
|
| 108 |
+
"link": 60
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"name": "patch",
|
| 112 |
+
"type": "INPAINT_PATCH",
|
| 113 |
+
"link": 62
|
| 114 |
+
},
|
| 115 |
+
{
|
| 116 |
+
"name": "latent",
|
| 117 |
+
"type": "LATENT",
|
| 118 |
+
"link": 127
|
| 119 |
+
}
|
| 120 |
+
],
|
| 121 |
+
"outputs": [
|
| 122 |
+
{
|
| 123 |
+
"name": "MODEL",
|
| 124 |
+
"type": "MODEL",
|
| 125 |
+
"links": [
|
| 126 |
+
120
|
| 127 |
+
],
|
| 128 |
+
"shape": 3,
|
| 129 |
+
"slot_index": 0
|
| 130 |
+
}
|
| 131 |
+
],
|
| 132 |
+
"properties": {
|
| 133 |
+
"Node name for S&R": "INPAINT_ApplyFooocusInpaint"
|
| 134 |
+
},
|
| 135 |
+
"color": "#323",
|
| 136 |
+
"bgcolor": "#535"
|
| 137 |
+
},
|
| 138 |
+
{
|
| 139 |
+
"id": 35,
|
| 140 |
+
"type": "INPAINT_LoadFooocusInpaint",
|
| 141 |
+
"pos": [
|
| 142 |
+
-11,
|
| 143 |
+
571
|
| 144 |
+
],
|
| 145 |
+
"size": {
|
| 146 |
+
"0": 276.6825256347656,
|
| 147 |
+
"1": 82
|
| 148 |
+
},
|
| 149 |
+
"flags": {},
|
| 150 |
+
"order": 0,
|
| 151 |
+
"mode": 0,
|
| 152 |
+
"outputs": [
|
| 153 |
+
{
|
| 154 |
+
"name": "INPAINT_PATCH",
|
| 155 |
+
"type": "INPAINT_PATCH",
|
| 156 |
+
"links": [
|
| 157 |
+
62
|
| 158 |
+
],
|
| 159 |
+
"shape": 3,
|
| 160 |
+
"slot_index": 0
|
| 161 |
+
}
|
| 162 |
+
],
|
| 163 |
+
"properties": {
|
| 164 |
+
"Node name for S&R": "INPAINT_LoadFooocusInpaint"
|
| 165 |
+
},
|
| 166 |
+
"widgets_values": [
|
| 167 |
+
"fooocus_inpaint_head.pth",
|
| 168 |
+
"inpaint_v26.fooocus.patch"
|
| 169 |
+
],
|
| 170 |
+
"color": "#323",
|
| 171 |
+
"bgcolor": "#535"
|
| 172 |
+
},
|
| 173 |
+
{
|
| 174 |
+
"id": 65,
|
| 175 |
+
"type": "ImageCompositeMasked",
|
| 176 |
+
"pos": [
|
| 177 |
+
870,
|
| 178 |
+
80
|
| 179 |
+
],
|
| 180 |
+
"size": {
|
| 181 |
+
"0": 240.56597900390625,
|
| 182 |
+
"1": 146
|
| 183 |
+
},
|
| 184 |
+
"flags": {},
|
| 185 |
+
"order": 12,
|
| 186 |
+
"mode": 0,
|
| 187 |
+
"inputs": [
|
| 188 |
+
{
|
| 189 |
+
"name": "destination",
|
| 190 |
+
"type": "IMAGE",
|
| 191 |
+
"link": 189
|
| 192 |
+
},
|
| 193 |
+
{
|
| 194 |
+
"name": "source",
|
| 195 |
+
"type": "IMAGE",
|
| 196 |
+
"link": 156
|
| 197 |
+
},
|
| 198 |
+
{
|
| 199 |
+
"name": "mask",
|
| 200 |
+
"type": "MASK",
|
| 201 |
+
"link": 190
|
| 202 |
+
}
|
| 203 |
+
],
|
| 204 |
+
"outputs": [
|
| 205 |
+
{
|
| 206 |
+
"name": "IMAGE",
|
| 207 |
+
"type": "IMAGE",
|
| 208 |
+
"links": [
|
| 209 |
+
155
|
| 210 |
+
],
|
| 211 |
+
"shape": 3,
|
| 212 |
+
"slot_index": 0
|
| 213 |
+
}
|
| 214 |
+
],
|
| 215 |
+
"properties": {
|
| 216 |
+
"Node name for S&R": "ImageCompositeMasked"
|
| 217 |
+
},
|
| 218 |
+
"widgets_values": [
|
| 219 |
+
0,
|
| 220 |
+
0,
|
| 221 |
+
false
|
| 222 |
+
]
|
| 223 |
+
},
|
| 224 |
+
{
|
| 225 |
+
"id": 14,
|
| 226 |
+
"type": "VAEDecode",
|
| 227 |
+
"pos": [
|
| 228 |
+
700,
|
| 229 |
+
180
|
| 230 |
+
],
|
| 231 |
+
"size": {
|
| 232 |
+
"0": 140,
|
| 233 |
+
"1": 49.74785232543945
|
| 234 |
+
},
|
| 235 |
+
"flags": {},
|
| 236 |
+
"order": 11,
|
| 237 |
+
"mode": 0,
|
| 238 |
+
"inputs": [
|
| 239 |
+
{
|
| 240 |
+
"name": "samples",
|
| 241 |
+
"type": "LATENT",
|
| 242 |
+
"link": 97
|
| 243 |
+
},
|
| 244 |
+
{
|
| 245 |
+
"name": "vae",
|
| 246 |
+
"type": "VAE",
|
| 247 |
+
"link": 43
|
| 248 |
+
}
|
| 249 |
+
],
|
| 250 |
+
"outputs": [
|
| 251 |
+
{
|
| 252 |
+
"name": "IMAGE",
|
| 253 |
+
"type": "IMAGE",
|
| 254 |
+
"links": [
|
| 255 |
+
156
|
| 256 |
+
],
|
| 257 |
+
"shape": 3,
|
| 258 |
+
"slot_index": 0
|
| 259 |
+
}
|
| 260 |
+
],
|
| 261 |
+
"properties": {
|
| 262 |
+
"Node name for S&R": "VAEDecode"
|
| 263 |
+
}
|
| 264 |
+
},
|
| 265 |
+
{
|
| 266 |
+
"id": 67,
|
| 267 |
+
"type": "ImagePadForOutpaint",
|
| 268 |
+
"pos": [
|
| 269 |
+
-127,
|
| 270 |
+
79
|
| 271 |
+
],
|
| 272 |
+
"size": [
|
| 273 |
+
238.84862258353508,
|
| 274 |
+
174
|
| 275 |
+
],
|
| 276 |
+
"flags": {},
|
| 277 |
+
"order": 3,
|
| 278 |
+
"mode": 0,
|
| 279 |
+
"inputs": [
|
| 280 |
+
{
|
| 281 |
+
"name": "image",
|
| 282 |
+
"type": "IMAGE",
|
| 283 |
+
"link": 179
|
| 284 |
+
}
|
| 285 |
+
],
|
| 286 |
+
"outputs": [
|
| 287 |
+
{
|
| 288 |
+
"name": "IMAGE",
|
| 289 |
+
"type": "IMAGE",
|
| 290 |
+
"links": [
|
| 291 |
+
180,
|
| 292 |
+
189
|
| 293 |
+
],
|
| 294 |
+
"shape": 3,
|
| 295 |
+
"slot_index": 0
|
| 296 |
+
},
|
| 297 |
+
{
|
| 298 |
+
"name": "MASK",
|
| 299 |
+
"type": "MASK",
|
| 300 |
+
"links": [
|
| 301 |
+
181,
|
| 302 |
+
190,
|
| 303 |
+
193,
|
| 304 |
+
197
|
| 305 |
+
],
|
| 306 |
+
"shape": 3,
|
| 307 |
+
"slot_index": 1
|
| 308 |
+
}
|
| 309 |
+
],
|
| 310 |
+
"properties": {
|
| 311 |
+
"Node name for S&R": "ImagePadForOutpaint"
|
| 312 |
+
},
|
| 313 |
+
"widgets_values": [
|
| 314 |
+
128,
|
| 315 |
+
0,
|
| 316 |
+
128,
|
| 317 |
+
0,
|
| 318 |
+
40
|
| 319 |
+
]
|
| 320 |
+
},
|
| 321 |
+
{
|
| 322 |
+
"id": 59,
|
| 323 |
+
"type": "SaveImage",
|
| 324 |
+
"pos": [
|
| 325 |
+
687,
|
| 326 |
+
291
|
| 327 |
+
],
|
| 328 |
+
"size": [
|
| 329 |
+
434.77541218136935,
|
| 330 |
+
440.62990692496203
|
| 331 |
+
],
|
| 332 |
+
"flags": {},
|
| 333 |
+
"order": 13,
|
| 334 |
+
"mode": 0,
|
| 335 |
+
"inputs": [
|
| 336 |
+
{
|
| 337 |
+
"name": "images",
|
| 338 |
+
"type": "IMAGE",
|
| 339 |
+
"link": 155
|
| 340 |
+
}
|
| 341 |
+
],
|
| 342 |
+
"properties": {},
|
| 343 |
+
"widgets_values": [
|
| 344 |
+
"ComfyUI"
|
| 345 |
+
]
|
| 346 |
+
},
|
| 347 |
+
{
|
| 348 |
+
"id": 33,
|
| 349 |
+
"type": "LoadImage",
|
| 350 |
+
"pos": [
|
| 351 |
+
-460,
|
| 352 |
+
74
|
| 353 |
+
],
|
| 354 |
+
"size": [
|
| 355 |
+
300.6123144221898,
|
| 356 |
+
309.42733495308704
|
| 357 |
+
],
|
| 358 |
+
"flags": {},
|
| 359 |
+
"order": 1,
|
| 360 |
+
"mode": 0,
|
| 361 |
+
"outputs": [
|
| 362 |
+
{
|
| 363 |
+
"name": "IMAGE",
|
| 364 |
+
"type": "IMAGE",
|
| 365 |
+
"links": [
|
| 366 |
+
179
|
| 367 |
+
],
|
| 368 |
+
"shape": 3,
|
| 369 |
+
"slot_index": 0
|
| 370 |
+
},
|
| 371 |
+
{
|
| 372 |
+
"name": "MASK",
|
| 373 |
+
"type": "MASK",
|
| 374 |
+
"links": [],
|
| 375 |
+
"shape": 3,
|
| 376 |
+
"slot_index": 1
|
| 377 |
+
}
|
| 378 |
+
],
|
| 379 |
+
"properties": {
|
| 380 |
+
"Node name for S&R": "LoadImage"
|
| 381 |
+
},
|
| 382 |
+
"widgets_values": [
|
| 383 |
+
"base1024.png",
|
| 384 |
+
"image"
|
| 385 |
+
]
|
| 386 |
+
},
|
| 387 |
+
{
|
| 388 |
+
"id": 19,
|
| 389 |
+
"type": "CheckpointLoaderSimple",
|
| 390 |
+
"pos": [
|
| 391 |
+
-461,
|
| 392 |
+
662
|
| 393 |
+
],
|
| 394 |
+
"size": [
|
| 395 |
+
406.4723173048857,
|
| 396 |
+
98
|
| 397 |
+
],
|
| 398 |
+
"flags": {},
|
| 399 |
+
"order": 2,
|
| 400 |
+
"mode": 0,
|
| 401 |
+
"outputs": [
|
| 402 |
+
{
|
| 403 |
+
"name": "MODEL",
|
| 404 |
+
"type": "MODEL",
|
| 405 |
+
"links": [
|
| 406 |
+
60
|
| 407 |
+
],
|
| 408 |
+
"shape": 3,
|
| 409 |
+
"slot_index": 0
|
| 410 |
+
},
|
| 411 |
+
{
|
| 412 |
+
"name": "CLIP",
|
| 413 |
+
"type": "CLIP",
|
| 414 |
+
"links": [
|
| 415 |
+
35,
|
| 416 |
+
88
|
| 417 |
+
],
|
| 418 |
+
"shape": 3,
|
| 419 |
+
"slot_index": 1
|
| 420 |
+
},
|
| 421 |
+
{
|
| 422 |
+
"name": "VAE",
|
| 423 |
+
"type": "VAE",
|
| 424 |
+
"links": [
|
| 425 |
+
43,
|
| 426 |
+
128
|
| 427 |
+
],
|
| 428 |
+
"shape": 3,
|
| 429 |
+
"slot_index": 2
|
| 430 |
+
}
|
| 431 |
+
],
|
| 432 |
+
"properties": {
|
| 433 |
+
"Node name for S&R": "CheckpointLoaderSimple"
|
| 434 |
+
},
|
| 435 |
+
"widgets_values": [
|
| 436 |
+
"juggernautXL_version6Rundiffusion.safetensors"
|
| 437 |
+
]
|
| 438 |
+
},
|
| 439 |
+
{
|
| 440 |
+
"id": 9,
|
| 441 |
+
"type": "CLIPTextEncode",
|
| 442 |
+
"pos": [
|
| 443 |
+
-458,
|
| 444 |
+
419
|
| 445 |
+
],
|
| 446 |
+
"size": {
|
| 447 |
+
"0": 326.6668701171875,
|
| 448 |
+
"1": 95.14787292480469
|
| 449 |
+
},
|
| 450 |
+
"flags": {},
|
| 451 |
+
"order": 5,
|
| 452 |
+
"mode": 0,
|
| 453 |
+
"inputs": [
|
| 454 |
+
{
|
| 455 |
+
"name": "clip",
|
| 456 |
+
"type": "CLIP",
|
| 457 |
+
"link": 88
|
| 458 |
+
}
|
| 459 |
+
],
|
| 460 |
+
"outputs": [
|
| 461 |
+
{
|
| 462 |
+
"name": "CONDITIONING",
|
| 463 |
+
"type": "CONDITIONING",
|
| 464 |
+
"links": [
|
| 465 |
+
122
|
| 466 |
+
],
|
| 467 |
+
"shape": 3,
|
| 468 |
+
"slot_index": 0
|
| 469 |
+
}
|
| 470 |
+
],
|
| 471 |
+
"properties": {
|
| 472 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 473 |
+
},
|
| 474 |
+
"widgets_values": [
|
| 475 |
+
"POSITIVE PROMPT"
|
| 476 |
+
],
|
| 477 |
+
"color": "#232",
|
| 478 |
+
"bgcolor": "#353"
|
| 479 |
+
},
|
| 480 |
+
{
|
| 481 |
+
"id": 10,
|
| 482 |
+
"type": "CLIPTextEncode",
|
| 483 |
+
"pos": [
|
| 484 |
+
-456,
|
| 485 |
+
551
|
| 486 |
+
],
|
| 487 |
+
"size": {
|
| 488 |
+
"0": 321.6668701171875,
|
| 489 |
+
"1": 76
|
| 490 |
+
},
|
| 491 |
+
"flags": {},
|
| 492 |
+
"order": 4,
|
| 493 |
+
"mode": 0,
|
| 494 |
+
"inputs": [
|
| 495 |
+
{
|
| 496 |
+
"name": "clip",
|
| 497 |
+
"type": "CLIP",
|
| 498 |
+
"link": 35
|
| 499 |
+
}
|
| 500 |
+
],
|
| 501 |
+
"outputs": [
|
| 502 |
+
{
|
| 503 |
+
"name": "CONDITIONING",
|
| 504 |
+
"type": "CONDITIONING",
|
| 505 |
+
"links": [
|
| 506 |
+
123
|
| 507 |
+
],
|
| 508 |
+
"shape": 3,
|
| 509 |
+
"slot_index": 0
|
| 510 |
+
}
|
| 511 |
+
],
|
| 512 |
+
"properties": {
|
| 513 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 514 |
+
},
|
| 515 |
+
"widgets_values": [
|
| 516 |
+
"text, watermark"
|
| 517 |
+
],
|
| 518 |
+
"color": "#322",
|
| 519 |
+
"bgcolor": "#533"
|
| 520 |
+
},
|
| 521 |
+
{
|
| 522 |
+
"id": 68,
|
| 523 |
+
"type": "INPAINT_MaskedFill",
|
| 524 |
+
"pos": [
|
| 525 |
+
170,
|
| 526 |
+
170
|
| 527 |
+
],
|
| 528 |
+
"size": [
|
| 529 |
+
210,
|
| 530 |
+
102
|
| 531 |
+
],
|
| 532 |
+
"flags": {},
|
| 533 |
+
"order": 6,
|
| 534 |
+
"mode": 0,
|
| 535 |
+
"inputs": [
|
| 536 |
+
{
|
| 537 |
+
"name": "image",
|
| 538 |
+
"type": "IMAGE",
|
| 539 |
+
"link": 180
|
| 540 |
+
},
|
| 541 |
+
{
|
| 542 |
+
"name": "mask",
|
| 543 |
+
"type": "MASK",
|
| 544 |
+
"link": 181
|
| 545 |
+
}
|
| 546 |
+
],
|
| 547 |
+
"outputs": [
|
| 548 |
+
{
|
| 549 |
+
"name": "IMAGE",
|
| 550 |
+
"type": "IMAGE",
|
| 551 |
+
"links": [
|
| 552 |
+
196
|
| 553 |
+
],
|
| 554 |
+
"shape": 3,
|
| 555 |
+
"slot_index": 0
|
| 556 |
+
}
|
| 557 |
+
],
|
| 558 |
+
"properties": {
|
| 559 |
+
"Node name for S&R": "INPAINT_MaskedFill"
|
| 560 |
+
},
|
| 561 |
+
"widgets_values": [
|
| 562 |
+
"navier-stokes",
|
| 563 |
+
0
|
| 564 |
+
]
|
| 565 |
+
},
|
| 566 |
+
{
|
| 567 |
+
"id": 73,
|
| 568 |
+
"type": "INPAINT_MaskedBlur",
|
| 569 |
+
"pos": [
|
| 570 |
+
410,
|
| 571 |
+
170
|
| 572 |
+
],
|
| 573 |
+
"size": [
|
| 574 |
+
210,
|
| 575 |
+
102
|
| 576 |
+
],
|
| 577 |
+
"flags": {},
|
| 578 |
+
"order": 7,
|
| 579 |
+
"mode": 0,
|
| 580 |
+
"inputs": [
|
| 581 |
+
{
|
| 582 |
+
"name": "image",
|
| 583 |
+
"type": "IMAGE",
|
| 584 |
+
"link": 196
|
| 585 |
+
},
|
| 586 |
+
{
|
| 587 |
+
"name": "mask",
|
| 588 |
+
"type": "MASK",
|
| 589 |
+
"link": 197
|
| 590 |
+
}
|
| 591 |
+
],
|
| 592 |
+
"outputs": [
|
| 593 |
+
{
|
| 594 |
+
"name": "IMAGE",
|
| 595 |
+
"type": "IMAGE",
|
| 596 |
+
"links": [
|
| 597 |
+
198
|
| 598 |
+
],
|
| 599 |
+
"shape": 3,
|
| 600 |
+
"slot_index": 0
|
| 601 |
+
}
|
| 602 |
+
],
|
| 603 |
+
"properties": {
|
| 604 |
+
"Node name for S&R": "INPAINT_MaskedBlur"
|
| 605 |
+
},
|
| 606 |
+
"widgets_values": [
|
| 607 |
+
65,
|
| 608 |
+
0
|
| 609 |
+
]
|
| 610 |
+
},
|
| 611 |
+
{
|
| 612 |
+
"id": 40,
|
| 613 |
+
"type": "KSampler",
|
| 614 |
+
"pos": [
|
| 615 |
+
341,
|
| 616 |
+
348
|
| 617 |
+
],
|
| 618 |
+
"size": {
|
| 619 |
+
"0": 315,
|
| 620 |
+
"1": 262
|
| 621 |
+
},
|
| 622 |
+
"flags": {},
|
| 623 |
+
"order": 10,
|
| 624 |
+
"mode": 0,
|
| 625 |
+
"inputs": [
|
| 626 |
+
{
|
| 627 |
+
"name": "model",
|
| 628 |
+
"type": "MODEL",
|
| 629 |
+
"link": 120
|
| 630 |
+
},
|
| 631 |
+
{
|
| 632 |
+
"name": "positive",
|
| 633 |
+
"type": "CONDITIONING",
|
| 634 |
+
"link": 124
|
| 635 |
+
},
|
| 636 |
+
{
|
| 637 |
+
"name": "negative",
|
| 638 |
+
"type": "CONDITIONING",
|
| 639 |
+
"link": 125
|
| 640 |
+
},
|
| 641 |
+
{
|
| 642 |
+
"name": "latent_image",
|
| 643 |
+
"type": "LATENT",
|
| 644 |
+
"link": 126
|
| 645 |
+
}
|
| 646 |
+
],
|
| 647 |
+
"outputs": [
|
| 648 |
+
{
|
| 649 |
+
"name": "LATENT",
|
| 650 |
+
"type": "LATENT",
|
| 651 |
+
"links": [
|
| 652 |
+
97
|
| 653 |
+
],
|
| 654 |
+
"shape": 3,
|
| 655 |
+
"slot_index": 0
|
| 656 |
+
}
|
| 657 |
+
],
|
| 658 |
+
"properties": {
|
| 659 |
+
"Node name for S&R": "KSampler"
|
| 660 |
+
},
|
| 661 |
+
"widgets_values": [
|
| 662 |
+
439968554343941,
|
| 663 |
+
"randomize",
|
| 664 |
+
28,
|
| 665 |
+
6,
|
| 666 |
+
"dpmpp_2m_sde_gpu",
|
| 667 |
+
"karras",
|
| 668 |
+
1
|
| 669 |
+
]
|
| 670 |
+
}
|
| 671 |
+
],
|
| 672 |
+
"links": [
|
| 673 |
+
[
|
| 674 |
+
35,
|
| 675 |
+
19,
|
| 676 |
+
1,
|
| 677 |
+
10,
|
| 678 |
+
0,
|
| 679 |
+
"CLIP"
|
| 680 |
+
],
|
| 681 |
+
[
|
| 682 |
+
43,
|
| 683 |
+
19,
|
| 684 |
+
2,
|
| 685 |
+
14,
|
| 686 |
+
1,
|
| 687 |
+
"VAE"
|
| 688 |
+
],
|
| 689 |
+
[
|
| 690 |
+
60,
|
| 691 |
+
19,
|
| 692 |
+
0,
|
| 693 |
+
36,
|
| 694 |
+
0,
|
| 695 |
+
"MODEL"
|
| 696 |
+
],
|
| 697 |
+
[
|
| 698 |
+
62,
|
| 699 |
+
35,
|
| 700 |
+
0,
|
| 701 |
+
36,
|
| 702 |
+
1,
|
| 703 |
+
"INPAINT_PATCH"
|
| 704 |
+
],
|
| 705 |
+
[
|
| 706 |
+
88,
|
| 707 |
+
19,
|
| 708 |
+
1,
|
| 709 |
+
9,
|
| 710 |
+
0,
|
| 711 |
+
"CLIP"
|
| 712 |
+
],
|
| 713 |
+
[
|
| 714 |
+
97,
|
| 715 |
+
40,
|
| 716 |
+
0,
|
| 717 |
+
14,
|
| 718 |
+
0,
|
| 719 |
+
"LATENT"
|
| 720 |
+
],
|
| 721 |
+
[
|
| 722 |
+
120,
|
| 723 |
+
36,
|
| 724 |
+
0,
|
| 725 |
+
40,
|
| 726 |
+
0,
|
| 727 |
+
"MODEL"
|
| 728 |
+
],
|
| 729 |
+
[
|
| 730 |
+
122,
|
| 731 |
+
9,
|
| 732 |
+
0,
|
| 733 |
+
44,
|
| 734 |
+
0,
|
| 735 |
+
"CONDITIONING"
|
| 736 |
+
],
|
| 737 |
+
[
|
| 738 |
+
123,
|
| 739 |
+
10,
|
| 740 |
+
0,
|
| 741 |
+
44,
|
| 742 |
+
1,
|
| 743 |
+
"CONDITIONING"
|
| 744 |
+
],
|
| 745 |
+
[
|
| 746 |
+
124,
|
| 747 |
+
44,
|
| 748 |
+
0,
|
| 749 |
+
40,
|
| 750 |
+
1,
|
| 751 |
+
"CONDITIONING"
|
| 752 |
+
],
|
| 753 |
+
[
|
| 754 |
+
125,
|
| 755 |
+
44,
|
| 756 |
+
1,
|
| 757 |
+
40,
|
| 758 |
+
2,
|
| 759 |
+
"CONDITIONING"
|
| 760 |
+
],
|
| 761 |
+
[
|
| 762 |
+
126,
|
| 763 |
+
44,
|
| 764 |
+
3,
|
| 765 |
+
40,
|
| 766 |
+
3,
|
| 767 |
+
"LATENT"
|
| 768 |
+
],
|
| 769 |
+
[
|
| 770 |
+
127,
|
| 771 |
+
44,
|
| 772 |
+
2,
|
| 773 |
+
36,
|
| 774 |
+
2,
|
| 775 |
+
"LATENT"
|
| 776 |
+
],
|
| 777 |
+
[
|
| 778 |
+
128,
|
| 779 |
+
19,
|
| 780 |
+
2,
|
| 781 |
+
44,
|
| 782 |
+
2,
|
| 783 |
+
"VAE"
|
| 784 |
+
],
|
| 785 |
+
[
|
| 786 |
+
155,
|
| 787 |
+
65,
|
| 788 |
+
0,
|
| 789 |
+
59,
|
| 790 |
+
0,
|
| 791 |
+
"IMAGE"
|
| 792 |
+
],
|
| 793 |
+
[
|
| 794 |
+
156,
|
| 795 |
+
14,
|
| 796 |
+
0,
|
| 797 |
+
65,
|
| 798 |
+
1,
|
| 799 |
+
"IMAGE"
|
| 800 |
+
],
|
| 801 |
+
[
|
| 802 |
+
179,
|
| 803 |
+
33,
|
| 804 |
+
0,
|
| 805 |
+
67,
|
| 806 |
+
0,
|
| 807 |
+
"IMAGE"
|
| 808 |
+
],
|
| 809 |
+
[
|
| 810 |
+
180,
|
| 811 |
+
67,
|
| 812 |
+
0,
|
| 813 |
+
68,
|
| 814 |
+
0,
|
| 815 |
+
"IMAGE"
|
| 816 |
+
],
|
| 817 |
+
[
|
| 818 |
+
181,
|
| 819 |
+
67,
|
| 820 |
+
1,
|
| 821 |
+
68,
|
| 822 |
+
1,
|
| 823 |
+
"MASK"
|
| 824 |
+
],
|
| 825 |
+
[
|
| 826 |
+
189,
|
| 827 |
+
67,
|
| 828 |
+
0,
|
| 829 |
+
65,
|
| 830 |
+
0,
|
| 831 |
+
"IMAGE"
|
| 832 |
+
],
|
| 833 |
+
[
|
| 834 |
+
190,
|
| 835 |
+
67,
|
| 836 |
+
1,
|
| 837 |
+
65,
|
| 838 |
+
2,
|
| 839 |
+
"MASK"
|
| 840 |
+
],
|
| 841 |
+
[
|
| 842 |
+
193,
|
| 843 |
+
67,
|
| 844 |
+
1,
|
| 845 |
+
44,
|
| 846 |
+
4,
|
| 847 |
+
"MASK"
|
| 848 |
+
],
|
| 849 |
+
[
|
| 850 |
+
196,
|
| 851 |
+
68,
|
| 852 |
+
0,
|
| 853 |
+
73,
|
| 854 |
+
0,
|
| 855 |
+
"IMAGE"
|
| 856 |
+
],
|
| 857 |
+
[
|
| 858 |
+
197,
|
| 859 |
+
67,
|
| 860 |
+
1,
|
| 861 |
+
73,
|
| 862 |
+
1,
|
| 863 |
+
"MASK"
|
| 864 |
+
],
|
| 865 |
+
[
|
| 866 |
+
198,
|
| 867 |
+
73,
|
| 868 |
+
0,
|
| 869 |
+
44,
|
| 870 |
+
3,
|
| 871 |
+
"IMAGE"
|
| 872 |
+
]
|
| 873 |
+
],
|
| 874 |
+
"groups": [],
|
| 875 |
+
"config": {},
|
| 876 |
+
"extra": {},
|
| 877 |
+
"version": 0.4
|
| 878 |
+
}
|