Upload folder using huggingface_hub
Browse files- .gitattributes +6 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/.github/workflows/publish.yml +25 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/.gitignore +3 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/LICENSE +674 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/README.md +153 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/__init__.py +16 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_flux.jpg +3 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_flux.json +1176 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_hires.jpg +3 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_hires.json +1335 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_sd15.jpg +3 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_sd15.json +726 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/inpaint_cropandstitch.py +1650 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/inpaint_flux.png +3 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/inpaint_hires.png +3 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/inpaint_sd15.png +3 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/js/showcontrol.js +159 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/pyproject.toml +14 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-105444.59999999404.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-1670481.1000000015.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-2116156.8999999985.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-213955.39999999944.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-219964.40000000596.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-225116.5.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-248882.59999999404.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-3225001.799999997.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-3255269.599999994.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-3492848.299999997.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-3535755.200000003.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-5472479.200000003.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-5485412.599999994.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-562340.6999999881.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-576288.900000006.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-588013.599999994.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-69973.90000000596.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-84438.39999999106.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-991989.900000006.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/example.png +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testscpu.json +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/testsgpu.json +0 -0
- v3-nodes/ComfyUI-Inpaint-CropAndStitch/windlereye.jpg +0 -0
.gitattributes
CHANGED
|
@@ -276,3 +276,9 @@ v3-nodes/a-person-mask-generator/readme/01-face.png filter=lfs diff=lfs merge=lf
|
|
| 276 |
v3-nodes/a-person-mask-generator/readme/05-refine_mask.png filter=lfs diff=lfs merge=lfs -text
|
| 277 |
v3-nodes/a-person-mask-generator/readme/ComfyUI-Workflow-FaceLandmarks.png filter=lfs diff=lfs merge=lfs -text
|
| 278 |
v3-nodes/a-person-mask-generator/readme/ComfyUI-workflow.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
v3-nodes/a-person-mask-generator/readme/05-refine_mask.png filter=lfs diff=lfs merge=lfs -text
|
| 277 |
v3-nodes/a-person-mask-generator/readme/ComfyUI-Workflow-FaceLandmarks.png filter=lfs diff=lfs merge=lfs -text
|
| 278 |
v3-nodes/a-person-mask-generator/readme/ComfyUI-workflow.png filter=lfs diff=lfs merge=lfs -text
|
| 279 |
+
v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_flux.jpg filter=lfs diff=lfs merge=lfs -text
|
| 280 |
+
v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_hires.jpg filter=lfs diff=lfs merge=lfs -text
|
| 281 |
+
v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_sd15.jpg filter=lfs diff=lfs merge=lfs -text
|
| 282 |
+
v3-nodes/ComfyUI-Inpaint-CropAndStitch/inpaint_flux.png filter=lfs diff=lfs merge=lfs -text
|
| 283 |
+
v3-nodes/ComfyUI-Inpaint-CropAndStitch/inpaint_hires.png filter=lfs diff=lfs merge=lfs -text
|
| 284 |
+
v3-nodes/ComfyUI-Inpaint-CropAndStitch/inpaint_sd15.png filter=lfs diff=lfs merge=lfs -text
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/.github/workflows/publish.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Publish to Comfy registry
|
| 2 |
+
on:
|
| 3 |
+
workflow_dispatch:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- main
|
| 7 |
+
paths:
|
| 8 |
+
- "pyproject.toml"
|
| 9 |
+
|
| 10 |
+
permissions:
|
| 11 |
+
issues: write
|
| 12 |
+
|
| 13 |
+
jobs:
|
| 14 |
+
publish-node:
|
| 15 |
+
name: Publish Custom Node to registry
|
| 16 |
+
runs-on: ubuntu-latest
|
| 17 |
+
if: ${{ github.repository_owner == 'lquesada' }}
|
| 18 |
+
steps:
|
| 19 |
+
- name: Check out code
|
| 20 |
+
uses: actions/checkout@v4
|
| 21 |
+
- name: Publish Custom Node
|
| 22 |
+
uses: Comfy-Org/publish-node-action@v1
|
| 23 |
+
with:
|
| 24 |
+
## Add your own personal access token to your Github Repository secrets and reference it here.
|
| 25 |
+
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
| 2 |
+
*.pyc
|
| 3 |
+
*.pyo
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/LICENSE
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 |
+
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>.
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ComfyUI-Inpaint-CropAndStitch
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2024-2026, Luis Quesada Torres - https://github.com/lquesada | www.luisquesada.com
|
| 4 |
+
|
| 5 |
+
Check ComfyUI here: https://github.com/comfyanonymous/ComfyUI
|
| 6 |
+
|
| 7 |
+
# Overview
|
| 8 |
+
|
| 9 |
+
The '✂️ Inpaint Crop' and '✂️ Inpaint Stitch' nodes enable inpainting only on masked area very easily
|
| 10 |
+
|
| 11 |
+
"✂️ Inpaint Crop" crops the image around the masked area (optionally with a context area that marks all parts relevant to the context), taking care of pre-resizing the image if desired, extending it for outpainting, filling mask holes, growing or blurring the mask, cutting around a larger context area, and resizing the cropped area to a target resolution.
|
| 12 |
+
|
| 13 |
+
The cropped image can be used in any standard workflow for sampling. It can even be rescaled up with any model (please keep the aspect ratio) and hiRes-fixed and it will be retrofit in the original image.
|
| 14 |
+
|
| 15 |
+
Then, the "✂️ Inpaint Stitch" node stitches the inpainted image back into the original image without altering unmasked areas.
|
| 16 |
+
|
| 17 |
+
The main advantages of inpainting only in a masked area with these nodes are:
|
| 18 |
+
- It is much faster than sampling the whole image.
|
| 19 |
+
- It enables setting the right amount of context from the image for the prompt to be more accurately represented in the generated picture.
|
| 20 |
+
- It enables upscaling before sampling in order to generate more detail, then stitching back in the original picture.
|
| 21 |
+
- It enables downscaling before sampling if the area is too large, in order to avoid artifacts such as double heads or double bodies.
|
| 22 |
+
- It enables forcing a specific resolution (e.g. 1024x1024 for SDXL models).
|
| 23 |
+
- It does not modify the unmasked part of the image, not even passing it through VAE encode and decode.
|
| 24 |
+
- It takes care of blending automatically.
|
| 25 |
+
|
| 26 |
+
# Support me!
|
| 27 |
+
|
| 28 |
+
GenAI is not just for the sake of GenAI, but to unblock creativity and empower humans. I am not only a developer; I use GenAI myself to do **more** things **better** than I could otherwise do.
|
| 29 |
+
|
| 30 |
+
Do you like this node? Check, listen to, or follow my GenAI music project [**Windlereye** on Spotify](https://open.spotify.com/artist/6GdiI8ZKeWhSY73WWOhbep) to support me!
|
| 31 |
+
|
| 32 |
+
[](https://open.spotify.com/artist/6GdiI8ZKeWhSY73WWOhbep)
|
| 33 |
+
|
| 34 |
+
# Video Tutorial
|
| 35 |
+
|
| 36 |
+
[](https://www.youtube.com/watch?v=mI0UWm7BNtQ)
|
| 37 |
+
|
| 38 |
+
[(click to open in YouTube)](https://www.youtube.com/watch?v=mI0UWm7BNtQ)
|
| 39 |
+
|
| 40 |
+
Note: this video tutorial is for the previous version of the nodes, but still it shows how to use them. The parameters are mostly the same.
|
| 41 |
+
|
| 42 |
+
## Parameters
|
| 43 |
+
- `downscale_algorithm` and `upscale_algorithm`: Which algorithms to use when resizing an image up or down.
|
| 44 |
+
- `preresize`: Shows options to resize the input image before any cropping: to ensure minimum resolution, to ensure maximum resolution, to ensure both minimum and maximum resolution. This makes it very convenient to ensure that any input images have a certain resolution.
|
| 45 |
+
- `mask_fill_holes`: Whether to fully fill any holes (small or large) in the mask, that is, mark fully enclosed areas as part of the mask.
|
| 46 |
+
- `mask_expand_pixels`: Grows the mask by the specified amount of pixels.
|
| 47 |
+
- `mask_invert`: Whether to fully invert the mask, that is, only keep what was masked, instead of removing what was marked.
|
| 48 |
+
- `mask_blend_pixels`: Grows the stitch mask and blurs it by the specified amount of pixels, so that the stitch is slowly blended and there are no seams.
|
| 49 |
+
- `mask_hipass_filter`: Ignores mask values lower than the one specified here. This is to avoid sections in the mask that are almost 0 (black) to count as masked area. Sometimes that leads to confusion, as the user believes the area is not really masked and the node is considering it as masked.
|
| 50 |
+
- `extend_for_outpainting`: Shows options to extend the mask in any/all directions (up/down/left/right) by a certain factor. >1 extends the image, e.g. 2 extends the image in a direction by the same amount of space the image takes. <1 crops the image, e.g. 0.75 removes 25% of the image on that direction.
|
| 51 |
+
- `context_from_mask_extend_factor`: Extends the context area by a factor of the size of the mask. The higher this value is, the more area will be cropped around the mask for the model to have more context. 1 means do not grow. 2 means grow the same size of the mask across every direction.
|
| 52 |
+
- `output_resize_to_target_size`: Forces that the cropped image has a specific resolution. This may involve resizing and extending out of the original image, but the stitch node reverts those changes to integrate the image seamlessly.
|
| 53 |
+
- `output_padding`: Ensures that the cropped image width and height are a multiple of this padding value. Models require images to be padded to a certain value (8, 16, 32) to function properly.
|
| 54 |
+
- `device_mode`: `cpu (compatible)` should always work but is slow, `gpu (much faster)` is much faster but may not work in all setups. Default is GPU given the performance improvements.
|
| 55 |
+
|
| 56 |
+
## Example (Stable Diffusion)
|
| 57 |
+
This example inpaints by sampling on a small section of the larger image, upscaling to fit 512x512, then stitching and blending back in the original image.
|
| 58 |
+
|
| 59 |
+
Download the following example workflow from [here](example_workflows/inpaint_sd15.json) or drag and drop the screenshot into ComfyUI.
|
| 60 |
+
|
| 61 |
+

|
| 62 |
+
|
| 63 |
+
## Example (Flux)
|
| 64 |
+
This example uses Flux. Requires the GGUF nodes.
|
| 65 |
+
|
| 66 |
+
Models used:
|
| 67 |
+
|
| 68 |
+
- `Flux Dev Q5 GGUF` from [here](https://civitai.com/models/711483/flux-dev-q5km-gguf-quantization-a-nice-balance-of-speed-and-quality-in-under-9-gigabytes?modelVersionId=795785). Put it in models/unet/.
|
| 69 |
+
- `Flux 1. dev controlnet inpainting beta` from [here](https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Beta). Put it in models/controlnet/.
|
| 70 |
+
- `t5 GGUF Q3_K_L` from [here](https://huggingface.co/city96/t5-v1_1-xxl-encoder-gguf/tree/main). Put it in models/clip/.
|
| 71 |
+
- `clip_l` from [here](https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/clip_l.safetensors). Put it in models/clip/.
|
| 72 |
+
- `ae VAE` from [here](https://huggingface.co/black-forest-labs/FLUX.1-schnell/blob/main/ae.safetensors). Put it in models/vae/.
|
| 73 |
+
|
| 74 |
+
Download the following example workflow from [here](example_workflows/inpaint_flux.json) or drag and drop the screenshot into ComfyUI.
|
| 75 |
+
|
| 76 |
+

|
| 77 |
+
|
| 78 |
+
## Example (Large resolution)
|
| 79 |
+
This example uses SD 1.5 to sample on a section of the larger image. Then it upscales the sampled image by 4x using an external model and applies a hiRes fix. Then it blends it back into the original image.
|
| 80 |
+
|
| 81 |
+
Models used:
|
| 82 |
+
|
| 83 |
+
- `4x Ultrasharp` from [here](https://huggingface.co/lokCX/4x-Ultrasharp/blob/main/4x-UltraSharp.pth).
|
| 84 |
+
|
| 85 |
+
Download the following example workflow from [here](example_workflows/inpaint_hires.json) or drag and drop the screenshot into ComfyUI.
|
| 86 |
+
|
| 87 |
+

|
| 88 |
+
|
| 89 |
+
# Installation Instructions
|
| 90 |
+
|
| 91 |
+
Install via ComfyUI-Manager or go to the custom_nodes/ directory and run ```$ git clone https://github.com/lquesada/ComfyUI-Inpaint-CropAndStitch.git```
|
| 92 |
+
|
| 93 |
+
## Best Practices
|
| 94 |
+
Use an inpainting model e.g. lazymixRealAmateur_v40Inpainting.
|
| 95 |
+
|
| 96 |
+
Use "InpaintModelConditioning" instead of "VAE Encode (for Inpainting)" to be able to set denoise values lower than 1.
|
| 97 |
+
|
| 98 |
+
Enable "resize to target size" and set it to a preferred resolution for your model, e.g. 512x512 for SD 1.5, 1024x1024 for SDXL or Flux.
|
| 99 |
+
|
| 100 |
+
If you mask an area and you can still see the original image through the rendered image, it is **very likely** that your mask is not fully opaque. Even if it looks fully opaque - the human brain cannot tell a difference between many shades of grey. Please make sure that the mask is 100% opaque, e.g. take a screenshot, check pixel values for 255, 255, 255 or #FFFFFF. If you use mask fill holes, check that the entire boundary is 255, 255, 255 or #FFFFFF e.g. with the fuzzy select tool in Gimp with threshold 0.
|
| 101 |
+
|
| 102 |
+
If you are running out of memory (likely you're processing very large videos), switch from GPU to CPU mode in the crop node - this will make both crop and stitch use CPU and RAM instead of VRAM.
|
| 103 |
+
|
| 104 |
+
# Changelog
|
| 105 |
+
## 2026-01-09
|
| 106 |
+
- Huge performance improvement of 30x-100x by adding GPU support (new default is GPU, CPU is available as an option for fallback).
|
| 107 |
+
- Clean up: Removed the long-deprecated old versions.
|
| 108 |
+
## 2025-04-06
|
| 109 |
+
- Published the improved version of the Crop and Stitch nodes.
|
| 110 |
+
- Improved: Stitching is now way more precise. In the previous version, stitching an image back into place could shift it by one pixel. That will not happen anymore.
|
| 111 |
+
- Improved: Images are now cropped before being resized. In the past, they were resized before being cropped. This triggered crashes when the input image was large and the masked area was small.
|
| 112 |
+
- Improved: Images are now not extended more than necessary. In the past, they were extended x3, which was memory inefficient.
|
| 113 |
+
- Improved: The cropped area will stay inside of the image if possible. In the past, the cropped area was centered around the mask and would go out of the image even if not needed.
|
| 114 |
+
- Improved: Fill mask holes will now supports grayscale masks. In the past, it turned the mask into binary (yes/no only).
|
| 115 |
+
- Improved: Added a hipass filter for mask that ignores values below a threshold. In the past, sometimes mask with a 0.01 value (basically black / no mask) would be considered mask, which was very confusing to users.
|
| 116 |
+
- Improved: In the (now rare) case that extending out of the image is needed, instead of mirroring the original image, the edges are extended. Mirroring caused confusion among users in the past.
|
| 117 |
+
- Improved: Integrated preresize and extend for outpainting in the crop node. In the past, they were external and could interact weirdly with features, e.g. expanding for outpainting on the four directions and having "fill_mask_holes" would cause the mask to be fully set across the whole image.
|
| 118 |
+
- Improved: Now works when passing one mask for several images or one image for several masks.
|
| 119 |
+
- UX: Streamlined many options, e.g. merged the blur and blend features in a single parameter, removed the ranged size option, removed context_expand_pixels as factor is more intuitive, etc.
|
| 120 |
+
- Clean up: Marked the old nodes ("Crop", "Stitch", "Extend Image for Outpainting", and "Resize Image Before Inpainting") as obsolete. They will continue working in old workflows but will have a note in the title asking to update. In particular, there's no replacement for "Extend Image for Outpainting" and "Resize Image Before Inpainting" because those features are now integrated in the Crop node.
|
| 121 |
+
## 2024-10-28
|
| 122 |
+
- Added a new example workflow for inpainting with flux.
|
| 123 |
+
## 2024-06-10
|
| 124 |
+
- Added a new node: "Resize Image Before Inpainting", which allows increasing the resolution of the input image by a factor or to a minimum width or height to obtain higher resolution inpaintings.
|
| 125 |
+
## 2024-06-08
|
| 126 |
+
- Added a new node: "Extend Image for Outpainting", which allows leveraging the power of Inpaint Crop and Stitch (rescaling, blur, blend, restitching) for outpainting.
|
| 127 |
+
## 2024-06-07
|
| 128 |
+
- Added a blending radius for seamless inpainting.
|
| 129 |
+
- Added a blur mask setting that grows and blurs the mask, providing better support.
|
| 130 |
+
- Updated default to ranged size.
|
| 131 |
+
## 2024-06-01
|
| 132 |
+
- Force_size is now specified as separate force_width and force_height, to match any desired sampling resolution.
|
| 133 |
+
- Added a new mode: ranged size, similar to free size but also takes min_width, min_height, max_width, and max_height, in order to avoid over scaling or under scaling beyond desirable limits.
|
| 134 |
+
## 2024-05-15
|
| 135 |
+
- Depending on the selected mode ("free size" or "forced size") some fields are hidden.
|
| 136 |
+
## 2024-05-14
|
| 137 |
+
- Added batch support.
|
| 138 |
+
- Enabled selecting rescaling algorithm and made bicubic the default for crop, which significantly speeds up the process.
|
| 139 |
+
## 2024-05-13
|
| 140 |
+
- Switched from adjust_to_preferred_sizes to modes: free size and forced size. Forced scales the section rather than growing the context area to fit preferred_sizes, to be used to e.g. force 1024x1024 for inpainting.
|
| 141 |
+
- Enabled internal_upscale_factor to be lower than 1 (that is, downscale), which can be used to avoid the double head issue in some models.
|
| 142 |
+
- Added padding on the croppedp image to avoid artifacts when the cropped image is not multiple of (default) 32
|
| 143 |
+
## 2024-05-12
|
| 144 |
+
- Added internal_upscale_factor to upscale the image before sampling and then downsizes to stitch it back.
|
| 145 |
+
## 2024-05-11
|
| 146 |
+
- Initial commit.
|
| 147 |
+
|
| 148 |
+
# Acknowledgements
|
| 149 |
+
|
| 150 |
+
This repository uses some code from comfy_extras (https://github.com/comfyanonymous/ComfyUI), KJNodes (https://github.com/kijai/ComfyUI-KJNodes), and Efficiency Nodes (https://github.com/LucianoCirino/efficiency-nodes-comfyui), all of them licensed under GNU GENERAL PUBLIC LICENSE Version 3.
|
| 151 |
+
|
| 152 |
+
# License
|
| 153 |
+
GNU GENERAL PUBLIC LICENSE Version 3, see [LICENSE](LICENSE)
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .inpaint_cropandstitch import InpaintCropImproved
|
| 2 |
+
from .inpaint_cropandstitch import InpaintStitchImproved
|
| 3 |
+
|
| 4 |
+
WEB_DIRECTORY = "js"
|
| 5 |
+
|
| 6 |
+
NODE_CLASS_MAPPINGS = {
|
| 7 |
+
"InpaintCropImproved": InpaintCropImproved,
|
| 8 |
+
"InpaintStitchImproved": InpaintStitchImproved,
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
NODE_DISPLAY_NAME_MAPPINGS = {
|
| 12 |
+
"InpaintCropImproved": "✂️ Inpaint Crop",
|
| 13 |
+
"InpaintStitchImproved": "✂️ Inpaint Stitch",
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_flux.jpg
ADDED
|
Git LFS Details
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_flux.json
ADDED
|
@@ -0,0 +1,1176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"last_node_id": 87,
|
| 3 |
+
"last_link_id": 174,
|
| 4 |
+
"nodes": [
|
| 5 |
+
{
|
| 6 |
+
"id": 25,
|
| 7 |
+
"type": "VAELoader",
|
| 8 |
+
"pos": [
|
| 9 |
+
620,
|
| 10 |
+
1120
|
| 11 |
+
],
|
| 12 |
+
"size": [
|
| 13 |
+
315,
|
| 14 |
+
58
|
| 15 |
+
],
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 0,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"inputs": [],
|
| 20 |
+
"outputs": [
|
| 21 |
+
{
|
| 22 |
+
"name": "VAE",
|
| 23 |
+
"type": "VAE",
|
| 24 |
+
"shape": 3,
|
| 25 |
+
"links": [
|
| 26 |
+
70,
|
| 27 |
+
147
|
| 28 |
+
],
|
| 29 |
+
"slot_index": 0
|
| 30 |
+
}
|
| 31 |
+
],
|
| 32 |
+
"properties": {
|
| 33 |
+
"cnr_id": "comfy-core",
|
| 34 |
+
"ver": "0.3.26",
|
| 35 |
+
"Node name for S&R": "VAELoader"
|
| 36 |
+
},
|
| 37 |
+
"widgets_values": [
|
| 38 |
+
"ae.safetensors"
|
| 39 |
+
]
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"id": 51,
|
| 43 |
+
"type": "UnetLoaderGGUF",
|
| 44 |
+
"pos": [
|
| 45 |
+
620,
|
| 46 |
+
1240
|
| 47 |
+
],
|
| 48 |
+
"size": [
|
| 49 |
+
315,
|
| 50 |
+
58
|
| 51 |
+
],
|
| 52 |
+
"flags": {},
|
| 53 |
+
"order": 1,
|
| 54 |
+
"mode": 0,
|
| 55 |
+
"inputs": [],
|
| 56 |
+
"outputs": [
|
| 57 |
+
{
|
| 58 |
+
"name": "MODEL",
|
| 59 |
+
"type": "MODEL",
|
| 60 |
+
"links": [
|
| 61 |
+
102,
|
| 62 |
+
150
|
| 63 |
+
],
|
| 64 |
+
"slot_index": 0
|
| 65 |
+
}
|
| 66 |
+
],
|
| 67 |
+
"properties": {
|
| 68 |
+
"cnr_id": "ComfyUI-GGUF",
|
| 69 |
+
"ver": "5aa6e98ad74e2fa826f80c8dbded5ec3dd09ba1f",
|
| 70 |
+
"Node name for S&R": "UnetLoaderGGUF"
|
| 71 |
+
},
|
| 72 |
+
"widgets_values": [
|
| 73 |
+
"fluxDevQ5KMGGUFQuantizationA_v10.gguf"
|
| 74 |
+
]
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"id": 29,
|
| 78 |
+
"type": "KSamplerSelect",
|
| 79 |
+
"pos": [
|
| 80 |
+
1410,
|
| 81 |
+
1050
|
| 82 |
+
],
|
| 83 |
+
"size": [
|
| 84 |
+
250,
|
| 85 |
+
60
|
| 86 |
+
],
|
| 87 |
+
"flags": {},
|
| 88 |
+
"order": 2,
|
| 89 |
+
"mode": 0,
|
| 90 |
+
"inputs": [],
|
| 91 |
+
"outputs": [
|
| 92 |
+
{
|
| 93 |
+
"name": "SAMPLER",
|
| 94 |
+
"type": "SAMPLER",
|
| 95 |
+
"shape": 3,
|
| 96 |
+
"links": [
|
| 97 |
+
152
|
| 98 |
+
]
|
| 99 |
+
}
|
| 100 |
+
],
|
| 101 |
+
"properties": {
|
| 102 |
+
"cnr_id": "comfy-core",
|
| 103 |
+
"ver": "0.3.26",
|
| 104 |
+
"Node name for S&R": "KSamplerSelect"
|
| 105 |
+
},
|
| 106 |
+
"widgets_values": [
|
| 107 |
+
"euler"
|
| 108 |
+
]
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"id": 84,
|
| 112 |
+
"type": "EmptySD3LatentImage",
|
| 113 |
+
"pos": [
|
| 114 |
+
1410,
|
| 115 |
+
1340
|
| 116 |
+
],
|
| 117 |
+
"size": [
|
| 118 |
+
250,
|
| 119 |
+
110
|
| 120 |
+
],
|
| 121 |
+
"flags": {},
|
| 122 |
+
"order": 3,
|
| 123 |
+
"mode": 0,
|
| 124 |
+
"inputs": [],
|
| 125 |
+
"outputs": [
|
| 126 |
+
{
|
| 127 |
+
"name": "LATENT",
|
| 128 |
+
"type": "LATENT",
|
| 129 |
+
"links": [
|
| 130 |
+
158
|
| 131 |
+
],
|
| 132 |
+
"slot_index": 0
|
| 133 |
+
}
|
| 134 |
+
],
|
| 135 |
+
"properties": {
|
| 136 |
+
"cnr_id": "comfy-core",
|
| 137 |
+
"ver": "0.3.26",
|
| 138 |
+
"Node name for S&R": "EmptySD3LatentImage"
|
| 139 |
+
},
|
| 140 |
+
"widgets_values": [
|
| 141 |
+
1024,
|
| 142 |
+
1024,
|
| 143 |
+
1
|
| 144 |
+
]
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"id": 32,
|
| 148 |
+
"type": "RandomNoise",
|
| 149 |
+
"pos": [
|
| 150 |
+
1410,
|
| 151 |
+
750
|
| 152 |
+
],
|
| 153 |
+
"size": [
|
| 154 |
+
250,
|
| 155 |
+
82
|
| 156 |
+
],
|
| 157 |
+
"flags": {},
|
| 158 |
+
"order": 4,
|
| 159 |
+
"mode": 0,
|
| 160 |
+
"inputs": [],
|
| 161 |
+
"outputs": [
|
| 162 |
+
{
|
| 163 |
+
"name": "NOISE",
|
| 164 |
+
"type": "NOISE",
|
| 165 |
+
"shape": 3,
|
| 166 |
+
"links": [
|
| 167 |
+
157
|
| 168 |
+
],
|
| 169 |
+
"slot_index": 0
|
| 170 |
+
}
|
| 171 |
+
],
|
| 172 |
+
"properties": {
|
| 173 |
+
"cnr_id": "comfy-core",
|
| 174 |
+
"ver": "0.3.26",
|
| 175 |
+
"Node name for S&R": "RandomNoise"
|
| 176 |
+
},
|
| 177 |
+
"widgets_values": [
|
| 178 |
+
1028751694899398,
|
| 179 |
+
"randomize"
|
| 180 |
+
],
|
| 181 |
+
"color": "#2a363b",
|
| 182 |
+
"bgcolor": "#3f5159"
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"id": 74,
|
| 186 |
+
"type": "ControlNetLoader",
|
| 187 |
+
"pos": [
|
| 188 |
+
620,
|
| 189 |
+
1350
|
| 190 |
+
],
|
| 191 |
+
"size": [
|
| 192 |
+
320,
|
| 193 |
+
60
|
| 194 |
+
],
|
| 195 |
+
"flags": {},
|
| 196 |
+
"order": 5,
|
| 197 |
+
"mode": 0,
|
| 198 |
+
"inputs": [],
|
| 199 |
+
"outputs": [
|
| 200 |
+
{
|
| 201 |
+
"name": "CONTROL_NET",
|
| 202 |
+
"label": "CONTROL_NET",
|
| 203 |
+
"type": "CONTROL_NET",
|
| 204 |
+
"shape": 3,
|
| 205 |
+
"links": [
|
| 206 |
+
126
|
| 207 |
+
],
|
| 208 |
+
"slot_index": 0
|
| 209 |
+
}
|
| 210 |
+
],
|
| 211 |
+
"properties": {
|
| 212 |
+
"cnr_id": "comfy-core",
|
| 213 |
+
"ver": "0.3.26",
|
| 214 |
+
"Node name for S&R": "ControlNetLoader"
|
| 215 |
+
},
|
| 216 |
+
"widgets_values": [
|
| 217 |
+
"FLUX.1-dev-Controlnet-Inpainting-Beta/diffusion_pytorch_model.safetensors"
|
| 218 |
+
]
|
| 219 |
+
},
|
| 220 |
+
{
|
| 221 |
+
"id": 59,
|
| 222 |
+
"type": "SamplerCustomAdvanced",
|
| 223 |
+
"pos": [
|
| 224 |
+
1700,
|
| 225 |
+
870
|
| 226 |
+
],
|
| 227 |
+
"size": [
|
| 228 |
+
240,
|
| 229 |
+
110
|
| 230 |
+
],
|
| 231 |
+
"flags": {},
|
| 232 |
+
"order": 16,
|
| 233 |
+
"mode": 0,
|
| 234 |
+
"inputs": [
|
| 235 |
+
{
|
| 236 |
+
"name": "noise",
|
| 237 |
+
"label": "noise",
|
| 238 |
+
"type": "NOISE",
|
| 239 |
+
"link": 157,
|
| 240 |
+
"slot_index": 0
|
| 241 |
+
},
|
| 242 |
+
{
|
| 243 |
+
"name": "guider",
|
| 244 |
+
"label": "guider",
|
| 245 |
+
"type": "GUIDER",
|
| 246 |
+
"link": 110,
|
| 247 |
+
"slot_index": 1
|
| 248 |
+
},
|
| 249 |
+
{
|
| 250 |
+
"name": "sampler",
|
| 251 |
+
"label": "sampler",
|
| 252 |
+
"type": "SAMPLER",
|
| 253 |
+
"link": 152,
|
| 254 |
+
"slot_index": 2
|
| 255 |
+
},
|
| 256 |
+
{
|
| 257 |
+
"name": "sigmas",
|
| 258 |
+
"label": "sigmas",
|
| 259 |
+
"type": "SIGMAS",
|
| 260 |
+
"link": 153,
|
| 261 |
+
"slot_index": 3
|
| 262 |
+
},
|
| 263 |
+
{
|
| 264 |
+
"name": "latent_image",
|
| 265 |
+
"label": "latent_image",
|
| 266 |
+
"type": "LATENT",
|
| 267 |
+
"link": 158,
|
| 268 |
+
"slot_index": 4
|
| 269 |
+
}
|
| 270 |
+
],
|
| 271 |
+
"outputs": [
|
| 272 |
+
{
|
| 273 |
+
"name": "output",
|
| 274 |
+
"label": "output",
|
| 275 |
+
"type": "LATENT",
|
| 276 |
+
"shape": 3,
|
| 277 |
+
"links": [
|
| 278 |
+
151
|
| 279 |
+
],
|
| 280 |
+
"slot_index": 0
|
| 281 |
+
},
|
| 282 |
+
{
|
| 283 |
+
"name": "denoised_output",
|
| 284 |
+
"label": "denoised_output",
|
| 285 |
+
"type": "LATENT",
|
| 286 |
+
"shape": 3,
|
| 287 |
+
"links": null
|
| 288 |
+
}
|
| 289 |
+
],
|
| 290 |
+
"properties": {
|
| 291 |
+
"cnr_id": "comfy-core",
|
| 292 |
+
"ver": "0.3.26",
|
| 293 |
+
"Node name for S&R": "SamplerCustomAdvanced"
|
| 294 |
+
},
|
| 295 |
+
"widgets_values": []
|
| 296 |
+
},
|
| 297 |
+
{
|
| 298 |
+
"id": 50,
|
| 299 |
+
"type": "DualCLIPLoaderGGUF",
|
| 300 |
+
"pos": [
|
| 301 |
+
620,
|
| 302 |
+
950
|
| 303 |
+
],
|
| 304 |
+
"size": [
|
| 305 |
+
315,
|
| 306 |
+
106
|
| 307 |
+
],
|
| 308 |
+
"flags": {},
|
| 309 |
+
"order": 6,
|
| 310 |
+
"mode": 0,
|
| 311 |
+
"inputs": [],
|
| 312 |
+
"outputs": [
|
| 313 |
+
{
|
| 314 |
+
"name": "CLIP",
|
| 315 |
+
"type": "CLIP",
|
| 316 |
+
"links": [
|
| 317 |
+
149,
|
| 318 |
+
159
|
| 319 |
+
],
|
| 320 |
+
"slot_index": 0
|
| 321 |
+
}
|
| 322 |
+
],
|
| 323 |
+
"properties": {
|
| 324 |
+
"cnr_id": "ComfyUI-GGUF",
|
| 325 |
+
"ver": "5aa6e98ad74e2fa826f80c8dbded5ec3dd09ba1f",
|
| 326 |
+
"Node name for S&R": "DualCLIPLoaderGGUF"
|
| 327 |
+
},
|
| 328 |
+
"widgets_values": [
|
| 329 |
+
"t5-v1_1-xxl-encoder-Q3_K_L.gguf",
|
| 330 |
+
"clip_l.safetensors",
|
| 331 |
+
"flux"
|
| 332 |
+
]
|
| 333 |
+
},
|
| 334 |
+
{
|
| 335 |
+
"id": 71,
|
| 336 |
+
"type": "ControlNetInpaintingAliMamaApply",
|
| 337 |
+
"pos": [
|
| 338 |
+
1060,
|
| 339 |
+
1210
|
| 340 |
+
],
|
| 341 |
+
"size": [
|
| 342 |
+
270,
|
| 343 |
+
210
|
| 344 |
+
],
|
| 345 |
+
"flags": {},
|
| 346 |
+
"order": 14,
|
| 347 |
+
"mode": 0,
|
| 348 |
+
"inputs": [
|
| 349 |
+
{
|
| 350 |
+
"name": "positive",
|
| 351 |
+
"label": "positive",
|
| 352 |
+
"type": "CONDITIONING",
|
| 353 |
+
"link": 155
|
| 354 |
+
},
|
| 355 |
+
{
|
| 356 |
+
"name": "negative",
|
| 357 |
+
"label": "negative",
|
| 358 |
+
"type": "CONDITIONING",
|
| 359 |
+
"link": 160
|
| 360 |
+
},
|
| 361 |
+
{
|
| 362 |
+
"name": "control_net",
|
| 363 |
+
"label": "control_net",
|
| 364 |
+
"type": "CONTROL_NET",
|
| 365 |
+
"link": 126
|
| 366 |
+
},
|
| 367 |
+
{
|
| 368 |
+
"name": "vae",
|
| 369 |
+
"label": "vae",
|
| 370 |
+
"type": "VAE",
|
| 371 |
+
"link": 147
|
| 372 |
+
},
|
| 373 |
+
{
|
| 374 |
+
"name": "image",
|
| 375 |
+
"label": "image",
|
| 376 |
+
"type": "IMAGE",
|
| 377 |
+
"link": 165
|
| 378 |
+
},
|
| 379 |
+
{
|
| 380 |
+
"name": "mask",
|
| 381 |
+
"label": "mask",
|
| 382 |
+
"type": "MASK",
|
| 383 |
+
"link": 166
|
| 384 |
+
}
|
| 385 |
+
],
|
| 386 |
+
"outputs": [
|
| 387 |
+
{
|
| 388 |
+
"name": "positive",
|
| 389 |
+
"label": "positive",
|
| 390 |
+
"type": "CONDITIONING",
|
| 391 |
+
"shape": 3,
|
| 392 |
+
"links": [
|
| 393 |
+
137
|
| 394 |
+
],
|
| 395 |
+
"slot_index": 0
|
| 396 |
+
},
|
| 397 |
+
{
|
| 398 |
+
"name": "negative",
|
| 399 |
+
"label": "negative",
|
| 400 |
+
"type": "CONDITIONING",
|
| 401 |
+
"shape": 3,
|
| 402 |
+
"links": [
|
| 403 |
+
138
|
| 404 |
+
],
|
| 405 |
+
"slot_index": 1
|
| 406 |
+
}
|
| 407 |
+
],
|
| 408 |
+
"properties": {
|
| 409 |
+
"cnr_id": "comfy-core",
|
| 410 |
+
"ver": "0.3.26",
|
| 411 |
+
"Node name for S&R": "ControlNetInpaintingAliMamaApply"
|
| 412 |
+
},
|
| 413 |
+
"widgets_values": [
|
| 414 |
+
0.7000000000000001,
|
| 415 |
+
0,
|
| 416 |
+
1
|
| 417 |
+
]
|
| 418 |
+
},
|
| 419 |
+
{
|
| 420 |
+
"id": 85,
|
| 421 |
+
"type": "CLIPTextEncodeFlux",
|
| 422 |
+
"pos": [
|
| 423 |
+
990,
|
| 424 |
+
990
|
| 425 |
+
],
|
| 426 |
+
"size": [
|
| 427 |
+
370,
|
| 428 |
+
166
|
| 429 |
+
],
|
| 430 |
+
"flags": {},
|
| 431 |
+
"order": 12,
|
| 432 |
+
"mode": 0,
|
| 433 |
+
"inputs": [
|
| 434 |
+
{
|
| 435 |
+
"name": "clip",
|
| 436 |
+
"label": "clip",
|
| 437 |
+
"type": "CLIP",
|
| 438 |
+
"link": 159
|
| 439 |
+
}
|
| 440 |
+
],
|
| 441 |
+
"outputs": [
|
| 442 |
+
{
|
| 443 |
+
"name": "CONDITIONING",
|
| 444 |
+
"label": "CONDITIONING",
|
| 445 |
+
"type": "CONDITIONING",
|
| 446 |
+
"shape": 3,
|
| 447 |
+
"links": [
|
| 448 |
+
160
|
| 449 |
+
],
|
| 450 |
+
"slot_index": 0
|
| 451 |
+
}
|
| 452 |
+
],
|
| 453 |
+
"properties": {
|
| 454 |
+
"cnr_id": "comfy-core",
|
| 455 |
+
"ver": "0.3.26",
|
| 456 |
+
"Node name for S&R": "CLIPTextEncodeFlux"
|
| 457 |
+
},
|
| 458 |
+
"widgets_values": [
|
| 459 |
+
"",
|
| 460 |
+
"bad, ugly, distorted, blurry",
|
| 461 |
+
3.5
|
| 462 |
+
],
|
| 463 |
+
"color": "#322",
|
| 464 |
+
"bgcolor": "#533"
|
| 465 |
+
},
|
| 466 |
+
{
|
| 467 |
+
"id": 80,
|
| 468 |
+
"type": "CFGGuider",
|
| 469 |
+
"pos": [
|
| 470 |
+
1410,
|
| 471 |
+
890
|
| 472 |
+
],
|
| 473 |
+
"size": [
|
| 474 |
+
250,
|
| 475 |
+
100
|
| 476 |
+
],
|
| 477 |
+
"flags": {},
|
| 478 |
+
"order": 15,
|
| 479 |
+
"mode": 0,
|
| 480 |
+
"inputs": [
|
| 481 |
+
{
|
| 482 |
+
"name": "model",
|
| 483 |
+
"type": "MODEL",
|
| 484 |
+
"link": 150
|
| 485 |
+
},
|
| 486 |
+
{
|
| 487 |
+
"name": "positive",
|
| 488 |
+
"type": "CONDITIONING",
|
| 489 |
+
"link": 137
|
| 490 |
+
},
|
| 491 |
+
{
|
| 492 |
+
"name": "negative",
|
| 493 |
+
"type": "CONDITIONING",
|
| 494 |
+
"link": 138
|
| 495 |
+
}
|
| 496 |
+
],
|
| 497 |
+
"outputs": [
|
| 498 |
+
{
|
| 499 |
+
"name": "GUIDER",
|
| 500 |
+
"type": "GUIDER",
|
| 501 |
+
"shape": 3,
|
| 502 |
+
"links": [
|
| 503 |
+
110
|
| 504 |
+
],
|
| 505 |
+
"slot_index": 0
|
| 506 |
+
}
|
| 507 |
+
],
|
| 508 |
+
"properties": {
|
| 509 |
+
"cnr_id": "comfy-core",
|
| 510 |
+
"ver": "0.3.26",
|
| 511 |
+
"Node name for S&R": "CFGGuider"
|
| 512 |
+
},
|
| 513 |
+
"widgets_values": [
|
| 514 |
+
1
|
| 515 |
+
]
|
| 516 |
+
},
|
| 517 |
+
{
|
| 518 |
+
"id": 10,
|
| 519 |
+
"type": "SaveImage",
|
| 520 |
+
"pos": [
|
| 521 |
+
1630,
|
| 522 |
+
250
|
| 523 |
+
],
|
| 524 |
+
"size": [
|
| 525 |
+
290,
|
| 526 |
+
350
|
| 527 |
+
],
|
| 528 |
+
"flags": {},
|
| 529 |
+
"order": 20,
|
| 530 |
+
"mode": 0,
|
| 531 |
+
"inputs": [
|
| 532 |
+
{
|
| 533 |
+
"name": "images",
|
| 534 |
+
"type": "IMAGE",
|
| 535 |
+
"link": 167,
|
| 536 |
+
"slot_index": 0
|
| 537 |
+
}
|
| 538 |
+
],
|
| 539 |
+
"outputs": [],
|
| 540 |
+
"properties": {
|
| 541 |
+
"cnr_id": "comfy-core",
|
| 542 |
+
"ver": "0.3.26"
|
| 543 |
+
},
|
| 544 |
+
"widgets_values": [
|
| 545 |
+
"%date:yyyyMMddhhmmss%"
|
| 546 |
+
]
|
| 547 |
+
},
|
| 548 |
+
{
|
| 549 |
+
"id": 54,
|
| 550 |
+
"type": "PreviewImage",
|
| 551 |
+
"pos": [
|
| 552 |
+
1730,
|
| 553 |
+
1060
|
| 554 |
+
],
|
| 555 |
+
"size": [
|
| 556 |
+
210,
|
| 557 |
+
246
|
| 558 |
+
],
|
| 559 |
+
"flags": {},
|
| 560 |
+
"order": 18,
|
| 561 |
+
"mode": 0,
|
| 562 |
+
"inputs": [
|
| 563 |
+
{
|
| 564 |
+
"name": "images",
|
| 565 |
+
"type": "IMAGE",
|
| 566 |
+
"link": 106
|
| 567 |
+
}
|
| 568 |
+
],
|
| 569 |
+
"outputs": [],
|
| 570 |
+
"properties": {
|
| 571 |
+
"cnr_id": "comfy-core",
|
| 572 |
+
"ver": "0.3.26",
|
| 573 |
+
"Node name for S&R": "PreviewImage"
|
| 574 |
+
},
|
| 575 |
+
"widgets_values": []
|
| 576 |
+
},
|
| 577 |
+
{
|
| 578 |
+
"id": 23,
|
| 579 |
+
"type": "VAEDecode",
|
| 580 |
+
"pos": [
|
| 581 |
+
1720,
|
| 582 |
+
750
|
| 583 |
+
],
|
| 584 |
+
"size": [
|
| 585 |
+
210,
|
| 586 |
+
46
|
| 587 |
+
],
|
| 588 |
+
"flags": {},
|
| 589 |
+
"order": 17,
|
| 590 |
+
"mode": 0,
|
| 591 |
+
"inputs": [
|
| 592 |
+
{
|
| 593 |
+
"name": "samples",
|
| 594 |
+
"type": "LATENT",
|
| 595 |
+
"link": 151
|
| 596 |
+
},
|
| 597 |
+
{
|
| 598 |
+
"name": "vae",
|
| 599 |
+
"type": "VAE",
|
| 600 |
+
"link": 70
|
| 601 |
+
}
|
| 602 |
+
],
|
| 603 |
+
"outputs": [
|
| 604 |
+
{
|
| 605 |
+
"name": "IMAGE",
|
| 606 |
+
"type": "IMAGE",
|
| 607 |
+
"links": [
|
| 608 |
+
106,
|
| 609 |
+
168
|
| 610 |
+
],
|
| 611 |
+
"slot_index": 0
|
| 612 |
+
}
|
| 613 |
+
],
|
| 614 |
+
"properties": {
|
| 615 |
+
"cnr_id": "comfy-core",
|
| 616 |
+
"ver": "0.3.26",
|
| 617 |
+
"Node name for S&R": "VAEDecode"
|
| 618 |
+
},
|
| 619 |
+
"widgets_values": []
|
| 620 |
+
},
|
| 621 |
+
{
|
| 622 |
+
"id": 87,
|
| 623 |
+
"type": "InpaintStitchImproved",
|
| 624 |
+
"pos": [
|
| 625 |
+
1200,
|
| 626 |
+
70
|
| 627 |
+
],
|
| 628 |
+
"size": [
|
| 629 |
+
240,
|
| 630 |
+
46
|
| 631 |
+
],
|
| 632 |
+
"flags": {},
|
| 633 |
+
"order": 19,
|
| 634 |
+
"mode": 0,
|
| 635 |
+
"inputs": [
|
| 636 |
+
{
|
| 637 |
+
"name": "stitcher",
|
| 638 |
+
"type": "STITCHER",
|
| 639 |
+
"link": 164
|
| 640 |
+
},
|
| 641 |
+
{
|
| 642 |
+
"name": "inpainted_image",
|
| 643 |
+
"type": "IMAGE",
|
| 644 |
+
"link": 168
|
| 645 |
+
}
|
| 646 |
+
],
|
| 647 |
+
"outputs": [
|
| 648 |
+
{
|
| 649 |
+
"name": "image",
|
| 650 |
+
"type": "IMAGE",
|
| 651 |
+
"links": [
|
| 652 |
+
167
|
| 653 |
+
],
|
| 654 |
+
"slot_index": 0
|
| 655 |
+
}
|
| 656 |
+
],
|
| 657 |
+
"properties": {
|
| 658 |
+
"Node name for S&R": "InpaintStitchImproved"
|
| 659 |
+
}
|
| 660 |
+
},
|
| 661 |
+
{
|
| 662 |
+
"id": 86,
|
| 663 |
+
"type": "InpaintCropImproved",
|
| 664 |
+
"pos": [
|
| 665 |
+
510,
|
| 666 |
+
70
|
| 667 |
+
],
|
| 668 |
+
"size": [
|
| 669 |
+
390,
|
| 670 |
+
578
|
| 671 |
+
],
|
| 672 |
+
"flags": {},
|
| 673 |
+
"order": 13,
|
| 674 |
+
"mode": 0,
|
| 675 |
+
"inputs": [
|
| 676 |
+
{
|
| 677 |
+
"name": "image",
|
| 678 |
+
"type": "IMAGE",
|
| 679 |
+
"link": 161
|
| 680 |
+
},
|
| 681 |
+
{
|
| 682 |
+
"name": "mask",
|
| 683 |
+
"type": "MASK",
|
| 684 |
+
"shape": 7,
|
| 685 |
+
"link": 162
|
| 686 |
+
},
|
| 687 |
+
{
|
| 688 |
+
"name": "optional_context_mask",
|
| 689 |
+
"type": "MASK",
|
| 690 |
+
"shape": 7,
|
| 691 |
+
"link": 163
|
| 692 |
+
}
|
| 693 |
+
],
|
| 694 |
+
"outputs": [
|
| 695 |
+
{
|
| 696 |
+
"name": "stitcher",
|
| 697 |
+
"type": "STITCHER",
|
| 698 |
+
"links": [
|
| 699 |
+
164
|
| 700 |
+
],
|
| 701 |
+
"slot_index": 0
|
| 702 |
+
},
|
| 703 |
+
{
|
| 704 |
+
"name": "cropped_image",
|
| 705 |
+
"type": "IMAGE",
|
| 706 |
+
"links": [
|
| 707 |
+
165
|
| 708 |
+
],
|
| 709 |
+
"slot_index": 1
|
| 710 |
+
},
|
| 711 |
+
{
|
| 712 |
+
"name": "cropped_mask",
|
| 713 |
+
"type": "MASK",
|
| 714 |
+
"links": [
|
| 715 |
+
166
|
| 716 |
+
],
|
| 717 |
+
"slot_index": 2
|
| 718 |
+
}
|
| 719 |
+
],
|
| 720 |
+
"properties": {
|
| 721 |
+
"Node name for S&R": "InpaintCropImproved"
|
| 722 |
+
},
|
| 723 |
+
"widgets_values": [
|
| 724 |
+
"bilinear",
|
| 725 |
+
"bicubic",
|
| 726 |
+
true,
|
| 727 |
+
"ensure minimum resolution",
|
| 728 |
+
1024,
|
| 729 |
+
1024,
|
| 730 |
+
16384,
|
| 731 |
+
16384,
|
| 732 |
+
true,
|
| 733 |
+
0,
|
| 734 |
+
false,
|
| 735 |
+
32,
|
| 736 |
+
0.1,
|
| 737 |
+
true,
|
| 738 |
+
1,
|
| 739 |
+
1,
|
| 740 |
+
1,
|
| 741 |
+
1,
|
| 742 |
+
1.2,
|
| 743 |
+
true,
|
| 744 |
+
1024,
|
| 745 |
+
1024,
|
| 746 |
+
"32"
|
| 747 |
+
]
|
| 748 |
+
},
|
| 749 |
+
{
|
| 750 |
+
"id": 3,
|
| 751 |
+
"type": "LoadImage",
|
| 752 |
+
"pos": [
|
| 753 |
+
40,
|
| 754 |
+
70
|
| 755 |
+
],
|
| 756 |
+
"size": [
|
| 757 |
+
370,
|
| 758 |
+
450
|
| 759 |
+
],
|
| 760 |
+
"flags": {},
|
| 761 |
+
"order": 7,
|
| 762 |
+
"mode": 0,
|
| 763 |
+
"inputs": [],
|
| 764 |
+
"outputs": [
|
| 765 |
+
{
|
| 766 |
+
"name": "IMAGE",
|
| 767 |
+
"type": "IMAGE",
|
| 768 |
+
"shape": 3,
|
| 769 |
+
"links": [
|
| 770 |
+
161
|
| 771 |
+
],
|
| 772 |
+
"slot_index": 0
|
| 773 |
+
},
|
| 774 |
+
{
|
| 775 |
+
"name": "MASK",
|
| 776 |
+
"type": "MASK",
|
| 777 |
+
"shape": 3,
|
| 778 |
+
"links": [
|
| 779 |
+
162
|
| 780 |
+
],
|
| 781 |
+
"slot_index": 1
|
| 782 |
+
}
|
| 783 |
+
],
|
| 784 |
+
"properties": {
|
| 785 |
+
"cnr_id": "comfy-core",
|
| 786 |
+
"ver": "0.3.26",
|
| 787 |
+
"Node name for S&R": "LoadImage"
|
| 788 |
+
},
|
| 789 |
+
"widgets_values": [
|
| 790 |
+
"clipspace/clipspace-mask-682793.8999999911.png [input]",
|
| 791 |
+
"image"
|
| 792 |
+
]
|
| 793 |
+
},
|
| 794 |
+
{
|
| 795 |
+
"id": 16,
|
| 796 |
+
"type": "LoadImage",
|
| 797 |
+
"pos": [
|
| 798 |
+
40,
|
| 799 |
+
610
|
| 800 |
+
],
|
| 801 |
+
"size": [
|
| 802 |
+
370,
|
| 803 |
+
450
|
| 804 |
+
],
|
| 805 |
+
"flags": {},
|
| 806 |
+
"order": 8,
|
| 807 |
+
"mode": 0,
|
| 808 |
+
"inputs": [],
|
| 809 |
+
"outputs": [
|
| 810 |
+
{
|
| 811 |
+
"name": "IMAGE",
|
| 812 |
+
"type": "IMAGE",
|
| 813 |
+
"shape": 3,
|
| 814 |
+
"links": [],
|
| 815 |
+
"slot_index": 0
|
| 816 |
+
},
|
| 817 |
+
{
|
| 818 |
+
"name": "MASK",
|
| 819 |
+
"type": "MASK",
|
| 820 |
+
"shape": 3,
|
| 821 |
+
"links": [
|
| 822 |
+
163
|
| 823 |
+
],
|
| 824 |
+
"slot_index": 1
|
| 825 |
+
}
|
| 826 |
+
],
|
| 827 |
+
"properties": {
|
| 828 |
+
"cnr_id": "comfy-core",
|
| 829 |
+
"ver": "0.3.26",
|
| 830 |
+
"Node name for S&R": "LoadImage"
|
| 831 |
+
},
|
| 832 |
+
"widgets_values": [
|
| 833 |
+
"clipspace/clipspace-mask-667975.png [input]",
|
| 834 |
+
"image"
|
| 835 |
+
]
|
| 836 |
+
},
|
| 837 |
+
{
|
| 838 |
+
"id": 73,
|
| 839 |
+
"type": "CLIPTextEncodeFlux",
|
| 840 |
+
"pos": [
|
| 841 |
+
990,
|
| 842 |
+
650
|
| 843 |
+
],
|
| 844 |
+
"size": [
|
| 845 |
+
370,
|
| 846 |
+
290
|
| 847 |
+
],
|
| 848 |
+
"flags": {},
|
| 849 |
+
"order": 11,
|
| 850 |
+
"mode": 0,
|
| 851 |
+
"inputs": [
|
| 852 |
+
{
|
| 853 |
+
"name": "clip",
|
| 854 |
+
"label": "clip",
|
| 855 |
+
"type": "CLIP",
|
| 856 |
+
"link": 149
|
| 857 |
+
}
|
| 858 |
+
],
|
| 859 |
+
"outputs": [
|
| 860 |
+
{
|
| 861 |
+
"name": "CONDITIONING",
|
| 862 |
+
"label": "CONDITIONING",
|
| 863 |
+
"type": "CONDITIONING",
|
| 864 |
+
"shape": 3,
|
| 865 |
+
"links": [
|
| 866 |
+
155
|
| 867 |
+
],
|
| 868 |
+
"slot_index": 0
|
| 869 |
+
}
|
| 870 |
+
],
|
| 871 |
+
"properties": {
|
| 872 |
+
"cnr_id": "comfy-core",
|
| 873 |
+
"ver": "0.3.26",
|
| 874 |
+
"Node name for S&R": "CLIPTextEncodeFlux"
|
| 875 |
+
},
|
| 876 |
+
"widgets_values": [
|
| 877 |
+
"a bottle full of red liquid, reflected on the floor",
|
| 878 |
+
"watercolor painting",
|
| 879 |
+
3.5
|
| 880 |
+
],
|
| 881 |
+
"color": "#232",
|
| 882 |
+
"bgcolor": "#353"
|
| 883 |
+
},
|
| 884 |
+
{
|
| 885 |
+
"id": 52,
|
| 886 |
+
"type": "Note",
|
| 887 |
+
"pos": [
|
| 888 |
+
20,
|
| 889 |
+
1110
|
| 890 |
+
],
|
| 891 |
+
"size": [
|
| 892 |
+
470,
|
| 893 |
+
330
|
| 894 |
+
],
|
| 895 |
+
"flags": {},
|
| 896 |
+
"order": 9,
|
| 897 |
+
"mode": 0,
|
| 898 |
+
"inputs": [],
|
| 899 |
+
"outputs": [],
|
| 900 |
+
"properties": {
|
| 901 |
+
"text": ""
|
| 902 |
+
},
|
| 903 |
+
"widgets_values": [
|
| 904 |
+
"Models used:\n\n- Flux Dev Q5 GGUF from https://civitai.com/models/711483/flux-dev-q5km-gguf-quantization-a-nice-balance-of-speed-and-quality-in-under-9-gigabytes?modelVersionId=795785.\n Put it in models/unet/\n\n- Flux 1. dev controlet inpainting beta from https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Beta\n Put it in models/controlnet/\n\n- t5 GGUF Q3_K_L from https://huggingface.co/city96/t5-v1_1-xxl-encoder-gguf/tree/main\n Put it in models/clip/\n\n- clip_l from https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/clip_l.safetensors\n Put it in models/clip/\n\n- ae VAE from https://huggingface.co/black-forest-labs/FLUX.1-schnell/blob/main/ae.safetensors\n Put it in models/vae/\n\n"
|
| 905 |
+
],
|
| 906 |
+
"color": "#432",
|
| 907 |
+
"bgcolor": "#653"
|
| 908 |
+
},
|
| 909 |
+
{
|
| 910 |
+
"id": 30,
|
| 911 |
+
"type": "BasicScheduler",
|
| 912 |
+
"pos": [
|
| 913 |
+
1410,
|
| 914 |
+
1170
|
| 915 |
+
],
|
| 916 |
+
"size": [
|
| 917 |
+
250,
|
| 918 |
+
110
|
| 919 |
+
],
|
| 920 |
+
"flags": {},
|
| 921 |
+
"order": 10,
|
| 922 |
+
"mode": 0,
|
| 923 |
+
"inputs": [
|
| 924 |
+
{
|
| 925 |
+
"name": "model",
|
| 926 |
+
"type": "MODEL",
|
| 927 |
+
"link": 102,
|
| 928 |
+
"slot_index": 0
|
| 929 |
+
}
|
| 930 |
+
],
|
| 931 |
+
"outputs": [
|
| 932 |
+
{
|
| 933 |
+
"name": "SIGMAS",
|
| 934 |
+
"type": "SIGMAS",
|
| 935 |
+
"shape": 3,
|
| 936 |
+
"links": [
|
| 937 |
+
153
|
| 938 |
+
]
|
| 939 |
+
}
|
| 940 |
+
],
|
| 941 |
+
"properties": {
|
| 942 |
+
"cnr_id": "comfy-core",
|
| 943 |
+
"ver": "0.3.26",
|
| 944 |
+
"Node name for S&R": "BasicScheduler"
|
| 945 |
+
},
|
| 946 |
+
"widgets_values": [
|
| 947 |
+
"simple",
|
| 948 |
+
8,
|
| 949 |
+
1
|
| 950 |
+
]
|
| 951 |
+
}
|
| 952 |
+
],
|
| 953 |
+
"links": [
|
| 954 |
+
[
|
| 955 |
+
70,
|
| 956 |
+
25,
|
| 957 |
+
0,
|
| 958 |
+
23,
|
| 959 |
+
1,
|
| 960 |
+
"VAE"
|
| 961 |
+
],
|
| 962 |
+
[
|
| 963 |
+
102,
|
| 964 |
+
51,
|
| 965 |
+
0,
|
| 966 |
+
30,
|
| 967 |
+
0,
|
| 968 |
+
"MODEL"
|
| 969 |
+
],
|
| 970 |
+
[
|
| 971 |
+
106,
|
| 972 |
+
23,
|
| 973 |
+
0,
|
| 974 |
+
54,
|
| 975 |
+
0,
|
| 976 |
+
"IMAGE"
|
| 977 |
+
],
|
| 978 |
+
[
|
| 979 |
+
110,
|
| 980 |
+
80,
|
| 981 |
+
0,
|
| 982 |
+
59,
|
| 983 |
+
1,
|
| 984 |
+
"GUIDER"
|
| 985 |
+
],
|
| 986 |
+
[
|
| 987 |
+
126,
|
| 988 |
+
74,
|
| 989 |
+
0,
|
| 990 |
+
71,
|
| 991 |
+
2,
|
| 992 |
+
"CONTROL_NET"
|
| 993 |
+
],
|
| 994 |
+
[
|
| 995 |
+
137,
|
| 996 |
+
71,
|
| 997 |
+
0,
|
| 998 |
+
80,
|
| 999 |
+
1,
|
| 1000 |
+
"CONDITIONING"
|
| 1001 |
+
],
|
| 1002 |
+
[
|
| 1003 |
+
138,
|
| 1004 |
+
71,
|
| 1005 |
+
1,
|
| 1006 |
+
80,
|
| 1007 |
+
2,
|
| 1008 |
+
"CONDITIONING"
|
| 1009 |
+
],
|
| 1010 |
+
[
|
| 1011 |
+
147,
|
| 1012 |
+
25,
|
| 1013 |
+
0,
|
| 1014 |
+
71,
|
| 1015 |
+
3,
|
| 1016 |
+
"VAE"
|
| 1017 |
+
],
|
| 1018 |
+
[
|
| 1019 |
+
149,
|
| 1020 |
+
50,
|
| 1021 |
+
0,
|
| 1022 |
+
73,
|
| 1023 |
+
0,
|
| 1024 |
+
"CLIP"
|
| 1025 |
+
],
|
| 1026 |
+
[
|
| 1027 |
+
150,
|
| 1028 |
+
51,
|
| 1029 |
+
0,
|
| 1030 |
+
80,
|
| 1031 |
+
0,
|
| 1032 |
+
"MODEL"
|
| 1033 |
+
],
|
| 1034 |
+
[
|
| 1035 |
+
151,
|
| 1036 |
+
59,
|
| 1037 |
+
0,
|
| 1038 |
+
23,
|
| 1039 |
+
0,
|
| 1040 |
+
"LATENT"
|
| 1041 |
+
],
|
| 1042 |
+
[
|
| 1043 |
+
152,
|
| 1044 |
+
29,
|
| 1045 |
+
0,
|
| 1046 |
+
59,
|
| 1047 |
+
2,
|
| 1048 |
+
"SAMPLER"
|
| 1049 |
+
],
|
| 1050 |
+
[
|
| 1051 |
+
153,
|
| 1052 |
+
30,
|
| 1053 |
+
0,
|
| 1054 |
+
59,
|
| 1055 |
+
3,
|
| 1056 |
+
"SIGMAS"
|
| 1057 |
+
],
|
| 1058 |
+
[
|
| 1059 |
+
155,
|
| 1060 |
+
73,
|
| 1061 |
+
0,
|
| 1062 |
+
71,
|
| 1063 |
+
0,
|
| 1064 |
+
"CONDITIONING"
|
| 1065 |
+
],
|
| 1066 |
+
[
|
| 1067 |
+
157,
|
| 1068 |
+
32,
|
| 1069 |
+
0,
|
| 1070 |
+
59,
|
| 1071 |
+
0,
|
| 1072 |
+
"NOISE"
|
| 1073 |
+
],
|
| 1074 |
+
[
|
| 1075 |
+
158,
|
| 1076 |
+
84,
|
| 1077 |
+
0,
|
| 1078 |
+
59,
|
| 1079 |
+
4,
|
| 1080 |
+
"LATENT"
|
| 1081 |
+
],
|
| 1082 |
+
[
|
| 1083 |
+
159,
|
| 1084 |
+
50,
|
| 1085 |
+
0,
|
| 1086 |
+
85,
|
| 1087 |
+
0,
|
| 1088 |
+
"CLIP"
|
| 1089 |
+
],
|
| 1090 |
+
[
|
| 1091 |
+
160,
|
| 1092 |
+
85,
|
| 1093 |
+
0,
|
| 1094 |
+
71,
|
| 1095 |
+
1,
|
| 1096 |
+
"CONDITIONING"
|
| 1097 |
+
],
|
| 1098 |
+
[
|
| 1099 |
+
161,
|
| 1100 |
+
3,
|
| 1101 |
+
0,
|
| 1102 |
+
86,
|
| 1103 |
+
0,
|
| 1104 |
+
"IMAGE"
|
| 1105 |
+
],
|
| 1106 |
+
[
|
| 1107 |
+
162,
|
| 1108 |
+
3,
|
| 1109 |
+
1,
|
| 1110 |
+
86,
|
| 1111 |
+
1,
|
| 1112 |
+
"MASK"
|
| 1113 |
+
],
|
| 1114 |
+
[
|
| 1115 |
+
163,
|
| 1116 |
+
16,
|
| 1117 |
+
1,
|
| 1118 |
+
86,
|
| 1119 |
+
2,
|
| 1120 |
+
"MASK"
|
| 1121 |
+
],
|
| 1122 |
+
[
|
| 1123 |
+
164,
|
| 1124 |
+
86,
|
| 1125 |
+
0,
|
| 1126 |
+
87,
|
| 1127 |
+
0,
|
| 1128 |
+
"STITCHER"
|
| 1129 |
+
],
|
| 1130 |
+
[
|
| 1131 |
+
165,
|
| 1132 |
+
86,
|
| 1133 |
+
1,
|
| 1134 |
+
71,
|
| 1135 |
+
4,
|
| 1136 |
+
"IMAGE"
|
| 1137 |
+
],
|
| 1138 |
+
[
|
| 1139 |
+
166,
|
| 1140 |
+
86,
|
| 1141 |
+
2,
|
| 1142 |
+
71,
|
| 1143 |
+
5,
|
| 1144 |
+
"MASK"
|
| 1145 |
+
],
|
| 1146 |
+
[
|
| 1147 |
+
167,
|
| 1148 |
+
87,
|
| 1149 |
+
0,
|
| 1150 |
+
10,
|
| 1151 |
+
0,
|
| 1152 |
+
"IMAGE"
|
| 1153 |
+
],
|
| 1154 |
+
[
|
| 1155 |
+
168,
|
| 1156 |
+
23,
|
| 1157 |
+
0,
|
| 1158 |
+
87,
|
| 1159 |
+
1,
|
| 1160 |
+
"IMAGE"
|
| 1161 |
+
]
|
| 1162 |
+
],
|
| 1163 |
+
"groups": [],
|
| 1164 |
+
"config": {},
|
| 1165 |
+
"extra": {
|
| 1166 |
+
"ds": {
|
| 1167 |
+
"scale": 0.8264462809917354,
|
| 1168 |
+
"offset": [
|
| 1169 |
+
22.553158958959973,
|
| 1170 |
+
78.18877073994109
|
| 1171 |
+
]
|
| 1172 |
+
},
|
| 1173 |
+
"ue_links": []
|
| 1174 |
+
},
|
| 1175 |
+
"version": 0.4
|
| 1176 |
+
}
|
v3-nodes/ComfyUI-Inp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|
+
"revision": 0,
|
| 4 |
+
"last_node_id": 37,
|
| 5 |
+
"last_link_id": 77,
|
| 6 |
+
"nodes": [
|
| 7 |
+
{
|
| 8 |
+
"id": 12,
|
| 9 |
+
"type": "CLIPTextEncode",
|
| 10 |
+
"pos": [
|
| 11 |
+
1050,
|
| 12 |
+
910
|
| 13 |
+
],
|
| 14 |
+
"size": [
|
| 15 |
+
302.3999938964844,
|
| 16 |
+
120
|
| 17 |
+
],
|
| 18 |
+
"flags": {},
|
| 19 |
+
"order": 6,
|
| 20 |
+
"mode": 0,
|
| 21 |
+
"inputs": [
|
| 22 |
+
{
|
| 23 |
+
"name": "clip",
|
| 24 |
+
"type": "CLIP",
|
| 25 |
+
"link": 24
|
| 26 |
+
}
|
| 27 |
+
],
|
| 28 |
+
"outputs": [
|
| 29 |
+
{
|
| 30 |
+
"name": "CONDITIONING",
|
| 31 |
+
"shape": 3,
|
| 32 |
+
"type": "CONDITIONING",
|
| 33 |
+
"slot_index": 0,
|
| 34 |
+
"links": [
|
| 35 |
+
38,
|
| 36 |
+
62
|
| 37 |
+
]
|
| 38 |
+
}
|
| 39 |
+
],
|
| 40 |
+
"title": "CLIP Text Encode (Prompt) - Negative",
|
| 41 |
+
"properties": {
|
| 42 |
+
"cnr_id": "comfy-core",
|
| 43 |
+
"ver": "0.3.26",
|
| 44 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 45 |
+
},
|
| 46 |
+
"widgets_values": [
|
| 47 |
+
"ugly, text, watermark"
|
| 48 |
+
],
|
| 49 |
+
"color": "#322",
|
| 50 |
+
"bgcolor": "#533"
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"id": 32,
|
| 54 |
+
"type": "VAEDecode",
|
| 55 |
+
"pos": [
|
| 56 |
+
2668.62060546875,
|
| 57 |
+
365.8939208984375
|
| 58 |
+
],
|
| 59 |
+
"size": [
|
| 60 |
+
210,
|
| 61 |
+
46
|
| 62 |
+
],
|
| 63 |
+
"flags": {},
|
| 64 |
+
"order": 18,
|
| 65 |
+
"mode": 0,
|
| 66 |
+
"inputs": [
|
| 67 |
+
{
|
| 68 |
+
"name": "samples",
|
| 69 |
+
"type": "LATENT",
|
| 70 |
+
"link": 67
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"name": "vae",
|
| 74 |
+
"type": "VAE",
|
| 75 |
+
"link": 66
|
| 76 |
+
}
|
| 77 |
+
],
|
| 78 |
+
"outputs": [
|
| 79 |
+
{
|
| 80 |
+
"name": "IMAGE",
|
| 81 |
+
"shape": 3,
|
| 82 |
+
"type": "IMAGE",
|
| 83 |
+
"slot_index": 0,
|
| 84 |
+
"links": [
|
| 85 |
+
68
|
| 86 |
+
]
|
| 87 |
+
}
|
| 88 |
+
],
|
| 89 |
+
"properties": {
|
| 90 |
+
"cnr_id": "comfy-core",
|
| 91 |
+
"ver": "0.3.26",
|
| 92 |
+
"Node name for S&R": "VAEDecode"
|
| 93 |
+
},
|
| 94 |
+
"widgets_values": []
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"id": 26,
|
| 98 |
+
"type": "InpaintStitchImproved",
|
| 99 |
+
"pos": [
|
| 100 |
+
2798.74755859375,
|
| 101 |
+
105.86776733398438
|
| 102 |
+
],
|
| 103 |
+
"size": [
|
| 104 |
+
235.1999969482422,
|
| 105 |
+
46
|
| 106 |
+
],
|
| 107 |
+
"flags": {},
|
| 108 |
+
"order": 19,
|
| 109 |
+
"mode": 0,
|
| 110 |
+
"inputs": [
|
| 111 |
+
{
|
| 112 |
+
"name": "stitcher",
|
| 113 |
+
"type": "STITCHER",
|
| 114 |
+
"link": 52
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"name": "inpainted_image",
|
| 118 |
+
"type": "IMAGE",
|
| 119 |
+
"link": 68
|
| 120 |
+
}
|
| 121 |
+
],
|
| 122 |
+
"outputs": [
|
| 123 |
+
{
|
| 124 |
+
"name": "image",
|
| 125 |
+
"type": "IMAGE",
|
| 126 |
+
"slot_index": 0,
|
| 127 |
+
"links": [
|
| 128 |
+
54
|
| 129 |
+
]
|
| 130 |
+
}
|
| 131 |
+
],
|
| 132 |
+
"properties": {
|
| 133 |
+
"cnr_id": "comfyui-inpaint-cropandstitch",
|
| 134 |
+
"ver": "de6c2f6462e5997519a07305ade0b987143da12b",
|
| 135 |
+
"Node name for S&R": "InpaintStitchImproved"
|
| 136 |
+
},
|
| 137 |
+
"widgets_values": []
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"id": 30,
|
| 141 |
+
"type": "InpaintModelConditioning",
|
| 142 |
+
"pos": [
|
| 143 |
+
2248.286865234375,
|
| 144 |
+
362.8361511230469
|
| 145 |
+
],
|
| 146 |
+
"size": [
|
| 147 |
+
216.59999084472656,
|
| 148 |
+
138
|
| 149 |
+
],
|
| 150 |
+
"flags": {},
|
| 151 |
+
"order": 16,
|
| 152 |
+
"mode": 0,
|
| 153 |
+
"inputs": [
|
| 154 |
+
{
|
| 155 |
+
"name": "positive",
|
| 156 |
+
"type": "CONDITIONING",
|
| 157 |
+
"link": 61
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
"name": "negative",
|
| 161 |
+
"type": "CONDITIONING",
|
| 162 |
+
"link": 62
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"name": "vae",
|
| 166 |
+
"type": "VAE",
|
| 167 |
+
"link": 60
|
| 168 |
+
},
|
| 169 |
+
{
|
| 170 |
+
"name": "pixels",
|
| 171 |
+
"type": "IMAGE",
|
| 172 |
+
"link": 59
|
| 173 |
+
},
|
| 174 |
+
{
|
| 175 |
+
"name": "mask",
|
| 176 |
+
"type": "MASK",
|
| 177 |
+
"link": 72
|
| 178 |
+
}
|
| 179 |
+
],
|
| 180 |
+
"outputs": [
|
| 181 |
+
{
|
| 182 |
+
"name": "positive",
|
| 183 |
+
"shape": 3,
|
| 184 |
+
"type": "CONDITIONING",
|
| 185 |
+
"slot_index": 0,
|
| 186 |
+
"links": [
|
| 187 |
+
63
|
| 188 |
+
]
|
| 189 |
+
},
|
| 190 |
+
{
|
| 191 |
+
"name": "negative",
|
| 192 |
+
"shape": 3,
|
| 193 |
+
"type": "CONDITIONING",
|
| 194 |
+
"slot_index": 1,
|
| 195 |
+
"links": [
|
| 196 |
+
64
|
| 197 |
+
]
|
| 198 |
+
},
|
| 199 |
+
{
|
| 200 |
+
"name": "latent",
|
| 201 |
+
"shape": 3,
|
| 202 |
+
"type": "LATENT",
|
| 203 |
+
"slot_index": 2,
|
| 204 |
+
"links": [
|
| 205 |
+
65
|
| 206 |
+
]
|
| 207 |
+
}
|
| 208 |
+
],
|
| 209 |
+
"properties": {
|
| 210 |
+
"cnr_id": "comfy-core",
|
| 211 |
+
"ver": "0.3.26",
|
| 212 |
+
"Node name for S&R": "InpaintModelConditioning"
|
| 213 |
+
},
|
| 214 |
+
"widgets_values": [
|
| 215 |
+
true
|
| 216 |
+
]
|
| 217 |
+
},
|
| 218 |
+
{
|
| 219 |
+
"id": 15,
|
| 220 |
+
"type": "VAEDecode",
|
| 221 |
+
"pos": [
|
| 222 |
+
1611.3004150390625,
|
| 223 |
+
350.0999450683594
|
| 224 |
+
],
|
| 225 |
+
"size": [
|
| 226 |
+
210,
|
| 227 |
+
46
|
| 228 |
+
],
|
| 229 |
+
"flags": {},
|
| 230 |
+
"order": 12,
|
| 231 |
+
"mode": 0,
|
| 232 |
+
"inputs": [
|
| 233 |
+
{
|
| 234 |
+
"name": "samples",
|
| 235 |
+
"type": "LATENT",
|
| 236 |
+
"link": 33
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"name": "vae",
|
| 240 |
+
"type": "VAE",
|
| 241 |
+
"link": 32
|
| 242 |
+
}
|
| 243 |
+
],
|
| 244 |
+
"outputs": [
|
| 245 |
+
{
|
| 246 |
+
"name": "IMAGE",
|
| 247 |
+
"shape": 3,
|
| 248 |
+
"type": "IMAGE",
|
| 249 |
+
"slot_index": 0,
|
| 250 |
+
"links": [
|
| 251 |
+
58,
|
| 252 |
+
74
|
| 253 |
+
]
|
| 254 |
+
}
|
| 255 |
+
],
|
| 256 |
+
"properties": {
|
| 257 |
+
"cnr_id": "comfy-core",
|
| 258 |
+
"ver": "0.3.26",
|
| 259 |
+
"Node name for S&R": "VAEDecode"
|
| 260 |
+
},
|
| 261 |
+
"widgets_values": []
|
| 262 |
+
},
|
| 263 |
+
{
|
| 264 |
+
"id": 19,
|
| 265 |
+
"type": "InpaintModelConditioning",
|
| 266 |
+
"pos": [
|
| 267 |
+
1233.3997802734375,
|
| 268 |
+
331.20001220703125
|
| 269 |
+
],
|
| 270 |
+
"size": [
|
| 271 |
+
216.59999084472656,
|
| 272 |
+
138
|
| 273 |
+
],
|
| 274 |
+
"flags": {},
|
| 275 |
+
"order": 8,
|
| 276 |
+
"mode": 0,
|
| 277 |
+
"inputs": [
|
| 278 |
+
{
|
| 279 |
+
"name": "positive",
|
| 280 |
+
"type": "CONDITIONING",
|
| 281 |
+
"link": 37
|
| 282 |
+
},
|
| 283 |
+
{
|
| 284 |
+
"name": "negative",
|
| 285 |
+
"type": "CONDITIONING",
|
| 286 |
+
"link": 38
|
| 287 |
+
},
|
| 288 |
+
{
|
| 289 |
+
"name": "vae",
|
| 290 |
+
"type": "VAE",
|
| 291 |
+
"link": 44
|
| 292 |
+
},
|
| 293 |
+
{
|
| 294 |
+
"name": "pixels",
|
| 295 |
+
"type": "IMAGE",
|
| 296 |
+
"link": 50
|
| 297 |
+
},
|
| 298 |
+
{
|
| 299 |
+
"name": "mask",
|
| 300 |
+
"type": "MASK",
|
| 301 |
+
"link": 51
|
| 302 |
+
}
|
| 303 |
+
],
|
| 304 |
+
"outputs": [
|
| 305 |
+
{
|
| 306 |
+
"name": "positive",
|
| 307 |
+
"shape": 3,
|
| 308 |
+
"type": "CONDITIONING",
|
| 309 |
+
"slot_index": 0,
|
| 310 |
+
"links": [
|
| 311 |
+
39
|
| 312 |
+
]
|
| 313 |
+
},
|
| 314 |
+
{
|
| 315 |
+
"name": "negative",
|
| 316 |
+
"shape": 3,
|
| 317 |
+
"type": "CONDITIONING",
|
| 318 |
+
"slot_index": 1,
|
| 319 |
+
"links": [
|
| 320 |
+
40
|
| 321 |
+
]
|
| 322 |
+
},
|
| 323 |
+
{
|
| 324 |
+
"name": "latent",
|
| 325 |
+
"shape": 3,
|
| 326 |
+
"type": "LATENT",
|
| 327 |
+
"slot_index": 2,
|
| 328 |
+
"links": [
|
| 329 |
+
41
|
| 330 |
+
]
|
| 331 |
+
}
|
| 332 |
+
],
|
| 333 |
+
"properties": {
|
| 334 |
+
"cnr_id": "comfy-core",
|
| 335 |
+
"ver": "0.3.26",
|
| 336 |
+
"Node name for S&R": "InpaintModelConditioning"
|
| 337 |
+
},
|
| 338 |
+
"widgets_values": [
|
| 339 |
+
true
|
| 340 |
+
]
|
| 341 |
+
},
|
| 342 |
+
{
|
| 343 |
+
"id": 25,
|
| 344 |
+
"type": "InpaintCropImproved",
|
| 345 |
+
"pos": [
|
| 346 |
+
620,
|
| 347 |
+
110
|
| 348 |
+
],
|
| 349 |
+
"size": [
|
| 350 |
+
390,
|
| 351 |
+
482
|
| 352 |
+
],
|
| 353 |
+
"flags": {},
|
| 354 |
+
"order": 7,
|
| 355 |
+
"mode": 0,
|
| 356 |
+
"inputs": [
|
| 357 |
+
{
|
| 358 |
+
"name": "image",
|
| 359 |
+
"type": "IMAGE",
|
| 360 |
+
"link": 48
|
| 361 |
+
},
|
| 362 |
+
{
|
| 363 |
+
"name": "mask",
|
| 364 |
+
"shape": 7,
|
| 365 |
+
"type": "MASK",
|
| 366 |
+
"link": 75
|
| 367 |
+
},
|
| 368 |
+
{
|
| 369 |
+
"name": "optional_context_mask",
|
| 370 |
+
"shape": 7,
|
| 371 |
+
"type": "MASK",
|
| 372 |
+
"link": 76
|
| 373 |
+
}
|
| 374 |
+
],
|
| 375 |
+
"outputs": [
|
| 376 |
+
{
|
| 377 |
+
"name": "stitcher",
|
| 378 |
+
"type": "STITCHER",
|
| 379 |
+
"slot_index": 0,
|
| 380 |
+
"links": [
|
| 381 |
+
52
|
| 382 |
+
]
|
| 383 |
+
},
|
| 384 |
+
{
|
| 385 |
+
"name": "cropped_image",
|
| 386 |
+
"type": "IMAGE",
|
| 387 |
+
"slot_index": 1,
|
| 388 |
+
"links": [
|
| 389 |
+
50
|
| 390 |
+
]
|
| 391 |
+
},
|
| 392 |
+
{
|
| 393 |
+
"name": "cropped_mask",
|
| 394 |
+
"type": "MASK",
|
| 395 |
+
"slot_index": 2,
|
| 396 |
+
"links": [
|
| 397 |
+
51,
|
| 398 |
+
69
|
| 399 |
+
]
|
| 400 |
+
}
|
| 401 |
+
],
|
| 402 |
+
"properties": {
|
| 403 |
+
"cnr_id": "comfyui-inpaint-cropandstitch",
|
| 404 |
+
"ver": "de6c2f6462e5997519a07305ade0b987143da12b",
|
| 405 |
+
"Node name for S&R": "InpaintCropImproved"
|
| 406 |
+
},
|
| 407 |
+
"widgets_values": [
|
| 408 |
+
"bilinear",
|
| 409 |
+
"bicubic",
|
| 410 |
+
true,
|
| 411 |
+
"ensure minimum resolution",
|
| 412 |
+
2048,
|
| 413 |
+
2048,
|
| 414 |
+
16384,
|
| 415 |
+
16384,
|
| 416 |
+
true,
|
| 417 |
+
0,
|
| 418 |
+
false,
|
| 419 |
+
32,
|
| 420 |
+
0.1,
|
| 421 |
+
false,
|
| 422 |
+
1,
|
| 423 |
+
1,
|
| 424 |
+
1,
|
| 425 |
+
1,
|
| 426 |
+
2.0000000000000004,
|
| 427 |
+
true,
|
| 428 |
+
512,
|
| 429 |
+
512,
|
| 430 |
+
"32"
|
| 431 |
+
]
|
| 432 |
+
},
|
| 433 |
+
{
|
| 434 |
+
"id": 34,
|
| 435 |
+
"type": "ImageScaleBy",
|
| 436 |
+
"pos": [
|
| 437 |
+
1885.878662109375,
|
| 438 |
+
234.75906372070312
|
| 439 |
+
],
|
| 440 |
+
"size": [
|
| 441 |
+
315,
|
| 442 |
+
82
|
| 443 |
+
],
|
| 444 |
+
"flags": {},
|
| 445 |
+
"order": 11,
|
| 446 |
+
"mode": 0,
|
| 447 |
+
"inputs": [
|
| 448 |
+
{
|
| 449 |
+
"name": "image",
|
| 450 |
+
"type": "IMAGE",
|
| 451 |
+
"link": 70
|
| 452 |
+
}
|
| 453 |
+
],
|
| 454 |
+
"outputs": [
|
| 455 |
+
{
|
| 456 |
+
"name": "IMAGE",
|
| 457 |
+
"type": "IMAGE",
|
| 458 |
+
"links": [
|
| 459 |
+
71
|
| 460 |
+
]
|
| 461 |
+
}
|
| 462 |
+
],
|
| 463 |
+
"properties": {
|
| 464 |
+
"cnr_id": "comfy-core",
|
| 465 |
+
"ver": "0.3.27",
|
| 466 |
+
"Node name for S&R": "ImageScaleBy"
|
| 467 |
+
},
|
| 468 |
+
"widgets_values": [
|
| 469 |
+
"nearest-exact",
|
| 470 |
+
4.000000000000001
|
| 471 |
+
]
|
| 472 |
+
},
|
| 473 |
+
{
|
| 474 |
+
"id": 33,
|
| 475 |
+
"type": "MaskToImage",
|
| 476 |
+
"pos": [
|
| 477 |
+
1904.9693603515625,
|
| 478 |
+
164.7589874267578
|
| 479 |
+
],
|
| 480 |
+
"size": [
|
| 481 |
+
264.5999755859375,
|
| 482 |
+
26
|
| 483 |
+
],
|
| 484 |
+
"flags": {},
|
| 485 |
+
"order": 9,
|
| 486 |
+
"mode": 0,
|
| 487 |
+
"inputs": [
|
| 488 |
+
{
|
| 489 |
+
"name": "mask",
|
| 490 |
+
"type": "MASK",
|
| 491 |
+
"link": 69
|
| 492 |
+
}
|
| 493 |
+
],
|
| 494 |
+
"outputs": [
|
| 495 |
+
{
|
| 496 |
+
"name": "IMAGE",
|
| 497 |
+
"type": "IMAGE",
|
| 498 |
+
"links": [
|
| 499 |
+
70
|
| 500 |
+
]
|
| 501 |
+
}
|
| 502 |
+
],
|
| 503 |
+
"properties": {
|
| 504 |
+
"cnr_id": "comfy-core",
|
| 505 |
+
"ver": "0.3.27",
|
| 506 |
+
"Node name for S&R": "MaskToImage"
|
| 507 |
+
},
|
| 508 |
+
"widgets_values": []
|
| 509 |
+
},
|
| 510 |
+
{
|
| 511 |
+
"id": 28,
|
| 512 |
+
"type": "UpscaleModelLoader",
|
| 513 |
+
"pos": [
|
| 514 |
+
1881.914306640625,
|
| 515 |
+
574.6688842773438
|
| 516 |
+
],
|
| 517 |
+
"size": [
|
| 518 |
+
315,
|
| 519 |
+
58
|
| 520 |
+
],
|
| 521 |
+
"flags": {},
|
| 522 |
+
"order": 0,
|
| 523 |
+
"mode": 0,
|
| 524 |
+
"inputs": [],
|
| 525 |
+
"outputs": [
|
| 526 |
+
{
|
| 527 |
+
"name": "UPSCALE_MODEL",
|
| 528 |
+
"type": "UPSCALE_MODEL",
|
| 529 |
+
"links": [
|
| 530 |
+
57
|
| 531 |
+
]
|
| 532 |
+
}
|
| 533 |
+
],
|
| 534 |
+
"properties": {
|
| 535 |
+
"cnr_id": "comfy-core",
|
| 536 |
+
"ver": "0.3.27",
|
| 537 |
+
"Node name for S&R": "UpscaleModelLoader"
|
| 538 |
+
},
|
| 539 |
+
"widgets_values": [
|
| 540 |
+
"4xUltrasharp_4xUltrasharpV10.pt"
|
| 541 |
+
],
|
| 542 |
+
"color": "#223",
|
| 543 |
+
"bgcolor": "#335"
|
| 544 |
+
},
|
| 545 |
+
{
|
| 546 |
+
"id": 29,
|
| 547 |
+
"type": "ImageUpscaleWithModel",
|
| 548 |
+
"pos": [
|
| 549 |
+
1874.0797119140625,
|
| 550 |
+
708.3599243164062
|
| 551 |
+
],
|
| 552 |
+
"size": [
|
| 553 |
+
340.20001220703125,
|
| 554 |
+
46
|
| 555 |
+
],
|
| 556 |
+
"flags": {},
|
| 557 |
+
"order": 14,
|
| 558 |
+
"mode": 0,
|
| 559 |
+
"inputs": [
|
| 560 |
+
{
|
| 561 |
+
"name": "upscale_model",
|
| 562 |
+
"type": "UPSCALE_MODEL",
|
| 563 |
+
"link": 57
|
| 564 |
+
},
|
| 565 |
+
{
|
| 566 |
+
"name": "image",
|
| 567 |
+
"type": "IMAGE",
|
| 568 |
+
"link": 58
|
| 569 |
+
}
|
| 570 |
+
],
|
| 571 |
+
"outputs": [
|
| 572 |
+
{
|
| 573 |
+
"name": "IMAGE",
|
| 574 |
+
"type": "IMAGE",
|
| 575 |
+
"links": [
|
| 576 |
+
59
|
| 577 |
+
]
|
| 578 |
+
}
|
| 579 |
+
],
|
| 580 |
+
"properties": {
|
| 581 |
+
"cnr_id": "comfy-core",
|
| 582 |
+
"ver": "0.3.27",
|
| 583 |
+
"Node name for S&R": "ImageUpscaleWithModel"
|
| 584 |
+
},
|
| 585 |
+
"widgets_values": []
|
| 586 |
+
},
|
| 587 |
+
{
|
| 588 |
+
"id": 10,
|
| 589 |
+
"type": "CheckpointLoaderSimple",
|
| 590 |
+
"pos": [
|
| 591 |
+
590,
|
| 592 |
+
680
|
| 593 |
+
],
|
| 594 |
+
"size": [
|
| 595 |
+
370,
|
| 596 |
+
100
|
| 597 |
+
],
|
| 598 |
+
"flags": {},
|
| 599 |
+
"order": 1,
|
| 600 |
+
"mode": 0,
|
| 601 |
+
"inputs": [],
|
| 602 |
+
"outputs": [
|
| 603 |
+
{
|
| 604 |
+
"name": "MODEL",
|
| 605 |
+
"shape": 3,
|
| 606 |
+
"type": "MODEL",
|
| 607 |
+
"slot_index": 0,
|
| 608 |
+
"links": [
|
| 609 |
+
28,
|
| 610 |
+
73
|
| 611 |
+
]
|
| 612 |
+
},
|
| 613 |
+
{
|
| 614 |
+
"name": "CLIP",
|
| 615 |
+
"shape": 3,
|
| 616 |
+
"type": "CLIP",
|
| 617 |
+
"slot_index": 1,
|
| 618 |
+
"links": [
|
| 619 |
+
21,
|
| 620 |
+
24
|
| 621 |
+
]
|
| 622 |
+
},
|
| 623 |
+
{
|
| 624 |
+
"name": "VAE",
|
| 625 |
+
"shape": 3,
|
| 626 |
+
"type": "VAE",
|
| 627 |
+
"slot_index": 2,
|
| 628 |
+
"links": [
|
| 629 |
+
32,
|
| 630 |
+
44,
|
| 631 |
+
60,
|
| 632 |
+
66
|
| 633 |
+
]
|
| 634 |
+
}
|
| 635 |
+
],
|
| 636 |
+
"properties": {
|
| 637 |
+
"cnr_id": "comfy-core",
|
| 638 |
+
"ver": "0.3.26",
|
| 639 |
+
"Node name for S&R": "CheckpointLoaderSimple"
|
| 640 |
+
},
|
| 641 |
+
"widgets_values": [
|
| 642 |
+
"sd1.5-inpainting/lazymixRealAmateur_v40Inpainting.safetensors"
|
| 643 |
+
]
|
| 644 |
+
},
|
| 645 |
+
{
|
| 646 |
+
"id": 3,
|
| 647 |
+
"type": "LoadImage",
|
| 648 |
+
"pos": [
|
| 649 |
+
90,
|
| 650 |
+
110
|
| 651 |
+
],
|
| 652 |
+
"size": [
|
| 653 |
+
400,
|
| 654 |
+
500
|
| 655 |
+
],
|
| 656 |
+
"flags": {},
|
| 657 |
+
"order": 2,
|
| 658 |
+
"mode": 0,
|
| 659 |
+
"inputs": [],
|
| 660 |
+
"outputs": [
|
| 661 |
+
{
|
| 662 |
+
"name": "IMAGE",
|
| 663 |
+
"shape": 3,
|
| 664 |
+
"type": "IMAGE",
|
| 665 |
+
"slot_index": 0,
|
| 666 |
+
"links": [
|
| 667 |
+
48
|
| 668 |
+
]
|
| 669 |
+
},
|
| 670 |
+
{
|
| 671 |
+
"name": "MASK",
|
| 672 |
+
"shape": 3,
|
| 673 |
+
"type": "MASK",
|
| 674 |
+
"slot_index": 1,
|
| 675 |
+
"links": [
|
| 676 |
+
75
|
| 677 |
+
]
|
| 678 |
+
}
|
| 679 |
+
],
|
| 680 |
+
"properties": {
|
| 681 |
+
"cnr_id": "comfy-core",
|
| 682 |
+
"ver": "0.3.26",
|
| 683 |
+
"Node name for S&R": "LoadImage"
|
| 684 |
+
},
|
| 685 |
+
"widgets_values": [
|
| 686 |
+
"clipspace/clipspace-mask-29086.800000000047.png [input]",
|
| 687 |
+
"image",
|
| 688 |
+
""
|
| 689 |
+
]
|
| 690 |
+
},
|
| 691 |
+
{
|
| 692 |
+
"id": 27,
|
| 693 |
+
"type": "LoadImage",
|
| 694 |
+
"pos": [
|
| 695 |
+
92.26223754882812,
|
| 696 |
+
662.6889038085938
|
| 697 |
+
],
|
| 698 |
+
"size": [
|
| 699 |
+
400,
|
| 700 |
+
500
|
| 701 |
+
],
|
| 702 |
+
"flags": {},
|
| 703 |
+
"order": 3,
|
| 704 |
+
"mode": 0,
|
| 705 |
+
"inputs": [],
|
| 706 |
+
"outputs": [
|
| 707 |
+
{
|
| 708 |
+
"name": "IMAGE",
|
| 709 |
+
"shape": 3,
|
| 710 |
+
"type": "IMAGE",
|
| 711 |
+
"slot_index": 0,
|
| 712 |
+
"links": []
|
| 713 |
+
},
|
| 714 |
+
{
|
| 715 |
+
"name": "MASK",
|
| 716 |
+
"shape": 3,
|
| 717 |
+
"type": "MASK",
|
| 718 |
+
"slot_index": 1,
|
| 719 |
+
"links": [
|
| 720 |
+
76
|
| 721 |
+
]
|
| 722 |
+
}
|
| 723 |
+
],
|
| 724 |
+
"properties": {
|
| 725 |
+
"cnr_id": "comfy-core",
|
| 726 |
+
"ver": "0.3.26",
|
| 727 |
+
"Node name for S&R": "LoadImage"
|
| 728 |
+
},
|
| 729 |
+
"widgets_values": [
|
| 730 |
+
"clipspace/clipspace-mask-51569.89999999991.png [input]",
|
| 731 |
+
"image",
|
| 732 |
+
""
|
| 733 |
+
]
|
| 734 |
+
},
|
| 735 |
+
{
|
| 736 |
+
"id": 11,
|
| 737 |
+
"type": "CLIPTextEncode",
|
| 738 |
+
"pos": [
|
| 739 |
+
1050,
|
| 740 |
+
700
|
| 741 |
+
],
|
| 742 |
+
"size": [
|
| 743 |
+
310,
|
| 744 |
+
140
|
| 745 |
+
],
|
| 746 |
+
"flags": {},
|
| 747 |
+
"order": 5,
|
| 748 |
+
"mode": 0,
|
| 749 |
+
"inputs": [
|
| 750 |
+
{
|
| 751 |
+
"name": "clip",
|
| 752 |
+
"type": "CLIP",
|
| 753 |
+
"link": 21
|
| 754 |
+
}
|
| 755 |
+
],
|
| 756 |
+
"outputs": [
|
| 757 |
+
{
|
| 758 |
+
"name": "CONDITIONING",
|
| 759 |
+
"shape": 3,
|
| 760 |
+
"type": "CONDITIONING",
|
| 761 |
+
"slot_index": 0,
|
| 762 |
+
"links": [
|
| 763 |
+
37,
|
| 764 |
+
61
|
| 765 |
+
]
|
| 766 |
+
}
|
| 767 |
+
],
|
| 768 |
+
"title": "CLIP Text Encode (Prompt) - Positive",
|
| 769 |
+
"properties": {
|
| 770 |
+
"cnr_id": "comfy-core",
|
| 771 |
+
"ver": "0.3.26",
|
| 772 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 773 |
+
},
|
| 774 |
+
"widgets_values": [
|
| 775 |
+
"a black hole"
|
| 776 |
+
],
|
| 777 |
+
"color": "#232",
|
| 778 |
+
"bgcolor": "#353"
|
| 779 |
+
},
|
| 780 |
+
{
|
| 781 |
+
"id": 14,
|
| 782 |
+
"type": "KSampler",
|
| 783 |
+
"pos": [
|
| 784 |
+
1420,
|
| 785 |
+
670
|
| 786 |
+
],
|
| 787 |
+
"size": [
|
| 788 |
+
320,
|
| 789 |
+
470
|
| 790 |
+
],
|
| 791 |
+
"flags": {},
|
| 792 |
+
"order": 10,
|
| 793 |
+
"mode": 0,
|
| 794 |
+
"inputs": [
|
| 795 |
+
{
|
| 796 |
+
"name": "model",
|
| 797 |
+
"type": "MODEL",
|
| 798 |
+
"link": 28
|
| 799 |
+
},
|
| 800 |
+
{
|
| 801 |
+
"name": "positive",
|
| 802 |
+
"type": "CONDITIONING",
|
| 803 |
+
"link": 39
|
| 804 |
+
},
|
| 805 |
+
{
|
| 806 |
+
"name": "negative",
|
| 807 |
+
"type": "CONDITIONING",
|
| 808 |
+
"link": 40
|
| 809 |
+
},
|
| 810 |
+
{
|
| 811 |
+
"name": "latent_image",
|
| 812 |
+
"type": "LATENT",
|
| 813 |
+
"link": 41
|
| 814 |
+
}
|
| 815 |
+
],
|
| 816 |
+
"outputs": [
|
| 817 |
+
{
|
| 818 |
+
"name": "LATENT",
|
| 819 |
+
"shape": 3,
|
| 820 |
+
"type": "LATENT",
|
| 821 |
+
"slot_index": 0,
|
| 822 |
+
"links": [
|
| 823 |
+
33
|
| 824 |
+
]
|
| 825 |
+
}
|
| 826 |
+
],
|
| 827 |
+
"properties": {
|
| 828 |
+
"cnr_id": "comfy-core",
|
| 829 |
+
"ver": "0.3.26",
|
| 830 |
+
"Node name for S&R": "KSampler"
|
| 831 |
+
},
|
| 832 |
+
"widgets_values": [
|
| 833 |
+
691360915987716,
|
| 834 |
+
"fixed",
|
| 835 |
+
20,
|
| 836 |
+
8,
|
| 837 |
+
"dpmpp_3m_sde",
|
| 838 |
+
"karras",
|
| 839 |
+
1
|
| 840 |
+
]
|
| 841 |
+
},
|
| 842 |
+
{
|
| 843 |
+
"id": 31,
|
| 844 |
+
"type": "KSampler",
|
| 845 |
+
"pos": [
|
| 846 |
+
2454.12109375,
|
| 847 |
+
672.7935791015625
|
| 848 |
+
],
|
| 849 |
+
"size": [
|
| 850 |
+
320,
|
| 851 |
+
470
|
| 852 |
+
],
|
| 853 |
+
"flags": {},
|
| 854 |
+
"order": 17,
|
| 855 |
+
"mode": 0,
|
| 856 |
+
"inputs": [
|
| 857 |
+
{
|
| 858 |
+
"name": "model",
|
| 859 |
+
"type": "MODEL",
|
| 860 |
+
"link": 73
|
| 861 |
+
},
|
| 862 |
+
{
|
| 863 |
+
"name": "positive",
|
| 864 |
+
"type": "CONDITIONING",
|
| 865 |
+
"link": 63
|
| 866 |
+
},
|
| 867 |
+
{
|
| 868 |
+
"name": "negative",
|
| 869 |
+
"type": "CONDITIONING",
|
| 870 |
+
"link": 64
|
| 871 |
+
},
|
| 872 |
+
{
|
| 873 |
+
"name": "latent_image",
|
| 874 |
+
"type": "LATENT",
|
| 875 |
+
"link": 65
|
| 876 |
+
}
|
| 877 |
+
],
|
| 878 |
+
"outputs": [
|
| 879 |
+
{
|
| 880 |
+
"name": "LATENT",
|
| 881 |
+
"shape": 3,
|
| 882 |
+
"type": "LATENT",
|
| 883 |
+
"slot_index": 0,
|
| 884 |
+
"links": [
|
| 885 |
+
67
|
| 886 |
+
]
|
| 887 |
+
}
|
| 888 |
+
],
|
| 889 |
+
"properties": {
|
| 890 |
+
"cnr_id": "comfy-core",
|
| 891 |
+
"ver": "0.3.26",
|
| 892 |
+
"Node name for S&R": "KSampler"
|
| 893 |
+
},
|
| 894 |
+
"widgets_values": [
|
| 895 |
+
547680698436999,
|
| 896 |
+
"fixed",
|
| 897 |
+
20,
|
| 898 |
+
8,
|
| 899 |
+
"dpmpp_3m_sde",
|
| 900 |
+
"karras",
|
| 901 |
+
0.4000000000000001
|
| 902 |
+
]
|
| 903 |
+
},
|
| 904 |
+
{
|
| 905 |
+
"id": 36,
|
| 906 |
+
"type": "PreviewImage",
|
| 907 |
+
"pos": [
|
| 908 |
+
1882.1004638671875,
|
| 909 |
+
861.1027221679688
|
| 910 |
+
],
|
| 911 |
+
"size": [
|
| 912 |
+
378.29998779296875,
|
| 913 |
+
536.4000244140625
|
| 914 |
+
],
|
| 915 |
+
"flags": {},
|
| 916 |
+
"order": 15,
|
| 917 |
+
"mode": 0,
|
| 918 |
+
"inputs": [
|
| 919 |
+
{
|
| 920 |
+
"name": "images",
|
| 921 |
+
"type": "IMAGE",
|
| 922 |
+
"link": 74
|
| 923 |
+
}
|
| 924 |
+
],
|
| 925 |
+
"outputs": [],
|
| 926 |
+
"properties": {
|
| 927 |
+
"cnr_id": "comfy-core",
|
| 928 |
+
"ver": "0.3.27",
|
| 929 |
+
"Node name for S&R": "PreviewImage"
|
| 930 |
+
},
|
| 931 |
+
"widgets_values": [
|
| 932 |
+
""
|
| 933 |
+
]
|
| 934 |
+
},
|
| 935 |
+
{
|
| 936 |
+
"id": 7,
|
| 937 |
+
"type": "PreviewImage",
|
| 938 |
+
"pos": [
|
| 939 |
+
3014.99560546875,
|
| 940 |
+
386.45294189453125
|
| 941 |
+
],
|
| 942 |
+
"size": [
|
| 943 |
+
500,
|
| 944 |
+
770
|
| 945 |
+
],
|
| 946 |
+
"flags": {},
|
| 947 |
+
"order": 20,
|
| 948 |
+
"mode": 0,
|
| 949 |
+
"inputs": [
|
| 950 |
+
{
|
| 951 |
+
"name": "images",
|
| 952 |
+
"type": "IMAGE",
|
| 953 |
+
"link": 54
|
| 954 |
+
}
|
| 955 |
+
],
|
| 956 |
+
"outputs": [],
|
| 957 |
+
"properties": {
|
| 958 |
+
"cnr_id": "comfy-core",
|
| 959 |
+
"ver": "0.3.26",
|
| 960 |
+
"Node name for S&R": "PreviewImage"
|
| 961 |
+
},
|
| 962 |
+
"widgets_values": [
|
| 963 |
+
""
|
| 964 |
+
]
|
| 965 |
+
},
|
| 966 |
+
{
|
| 967 |
+
"id": 22,
|
| 968 |
+
"type": "Note",
|
| 969 |
+
"pos": [
|
| 970 |
+
545.6982421875,
|
| 971 |
+
854.726318359375
|
| 972 |
+
],
|
| 973 |
+
"size": [
|
| 974 |
+
435.1099853515625,
|
| 975 |
+
490.7263488769531
|
| 976 |
+
],
|
| 977 |
+
"flags": {},
|
| 978 |
+
"order": 4,
|
| 979 |
+
"mode": 0,
|
| 980 |
+
"inputs": [],
|
| 981 |
+
"outputs": [],
|
| 982 |
+
"title": "Instructions",
|
| 983 |
+
"properties": {
|
| 984 |
+
"text": ""
|
| 985 |
+
},
|
| 986 |
+
"widgets_values": [
|
| 987 |
+
"This workflow:\n- Resizes the input image to a minimum of 2048x2048 and crops the area\n- Inpaints only on the masked area with a specific resolution (e.g. 512 x 512), which means any SD1.5 model can be used to define the inpainting.\n- Then upscales the inpainted part by x4 using an upscale model.\n- Then resamples at that new resolution to do a hiRes fix.\n\n\nThe easiest way to run it is:\n\n1. Load the desired image in the top \"Load Image\" node and mask the area you want to replace.\n\n2. Load the same image in the bottom \"Load Image\" node. Optionally, mask the context area that is relevant for sampling (corners is OK, square is OK). You may as well just remove that bottom \"Load Image\" node.\n\n3. Select a checkpoint for inpainting in the \"Load Checkpoint\" node.\n\n4. Write the positive and negative prompts in the green and red node. These prompts do not have to match the whole image, but only the masked area.\n\n5. Adjust denoise in the first sampler (e.g. 1 to fully replace the content, ~0.8 to keep part of it, 0.1 to match around.\n\n6. Select an upscale model in the blue node.\n\n7. Run!\n\nThe default parameters for Inpaint Crop and Inpaint Stitch work well for most inpainting tasks.\n\nFor SDXL or Flux, increase output_target_width and output_target_height to 1024.\n\nYou may also tweak the number of steps, seeds, etc."
|
| 988 |
+
],
|
| 989 |
+
"color": "#432",
|
| 990 |
+
"bgcolor": "#653"
|
| 991 |
+
},
|
| 992 |
+
{
|
| 993 |
+
"id": 35,
|
| 994 |
+
"type": "ImageToMask",
|
| 995 |
+
"pos": [
|
| 996 |
+
1887.69677734375,
|
| 997 |
+
367.4862365722656
|
| 998 |
+
],
|
| 999 |
+
"size": [
|
| 1000 |
+
315,
|
| 1001 |
+
58
|
| 1002 |
+
],
|
| 1003 |
+
"flags": {},
|
| 1004 |
+
"order": 13,
|
| 1005 |
+
"mode": 0,
|
| 1006 |
+
"inputs": [
|
| 1007 |
+
{
|
| 1008 |
+
"name": "image",
|
| 1009 |
+
"type": "IMAGE",
|
| 1010 |
+
"link": 71
|
| 1011 |
+
}
|
| 1012 |
+
],
|
| 1013 |
+
"outputs": [
|
| 1014 |
+
{
|
| 1015 |
+
"name": "MASK",
|
| 1016 |
+
"type": "MASK",
|
| 1017 |
+
"links": [
|
| 1018 |
+
72
|
| 1019 |
+
]
|
| 1020 |
+
}
|
| 1021 |
+
],
|
| 1022 |
+
"properties": {
|
| 1023 |
+
"cnr_id": "comfy-core",
|
| 1024 |
+
"ver": "0.3.27",
|
| 1025 |
+
"Node name for S&R": "ImageToMask"
|
| 1026 |
+
},
|
| 1027 |
+
"widgets_values": [
|
| 1028 |
+
"red"
|
| 1029 |
+
]
|
| 1030 |
+
}
|
| 1031 |
+
],
|
| 1032 |
+
"links": [
|
| 1033 |
+
[
|
| 1034 |
+
21,
|
| 1035 |
+
10,
|
| 1036 |
+
1,
|
| 1037 |
+
11,
|
| 1038 |
+
0,
|
| 1039 |
+
"CLIP"
|
| 1040 |
+
],
|
| 1041 |
+
[
|
| 1042 |
+
24,
|
| 1043 |
+
10,
|
| 1044 |
+
1,
|
| 1045 |
+
12,
|
| 1046 |
+
0,
|
| 1047 |
+
"CLIP"
|
| 1048 |
+
],
|
| 1049 |
+
[
|
| 1050 |
+
28,
|
| 1051 |
+
10,
|
| 1052 |
+
0,
|
| 1053 |
+
14,
|
| 1054 |
+
0,
|
| 1055 |
+
"MODEL"
|
| 1056 |
+
],
|
| 1057 |
+
[
|
| 1058 |
+
32,
|
| 1059 |
+
10,
|
| 1060 |
+
2,
|
| 1061 |
+
15,
|
| 1062 |
+
1,
|
| 1063 |
+
"VAE"
|
| 1064 |
+
],
|
| 1065 |
+
[
|
| 1066 |
+
33,
|
| 1067 |
+
14,
|
| 1068 |
+
0,
|
| 1069 |
+
15,
|
| 1070 |
+
0,
|
| 1071 |
+
"LATENT"
|
| 1072 |
+
],
|
| 1073 |
+
[
|
| 1074 |
+
37,
|
| 1075 |
+
11,
|
| 1076 |
+
0,
|
| 1077 |
+
19,
|
| 1078 |
+
0,
|
| 1079 |
+
"CONDITIONING"
|
| 1080 |
+
],
|
| 1081 |
+
[
|
| 1082 |
+
38,
|
| 1083 |
+
12,
|
| 1084 |
+
0,
|
| 1085 |
+
19,
|
| 1086 |
+
1,
|
| 1087 |
+
"CONDITIONING"
|
| 1088 |
+
],
|
| 1089 |
+
[
|
| 1090 |
+
39,
|
| 1091 |
+
19,
|
| 1092 |
+
0,
|
| 1093 |
+
14,
|
| 1094 |
+
1,
|
| 1095 |
+
"CONDITIONING"
|
| 1096 |
+
],
|
| 1097 |
+
[
|
| 1098 |
+
40,
|
| 1099 |
+
19,
|
| 1100 |
+
1,
|
| 1101 |
+
14,
|
| 1102 |
+
2,
|
| 1103 |
+
"CONDITIONING"
|
| 1104 |
+
],
|
| 1105 |
+
[
|
| 1106 |
+
41,
|
| 1107 |
+
19,
|
| 1108 |
+
2,
|
| 1109 |
+
14,
|
| 1110 |
+
3,
|
| 1111 |
+
"LATENT"
|
| 1112 |
+
],
|
| 1113 |
+
[
|
| 1114 |
+
44,
|
| 1115 |
+
10,
|
| 1116 |
+
2,
|
| 1117 |
+
19,
|
| 1118 |
+
2,
|
| 1119 |
+
"VAE"
|
| 1120 |
+
],
|
| 1121 |
+
[
|
| 1122 |
+
48,
|
| 1123 |
+
3,
|
| 1124 |
+
0,
|
| 1125 |
+
25,
|
| 1126 |
+
0,
|
| 1127 |
+
"IMAGE"
|
| 1128 |
+
],
|
| 1129 |
+
[
|
| 1130 |
+
50,
|
| 1131 |
+
25,
|
| 1132 |
+
1,
|
| 1133 |
+
19,
|
| 1134 |
+
3,
|
| 1135 |
+
"IMAGE"
|
| 1136 |
+
],
|
| 1137 |
+
[
|
| 1138 |
+
51,
|
| 1139 |
+
25,
|
| 1140 |
+
2,
|
| 1141 |
+
19,
|
| 1142 |
+
4,
|
| 1143 |
+
"MASK"
|
| 1144 |
+
],
|
| 1145 |
+
[
|
| 1146 |
+
52,
|
| 1147 |
+
25,
|
| 1148 |
+
0,
|
| 1149 |
+
26,
|
| 1150 |
+
0,
|
| 1151 |
+
"STITCHER"
|
| 1152 |
+
],
|
| 1153 |
+
[
|
| 1154 |
+
54,
|
| 1155 |
+
26,
|
| 1156 |
+
0,
|
| 1157 |
+
7,
|
| 1158 |
+
0,
|
| 1159 |
+
"IMAGE"
|
| 1160 |
+
],
|
| 1161 |
+
[
|
| 1162 |
+
57,
|
| 1163 |
+
28,
|
| 1164 |
+
0,
|
| 1165 |
+
29,
|
| 1166 |
+
0,
|
| 1167 |
+
"UPSCALE_MODEL"
|
| 1168 |
+
],
|
| 1169 |
+
[
|
| 1170 |
+
58,
|
| 1171 |
+
15,
|
| 1172 |
+
0,
|
| 1173 |
+
29,
|
| 1174 |
+
1,
|
| 1175 |
+
"IMAGE"
|
| 1176 |
+
],
|
| 1177 |
+
[
|
| 1178 |
+
59,
|
| 1179 |
+
29,
|
| 1180 |
+
0,
|
| 1181 |
+
30,
|
| 1182 |
+
3,
|
| 1183 |
+
"IMAGE"
|
| 1184 |
+
],
|
| 1185 |
+
[
|
| 1186 |
+
60,
|
| 1187 |
+
10,
|
| 1188 |
+
2,
|
| 1189 |
+
30,
|
| 1190 |
+
2,
|
| 1191 |
+
"VAE"
|
| 1192 |
+
],
|
| 1193 |
+
[
|
| 1194 |
+
61,
|
| 1195 |
+
11,
|
| 1196 |
+
0,
|
| 1197 |
+
30,
|
| 1198 |
+
0,
|
| 1199 |
+
"CONDITIONING"
|
| 1200 |
+
],
|
| 1201 |
+
[
|
| 1202 |
+
62,
|
| 1203 |
+
12,
|
| 1204 |
+
0,
|
| 1205 |
+
30,
|
| 1206 |
+
1,
|
| 1207 |
+
"CONDITIONING"
|
| 1208 |
+
],
|
| 1209 |
+
[
|
| 1210 |
+
63,
|
| 1211 |
+
30,
|
| 1212 |
+
0,
|
| 1213 |
+
31,
|
| 1214 |
+
1,
|
| 1215 |
+
"CONDITIONING"
|
| 1216 |
+
],
|
| 1217 |
+
[
|
| 1218 |
+
64,
|
| 1219 |
+
30,
|
| 1220 |
+
1,
|
| 1221 |
+
31,
|
| 1222 |
+
2,
|
| 1223 |
+
"CONDITIONING"
|
| 1224 |
+
],
|
| 1225 |
+
[
|
| 1226 |
+
65,
|
| 1227 |
+
30,
|
| 1228 |
+
2,
|
| 1229 |
+
31,
|
| 1230 |
+
3,
|
| 1231 |
+
"LATENT"
|
| 1232 |
+
],
|
| 1233 |
+
[
|
| 1234 |
+
66,
|
| 1235 |
+
10,
|
| 1236 |
+
2,
|
| 1237 |
+
32,
|
| 1238 |
+
1,
|
| 1239 |
+
"VAE"
|
| 1240 |
+
],
|
| 1241 |
+
[
|
| 1242 |
+
67,
|
| 1243 |
+
31,
|
| 1244 |
+
0,
|
| 1245 |
+
32,
|
| 1246 |
+
0,
|
| 1247 |
+
"LATENT"
|
| 1248 |
+
],
|
| 1249 |
+
[
|
| 1250 |
+
68,
|
| 1251 |
+
32,
|
| 1252 |
+
0,
|
| 1253 |
+
26,
|
| 1254 |
+
1,
|
| 1255 |
+
"IMAGE"
|
| 1256 |
+
],
|
| 1257 |
+
[
|
| 1258 |
+
69,
|
| 1259 |
+
25,
|
| 1260 |
+
2,
|
| 1261 |
+
33,
|
| 1262 |
+
0,
|
| 1263 |
+
"MASK"
|
| 1264 |
+
],
|
| 1265 |
+
[
|
| 1266 |
+
70,
|
| 1267 |
+
33,
|
| 1268 |
+
0,
|
| 1269 |
+
34,
|
| 1270 |
+
0,
|
| 1271 |
+
"IMAGE"
|
| 1272 |
+
],
|
| 1273 |
+
[
|
| 1274 |
+
71,
|
| 1275 |
+
34,
|
| 1276 |
+
0,
|
| 1277 |
+
35,
|
| 1278 |
+
0,
|
| 1279 |
+
"IMAGE"
|
| 1280 |
+
],
|
| 1281 |
+
[
|
| 1282 |
+
72,
|
| 1283 |
+
35,
|
| 1284 |
+
0,
|
| 1285 |
+
30,
|
| 1286 |
+
4,
|
| 1287 |
+
"MASK"
|
| 1288 |
+
],
|
| 1289 |
+
[
|
| 1290 |
+
73,
|
| 1291 |
+
10,
|
| 1292 |
+
0,
|
| 1293 |
+
31,
|
| 1294 |
+
0,
|
| 1295 |
+
"MODEL"
|
| 1296 |
+
],
|
| 1297 |
+
[
|
| 1298 |
+
74,
|
| 1299 |
+
15,
|
| 1300 |
+
0,
|
| 1301 |
+
36,
|
| 1302 |
+
0,
|
| 1303 |
+
"IMAGE"
|
| 1304 |
+
],
|
| 1305 |
+
[
|
| 1306 |
+
75,
|
| 1307 |
+
3,
|
| 1308 |
+
1,
|
| 1309 |
+
25,
|
| 1310 |
+
1,
|
| 1311 |
+
"MASK"
|
| 1312 |
+
],
|
| 1313 |
+
[
|
| 1314 |
+
76,
|
| 1315 |
+
27,
|
| 1316 |
+
1,
|
| 1317 |
+
25,
|
| 1318 |
+
2,
|
| 1319 |
+
"MASK"
|
| 1320 |
+
]
|
| 1321 |
+
],
|
| 1322 |
+
"groups": [],
|
| 1323 |
+
"config": {},
|
| 1324 |
+
"extra": {
|
| 1325 |
+
"ds": {
|
| 1326 |
+
"scale": 0.6934334949441344,
|
| 1327 |
+
"offset": [
|
| 1328 |
+
181.98543829364752,
|
| 1329 |
+
356.1328928532488
|
| 1330 |
+
]
|
| 1331 |
+
},
|
| 1332 |
+
"ue_links": []
|
| 1333 |
+
},
|
| 1334 |
+
"version": 0.4
|
| 1335 |
+
}
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_sd15.jpg
ADDED
|
Git LFS Details
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/example_workflows/inpaint_sd15.json
ADDED
|
@@ -0,0 +1,726 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"last_node_id": 26,
|
| 3 |
+
"last_link_id": 55,
|
| 4 |
+
"nodes": [
|
| 5 |
+
{
|
| 6 |
+
"id": 12,
|
| 7 |
+
"type": "CLIPTextEncode",
|
| 8 |
+
"pos": [
|
| 9 |
+
1050,
|
| 10 |
+
910
|
| 11 |
+
],
|
| 12 |
+
"size": [
|
| 13 |
+
302.3999938964844,
|
| 14 |
+
120
|
| 15 |
+
],
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 4,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"inputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "clip",
|
| 22 |
+
"type": "CLIP",
|
| 23 |
+
"link": 24,
|
| 24 |
+
"slot_index": 0
|
| 25 |
+
}
|
| 26 |
+
],
|
| 27 |
+
"outputs": [
|
| 28 |
+
{
|
| 29 |
+
"name": "CONDITIONING",
|
| 30 |
+
"type": "CONDITIONING",
|
| 31 |
+
"shape": 3,
|
| 32 |
+
"links": [
|
| 33 |
+
38
|
| 34 |
+
],
|
| 35 |
+
"slot_index": 0
|
| 36 |
+
}
|
| 37 |
+
],
|
| 38 |
+
"title": "CLIP Text Encode (Prompt) - Negative",
|
| 39 |
+
"properties": {
|
| 40 |
+
"cnr_id": "comfy-core",
|
| 41 |
+
"ver": "0.3.26",
|
| 42 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 43 |
+
},
|
| 44 |
+
"widgets_values": [
|
| 45 |
+
"ugly, text, watermark"
|
| 46 |
+
],
|
| 47 |
+
"color": "#322",
|
| 48 |
+
"bgcolor": "#533"
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"id": 19,
|
| 52 |
+
"type": "InpaintModelConditioning",
|
| 53 |
+
"pos": [
|
| 54 |
+
1130,
|
| 55 |
+
340
|
| 56 |
+
],
|
| 57 |
+
"size": [
|
| 58 |
+
216.59999084472656,
|
| 59 |
+
138
|
| 60 |
+
],
|
| 61 |
+
"flags": {},
|
| 62 |
+
"order": 6,
|
| 63 |
+
"mode": 0,
|
| 64 |
+
"inputs": [
|
| 65 |
+
{
|
| 66 |
+
"name": "positive",
|
| 67 |
+
"type": "CONDITIONING",
|
| 68 |
+
"link": 37
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"name": "negative",
|
| 72 |
+
"type": "CONDITIONING",
|
| 73 |
+
"link": 38
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"name": "vae",
|
| 77 |
+
"type": "VAE",
|
| 78 |
+
"link": 44
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"name": "pixels",
|
| 82 |
+
"type": "IMAGE",
|
| 83 |
+
"link": 50
|
| 84 |
+
},
|
| 85 |
+
{
|
| 86 |
+
"name": "mask",
|
| 87 |
+
"type": "MASK",
|
| 88 |
+
"link": 51
|
| 89 |
+
}
|
| 90 |
+
],
|
| 91 |
+
"outputs": [
|
| 92 |
+
{
|
| 93 |
+
"name": "positive",
|
| 94 |
+
"type": "CONDITIONING",
|
| 95 |
+
"shape": 3,
|
| 96 |
+
"links": [
|
| 97 |
+
39
|
| 98 |
+
],
|
| 99 |
+
"slot_index": 0
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"name": "negative",
|
| 103 |
+
"type": "CONDITIONING",
|
| 104 |
+
"shape": 3,
|
| 105 |
+
"links": [
|
| 106 |
+
40
|
| 107 |
+
],
|
| 108 |
+
"slot_index": 1
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"name": "latent",
|
| 112 |
+
"type": "LATENT",
|
| 113 |
+
"shape": 3,
|
| 114 |
+
"links": [
|
| 115 |
+
41
|
| 116 |
+
],
|
| 117 |
+
"slot_index": 2
|
| 118 |
+
}
|
| 119 |
+
],
|
| 120 |
+
"properties": {
|
| 121 |
+
"cnr_id": "comfy-core",
|
| 122 |
+
"ver": "0.3.26",
|
| 123 |
+
"Node name for S&R": "InpaintModelConditioning"
|
| 124 |
+
},
|
| 125 |
+
"widgets_values": [
|
| 126 |
+
true
|
| 127 |
+
]
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"id": 10,
|
| 131 |
+
"type": "CheckpointLoaderSimple",
|
| 132 |
+
"pos": [
|
| 133 |
+
590,
|
| 134 |
+
680
|
| 135 |
+
],
|
| 136 |
+
"size": [
|
| 137 |
+
370,
|
| 138 |
+
100
|
| 139 |
+
],
|
| 140 |
+
"flags": {},
|
| 141 |
+
"order": 0,
|
| 142 |
+
"mode": 0,
|
| 143 |
+
"inputs": [],
|
| 144 |
+
"outputs": [
|
| 145 |
+
{
|
| 146 |
+
"name": "MODEL",
|
| 147 |
+
"type": "MODEL",
|
| 148 |
+
"shape": 3,
|
| 149 |
+
"links": [
|
| 150 |
+
28
|
| 151 |
+
],
|
| 152 |
+
"slot_index": 0
|
| 153 |
+
},
|
| 154 |
+
{
|
| 155 |
+
"name": "CLIP",
|
| 156 |
+
"type": "CLIP",
|
| 157 |
+
"shape": 3,
|
| 158 |
+
"links": [
|
| 159 |
+
21,
|
| 160 |
+
24
|
| 161 |
+
],
|
| 162 |
+
"slot_index": 1
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"name": "VAE",
|
| 166 |
+
"type": "VAE",
|
| 167 |
+
"shape": 3,
|
| 168 |
+
"links": [
|
| 169 |
+
32,
|
| 170 |
+
44
|
| 171 |
+
],
|
| 172 |
+
"slot_index": 2
|
| 173 |
+
}
|
| 174 |
+
],
|
| 175 |
+
"properties": {
|
| 176 |
+
"cnr_id": "comfy-core",
|
| 177 |
+
"ver": "0.3.26",
|
| 178 |
+
"Node name for S&R": "CheckpointLoaderSimple"
|
| 179 |
+
},
|
| 180 |
+
"widgets_values": [
|
| 181 |
+
"sd1.5-inpainting/lazymixRealAmateur_v40Inpainting.safetensors"
|
| 182 |
+
]
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"id": 7,
|
| 186 |
+
"type": "PreviewImage",
|
| 187 |
+
"pos": [
|
| 188 |
+
1860,
|
| 189 |
+
370
|
| 190 |
+
],
|
| 191 |
+
"size": [
|
| 192 |
+
500,
|
| 193 |
+
770
|
| 194 |
+
],
|
| 195 |
+
"flags": {},
|
| 196 |
+
"order": 10,
|
| 197 |
+
"mode": 0,
|
| 198 |
+
"inputs": [
|
| 199 |
+
{
|
| 200 |
+
"name": "images",
|
| 201 |
+
"type": "IMAGE",
|
| 202 |
+
"link": 54
|
| 203 |
+
}
|
| 204 |
+
],
|
| 205 |
+
"outputs": [],
|
| 206 |
+
"properties": {
|
| 207 |
+
"cnr_id": "comfy-core",
|
| 208 |
+
"ver": "0.3.26",
|
| 209 |
+
"Node name for S&R": "PreviewImage"
|
| 210 |
+
},
|
| 211 |
+
"widgets_values": []
|
| 212 |
+
},
|
| 213 |
+
{
|
| 214 |
+
"id": 14,
|
| 215 |
+
"type": "KSampler",
|
| 216 |
+
"pos": [
|
| 217 |
+
1420,
|
| 218 |
+
670
|
| 219 |
+
],
|
| 220 |
+
"size": [
|
| 221 |
+
320,
|
| 222 |
+
470
|
| 223 |
+
],
|
| 224 |
+
"flags": {},
|
| 225 |
+
"order": 7,
|
| 226 |
+
"mode": 0,
|
| 227 |
+
"inputs": [
|
| 228 |
+
{
|
| 229 |
+
"name": "model",
|
| 230 |
+
"type": "MODEL",
|
| 231 |
+
"link": 28
|
| 232 |
+
},
|
| 233 |
+
{
|
| 234 |
+
"name": "positive",
|
| 235 |
+
"type": "CONDITIONING",
|
| 236 |
+
"link": 39
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"name": "negative",
|
| 240 |
+
"type": "CONDITIONING",
|
| 241 |
+
"link": 40
|
| 242 |
+
},
|
| 243 |
+
{
|
| 244 |
+
"name": "latent_image",
|
| 245 |
+
"type": "LATENT",
|
| 246 |
+
"link": 41,
|
| 247 |
+
"slot_index": 3
|
| 248 |
+
}
|
| 249 |
+
],
|
| 250 |
+
"outputs": [
|
| 251 |
+
{
|
| 252 |
+
"name": "LATENT",
|
| 253 |
+
"type": "LATENT",
|
| 254 |
+
"shape": 3,
|
| 255 |
+
"links": [
|
| 256 |
+
33
|
| 257 |
+
],
|
| 258 |
+
"slot_index": 0
|
| 259 |
+
}
|
| 260 |
+
],
|
| 261 |
+
"properties": {
|
| 262 |
+
"cnr_id": "comfy-core",
|
| 263 |
+
"ver": "0.3.26",
|
| 264 |
+
"Node name for S&R": "KSampler"
|
| 265 |
+
},
|
| 266 |
+
"widgets_values": [
|
| 267 |
+
900559780374547,
|
| 268 |
+
"randomize",
|
| 269 |
+
20,
|
| 270 |
+
8,
|
| 271 |
+
"dpmpp_3m_sde",
|
| 272 |
+
"karras",
|
| 273 |
+
1
|
| 274 |
+
]
|
| 275 |
+
},
|
| 276 |
+
{
|
| 277 |
+
"id": 15,
|
| 278 |
+
"type": "VAEDecode",
|
| 279 |
+
"pos": [
|
| 280 |
+
1520,
|
| 281 |
+
360
|
| 282 |
+
],
|
| 283 |
+
"size": [
|
| 284 |
+
210,
|
| 285 |
+
46
|
| 286 |
+
],
|
| 287 |
+
"flags": {},
|
| 288 |
+
"order": 8,
|
| 289 |
+
"mode": 0,
|
| 290 |
+
"inputs": [
|
| 291 |
+
{
|
| 292 |
+
"name": "samples",
|
| 293 |
+
"type": "LATENT",
|
| 294 |
+
"link": 33,
|
| 295 |
+
"slot_index": 0
|
| 296 |
+
},
|
| 297 |
+
{
|
| 298 |
+
"name": "vae",
|
| 299 |
+
"type": "VAE",
|
| 300 |
+
"link": 32,
|
| 301 |
+
"slot_index": 1
|
| 302 |
+
}
|
| 303 |
+
],
|
| 304 |
+
"outputs": [
|
| 305 |
+
{
|
| 306 |
+
"name": "IMAGE",
|
| 307 |
+
"type": "IMAGE",
|
| 308 |
+
"shape": 3,
|
| 309 |
+
"links": [
|
| 310 |
+
55
|
| 311 |
+
],
|
| 312 |
+
"slot_index": 0
|
| 313 |
+
}
|
| 314 |
+
],
|
| 315 |
+
"properties": {
|
| 316 |
+
"cnr_id": "comfy-core",
|
| 317 |
+
"ver": "0.3.26",
|
| 318 |
+
"Node name for S&R": "VAEDecode"
|
| 319 |
+
},
|
| 320 |
+
"widgets_values": []
|
| 321 |
+
},
|
| 322 |
+
{
|
| 323 |
+
"id": 26,
|
| 324 |
+
"type": "InpaintStitchImproved",
|
| 325 |
+
"pos": [
|
| 326 |
+
1640,
|
| 327 |
+
110
|
| 328 |
+
],
|
| 329 |
+
"size": [
|
| 330 |
+
235.1999969482422,
|
| 331 |
+
46
|
| 332 |
+
],
|
| 333 |
+
"flags": {},
|
| 334 |
+
"order": 9,
|
| 335 |
+
"mode": 0,
|
| 336 |
+
"inputs": [
|
| 337 |
+
{
|
| 338 |
+
"name": "stitcher",
|
| 339 |
+
"type": "STITCHER",
|
| 340 |
+
"link": 52
|
| 341 |
+
},
|
| 342 |
+
{
|
| 343 |
+
"name": "inpainted_image",
|
| 344 |
+
"type": "IMAGE",
|
| 345 |
+
"link": 55
|
| 346 |
+
}
|
| 347 |
+
],
|
| 348 |
+
"outputs": [
|
| 349 |
+
{
|
| 350 |
+
"name": "image",
|
| 351 |
+
"type": "IMAGE",
|
| 352 |
+
"links": [
|
| 353 |
+
54
|
| 354 |
+
],
|
| 355 |
+
"slot_index": 0
|
| 356 |
+
}
|
| 357 |
+
],
|
| 358 |
+
"properties": {
|
| 359 |
+
"Node name for S&R": "InpaintStitchImproved"
|
| 360 |
+
},
|
| 361 |
+
"widgets_values": []
|
| 362 |
+
},
|
| 363 |
+
{
|
| 364 |
+
"id": 3,
|
| 365 |
+
"type": "LoadImage",
|
| 366 |
+
"pos": [
|
| 367 |
+
90,
|
| 368 |
+
110
|
| 369 |
+
],
|
| 370 |
+
"size": [
|
| 371 |
+
400,
|
| 372 |
+
500
|
| 373 |
+
],
|
| 374 |
+
"flags": {},
|
| 375 |
+
"order": 1,
|
| 376 |
+
"mode": 0,
|
| 377 |
+
"inputs": [],
|
| 378 |
+
"outputs": [
|
| 379 |
+
{
|
| 380 |
+
"name": "IMAGE",
|
| 381 |
+
"type": "IMAGE",
|
| 382 |
+
"shape": 3,
|
| 383 |
+
"links": [
|
| 384 |
+
48
|
| 385 |
+
],
|
| 386 |
+
"slot_index": 0
|
| 387 |
+
},
|
| 388 |
+
{
|
| 389 |
+
"name": "MASK",
|
| 390 |
+
"type": "MASK",
|
| 391 |
+
"shape": 3,
|
| 392 |
+
"links": [
|
| 393 |
+
49
|
| 394 |
+
],
|
| 395 |
+
"slot_index": 1
|
| 396 |
+
}
|
| 397 |
+
],
|
| 398 |
+
"properties": {
|
| 399 |
+
"cnr_id": "comfy-core",
|
| 400 |
+
"ver": "0.3.26",
|
| 401 |
+
"Node name for S&R": "LoadImage"
|
| 402 |
+
},
|
| 403 |
+
"widgets_values": [
|
| 404 |
+
"clipspace/clipspace-mask-324879.39999999106.png [input]",
|
| 405 |
+
"image"
|
| 406 |
+
]
|
| 407 |
+
},
|
| 408 |
+
{
|
| 409 |
+
"id": 22,
|
| 410 |
+
"type": "Note",
|
| 411 |
+
"pos": [
|
| 412 |
+
40,
|
| 413 |
+
680
|
| 414 |
+
],
|
| 415 |
+
"size": [
|
| 416 |
+
500,
|
| 417 |
+
470
|
| 418 |
+
],
|
| 419 |
+
"flags": {},
|
| 420 |
+
"order": 2,
|
| 421 |
+
"mode": 0,
|
| 422 |
+
"inputs": [],
|
| 423 |
+
"outputs": [],
|
| 424 |
+
"title": "Instructions",
|
| 425 |
+
"properties": {
|
| 426 |
+
"text": ""
|
| 427 |
+
},
|
| 428 |
+
"widgets_values": [
|
| 429 |
+
"Simplest way to run:\n\n1. Load desired image in the \"Load Image\" node and mask the area you want to replace.\n\n2. Select a checkpoint for inpainting in the \"Load Checkpoint\" node.\n\n3. Write the positive and negative prompts in the green and red boxes. These prompts do not have to match the whole image, but only the masked area.\n\n4. Adjust denoise (e.g. 1 to fully replace the content, ~0.8 to keep part of it, 0.1 to match around.\n\n5. Run!\n\n\n\nHow to increase the context area for the model to know better what to draw:\n- Option 1: Increase context_expand_factor, e.g. set it to 2.\n- Option 2: Duplicate the load image node and connect its mask to \"optional_context_mask\" in the \"Inpaint Crop\" node. Mask the area that is relevant for context (no need to fill it, only the corners of the masked area matter.\n\n\n\nThe default parameters for Inpaint Crop and Inpaint Stitch work well for most inpainting tasks.\n\nFor SDXL or Flux, increase output_target_width and output_target_height to 1024."
|
| 430 |
+
],
|
| 431 |
+
"color": "#432",
|
| 432 |
+
"bgcolor": "#653"
|
| 433 |
+
},
|
| 434 |
+
{
|
| 435 |
+
"id": 25,
|
| 436 |
+
"type": "InpaintCropImproved",
|
| 437 |
+
"pos": [
|
| 438 |
+
620,
|
| 439 |
+
110
|
| 440 |
+
],
|
| 441 |
+
"size": [
|
| 442 |
+
390,
|
| 443 |
+
410
|
| 444 |
+
],
|
| 445 |
+
"flags": {},
|
| 446 |
+
"order": 5,
|
| 447 |
+
"mode": 0,
|
| 448 |
+
"inputs": [
|
| 449 |
+
{
|
| 450 |
+
"name": "image",
|
| 451 |
+
"type": "IMAGE",
|
| 452 |
+
"link": 48
|
| 453 |
+
},
|
| 454 |
+
{
|
| 455 |
+
"name": "mask",
|
| 456 |
+
"type": "MASK",
|
| 457 |
+
"shape": 7,
|
| 458 |
+
"link": 49
|
| 459 |
+
},
|
| 460 |
+
{
|
| 461 |
+
"name": "optional_context_mask",
|
| 462 |
+
"type": "MASK",
|
| 463 |
+
"shape": 7,
|
| 464 |
+
"link": null
|
| 465 |
+
}
|
| 466 |
+
],
|
| 467 |
+
"outputs": [
|
| 468 |
+
{
|
| 469 |
+
"name": "stitcher",
|
| 470 |
+
"type": "STITCHER",
|
| 471 |
+
"links": [
|
| 472 |
+
52
|
| 473 |
+
],
|
| 474 |
+
"slot_index": 0
|
| 475 |
+
},
|
| 476 |
+
{
|
| 477 |
+
"name": "cropped_image",
|
| 478 |
+
"type": "IMAGE",
|
| 479 |
+
"links": [
|
| 480 |
+
50
|
| 481 |
+
],
|
| 482 |
+
"slot_index": 1
|
| 483 |
+
},
|
| 484 |
+
{
|
| 485 |
+
"name": "cropped_mask",
|
| 486 |
+
"type": "MASK",
|
| 487 |
+
"links": [
|
| 488 |
+
51
|
| 489 |
+
],
|
| 490 |
+
"slot_index": 2
|
| 491 |
+
}
|
| 492 |
+
],
|
| 493 |
+
"properties": {
|
| 494 |
+
"Node name for S&R": "InpaintCropImproved"
|
| 495 |
+
},
|
| 496 |
+
"widgets_values": [
|
| 497 |
+
"bilinear",
|
| 498 |
+
"bicubic",
|
| 499 |
+
false,
|
| 500 |
+
"ensure minimum resolution",
|
| 501 |
+
1024,
|
| 502 |
+
1024,
|
| 503 |
+
16384,
|
| 504 |
+
16384,
|
| 505 |
+
true,
|
| 506 |
+
0,
|
| 507 |
+
false,
|
| 508 |
+
32,
|
| 509 |
+
0.1,
|
| 510 |
+
false,
|
| 511 |
+
1,
|
| 512 |
+
1,
|
| 513 |
+
1,
|
| 514 |
+
1,
|
| 515 |
+
2.0000000000000004,
|
| 516 |
+
true,
|
| 517 |
+
512,
|
| 518 |
+
512,
|
| 519 |
+
"32"
|
| 520 |
+
]
|
| 521 |
+
},
|
| 522 |
+
{
|
| 523 |
+
"id": 11,
|
| 524 |
+
"type": "CLIPTextEncode",
|
| 525 |
+
"pos": [
|
| 526 |
+
1050,
|
| 527 |
+
700
|
| 528 |
+
],
|
| 529 |
+
"size": [
|
| 530 |
+
310,
|
| 531 |
+
140
|
| 532 |
+
],
|
| 533 |
+
"flags": {},
|
| 534 |
+
"order": 3,
|
| 535 |
+
"mode": 0,
|
| 536 |
+
"inputs": [
|
| 537 |
+
{
|
| 538 |
+
"name": "clip",
|
| 539 |
+
"type": "CLIP",
|
| 540 |
+
"link": 21
|
| 541 |
+
}
|
| 542 |
+
],
|
| 543 |
+
"outputs": [
|
| 544 |
+
{
|
| 545 |
+
"name": "CONDITIONING",
|
| 546 |
+
"type": "CONDITIONING",
|
| 547 |
+
"shape": 3,
|
| 548 |
+
"links": [
|
| 549 |
+
37
|
| 550 |
+
],
|
| 551 |
+
"slot_index": 0
|
| 552 |
+
}
|
| 553 |
+
],
|
| 554 |
+
"title": "CLIP Text Encode (Prompt) - Positive",
|
| 555 |
+
"properties": {
|
| 556 |
+
"cnr_id": "comfy-core",
|
| 557 |
+
"ver": "0.3.26",
|
| 558 |
+
"Node name for S&R": "CLIPTextEncode"
|
| 559 |
+
},
|
| 560 |
+
"widgets_values": [
|
| 561 |
+
"metal cap covering a bottle, watercolor painting"
|
| 562 |
+
],
|
| 563 |
+
"color": "#232",
|
| 564 |
+
"bgcolor": "#353"
|
| 565 |
+
}
|
| 566 |
+
],
|
| 567 |
+
"links": [
|
| 568 |
+
[
|
| 569 |
+
21,
|
| 570 |
+
10,
|
| 571 |
+
1,
|
| 572 |
+
11,
|
| 573 |
+
0,
|
| 574 |
+
"CLIP"
|
| 575 |
+
],
|
| 576 |
+
[
|
| 577 |
+
24,
|
| 578 |
+
10,
|
| 579 |
+
1,
|
| 580 |
+
12,
|
| 581 |
+
0,
|
| 582 |
+
"CLIP"
|
| 583 |
+
],
|
| 584 |
+
[
|
| 585 |
+
28,
|
| 586 |
+
10,
|
| 587 |
+
0,
|
| 588 |
+
14,
|
| 589 |
+
0,
|
| 590 |
+
"MODEL"
|
| 591 |
+
],
|
| 592 |
+
[
|
| 593 |
+
32,
|
| 594 |
+
10,
|
| 595 |
+
2,
|
| 596 |
+
15,
|
| 597 |
+
1,
|
| 598 |
+
"VAE"
|
| 599 |
+
],
|
| 600 |
+
[
|
| 601 |
+
33,
|
| 602 |
+
14,
|
| 603 |
+
0,
|
| 604 |
+
15,
|
| 605 |
+
0,
|
| 606 |
+
"LATENT"
|
| 607 |
+
],
|
| 608 |
+
[
|
| 609 |
+
37,
|
| 610 |
+
11,
|
| 611 |
+
0,
|
| 612 |
+
19,
|
| 613 |
+
0,
|
| 614 |
+
"CONDITIONING"
|
| 615 |
+
],
|
| 616 |
+
[
|
| 617 |
+
38,
|
| 618 |
+
12,
|
| 619 |
+
0,
|
| 620 |
+
19,
|
| 621 |
+
1,
|
| 622 |
+
"CONDITIONING"
|
| 623 |
+
],
|
| 624 |
+
[
|
| 625 |
+
39,
|
| 626 |
+
19,
|
| 627 |
+
0,
|
| 628 |
+
14,
|
| 629 |
+
1,
|
| 630 |
+
"CONDITIONING"
|
| 631 |
+
],
|
| 632 |
+
[
|
| 633 |
+
40,
|
| 634 |
+
19,
|
| 635 |
+
1,
|
| 636 |
+
14,
|
| 637 |
+
2,
|
| 638 |
+
"CONDITIONING"
|
| 639 |
+
],
|
| 640 |
+
[
|
| 641 |
+
41,
|
| 642 |
+
19,
|
| 643 |
+
2,
|
| 644 |
+
14,
|
| 645 |
+
3,
|
| 646 |
+
"LATENT"
|
| 647 |
+
],
|
| 648 |
+
[
|
| 649 |
+
44,
|
| 650 |
+
10,
|
| 651 |
+
2,
|
| 652 |
+
19,
|
| 653 |
+
2,
|
| 654 |
+
"VAE"
|
| 655 |
+
],
|
| 656 |
+
[
|
| 657 |
+
48,
|
| 658 |
+
3,
|
| 659 |
+
0,
|
| 660 |
+
25,
|
| 661 |
+
0,
|
| 662 |
+
"IMAGE"
|
| 663 |
+
],
|
| 664 |
+
[
|
| 665 |
+
49,
|
| 666 |
+
3,
|
| 667 |
+
1,
|
| 668 |
+
25,
|
| 669 |
+
1,
|
| 670 |
+
"MASK"
|
| 671 |
+
],
|
| 672 |
+
[
|
| 673 |
+
50,
|
| 674 |
+
25,
|
| 675 |
+
1,
|
| 676 |
+
19,
|
| 677 |
+
3,
|
| 678 |
+
"IMAGE"
|
| 679 |
+
],
|
| 680 |
+
[
|
| 681 |
+
51,
|
| 682 |
+
25,
|
| 683 |
+
2,
|
| 684 |
+
19,
|
| 685 |
+
4,
|
| 686 |
+
"MASK"
|
| 687 |
+
],
|
| 688 |
+
[
|
| 689 |
+
52,
|
| 690 |
+
25,
|
| 691 |
+
0,
|
| 692 |
+
26,
|
| 693 |
+
0,
|
| 694 |
+
"STITCHER"
|
| 695 |
+
],
|
| 696 |
+
[
|
| 697 |
+
54,
|
| 698 |
+
26,
|
| 699 |
+
0,
|
| 700 |
+
7,
|
| 701 |
+
0,
|
| 702 |
+
"IMAGE"
|
| 703 |
+
],
|
| 704 |
+
[
|
| 705 |
+
55,
|
| 706 |
+
15,
|
| 707 |
+
0,
|
| 708 |
+
26,
|
| 709 |
+
1,
|
| 710 |
+
"IMAGE"
|
| 711 |
+
]
|
| 712 |
+
],
|
| 713 |
+
"groups": [],
|
| 714 |
+
"config": {},
|
| 715 |
+
"extra": {
|
| 716 |
+
"ds": {
|
| 717 |
+
"scale": 0.6830134553650709,
|
| 718 |
+
"offset": [
|
| 719 |
+
259.9247209661792,
|
| 720 |
+
171.64611986059646
|
| 721 |
+
]
|
| 722 |
+
},
|
| 723 |
+
"ue_links": []
|
| 724 |
+
},
|
| 725 |
+
"version": 0.4
|
| 726 |
+
}
|
v3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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import comfy.utils
|
| 2 |
+
import comfy.model_management
|
| 3 |
+
import math
|
| 4 |
+
import nodes
|
| 5 |
+
import numpy as np
|
| 6 |
+
import torch
|
| 7 |
+
import torch.nn.functional as TF
|
| 8 |
+
import torchvision.transforms.functional as F
|
| 9 |
+
from PIL import Image
|
| 10 |
+
from scipy.ndimage import gaussian_filter, grey_dilation, binary_closing, binary_fill_holes
|
| 11 |
+
from abc import ABC, abstractmethod
|
| 12 |
+
|
| 13 |
+
class ProcessorLogic(ABC):
|
| 14 |
+
@abstractmethod
|
| 15 |
+
def rescale_i(self, samples, width, height, algorithm: str):
|
| 16 |
+
pass
|
| 17 |
+
|
| 18 |
+
@abstractmethod
|
| 19 |
+
def rescale_m(self, samples, width, height, algorithm: str):
|
| 20 |
+
pass
|
| 21 |
+
|
| 22 |
+
@abstractmethod
|
| 23 |
+
def fillholes_iterative_hipass_fill_m(self, samples):
|
| 24 |
+
pass
|
| 25 |
+
|
| 26 |
+
@abstractmethod
|
| 27 |
+
def hipassfilter_m(self, samples, threshold):
|
| 28 |
+
pass
|
| 29 |
+
|
| 30 |
+
@abstractmethod
|
| 31 |
+
def expand_m(self, samples, pixels):
|
| 32 |
+
pass
|
| 33 |
+
|
| 34 |
+
@abstractmethod
|
| 35 |
+
def invert_m(self, samples):
|
| 36 |
+
pass
|
| 37 |
+
|
| 38 |
+
@abstractmethod
|
| 39 |
+
def blur_m(self, samples, pixels):
|
| 40 |
+
pass
|
| 41 |
+
|
| 42 |
+
@abstractmethod
|
| 43 |
+
def debug_context_location_in_image(self, image, x, y, w, h):
|
| 44 |
+
pass
|
| 45 |
+
|
| 46 |
+
@abstractmethod
|
| 47 |
+
def pad_to_multiple(self, value, multiple):
|
| 48 |
+
pass
|
| 49 |
+
|
| 50 |
+
@abstractmethod
|
| 51 |
+
def preresize_imm(self, image, mask, optional_context_mask, downscale_algorithm, upscale_algorithm, preresize_mode, preresize_min_width, preresize_min_height, preresize_max_width, preresize_max_height):
|
| 52 |
+
pass
|
| 53 |
+
|
| 54 |
+
@abstractmethod
|
| 55 |
+
def extend_imm(self, image, mask, optional_context_mask, extend_up_factor, extend_down_factor, extend_left_factor, extend_right_factor):
|
| 56 |
+
pass
|
| 57 |
+
|
| 58 |
+
@abstractmethod
|
| 59 |
+
def batched_findcontextarea_m(self, mask):
|
| 60 |
+
pass
|
| 61 |
+
|
| 62 |
+
def findcontextarea_m(self, mask):
|
| 63 |
+
# Default implementation for single masks using the batched version
|
| 64 |
+
# mask is [1, H, W]
|
| 65 |
+
_, x, y, w, h = self.batched_findcontextarea_m(mask)
|
| 66 |
+
context = mask[:, y[0]:y[0]+h[0], x[0]:x[0]+w[0]]
|
| 67 |
+
return context, x[0].item(), y[0].item(), w[0].item(), h[0].item()
|
| 68 |
+
|
| 69 |
+
@abstractmethod
|
| 70 |
+
def batched_growcontextarea_m(self, mask, x, y, w, h, extend_factor):
|
| 71 |
+
pass
|
| 72 |
+
|
| 73 |
+
def growcontextarea_m(self, context, mask, x, y, w, h, extend_factor):
|
| 74 |
+
_, nx, ny, nw, nh = self.batched_growcontextarea_m(mask, torch.tensor([x], device=mask.device), torch.tensor([y], device=mask.device), torch.tensor([w], device=mask.device), torch.tensor([h], device=mask.device), extend_factor)
|
| 75 |
+
nx, ny, nw, nh = nx[0].item(), ny[0].item(), nw[0].item(), nh[0].item()
|
| 76 |
+
ctx = mask[:, ny:ny+nh, nx:nx+nw]
|
| 77 |
+
return ctx, nx, ny, nw, nh
|
| 78 |
+
|
| 79 |
+
@abstractmethod
|
| 80 |
+
def batched_combinecontextmask_m(self, mask, x, y, w, h, optional_context_mask):
|
| 81 |
+
pass
|
| 82 |
+
|
| 83 |
+
def combinecontextmask_m(self, context, mask, x, y, w, h, optional_context_mask):
|
| 84 |
+
_, nx, ny, nw, nh = self.batched_combinecontextmask_m(mask, torch.tensor([x], device=mask.device), torch.tensor([y], device=mask.device), torch.tensor([w], device=mask.device), torch.tensor([h], device=mask.device), optional_context_mask)
|
| 85 |
+
nx, ny, nw, nh = nx[0].item(), ny[0].item(), nw[0].item(), nh[0].item()
|
| 86 |
+
ctx = mask[:, ny:ny+nh, nx:nx+nw]
|
| 87 |
+
return ctx, nx, ny, nw, nh
|
| 88 |
+
|
| 89 |
+
@abstractmethod
|
| 90 |
+
def crop_magic_im(self, image, mask, x, y, w, h, target_w, target_h, padding, downscale_algorithm, upscale_algorithm, resize_output=True):
|
| 91 |
+
pass
|
| 92 |
+
|
| 93 |
+
@abstractmethod
|
| 94 |
+
def stitch_magic_im(self, canvas_image, inpainted_image, mask, ctc_x, ctc_y, ctc_w, ctc_h, cto_x, cto_y, cto_w, cto_h, downscale_algorithm, upscale_algorithm):
|
| 95 |
+
pass
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
class CPUProcessorLogic(ProcessorLogic):
|
| 99 |
+
def rescale_i(self, samples, width, height, algorithm: str):
|
| 100 |
+
# samples shape: [B, H, W, C]
|
| 101 |
+
samples = samples.movedim(-1, 1) # [B, C, H, W]
|
| 102 |
+
algorithm_enum = getattr(Image, algorithm.upper()) # i.e. Image.BICUBIC
|
| 103 |
+
results = []
|
| 104 |
+
for i in range(samples.shape[0]):
|
| 105 |
+
samples_pil: Image.Image = F.to_pil_image(samples[i].cpu()).resize((width, height), algorithm_enum)
|
| 106 |
+
results.append(F.to_tensor(samples_pil))
|
| 107 |
+
samples = torch.stack(results, dim=0)
|
| 108 |
+
samples = samples.movedim(1, -1)
|
| 109 |
+
return samples
|
| 110 |
+
|
| 111 |
+
def rescale_m(self, samples, width, height, algorithm: str):
|
| 112 |
+
# samples shape: [B, H, W]
|
| 113 |
+
algorithm_enum = getattr(Image, algorithm.upper()) # i.e. Image.BICUBIC
|
| 114 |
+
results = []
|
| 115 |
+
for i in range(samples.shape[0]):
|
| 116 |
+
samples_pil: Image.Image = F.to_pil_image(samples[i].cpu()).resize((width, height), algorithm_enum)
|
| 117 |
+
results.append(F.to_tensor(samples_pil).squeeze(0))
|
| 118 |
+
samples = torch.stack(results, dim=0)
|
| 119 |
+
return samples
|
| 120 |
+
|
| 121 |
+
def fillholes_iterative_hipass_fill_m(self, samples):
|
| 122 |
+
thresholds = [1, 0.99, 0.97, 0.95, 0.93, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1]
|
| 123 |
+
results = []
|
| 124 |
+
for i in range(samples.shape[0]):
|
| 125 |
+
mask_np = samples[i].cpu().numpy()
|
| 126 |
+
for threshold in thresholds:
|
| 127 |
+
thresholded_mask = mask_np >= threshold
|
| 128 |
+
closed_mask = binary_closing(thresholded_mask, structure=np.ones((3, 3)), border_value=1)
|
| 129 |
+
filled_mask = binary_fill_holes(closed_mask)
|
| 130 |
+
mask_np = np.maximum(mask_np, np.where(filled_mask != 0, threshold, 0))
|
| 131 |
+
results.append(torch.from_numpy(mask_np.astype(np.float32)))
|
| 132 |
+
return torch.stack(results, dim=0)
|
| 133 |
+
|
| 134 |
+
def hipassfilter_m(self, samples, threshold):
|
| 135 |
+
filtered_mask = samples.clone()
|
| 136 |
+
filtered_mask[filtered_mask < threshold] = 0
|
| 137 |
+
return filtered_mask
|
| 138 |
+
|
| 139 |
+
def expand_m(self, mask, pixels):
|
| 140 |
+
sigma = pixels / 4
|
| 141 |
+
kernel_size = math.ceil(sigma * 1.5 + 1)
|
| 142 |
+
kernel = np.ones((kernel_size, kernel_size), dtype=np.uint8)
|
| 143 |
+
results = []
|
| 144 |
+
for i in range(mask.shape[0]):
|
| 145 |
+
mask_np = mask[i].cpu().numpy()
|
| 146 |
+
dilated_mask = grey_dilation(mask_np, footprint=kernel)
|
| 147 |
+
results.append(torch.from_numpy(dilated_mask.astype(np.float32)).clamp(0.0, 1.0))
|
| 148 |
+
return torch.stack(results, dim=0)
|
| 149 |
+
|
| 150 |
+
def invert_m(self, samples):
|
| 151 |
+
inverted_mask = samples.clone()
|
| 152 |
+
inverted_mask = 1.0 - inverted_mask
|
| 153 |
+
return inverted_mask
|
| 154 |
+
|
| 155 |
+
def blur_m(self, samples, pixels):
|
| 156 |
+
sigma = pixels / 4
|
| 157 |
+
results = []
|
| 158 |
+
for i in range(samples.shape[0]):
|
| 159 |
+
mask_np = samples[i].cpu().numpy()
|
| 160 |
+
blurred_mask = gaussian_filter(mask_np, sigma=sigma)
|
| 161 |
+
results.append(torch.from_numpy(blurred_mask).float().clamp(0.0, 1.0))
|
| 162 |
+
return torch.stack(results, dim=0)
|
| 163 |
+
|
| 164 |
+
def debug_context_location_in_image(self, image, x, y, w, h):
|
| 165 |
+
debug_image = image.clone()
|
| 166 |
+
debug_image[:, y:y+h, x:x+w, :] = 1.0 - debug_image[:, y:y+h, x:x+w, :]
|
| 167 |
+
return debug_image
|
| 168 |
+
|
| 169 |
+
def pad_to_multiple(self, value, multiple):
|
| 170 |
+
return int(math.ceil(value / multiple) * multiple)
|
| 171 |
+
|
| 172 |
+
def preresize_imm(self, image, mask, optional_context_mask, downscale_algorithm, upscale_algorithm, preresize_mode, preresize_min_width, preresize_min_height, preresize_max_width, preresize_max_height):
|
| 173 |
+
current_width, current_height = image.shape[2], image.shape[1]
|
| 174 |
+
|
| 175 |
+
if preresize_mode == "ensure minimum resolution":
|
| 176 |
+
if current_width >= preresize_min_width and current_height >= preresize_min_height:
|
| 177 |
+
return image, mask, optional_context_mask
|
| 178 |
+
|
| 179 |
+
scale_factor_min_width = preresize_min_width / current_width
|
| 180 |
+
scale_factor_min_height = preresize_min_height / current_height
|
| 181 |
+
|
| 182 |
+
scale_factor = max(scale_factor_min_width, scale_factor_min_height)
|
| 183 |
+
|
| 184 |
+
target_width = math.ceil(current_width * scale_factor)
|
| 185 |
+
target_height = math.ceil(current_height * scale_factor)
|
| 186 |
+
|
| 187 |
+
image = self.rescale_i(image, target_width, target_height, upscale_algorithm)
|
| 188 |
+
mask = self.rescale_m(mask, target_width, target_height, 'bilinear')
|
| 189 |
+
optional_context_mask = self.rescale_m(optional_context_mask, target_width, target_height, 'bilinear')
|
| 190 |
+
|
| 191 |
+
assert target_width >= preresize_min_width and target_height >= preresize_min_height, \
|
| 192 |
+
f"Internal error: After resizing, target size {target_width}x{target_height} is smaller than min size {preresize_min_width}x{preresize_min_height}"
|
| 193 |
+
|
| 194 |
+
elif preresize_mode == "ensure minimum and maximum resolution":
|
| 195 |
+
if preresize_min_width <= current_width <= preresize_max_width and preresize_min_height <= current_height <= preresize_max_height:
|
| 196 |
+
return image, mask, optional_context_mask
|
| 197 |
+
|
| 198 |
+
scale_factor_min_width = preresize_min_width / current_width
|
| 199 |
+
scale_factor_min_height = preresize_min_height / current_height
|
| 200 |
+
scale_factor_min = max(scale_factor_min_width, scale_factor_min_height)
|
| 201 |
+
|
| 202 |
+
scale_factor_max_width = preresize_max_width / current_width
|
| 203 |
+
scale_factor_max_height = preresize_max_height / current_height
|
| 204 |
+
scale_factor_max = min(scale_factor_max_width, scale_factor_max_height)
|
| 205 |
+
|
| 206 |
+
if scale_factor_min > 1 and scale_factor_max < 1:
|
| 207 |
+
assert False, "Cannot meet both minimum and maximum resolution requirements with aspect ratio preservation."
|
| 208 |
+
|
| 209 |
+
if scale_factor_min > 1: # We're upscaling to meet min resolution
|
| 210 |
+
scale_factor = scale_factor_min
|
| 211 |
+
rescale_algorithm = upscale_algorithm # Use upscale algorithm for min resolution
|
| 212 |
+
else: # We're downscaling to meet max resolution
|
| 213 |
+
scale_factor = scale_factor_max
|
| 214 |
+
rescale_algorithm = downscale_algorithm # Use downscale algorithm for max resolution
|
| 215 |
+
|
| 216 |
+
if scale_factor >= 1.0:
|
| 217 |
+
target_width = math.ceil(current_width * scale_factor)
|
| 218 |
+
target_height = math.ceil(current_height * scale_factor)
|
| 219 |
+
else:
|
| 220 |
+
target_width = int(current_width * scale_factor)
|
| 221 |
+
target_height = int(current_height * scale_factor)
|
| 222 |
+
|
| 223 |
+
image = self.rescale_i(image, target_width, target_height, rescale_algorithm)
|
| 224 |
+
mask = self.rescale_m(mask, target_width, target_height, 'nearest') # Always nearest for efficiency
|
| 225 |
+
optional_context_mask = self.rescale_m(optional_context_mask, target_width, target_height, 'nearest') # Always nearest for efficiency
|
| 226 |
+
|
| 227 |
+
assert preresize_min_width <= target_width <= preresize_max_width, \
|
| 228 |
+
f"Internal error: Target width {target_width} is outside the range {preresize_min_width} - {preresize_max_width}"
|
| 229 |
+
assert preresize_min_height <= target_height <= preresize_max_height, \
|
| 230 |
+
f"Internal error: Target height {target_height} is outside the range {preresize_min_height} - {preresize_max_height}"
|
| 231 |
+
|
| 232 |
+
elif preresize_mode == "ensure maximum resolution":
|
| 233 |
+
if current_width <= preresize_max_width and current_height <= preresize_max_height:
|
| 234 |
+
return image, mask, optional_context_mask
|
| 235 |
+
|
| 236 |
+
scale_factor_max_width = preresize_max_width / current_width
|
| 237 |
+
scale_factor_max_height = preresize_max_height / current_height
|
| 238 |
+
scale_factor_max = min(scale_factor_max_width, scale_factor_max_height)
|
| 239 |
+
|
| 240 |
+
target_width = int(current_width * scale_factor_max)
|
| 241 |
+
target_height = int(current_height * scale_factor_max)
|
| 242 |
+
|
| 243 |
+
image = self.rescale_i(image, target_width, target_height, downscale_algorithm)
|
| 244 |
+
mask = self.rescale_m(mask, target_width, target_height, 'nearest') # Always nearest for efficiency
|
| 245 |
+
optional_context_mask = self.rescale_m(optional_context_mask, target_width, target_height, 'nearest') # Always nearest for efficiency
|
| 246 |
+
|
| 247 |
+
assert target_width <= preresize_max_width and target_height <= preresize_max_height, \
|
| 248 |
+
f"Internal error: Target size {target_width}x{target_height} is greater than max size {preresize_max_width}x{preresize_max_height}"
|
| 249 |
+
|
| 250 |
+
return image, mask, optional_context_mask
|
| 251 |
+
|
| 252 |
+
def extend_imm(self, image, mask, optional_context_mask, extend_up_factor, extend_down_factor, extend_left_factor, extend_right_factor):
|
| 253 |
+
B, H, W, C = image.shape
|
| 254 |
+
|
| 255 |
+
new_H = int(H * (1.0 + extend_up_factor - 1.0 + extend_down_factor - 1.0))
|
| 256 |
+
new_W = int(W * (1.0 + extend_left_factor - 1.0 + extend_right_factor - 1.0))
|
| 257 |
+
|
| 258 |
+
assert new_H >= 0, f"Error: Trying to crop too much, height ({new_H}) must be >= 0"
|
| 259 |
+
assert new_W >= 0, f"Error: Trying to crop too much, width ({new_W}) must be >= 0"
|
| 260 |
+
|
| 261 |
+
expanded_image = torch.zeros(B, new_H, new_W, C, device=image.device)
|
| 262 |
+
expanded_mask = torch.ones(B, new_H, new_W, device=mask.device)
|
| 263 |
+
expanded_optional_context_mask = torch.zeros(B, new_H, new_W, device=optional_context_mask.device)
|
| 264 |
+
|
| 265 |
+
up_padding = int(H * (extend_up_factor - 1.0))
|
| 266 |
+
down_padding = new_H - H - up_padding
|
| 267 |
+
left_padding = int(W * (extend_left_factor - 1.0))
|
| 268 |
+
right_padding = new_W - W - left_padding
|
| 269 |
+
|
| 270 |
+
slice_target_up = max(0, up_padding)
|
| 271 |
+
slice_target_down = min(new_H, up_padding + H)
|
| 272 |
+
slice_target_left = max(0, left_padding)
|
| 273 |
+
slice_target_right = min(new_W, left_padding + W)
|
| 274 |
+
|
| 275 |
+
slice_source_up = max(0, -up_padding)
|
| 276 |
+
slice_source_down = min(H, new_H - up_padding)
|
| 277 |
+
slice_source_left = max(0, -left_padding)
|
| 278 |
+
slice_source_right = min(W, new_W - left_padding)
|
| 279 |
+
|
| 280 |
+
image = image.permute(0, 3, 1, 2) # [B, H, W, C] -> [B, C, H, W]
|
| 281 |
+
expanded_image = expanded_image.permute(0, 3, 1, 2) # [B, H, W, C] -> [B, C, H, W]
|
| 282 |
+
|
| 283 |
+
expanded_image[:, :, slice_target_up:slice_target_down, slice_target_left:slice_target_right] = image[:, :, slice_source_up:slice_source_down, slice_source_left:slice_source_right]
|
| 284 |
+
if up_padding > 0:
|
| 285 |
+
expanded_image[:, :, :up_padding, slice_target_left:slice_target_right] = image[:, :, 0:1, slice_source_left:slice_source_right].repeat(1, 1, up_padding, 1)
|
| 286 |
+
if down_padding > 0:
|
| 287 |
+
expanded_image[:, :, -down_padding:, slice_target_left:slice_target_right] = image[:, :, -1:, slice_source_left:slice_source_right].repeat(1, 1, down_padding, 1)
|
| 288 |
+
if left_padding > 0:
|
| 289 |
+
expanded_image[:, :, slice_target_up:slice_target_down, :left_padding] = expanded_image[:, :, slice_target_up:slice_target_down, left_padding:left_padding+1].repeat(1, 1, 1, left_padding)
|
| 290 |
+
if right_padding > 0:
|
| 291 |
+
expanded_image[:, :, slice_target_up:slice_target_down, -right_padding:] = expanded_image[:, :, slice_target_up:slice_target_down, -right_padding-1:-right_padding].repeat(1, 1, 1, right_padding)
|
| 292 |
+
|
| 293 |
+
expanded_mask[:, slice_target_up:slice_target_down, slice_target_left:slice_target_right] = mask[:, slice_source_up:slice_source_down, slice_source_left:slice_source_right]
|
| 294 |
+
expanded_optional_context_mask[:, slice_target_up:slice_target_down, slice_target_left:slice_target_right] = optional_context_mask[:, slice_source_up:slice_source_down, slice_source_left:slice_source_right]
|
| 295 |
+
|
| 296 |
+
expanded_image = expanded_image.permute(0, 2, 3, 1) # [B, C, H, W] -> [B, H, W, C]
|
| 297 |
+
image = image.permute(0, 2, 3, 1) # [B, C, H, W] -> [B, H, W, C]
|
| 298 |
+
|
| 299 |
+
return expanded_image, expanded_mask, expanded_optional_context_mask
|
| 300 |
+
|
| 301 |
+
def batched_findcontextarea_m(self, mask):
|
| 302 |
+
# Optimized GPU implementation or CPU fallback
|
| 303 |
+
B, H, W = mask.shape
|
| 304 |
+
device = mask.device
|
| 305 |
+
|
| 306 |
+
# If on GPU, we can use vectorized approach.
|
| 307 |
+
# But for now, let's just use the shared logic that works on both.
|
| 308 |
+
# Wait, I'll use the vectorized one in the NEXT step for GPU specifically.
|
| 309 |
+
# This global step just fixes the placeholder.
|
| 310 |
+
|
| 311 |
+
x_list, y_list, w_list, h_list = [], [], [], []
|
| 312 |
+
for i in range(B):
|
| 313 |
+
mask_squeezed = mask[i]
|
| 314 |
+
non_zero_indices = torch.nonzero(mask_squeezed)
|
| 315 |
+
if non_zero_indices.numel() == 0:
|
| 316 |
+
bx, by, bw, bh = -1, -1, -1, -1
|
| 317 |
+
else:
|
| 318 |
+
by = torch.min(non_zero_indices[:, 0]).item()
|
| 319 |
+
bx = torch.min(non_zero_indices[:, 1]).item()
|
| 320 |
+
by_max = torch.max(non_zero_indices[:, 0]).item()
|
| 321 |
+
bx_max = torch.max(non_zero_indices[:, 1]).item()
|
| 322 |
+
bw = bx_max - bx + 1
|
| 323 |
+
bh = by_max - by + 1
|
| 324 |
+
x_list.append(bx)
|
| 325 |
+
y_list.append(by)
|
| 326 |
+
w_list.append(bw)
|
| 327 |
+
h_list.append(bh)
|
| 328 |
+
return None, torch.tensor(x_list, device=device), torch.tensor(y_list, device=device), torch.tensor(w_list, device=device), torch.tensor(h_list, device=device)
|
| 329 |
+
|
| 330 |
+
def batched_growcontextarea_m(self, mask, x, y, w, h, extend_factor):
|
| 331 |
+
img_h, img_w = mask.shape[1], mask.shape[2]
|
| 332 |
+
device = mask.device
|
| 333 |
+
|
| 334 |
+
grow_x = (w.float() * (extend_factor - 1.0) / 2.0).round().long()
|
| 335 |
+
grow_y = (h.float() * (extend_factor - 1.0) / 2.0).round().long()
|
| 336 |
+
|
| 337 |
+
new_x = torch.clamp(x - grow_x, min=0)
|
| 338 |
+
new_y = torch.clamp(y - grow_y, min=0)
|
| 339 |
+
new_x2 = torch.clamp(x + w + grow_x, max=img_w)
|
| 340 |
+
new_y2 = torch.clamp(y + h + grow_y, max=img_h)
|
| 341 |
+
|
| 342 |
+
new_w = new_x2 - new_x
|
| 343 |
+
new_h = new_y2 - new_y
|
| 344 |
+
|
| 345 |
+
empty = (w == -1)
|
| 346 |
+
new_x[empty] = 0
|
| 347 |
+
new_y[empty] = 0
|
| 348 |
+
new_w[empty] = img_w
|
| 349 |
+
new_h[empty] = img_h
|
| 350 |
+
|
| 351 |
+
return None, new_x, new_y, new_w, new_h
|
| 352 |
+
|
| 353 |
+
def batched_combinecontextmask_m(self, mask, x, y, w, h, optional_context_mask):
|
| 354 |
+
_, ox, oy, ow, oh = self.batched_findcontextarea_m(optional_context_mask)
|
| 355 |
+
|
| 356 |
+
mask_x_neg1 = (x == -1)
|
| 357 |
+
x_1 = torch.where(mask_x_neg1, ox, x)
|
| 358 |
+
y_1 = torch.where(mask_x_neg1, oy, y)
|
| 359 |
+
w_1 = torch.where(mask_x_neg1, ow, w)
|
| 360 |
+
h_1 = torch.where(mask_x_neg1, oh, h)
|
| 361 |
+
|
| 362 |
+
mask_ox_neg1 = (ox == -1)
|
| 363 |
+
ox_2 = torch.where(mask_ox_neg1, x_1, ox)
|
| 364 |
+
oy_2 = torch.where(mask_ox_neg1, y_1, oy)
|
| 365 |
+
ow_2 = torch.where(mask_ox_neg1, w_1, ow)
|
| 366 |
+
oh_2 = torch.where(mask_ox_neg1, h_1, oh)
|
| 367 |
+
|
| 368 |
+
new_x = torch.min(x_1, ox_2)
|
| 369 |
+
new_y = torch.min(y_1, oy_2)
|
| 370 |
+
new_x_max = torch.max(x_1 + w_1, ox_2 + ow_2)
|
| 371 |
+
new_y_max = torch.max(y_1 + h_1, oy_2 + oh_2)
|
| 372 |
+
new_w = new_x_max - new_x
|
| 373 |
+
new_h = new_y_max - new_y
|
| 374 |
+
|
| 375 |
+
both_empty = (x_1 == -1)
|
| 376 |
+
new_x[both_empty] = -1
|
| 377 |
+
new_y[both_empty] = -1
|
| 378 |
+
new_w[both_empty] = -1
|
| 379 |
+
new_h[both_empty] = -1
|
| 380 |
+
|
| 381 |
+
return None, new_x, new_y, new_w, new_h
|
| 382 |
+
|
| 383 |
+
def crop_magic_im(self, image, mask, x, y, w, h, target_w, target_h, padding, downscale_algorithm, upscale_algorithm, resize_output=True):
|
| 384 |
+
image = image.clone()
|
| 385 |
+
mask = mask.clone()
|
| 386 |
+
|
| 387 |
+
# Check for invalid inputs
|
| 388 |
+
if target_w <= 0 or target_h <= 0 or w == 0 or h == 0:
|
| 389 |
+
return image, 0, 0, image.shape[2], image.shape[1], image, mask, 0, 0, image.shape[2], image.shape[1]
|
| 390 |
+
|
| 391 |
+
# Step 1: Pad target dimensions to be multiples of padding
|
| 392 |
+
if padding != 0:
|
| 393 |
+
target_w = self.pad_to_multiple(target_w, padding)
|
| 394 |
+
target_h = self.pad_to_multiple(target_h, padding)
|
| 395 |
+
|
| 396 |
+
# Step 2: Calculate target aspect ratio
|
| 397 |
+
target_aspect_ratio = target_w / target_h
|
| 398 |
+
|
| 399 |
+
# Step 3: Grow current context area to meet the target aspect ratio
|
| 400 |
+
B, image_h, image_w, C = image.shape
|
| 401 |
+
context_aspect_ratio = w / h
|
| 402 |
+
if context_aspect_ratio < target_aspect_ratio:
|
| 403 |
+
# Grow width to meet aspect ratio
|
| 404 |
+
new_w = int(h * target_aspect_ratio)
|
| 405 |
+
new_h = h
|
| 406 |
+
new_x = x - (new_w - w) // 2
|
| 407 |
+
new_y = y
|
| 408 |
+
|
| 409 |
+
# Adjust new_x to keep within bounds
|
| 410 |
+
if new_x < 0:
|
| 411 |
+
shift = -new_x
|
| 412 |
+
if new_x + new_w + shift <= image_w:
|
| 413 |
+
new_x += shift
|
| 414 |
+
else:
|
| 415 |
+
overflow = (new_w - image_w) // 2
|
| 416 |
+
new_x = -overflow
|
| 417 |
+
elif new_x + new_w > image_w:
|
| 418 |
+
overflow = new_x + new_w - image_w
|
| 419 |
+
if new_x - overflow >= 0:
|
| 420 |
+
new_x -= overflow
|
| 421 |
+
else:
|
| 422 |
+
overflow = (new_w - image_w) // 2
|
| 423 |
+
new_x = -overflow
|
| 424 |
+
|
| 425 |
+
else:
|
| 426 |
+
# Grow height to meet aspect ratio
|
| 427 |
+
new_w = w
|
| 428 |
+
new_h = int(w / target_aspect_ratio)
|
| 429 |
+
new_x = x
|
| 430 |
+
new_y = y - (new_h - h) // 2
|
| 431 |
+
|
| 432 |
+
# Adjust new_y to keep within bounds
|
| 433 |
+
if new_y < 0:
|
| 434 |
+
shift = -new_y
|
| 435 |
+
if new_y + new_h + shift <= image_h:
|
| 436 |
+
new_y += shift
|
| 437 |
+
else:
|
| 438 |
+
overflow = (new_h - image_h) // 2
|
| 439 |
+
new_y = -overflow
|
| 440 |
+
elif new_y + new_h > image_h:
|
| 441 |
+
overflow = new_y + new_h - image_h
|
| 442 |
+
if new_y - overflow >= 0:
|
| 443 |
+
new_y -= overflow
|
| 444 |
+
else:
|
| 445 |
+
overflow = (new_h - image_h) // 2
|
| 446 |
+
new_y = -overflow
|
| 447 |
+
|
| 448 |
+
# Step 3b: When not resizing output, ensure dimensions are at least target dimensions
|
| 449 |
+
# This ensures output_padding works correctly even without resize (Option A: expand context, keep centered)
|
| 450 |
+
if not resize_output:
|
| 451 |
+
if new_w < target_w:
|
| 452 |
+
grow_w = target_w - new_w
|
| 453 |
+
new_x -= grow_w // 2
|
| 454 |
+
new_w = target_w
|
| 455 |
+
# Recalculate bounds
|
| 456 |
+
if new_x < 0:
|
| 457 |
+
shift = -new_x
|
| 458 |
+
if new_x + new_w + shift <= image_w:
|
| 459 |
+
new_x += shift
|
| 460 |
+
else:
|
| 461 |
+
new_x = -((new_w - image_w) // 2)
|
| 462 |
+
elif new_x + new_w > image_w:
|
| 463 |
+
overflow = new_x + new_w - image_w
|
| 464 |
+
if new_x - overflow >= 0:
|
| 465 |
+
new_x -= overflow
|
| 466 |
+
else:
|
| 467 |
+
new_x = -((new_w - image_w) // 2)
|
| 468 |
+
if new_h < target_h:
|
| 469 |
+
grow_h = target_h - new_h
|
| 470 |
+
new_y -= grow_h // 2
|
| 471 |
+
new_h = target_h
|
| 472 |
+
# Recalculate bounds
|
| 473 |
+
if new_y < 0:
|
| 474 |
+
shift = -new_y
|
| 475 |
+
if new_y + new_h + shift <= image_h:
|
| 476 |
+
new_y += shift
|
| 477 |
+
else:
|
| 478 |
+
new_y = -((new_h - image_h) // 2)
|
| 479 |
+
elif new_y + new_h > image_h:
|
| 480 |
+
overflow = new_y + new_h - image_h
|
| 481 |
+
if new_y - overflow >= 0:
|
| 482 |
+
new_y -= overflow
|
| 483 |
+
else:
|
| 484 |
+
new_y = -((new_h - image_h) // 2)
|
| 485 |
+
|
| 486 |
+
# Step 4: Grow the image to accommodate the new context area
|
| 487 |
+
up_padding, down_padding, left_padding, right_padding = 0, 0, 0, 0
|
| 488 |
+
|
| 489 |
+
expanded_image_w = image_w
|
| 490 |
+
expanded_image_h = image_h
|
| 491 |
+
|
| 492 |
+
# Adjust width for left overflow (x < 0) and right overflow (x + w > image_w)
|
| 493 |
+
if new_x < 0:
|
| 494 |
+
left_padding = -new_x
|
| 495 |
+
expanded_image_w += left_padding
|
| 496 |
+
if new_x + new_w > image_w:
|
| 497 |
+
right_padding = (new_x + new_w - image_w)
|
| 498 |
+
expanded_image_w += right_padding
|
| 499 |
+
# Adjust height for top overflow (y < 0) and bottom overflow (y + h > image_h)
|
| 500 |
+
if new_y < 0:
|
| 501 |
+
up_padding = -new_y
|
| 502 |
+
expanded_image_h += up_padding
|
| 503 |
+
if new_y + new_h > image_h:
|
| 504 |
+
down_padding = (new_y + new_h - image_h)
|
| 505 |
+
expanded_image_h += down_padding
|
| 506 |
+
|
| 507 |
+
# Step 5: Create the new image and mask
|
| 508 |
+
expanded_image = torch.zeros((image.shape[0], expanded_image_h, expanded_image_w, image.shape[3]), device=image.device)
|
| 509 |
+
expanded_mask = torch.ones((mask.shape[0], expanded_image_h, expanded_image_w), device=mask.device)
|
| 510 |
+
|
| 511 |
+
# Reorder the tensors to match the required dimension format for padding
|
| 512 |
+
image = image.permute(0, 3, 1, 2) # [B, H, W, C] -> [B, C, H, W]
|
| 513 |
+
expanded_image = expanded_image.permute(0, 3, 1, 2) # [B, H, W, C] -> [B, C, H, W]
|
| 514 |
+
|
| 515 |
+
# Ensure the expanded image has enough room to hold the padded version of the original image
|
| 516 |
+
expanded_image[:, :, up_padding:up_padding + image_h, left_padding:left_padding + image_w] = image
|
| 517 |
+
|
| 518 |
+
# Fill the new extended areas with the edge values of the image
|
| 519 |
+
if up_padding > 0:
|
| 520 |
+
expanded_image[:, :, :up_padding, left_padding:left_padding + image_w] = expanded_image[:, :, up_padding:up_padding + 1, left_padding:left_padding + image_w].repeat(1, 1, up_padding, 1)
|
| 521 |
+
if down_padding > 0:
|
| 522 |
+
expanded_image[:, :, -down_padding:, left_padding:left_padding + image_w] = expanded_image[:, :, up_padding + image_h - 1:up_padding + image_h, left_padding:left_padding + image_w].repeat(1, 1, down_padding, 1)
|
| 523 |
+
if left_padding > 0:
|
| 524 |
+
expanded_image[:, :, up_padding:up_padding + image_h, :left_padding] = expanded_image[:, :, up_padding:up_padding + image_h, left_padding:left_padding+1].repeat(1, 1, 1, left_padding)
|
| 525 |
+
if right_padding > 0:
|
| 526 |
+
expanded_image[:, :, up_padding:up_padding + image_h, -right_padding:] = expanded_image[:, :, up_padding:up_padding + image_h, -right_padding-1:-right_padding].repeat(1, 1, 1, right_padding)
|
| 527 |
+
|
| 528 |
+
# Reorder the tensors back to [B, H, W, C] format
|
| 529 |
+
expanded_image = expanded_image.permute(0, 2, 3, 1) # [B, C, H, W] -> [B, H, W, C]
|
| 530 |
+
image = image.permute(0, 2, 3, 1) # [B, C, H, W] -> [B, H, W, C]
|
| 531 |
+
|
| 532 |
+
# Same for the mask
|
| 533 |
+
expanded_mask[:, up_padding:up_padding + image_h, left_padding:left_padding + image_w] = mask
|
| 534 |
+
|
| 535 |
+
# Record the cto values (canvas to original)
|
| 536 |
+
cto_x = left_padding
|
| 537 |
+
cto_y = up_padding
|
| 538 |
+
cto_w = image_w
|
| 539 |
+
cto_h = image_h
|
| 540 |
+
|
| 541 |
+
# The final expanded image and mask
|
| 542 |
+
canvas_image = expanded_image
|
| 543 |
+
canvas_mask = expanded_mask
|
| 544 |
+
|
| 545 |
+
# Step 6: Crop the image and mask around x, y, w, h
|
| 546 |
+
ctc_x = new_x+left_padding
|
| 547 |
+
ctc_y = new_y+up_padding
|
| 548 |
+
ctc_w = new_w
|
| 549 |
+
ctc_h = new_h
|
| 550 |
+
|
| 551 |
+
# Crop the image and mask
|
| 552 |
+
cropped_image = canvas_image[:, ctc_y:ctc_y + ctc_h, ctc_x:ctc_x + ctc_w]
|
| 553 |
+
cropped_mask = canvas_mask[:, ctc_y:ctc_y + ctc_h, ctc_x:ctc_x + ctc_w]
|
| 554 |
+
|
| 555 |
+
# Step 7: Resize image and mask to the target width and height
|
| 556 |
+
if resize_output:
|
| 557 |
+
# Decide which algorithm to use based on the scaling direction
|
| 558 |
+
if target_w > ctc_w or target_h > ctc_h: # Upscaling
|
| 559 |
+
cropped_image = self.rescale_i(cropped_image, target_w, target_h, upscale_algorithm)
|
| 560 |
+
cropped_mask = self.rescale_m(cropped_mask, target_w, target_h, upscale_algorithm)
|
| 561 |
+
else: # Downscaling
|
| 562 |
+
cropped_image = self.rescale_i(cropped_image, target_w, target_h, downscale_algorithm)
|
| 563 |
+
cropped_mask = self.rescale_m(cropped_mask, target_w, target_h, downscale_algorithm)
|
| 564 |
+
|
| 565 |
+
return canvas_image, cto_x, cto_y, cto_w, cto_h, cropped_image, cropped_mask, ctc_x, ctc_y, ctc_w, ctc_h
|
| 566 |
+
|
| 567 |
+
def stitch_magic_im(self, canvas_image, inpainted_image, mask, ctc_x, ctc_y, ctc_w, ctc_h, cto_x, cto_y, cto_w, cto_h, downscale_algorithm, upscale_algorithm):
|
| 568 |
+
canvas_image = canvas_image.clone()
|
| 569 |
+
inpainted_image = inpainted_image.clone()
|
| 570 |
+
mask = mask.clone()
|
| 571 |
+
|
| 572 |
+
# Resize inpainted image and mask to match the context size
|
| 573 |
+
B, h, w, _ = inpainted_image.shape
|
| 574 |
+
if ctc_w > w or ctc_h > h: # Upscaling
|
| 575 |
+
resized_image = self.rescale_i(inpainted_image, ctc_w, ctc_h, upscale_algorithm)
|
| 576 |
+
resized_mask = self.rescale_m(mask, ctc_w, ctc_h, upscale_algorithm)
|
| 577 |
+
else: # Downscaling
|
| 578 |
+
resized_image = self.rescale_i(inpainted_image, ctc_w, ctc_h, downscale_algorithm)
|
| 579 |
+
resized_mask = self.rescale_m(mask, ctc_w, ctc_h, downscale_algorithm)
|
| 580 |
+
|
| 581 |
+
# Clamp mask to [0, 1] and expand to match image channels
|
| 582 |
+
resized_mask = resized_mask.clamp(0, 1).unsqueeze(-1) # shape: [B, H, W, 1]
|
| 583 |
+
|
| 584 |
+
# Extract the canvas region we're about to overwrite
|
| 585 |
+
canvas_crop = canvas_image[:, ctc_y:ctc_y + ctc_h, ctc_x:ctc_x + ctc_w]
|
| 586 |
+
|
| 587 |
+
# Blend: new = mask * inpainted + (1 - mask) * canvas
|
| 588 |
+
blended = resized_mask * resized_image + (1.0 - resized_mask) * canvas_crop
|
| 589 |
+
|
| 590 |
+
# Paste the blended region back onto the canvas
|
| 591 |
+
canvas_image[:, ctc_y:ctc_y + ctc_h, ctc_x:ctc_x + ctc_w] = blended
|
| 592 |
+
|
| 593 |
+
# Final crop to get back the original image area
|
| 594 |
+
output_image = canvas_image[:, cto_y:cto_y + cto_h, cto_x:cto_x + cto_w]
|
| 595 |
+
|
| 596 |
+
return output_image
|
| 597 |
+
|
| 598 |
+
|
| 599 |
+
class GPUProcessorLogic(ProcessorLogic):
|
| 600 |
+
def rescale_i(self, samples, width, height, algorithm: str):
|
| 601 |
+
# samples shape: [B, H, W, C]
|
| 602 |
+
mode = algorithm.lower()
|
| 603 |
+
|
| 604 |
+
# CPU works better, fallback to CPU for rescaling
|
| 605 |
+
original_device = samples.device
|
| 606 |
+
samples = samples.movedim(-1, 1) # [B, C, H, W]
|
| 607 |
+
algorithm_enum = getattr(Image, algorithm.upper())
|
| 608 |
+
results = []
|
| 609 |
+
for i in range(samples.shape[0]):
|
| 610 |
+
samples_pil: Image.Image = F.to_pil_image(samples[i].float().cpu()).resize((width, height), algorithm_enum)
|
| 611 |
+
results.append(F.to_tensor(samples_pil))
|
| 612 |
+
samples = torch.stack(results, dim=0).to(original_device)
|
| 613 |
+
samples = samples.movedim(1, -1)
|
| 614 |
+
return samples
|
| 615 |
+
|
| 616 |
+
#samples = samples.movedim(-1, 1) # [B, C, H, W]
|
| 617 |
+
#samples = TF.interpolate(samples, size=(height, width), mode=mode, align_corners=False if mode not in ['nearest', 'area'] else None)
|
| 618 |
+
#samples = samples.movedim(1, -1)
|
| 619 |
+
#return samples
|
| 620 |
+
|
| 621 |
+
def rescale_m(self, samples, width, height, algorithm: str):
|
| 622 |
+
# samples shape: [B, H, W]
|
| 623 |
+
mode = algorithm.lower()
|
| 624 |
+
|
| 625 |
+
# CPU works better, fallback to CPU for rescaling
|
| 626 |
+
original_device = samples.device
|
| 627 |
+
algorithm_enum = getattr(Image, algorithm.upper())
|
| 628 |
+
results = []
|
| 629 |
+
for i in range(samples.shape[0]):
|
| 630 |
+
samples_pil: Image.Image = F.to_pil_image(samples[i].float().cpu()).resize((width, height), algorithm_enum)
|
| 631 |
+
results.append(F.to_tensor(samples_pil).squeeze(0))
|
| 632 |
+
samples = torch.stack(results, dim=0).to(original_device)
|
| 633 |
+
return samples
|
| 634 |
+
|
| 635 |
+
#samples = samples.unsqueeze(1) # [B, H, W] -> [B, 1, H, W]
|
| 636 |
+
#samples = TF.interpolate(samples, size=(height, width), mode=mode, align_corners=False if mode not in ['nearest', 'area'] else None)
|
| 637 |
+
#samples = samples.squeeze(1)
|
| 638 |
+
#return samples
|
| 639 |
+
|
| 640 |
+
def fillholes_iterative_hipass_fill_m(self, samples):
|
| 641 |
+
# We want this to always run in CPU for simplicity of implementation.
|
| 642 |
+
# Just convert whatever inputs from GPU to CPU at the beginning of the function,
|
| 643 |
+
# then convert them back to GPU at the end of the function.
|
| 644 |
+
# The implementation is verbatim from CPUProcessorLogic.
|
| 645 |
+
|
| 646 |
+
thresholds = [1, 0.99, 0.97, 0.95, 0.93, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1]
|
| 647 |
+
results = []
|
| 648 |
+
original_device = samples.device
|
| 649 |
+
for i in range(samples.shape[0]):
|
| 650 |
+
mask_np = samples[i].cpu().numpy()
|
| 651 |
+
for threshold in thresholds:
|
| 652 |
+
thresholded_mask = mask_np >= threshold
|
| 653 |
+
closed_mask = binary_closing(thresholded_mask, structure=np.ones((3, 3)), border_value=1)
|
| 654 |
+
filled_mask = binary_fill_holes(closed_mask)
|
| 655 |
+
mask_np = np.maximum(mask_np, np.where(filled_mask != 0, threshold, 0))
|
| 656 |
+
results.append(torch.from_numpy(mask_np.astype(np.float32)))
|
| 657 |
+
return torch.stack(results, dim=0).to(original_device)
|
| 658 |
+
|
| 659 |
+
def hipassfilter_m(self, samples, threshold):
|
| 660 |
+
filtered_mask = samples.clone()
|
| 661 |
+
filtered_mask[filtered_mask < threshold] = 0
|
| 662 |
+
return filtered_mask
|
| 663 |
+
|
| 664 |
+
def expand_m(self, mask, pixels):
|
| 665 |
+
# Dilation can be approximated with max pooling
|
| 666 |
+
sigma = pixels / 4
|
| 667 |
+
kernel_size = math.ceil(sigma * 1.5 + 1)
|
| 668 |
+
if kernel_size % 2 == 0:
|
| 669 |
+
kernel_size += 1
|
| 670 |
+
|
| 671 |
+
padding = kernel_size // 2
|
| 672 |
+
|
| 673 |
+
# mask is [B, H, W] -> [B, 1, H, W]
|
| 674 |
+
mask_in = mask.unsqueeze(1)
|
| 675 |
+
|
| 676 |
+
# MaxPool2d is equivalent to dilation with a square kernel of 1s
|
| 677 |
+
dilated = TF.max_pool2d(mask_in, kernel_size=kernel_size, stride=1, padding=padding)
|
| 678 |
+
|
| 679 |
+
return dilated.squeeze(1)
|
| 680 |
+
|
| 681 |
+
def invert_m(self, samples):
|
| 682 |
+
inverted_mask = samples.clone()
|
| 683 |
+
inverted_mask = 1.0 - inverted_mask
|
| 684 |
+
return inverted_mask
|
| 685 |
+
|
| 686 |
+
def blur_m(self, samples, pixels):
|
| 687 |
+
sigma = pixels / 4
|
| 688 |
+
# Gaussian blur implementation on GPU
|
| 689 |
+
kernel_size = 2 * int(4.0 * sigma + 0.5) + 1
|
| 690 |
+
|
| 691 |
+
# Create gaussian kernel
|
| 692 |
+
x = torch.arange(kernel_size, device=samples.device, dtype=samples.dtype) - (kernel_size - 1) / 2
|
| 693 |
+
kernel_1d = torch.exp(-0.5 * (x / sigma).pow(2))
|
| 694 |
+
kernel_1d = kernel_1d / kernel_1d.sum()
|
| 695 |
+
|
| 696 |
+
kernel_2d = kernel_1d.unsqueeze(1) * kernel_1d.unsqueeze(0)
|
| 697 |
+
kernel_2d = kernel_2d.expand(1, 1, kernel_size, kernel_size)
|
| 698 |
+
|
| 699 |
+
mask_in = samples.unsqueeze(1)
|
| 700 |
+
blurred = TF.conv2d(mask_in, kernel_2d, padding=kernel_size//2, groups=1)
|
| 701 |
+
|
| 702 |
+
return blurred.squeeze(1).clamp(0.0, 1.0)
|
| 703 |
+
|
| 704 |
+
def debug_context_location_in_image(self, image, x, y, w, h):
|
| 705 |
+
debug_image = image.clone()
|
| 706 |
+
debug_image[:, y:y+h, x:x+w, :] = 1.0 - debug_image[:, y:y+h, x:x+w, :]
|
| 707 |
+
return debug_image
|
| 708 |
+
|
| 709 |
+
def pad_to_multiple(self, value, multiple):
|
| 710 |
+
return int(math.ceil(value / multiple) * multiple)
|
| 711 |
+
|
| 712 |
+
def preresize_imm(self, image, mask, optional_context_mask, downscale_algorithm, upscale_algorithm, preresize_mode, preresize_min_width, preresize_min_height, preresize_max_width, preresize_max_height):
|
| 713 |
+
current_width, current_height = image.shape[2], image.shape[1]
|
| 714 |
+
|
| 715 |
+
if preresize_mode == "ensure minimum resolution":
|
| 716 |
+
if current_width >= preresize_min_width and current_height >= preresize_min_height:
|
| 717 |
+
return image, mask, optional_context_mask
|
| 718 |
+
|
| 719 |
+
scale_factor_min_width = preresize_min_width / current_width
|
| 720 |
+
scale_factor_min_height = preresize_min_height / current_height
|
| 721 |
+
|
| 722 |
+
scale_factor = max(scale_factor_min_width, scale_factor_min_height)
|
| 723 |
+
|
| 724 |
+
target_width = math.ceil(current_width * scale_factor)
|
| 725 |
+
target_height = math.ceil(current_height * scale_factor)
|
| 726 |
+
|
| 727 |
+
image = self.rescale_i(image, target_width, target_height, upscale_algorithm)
|
| 728 |
+
mask = self.rescale_m(mask, target_width, target_height, 'bilinear')
|
| 729 |
+
optional_context_mask = self.rescale_m(optional_context_mask, target_width, target_height, 'bilinear')
|
| 730 |
+
|
| 731 |
+
assert target_width >= preresize_min_width and target_height >= preresize_min_height, \
|
| 732 |
+
f"Internal error: After resizing, target size {target_width}x{target_height} is smaller than min size {preresize_min_width}x{preresize_min_height}"
|
| 733 |
+
|
| 734 |
+
elif preresize_mode == "ensure minimum and maximum resolution":
|
| 735 |
+
if preresize_min_width <= current_width <= preresize_max_width and preresize_min_height <= current_height <= preresize_max_height:
|
| 736 |
+
return image, mask, optional_context_mask
|
| 737 |
+
|
| 738 |
+
scale_factor_min_width = preresize_min_width / current_width
|
| 739 |
+
scale_factor_min_height = preresize_min_height / current_height
|
| 740 |
+
scale_factor_min = max(scale_factor_min_width, scale_factor_min_height)
|
| 741 |
+
|
| 742 |
+
scale_factor_max_width = preresize_max_width / current_width
|
| 743 |
+
scale_factor_max_height = preresize_max_height / current_height
|
| 744 |
+
scale_factor_max = min(scale_factor_max_width, scale_factor_max_height)
|
| 745 |
+
|
| 746 |
+
if scale_factor_min > 1 and scale_factor_max < 1:
|
| 747 |
+
assert False, "Cannot meet both minimum and maximum resolution requirements with aspect ratio preservation."
|
| 748 |
+
|
| 749 |
+
if scale_factor_min > 1: # We're upscaling to meet min resolution
|
| 750 |
+
scale_factor = scale_factor_min
|
| 751 |
+
rescale_algorithm = upscale_algorithm # Use upscale algorithm for min resolution
|
| 752 |
+
else: # We're downscaling to meet max resolution
|
| 753 |
+
scale_factor = scale_factor_max
|
| 754 |
+
rescale_algorithm = downscale_algorithm # Use downscale algorithm for max resolution
|
| 755 |
+
|
| 756 |
+
if scale_factor >= 1.0:
|
| 757 |
+
target_width = math.ceil(current_width * scale_factor)
|
| 758 |
+
target_height = math.ceil(current_height * scale_factor)
|
| 759 |
+
else:
|
| 760 |
+
target_width = int(current_width * scale_factor)
|
| 761 |
+
target_height = int(current_height * scale_factor)
|
| 762 |
+
|
| 763 |
+
image = self.rescale_i(image, target_width, target_height, rescale_algorithm)
|
| 764 |
+
mask = self.rescale_m(mask, target_width, target_height, 'nearest') # Always nearest for efficiency
|
| 765 |
+
optional_context_mask = self.rescale_m(optional_context_mask, target_width, target_height, 'nearest') # Always nearest for efficiency
|
| 766 |
+
|
| 767 |
+
assert preresize_min_width <= target_width <= preresize_max_width, \
|
| 768 |
+
f"Internal error: Target width {target_width} is outside the range {preresize_min_width} - {preresize_max_width}"
|
| 769 |
+
assert preresize_min_height <= target_height <= preresize_max_height, \
|
| 770 |
+
f"Internal error: Target height {target_height} is outside the range {preresize_min_height} - {preresize_max_height}"
|
| 771 |
+
|
| 772 |
+
elif preresize_mode == "ensure maximum resolution":
|
| 773 |
+
if current_width <= preresize_max_width and current_height <= preresize_max_height:
|
| 774 |
+
return image, mask, optional_context_mask
|
| 775 |
+
|
| 776 |
+
scale_factor_max_width = preresize_max_width / current_width
|
| 777 |
+
scale_factor_max_height = preresize_max_height / current_height
|
| 778 |
+
scale_factor_max = min(scale_factor_max_width, scale_factor_max_height)
|
| 779 |
+
|
| 780 |
+
target_width = int(current_width * scale_factor_max)
|
| 781 |
+
target_height = int(current_height * scale_factor_max)
|
| 782 |
+
|
| 783 |
+
image = self.rescale_i(image, target_width, target_height, downscale_algorithm)
|
| 784 |
+
mask = self.rescale_m(mask, target_width, target_height, 'nearest') # Always nearest for efficiency
|
| 785 |
+
optional_context_mask = self.rescale_m(optional_context_mask, target_width, target_height, 'nearest') # Always nearest for efficiency
|
| 786 |
+
|
| 787 |
+
assert target_width <= preresize_max_width and target_height <= preresize_max_height, \
|
| 788 |
+
f"Internal error: Target size {target_width}x{target_height} is greater than max size {preresize_max_width}x{preresize_max_height}"
|
| 789 |
+
|
| 790 |
+
return image, mask, optional_context_mask
|
| 791 |
+
|
| 792 |
+
def extend_imm(self, image, mask, optional_context_mask, extend_up_factor, extend_down_factor, extend_left_factor, extend_right_factor):
|
| 793 |
+
B, H, W, C = image.shape
|
| 794 |
+
|
| 795 |
+
new_H = int(H * (1.0 + extend_up_factor - 1.0 + extend_down_factor - 1.0))
|
| 796 |
+
new_W = int(W * (1.0 + extend_left_factor - 1.0 + extend_right_factor - 1.0))
|
| 797 |
+
|
| 798 |
+
assert new_H >= 0, f"Error: Trying to crop too much, height ({new_H}) must be >= 0"
|
| 799 |
+
assert new_W >= 0, f"Error: Trying to crop too much, width ({new_W}) must be >= 0"
|
| 800 |
+
|
| 801 |
+
expanded_image = torch.zeros(B, new_H, new_W, C, device=image.device)
|
| 802 |
+
expanded_mask = torch.ones(B, new_H, new_W, device=mask.device)
|
| 803 |
+
expanded_optional_context_mask = torch.zeros(B, new_H, new_W, device=optional_context_mask.device)
|
| 804 |
+
|
| 805 |
+
up_padding = int(H * (extend_up_factor - 1.0))
|
| 806 |
+
down_padding = new_H - H - up_padding
|
| 807 |
+
left_padding = int(W * (extend_left_factor - 1.0))
|
| 808 |
+
right_padding = new_W - W - left_padding
|
| 809 |
+
|
| 810 |
+
slice_target_up = max(0, up_padding)
|
| 811 |
+
slice_target_down = min(new_H, up_padding + H)
|
| 812 |
+
slice_target_left = max(0, left_padding)
|
| 813 |
+
slice_target_right = min(new_W, left_padding + W)
|
| 814 |
+
|
| 815 |
+
slice_source_up = max(0, -up_padding)
|
| 816 |
+
slice_source_down = min(H, new_H - up_padding)
|
| 817 |
+
slice_source_left = max(0, -left_padding)
|
| 818 |
+
slice_source_right = min(W, new_W - left_padding)
|
| 819 |
+
|
| 820 |
+
image = image.permute(0, 3, 1, 2) # [B, H, W, C] -> [B, C, H, W]
|
| 821 |
+
expanded_image = expanded_image.permute(0, 3, 1, 2) # [B, H, W, C] -> [B, C, H, W]
|
| 822 |
+
|
| 823 |
+
expanded_image[:, :, slice_target_up:slice_target_down, slice_target_left:slice_target_right] = image[:, :, slice_source_up:slice_source_down, slice_source_left:slice_source_right]
|
| 824 |
+
if up_padding > 0:
|
| 825 |
+
expanded_image[:, :, :up_padding, slice_target_left:slice_target_right] = image[:, :, 0:1, slice_source_left:slice_source_right].repeat(1, 1, up_padding, 1)
|
| 826 |
+
if down_padding > 0:
|
| 827 |
+
expanded_image[:, :, -down_padding:, slice_target_left:slice_target_right] = image[:, :, -1:, slice_source_left:slice_source_right].repeat(1, 1, down_padding, 1)
|
| 828 |
+
if left_padding > 0:
|
| 829 |
+
expanded_image[:, :, slice_target_up:slice_target_down, :left_padding] = expanded_image[:, :, slice_target_up:slice_target_down, left_padding:left_padding+1].repeat(1, 1, 1, left_padding)
|
| 830 |
+
if right_padding > 0:
|
| 831 |
+
expanded_image[:, :, slice_target_up:slice_target_down, -right_padding:] = expanded_image[:, :, slice_target_up:slice_target_down, -right_padding-1:-right_padding].repeat(1, 1, 1, right_padding)
|
| 832 |
+
|
| 833 |
+
expanded_mask[:, slice_target_up:slice_target_down, slice_target_left:slice_target_right] = mask[:, slice_source_up:slice_source_down, slice_source_left:slice_source_right]
|
| 834 |
+
expanded_optional_context_mask[:, slice_target_up:slice_target_down, slice_target_left:slice_target_right] = optional_context_mask[:, slice_source_up:slice_source_down, slice_source_left:slice_source_right]
|
| 835 |
+
|
| 836 |
+
expanded_image = expanded_image.permute(0, 2, 3, 1) # [B, C, H, W] -> [B, H, W, C]
|
| 837 |
+
image = image.permute(0, 2, 3, 1) # [B, C, H, W] -> [B, H, W, C]
|
| 838 |
+
|
| 839 |
+
return expanded_image, expanded_mask, expanded_optional_context_mask
|
| 840 |
+
|
| 841 |
+
def batched_findcontextarea_m(self, mask):
|
| 842 |
+
# Optimized GPU implementation using parallel max/where
|
| 843 |
+
B, H, W = mask.shape
|
| 844 |
+
device = mask.device
|
| 845 |
+
|
| 846 |
+
# Find which rows and columns have any mask content
|
| 847 |
+
any_y = mask.max(dim=2).values > 0. # [B, H]
|
| 848 |
+
any_x = mask.max(dim=1).values > 0. # [B, W]
|
| 849 |
+
|
| 850 |
+
def get_min_max(any_dim, size):
|
| 851 |
+
indices = torch.arange(size, device=device).unsqueeze(0).expand(B, -1)
|
| 852 |
+
# Use large value for min where it's False, -1 for max where it's False
|
| 853 |
+
min_indices = torch.where(any_dim, indices, torch.tensor(size, device=device))
|
| 854 |
+
max_indices = torch.where(any_dim, indices, torch.tensor(-1, device=device))
|
| 855 |
+
|
| 856 |
+
b_min = torch.min(min_indices, dim=1).values
|
| 857 |
+
b_max = torch.max(max_indices, dim=1).values
|
| 858 |
+
|
| 859 |
+
# Handle cases where the whole row is False (no mask content for that batch item)
|
| 860 |
+
empty = ~any_dim.any(dim=1)
|
| 861 |
+
b_min[empty] = -1
|
| 862 |
+
b_max[empty] = -1
|
| 863 |
+
|
| 864 |
+
return b_min, b_max
|
| 865 |
+
|
| 866 |
+
y_min, y_max = get_min_max(any_y, H)
|
| 867 |
+
x_min, x_max = get_min_max(any_x, W)
|
| 868 |
+
|
| 869 |
+
w = torch.where(x_min >= 0, x_max - x_min + 1, torch.tensor(-1, device=device))
|
| 870 |
+
h = torch.where(y_min >= 0, y_max - y_min + 1, torch.tensor(-1, device=device))
|
| 871 |
+
|
| 872 |
+
return None, x_min, y_min, w, h
|
| 873 |
+
|
| 874 |
+
def batched_growcontextarea_m(self, mask, x, y, w, h, extend_factor):
|
| 875 |
+
img_h, img_w = mask.shape[1], mask.shape[2]
|
| 876 |
+
device = mask.device
|
| 877 |
+
|
| 878 |
+
grow_x = (w.float() * (extend_factor - 1.0) / 2.0).round().long()
|
| 879 |
+
grow_y = (h.float() * (extend_factor - 1.0) / 2.0).round().long()
|
| 880 |
+
|
| 881 |
+
new_x = torch.clamp(x - grow_x, min=0)
|
| 882 |
+
new_y = torch.clamp(y - grow_y, min=0)
|
| 883 |
+
new_x2 = torch.clamp(x + w + grow_x, max=img_w)
|
| 884 |
+
new_y2 = torch.clamp(y + h + grow_y, max=img_h)
|
| 885 |
+
|
| 886 |
+
new_w = new_x2 - new_x
|
| 887 |
+
new_h = new_y2 - new_y
|
| 888 |
+
|
| 889 |
+
empty = (w == -1)
|
| 890 |
+
new_x[empty] = 0
|
| 891 |
+
new_y[empty] = 0
|
| 892 |
+
new_w[empty] = img_w
|
| 893 |
+
new_h[empty] = img_h
|
| 894 |
+
|
| 895 |
+
return None, new_x, new_y, new_w, new_h
|
| 896 |
+
|
| 897 |
+
def batched_combinecontextmask_m(self, mask, x, y, w, h, optional_context_mask):
|
| 898 |
+
_, ox, oy, ow, oh = self.batched_findcontextarea_m(optional_context_mask)
|
| 899 |
+
|
| 900 |
+
mask_x_neg1 = (x == -1)
|
| 901 |
+
x_1 = torch.where(mask_x_neg1, ox, x)
|
| 902 |
+
y_1 = torch.where(mask_x_neg1, oy, y)
|
| 903 |
+
w_1 = torch.where(mask_x_neg1, ow, w)
|
| 904 |
+
h_1 = torch.where(mask_x_neg1, oh, h)
|
| 905 |
+
|
| 906 |
+
mask_ox_neg1 = (ox == -1)
|
| 907 |
+
ox_2 = torch.where(mask_ox_neg1, x_1, ox)
|
| 908 |
+
oy_2 = torch.where(mask_ox_neg1, y_1, oy)
|
| 909 |
+
ow_2 = torch.where(mask_ox_neg1, w_1, ow)
|
| 910 |
+
oh_2 = torch.where(mask_ox_neg1, h_1, oh)
|
| 911 |
+
|
| 912 |
+
new_x = torch.min(x_1, ox_2)
|
| 913 |
+
new_y = torch.min(y_1, oy_2)
|
| 914 |
+
new_x_max = torch.max(x_1 + w_1, ox_2 + ow_2)
|
| 915 |
+
new_y_max = torch.max(y_1 + h_1, oy_2 + oh_2)
|
| 916 |
+
new_w = new_x_max - new_x
|
| 917 |
+
new_h = new_y_max - new_y
|
| 918 |
+
|
| 919 |
+
both_empty = (x_1 == -1)
|
| 920 |
+
new_x[both_empty] = -1
|
| 921 |
+
new_y[both_empty] = -1
|
| 922 |
+
new_w[both_empty] = -1
|
| 923 |
+
new_h[both_empty] = -1
|
| 924 |
+
|
| 925 |
+
return None, new_x, new_y, new_w, new_h
|
| 926 |
+
|
| 927 |
+
def crop_magic_im(self, image, mask, x, y, w, h, target_w, target_h, padding, downscale_algorithm, upscale_algorithm, resize_output=True):
|
| 928 |
+
image = image.clone()
|
| 929 |
+
mask = mask.clone()
|
| 930 |
+
|
| 931 |
+
# Check for invalid inputs
|
| 932 |
+
if target_w <= 0 or target_h <= 0 or w == 0 or h == 0:
|
| 933 |
+
return image, 0, 0, image.shape[2], image.shape[1], image, mask, 0, 0, image.shape[2], image.shape[1]
|
| 934 |
+
|
| 935 |
+
# Step 1: Pad target dimensions to be multiples of padding
|
| 936 |
+
if padding != 0:
|
| 937 |
+
target_w = self.pad_to_multiple(target_w, padding)
|
| 938 |
+
target_h = self.pad_to_multiple(target_h, padding)
|
| 939 |
+
|
| 940 |
+
# Step 2: Calculate target aspect ratio
|
| 941 |
+
target_aspect_ratio = target_w / target_h
|
| 942 |
+
|
| 943 |
+
# Step 3: Grow current context area to meet the target aspect ratio
|
| 944 |
+
B, image_h, image_w, C = image.shape
|
| 945 |
+
context_aspect_ratio = w / h
|
| 946 |
+
if context_aspect_ratio < target_aspect_ratio:
|
| 947 |
+
# Grow width to meet aspect ratio
|
| 948 |
+
new_w = int(h * target_aspect_ratio)
|
| 949 |
+
new_h = h
|
| 950 |
+
new_x = x - (new_w - w) // 2
|
| 951 |
+
new_y = y
|
| 952 |
+
|
| 953 |
+
# Adjust new_x to keep within bounds
|
| 954 |
+
if new_x < 0:
|
| 955 |
+
shift = -new_x
|
| 956 |
+
if new_x + new_w + shift <= image_w:
|
| 957 |
+
new_x += shift
|
| 958 |
+
else:
|
| 959 |
+
overflow = (new_w - image_w) // 2
|
| 960 |
+
new_x = -overflow
|
| 961 |
+
elif new_x + new_w > image_w:
|
| 962 |
+
overflow = new_x + new_w - image_w
|
| 963 |
+
if new_x - overflow >= 0:
|
| 964 |
+
new_x -= overflow
|
| 965 |
+
else:
|
| 966 |
+
overflow = (new_w - image_w) // 2
|
| 967 |
+
new_x = -overflow
|
| 968 |
+
|
| 969 |
+
else:
|
| 970 |
+
# Grow height to meet aspect ratio
|
| 971 |
+
new_w = w
|
| 972 |
+
new_h = int(w / target_aspect_ratio)
|
| 973 |
+
new_x = x
|
| 974 |
+
new_y = y - (new_h - h) // 2
|
| 975 |
+
|
| 976 |
+
# Adjust new_y to keep within bounds
|
| 977 |
+
if new_y < 0:
|
| 978 |
+
shift = -new_y
|
| 979 |
+
if new_y + new_h + shift <= image_h:
|
| 980 |
+
new_y += shift
|
| 981 |
+
else:
|
| 982 |
+
overflow = (new_h - image_h) // 2
|
| 983 |
+
new_y = -overflow
|
| 984 |
+
elif new_y + new_h > image_h:
|
| 985 |
+
overflow = new_y + new_h - image_h
|
| 986 |
+
if new_y - overflow >= 0:
|
| 987 |
+
new_y -= overflow
|
| 988 |
+
else:
|
| 989 |
+
overflow = (new_h - image_h) // 2
|
| 990 |
+
new_y = -overflow
|
| 991 |
+
|
| 992 |
+
# Step 3b: When not resizing output, ensure dimensions are at least target dimensions
|
| 993 |
+
# This ensures output_padding works correctly even without resize (Option A: expand context, keep centered)
|
| 994 |
+
if not resize_output:
|
| 995 |
+
if new_w < target_w:
|
| 996 |
+
grow_w = target_w - new_w
|
| 997 |
+
new_x -= grow_w // 2
|
| 998 |
+
new_w = target_w
|
| 999 |
+
# Recalculate bounds
|
| 1000 |
+
if new_x < 0:
|
| 1001 |
+
shift = -new_x
|
| 1002 |
+
if new_x + new_w + shift <= image_w:
|
| 1003 |
+
new_x += shift
|
| 1004 |
+
else:
|
| 1005 |
+
new_x = -((new_w - image_w) // 2)
|
| 1006 |
+
elif new_x + new_w > image_w:
|
| 1007 |
+
overflow = new_x + new_w - image_w
|
| 1008 |
+
if new_x - overflow >= 0:
|
| 1009 |
+
new_x -= overflow
|
| 1010 |
+
else:
|
| 1011 |
+
new_x = -((new_w - image_w) // 2)
|
| 1012 |
+
if new_h < target_h:
|
| 1013 |
+
grow_h = target_h - new_h
|
| 1014 |
+
new_y -= grow_h // 2
|
| 1015 |
+
new_h = target_h
|
| 1016 |
+
# Recalculate bounds
|
| 1017 |
+
if new_y < 0:
|
| 1018 |
+
shift = -new_y
|
| 1019 |
+
if new_y + new_h + shift <= image_h:
|
| 1020 |
+
new_y += shift
|
| 1021 |
+
else:
|
| 1022 |
+
new_y = -((new_h - image_h) // 2)
|
| 1023 |
+
elif new_y + new_h > image_h:
|
| 1024 |
+
overflow = new_y + new_h - image_h
|
| 1025 |
+
if new_y - overflow >= 0:
|
| 1026 |
+
new_y -= overflow
|
| 1027 |
+
else:
|
| 1028 |
+
new_y = -((new_h - image_h) // 2)
|
| 1029 |
+
|
| 1030 |
+
# Step 4: Grow the image to accommodate the new context area
|
| 1031 |
+
up_padding, down_padding, left_padding, right_padding = 0, 0, 0, 0
|
| 1032 |
+
|
| 1033 |
+
expanded_image_w = image_w
|
| 1034 |
+
expanded_image_h = image_h
|
| 1035 |
+
|
| 1036 |
+
# Adjust width for left overflow (x < 0) and right overflow (x + w > image_w)
|
| 1037 |
+
if new_x < 0:
|
| 1038 |
+
left_padding = -new_x
|
| 1039 |
+
expanded_image_w += left_padding
|
| 1040 |
+
if new_x + new_w > image_w:
|
| 1041 |
+
right_padding = (new_x + new_w - image_w)
|
| 1042 |
+
expanded_image_w += right_padding
|
| 1043 |
+
# Adjust height for top overflow (y < 0) and bottom overflow (y + h > image_h)
|
| 1044 |
+
if new_y < 0:
|
| 1045 |
+
up_padding = -new_y
|
| 1046 |
+
expanded_image_h += up_padding
|
| 1047 |
+
if new_y + new_h > image_h:
|
| 1048 |
+
down_padding = (new_y + new_h - image_h)
|
| 1049 |
+
expanded_image_h += down_padding
|
| 1050 |
+
|
| 1051 |
+
# Step 5: Create the new image and mask
|
| 1052 |
+
expanded_image = torch.zeros((image.shape[0], expanded_image_h, expanded_image_w, image.shape[3]), device=image.device)
|
| 1053 |
+
expanded_mask = torch.ones((mask.shape[0], expanded_image_h, expanded_image_w), device=mask.device)
|
| 1054 |
+
|
| 1055 |
+
# Reorder the tensors to match the required dimension format for padding
|
| 1056 |
+
image = image.permute(0, 3, 1, 2) # [B, H, W, C] -> [B, C, H, W]
|
| 1057 |
+
expanded_image = expanded_image.permute(0, 3, 1, 2) # [B, H, W, C] -> [B, C, H, W]
|
| 1058 |
+
|
| 1059 |
+
# Ensure the expanded image has enough room to hold the padded version of the original image
|
| 1060 |
+
expanded_image[:, :, up_padding:up_padding + image_h, left_padding:left_padding + image_w] = image
|
| 1061 |
+
|
| 1062 |
+
# Fill the new extended areas with the edge values of the image
|
| 1063 |
+
if up_padding > 0:
|
| 1064 |
+
expanded_image[:, :, :up_padding, left_padding:left_padding + image_w] = expanded_image[:, :, up_padding:up_padding + 1, left_padding:left_padding + image_w].repeat(1, 1, up_padding, 1)
|
| 1065 |
+
if down_padding > 0:
|
| 1066 |
+
expanded_image[:, :, -down_padding:, left_padding:left_padding + image_w] = expanded_image[:, :, up_padding + image_h - 1:up_padding + image_h, left_padding:left_padding + image_w].repeat(1, 1, down_padding, 1)
|
| 1067 |
+
if left_padding > 0:
|
| 1068 |
+
expanded_image[:, :, up_padding:up_padding + image_h, :left_padding] = expanded_image[:, :, up_padding:up_padding + image_h, left_padding:left_padding+1].repeat(1, 1, 1, left_padding)
|
| 1069 |
+
if right_padding > 0:
|
| 1070 |
+
expanded_image[:, :, up_padding:up_padding + image_h, -right_padding:] = expanded_image[:, :, up_padding:up_padding + image_h, -right_padding-1:-right_padding].repeat(1, 1, 1, right_padding)
|
| 1071 |
+
|
| 1072 |
+
# Reorder the tensors back to [B, H, W, C] format
|
| 1073 |
+
expanded_image = expanded_image.permute(0, 2, 3, 1) # [B, C, H, W] -> [B, H, W, C]
|
| 1074 |
+
image = image.permute(0, 2, 3, 1) # [B, C, H, W] -> [B, H, W, C]
|
| 1075 |
+
|
| 1076 |
+
# Same for the mask
|
| 1077 |
+
expanded_mask[:, up_padding:up_padding + image_h, left_padding:left_padding + image_w] = mask
|
| 1078 |
+
|
| 1079 |
+
# Record the cto values (canvas to original)
|
| 1080 |
+
cto_x = left_padding
|
| 1081 |
+
cto_y = up_padding
|
| 1082 |
+
cto_w = image_w
|
| 1083 |
+
cto_h = image_h
|
| 1084 |
+
|
| 1085 |
+
# The final expanded image and mask
|
| 1086 |
+
canvas_image = expanded_image
|
| 1087 |
+
canvas_mask = expanded_mask
|
| 1088 |
+
|
| 1089 |
+
# Step 6: Crop the image and mask around x, y, w, h
|
| 1090 |
+
ctc_x = new_x+left_padding
|
| 1091 |
+
ctc_y = new_y+up_padding
|
| 1092 |
+
ctc_w = new_w
|
| 1093 |
+
ctc_h = new_h
|
| 1094 |
+
|
| 1095 |
+
# Crop the image and mask
|
| 1096 |
+
cropped_image = canvas_image[:, ctc_y:ctc_y + ctc_h, ctc_x:ctc_x + ctc_w]
|
| 1097 |
+
cropped_mask = canvas_mask[:, ctc_y:ctc_y + ctc_h, ctc_x:ctc_x + ctc_w]
|
| 1098 |
+
|
| 1099 |
+
# Step 7: Resize image and mask to the target width and height
|
| 1100 |
+
if resize_output:
|
| 1101 |
+
# Decide which algorithm to use based on the scaling direction
|
| 1102 |
+
if target_w > ctc_w or target_h > ctc_h: # Upscaling
|
| 1103 |
+
cropped_image = self.rescale_i(cropped_image, target_w, target_h, upscale_algorithm)
|
| 1104 |
+
cropped_mask = self.rescale_m(cropped_mask, target_w, target_h, upscale_algorithm)
|
| 1105 |
+
else: # Downscaling
|
| 1106 |
+
cropped_image = self.rescale_i(cropped_image, target_w, target_h, downscale_algorithm)
|
| 1107 |
+
cropped_mask = self.rescale_m(cropped_mask, target_w, target_h, downscale_algorithm)
|
| 1108 |
+
|
| 1109 |
+
return canvas_image, cto_x, cto_y, cto_w, cto_h, cropped_image, cropped_mask, ctc_x, ctc_y, ctc_w, ctc_h
|
| 1110 |
+
|
| 1111 |
+
def stitch_magic_im(self, canvas_image, inpainted_image, mask, ctc_x, ctc_y, ctc_w, ctc_h, cto_x, cto_y, cto_w, cto_h, downscale_algorithm, upscale_algorithm):
|
| 1112 |
+
canvas_image = canvas_image.clone()
|
| 1113 |
+
inpainted_image = inpainted_image.clone()
|
| 1114 |
+
mask = mask.clone()
|
| 1115 |
+
|
| 1116 |
+
# Resize inpainted image and mask to match the context size
|
| 1117 |
+
B, h, w, _ = inpainted_image.shape
|
| 1118 |
+
if ctc_w > w or ctc_h > h: # Upscaling
|
| 1119 |
+
resized_image = self.rescale_i(inpainted_image, ctc_w, ctc_h, upscale_algorithm)
|
| 1120 |
+
resized_mask = self.rescale_m(mask, ctc_w, ctc_h, upscale_algorithm)
|
| 1121 |
+
else: # Downscaling
|
| 1122 |
+
resized_image = self.rescale_i(inpainted_image, ctc_w, ctc_h, downscale_algorithm)
|
| 1123 |
+
resized_mask = self.rescale_m(mask, ctc_w, ctc_h, downscale_algorithm)
|
| 1124 |
+
|
| 1125 |
+
# Clamp mask to [0, 1] and expand to match image channels
|
| 1126 |
+
resized_mask = resized_mask.clamp(0, 1).unsqueeze(-1) # shape: [B, H, W, 1]
|
| 1127 |
+
|
| 1128 |
+
# Extract the canvas region we're about to overwrite
|
| 1129 |
+
canvas_crop = canvas_image[:, ctc_y:ctc_y + ctc_h, ctc_x:ctc_x + ctc_w]
|
| 1130 |
+
|
| 1131 |
+
# Blend: new = mask * inpainted + (1 - mask) * canvas
|
| 1132 |
+
blended = resized_mask * resized_image + (1.0 - resized_mask) * canvas_crop
|
| 1133 |
+
|
| 1134 |
+
# Paste the blended region back onto the canvas
|
| 1135 |
+
canvas_image[:, ctc_y:ctc_y + ctc_h, ctc_x:ctc_x + ctc_w] = blended
|
| 1136 |
+
|
| 1137 |
+
# Final crop to get back the original image area
|
| 1138 |
+
output_image = canvas_image[:, cto_y:cto_y + cto_h, cto_x:cto_x + cto_w]
|
| 1139 |
+
|
| 1140 |
+
return output_image
|
| 1141 |
+
|
| 1142 |
+
class InpaintCropImproved:
|
| 1143 |
+
@classmethod
|
| 1144 |
+
def INPUT_TYPES(cls):
|
| 1145 |
+
return {
|
| 1146 |
+
"required": {
|
| 1147 |
+
# Required inputs
|
| 1148 |
+
"image": ("IMAGE",),
|
| 1149 |
+
|
| 1150 |
+
# Resize algorithms
|
| 1151 |
+
"downscale_algorithm": (["nearest", "bilinear", "bicubic", "lanczos", "box", "hamming"], {"default": "bilinear"}),
|
| 1152 |
+
"upscale_algorithm": (["nearest", "bilinear", "bicubic", "lanczos", "box", "hamming"], {"default": "bicubic"}),
|
| 1153 |
+
|
| 1154 |
+
# Pre-resize input image
|
| 1155 |
+
"preresize": ("BOOLEAN", {"default": False, "tooltip": "Resize the original image before processing."}),
|
| 1156 |
+
"preresize_mode": (["ensure minimum resolution", "ensure maximum resolution", "ensure minimum and maximum resolution"], {"default": "ensure minimum resolution"}),
|
| 1157 |
+
"preresize_min_width": ("INT", {"default": 1024, "min": 0, "max": nodes.MAX_RESOLUTION, "step": 1}),
|
| 1158 |
+
"preresize_min_height": ("INT", {"default": 1024, "min": 0, "max": nodes.MAX_RESOLUTION, "step": 1}),
|
| 1159 |
+
"preresize_max_width": ("INT", {"default": nodes.MAX_RESOLUTION, "min": 0, "max": nodes.MAX_RESOLUTION, "step": 1}),
|
| 1160 |
+
"preresize_max_height": ("INT", {"default": nodes.MAX_RESOLUTION, "min": 0, "max": nodes.MAX_RESOLUTION, "step": 1}),
|
| 1161 |
+
|
| 1162 |
+
# Mask manipulation
|
| 1163 |
+
"mask_fill_holes": ("BOOLEAN", {"default": True, "tooltip": "Mark as masked any areas fully enclosed by mask."}),
|
| 1164 |
+
"mask_expand_pixels": ("INT", {"default": 0, "min": 0, "max": nodes.MAX_RESOLUTION, "step": 1, "tooltip": "Expand the mask by a certain amount of pixels before processing."}),
|
| 1165 |
+
"mask_invert": ("BOOLEAN", {"default": False,"tooltip": "Invert mask so that anything masked will be kept."}),
|
| 1166 |
+
"mask_blend_pixels": ("INT", {"default": 32, "min": 0, "max": 64, "step": 1, "tooltip": "How many pixels to blend into the original image."}),
|
| 1167 |
+
"mask_hipass_filter": ("FLOAT", {"default": 0.1, "min": 0, "max": 1, "step": 0.01, "tooltip": "Ignore mask values lower than this value."}),
|
| 1168 |
+
|
| 1169 |
+
# Extend image for outpainting
|
| 1170 |
+
"extend_for_outpainting": ("BOOLEAN", {"default": False, "tooltip": "Extend the image for outpainting."}),
|
| 1171 |
+
"extend_up_factor": ("FLOAT", {"default": 1.0, "min": 0.01, "max": 100.0, "step": 0.01}),
|
| 1172 |
+
"extend_down_factor": ("FLOAT", {"default": 1.0, "min": 0.01, "max": 100.0, "step": 0.01}),
|
| 1173 |
+
"extend_left_factor": ("FLOAT", {"default": 1.0, "min": 0.01, "max": 100.0, "step": 0.01}),
|
| 1174 |
+
"extend_right_factor": ("FLOAT", {"default": 1.0, "min": 0.01, "max": 100.0, "step": 0.01}),
|
| 1175 |
+
|
| 1176 |
+
# Context
|
| 1177 |
+
"context_from_mask_extend_factor": ("FLOAT", {"default": 1.2, "min": 1.0, "max": 100.0, "step": 0.01, "tooltip": "Grow the context area from the mask by a certain factor in every direction. For example, 1.5 grabs extra 50% up, down, left, and right as context."}),
|
| 1178 |
+
|
| 1179 |
+
# Output
|
| 1180 |
+
"output_resize_to_target_size": ("BOOLEAN", {"default": True, "tooltip": "Force a specific resolution for sampling."}),
|
| 1181 |
+
"output_target_width": ("INT", {"default": 512, "min": 64, "max": nodes.MAX_RESOLUTION, "step": 1}),
|
| 1182 |
+
"output_target_height": ("INT", {"default": 512, "min": 64, "max": nodes.MAX_RESOLUTION, "step": 1}),
|
| 1183 |
+
"output_padding": (["0", "8", "16", "32", "64", "128", "256", "512"], {"default": "32"}),
|
| 1184 |
+
|
| 1185 |
+
# Device Mode
|
| 1186 |
+
"device_mode": (["cpu (compatible)", "gpu (much faster)"], {"default": "gpu (much faster)"}),
|
| 1187 |
+
},
|
| 1188 |
+
"optional": {
|
| 1189 |
+
# Optional inputs
|
| 1190 |
+
"mask": ("MASK",),
|
| 1191 |
+
"optional_context_mask": ("MASK",),
|
| 1192 |
+
}
|
| 1193 |
+
}
|
| 1194 |
+
|
| 1195 |
+
FUNCTION = "inpaint_crop"
|
| 1196 |
+
CATEGORY = "inpaint"
|
| 1197 |
+
DESCRIPTION = "Crops an image around a mask for inpainting, the optional context mask defines an extra area to keep for the context."
|
| 1198 |
+
|
| 1199 |
+
# Remove the following # to turn on debug mode (extra outputs, print statements)
|
| 1200 |
+
#'''
|
| 1201 |
+
DEBUG_MODE = False
|
| 1202 |
+
RETURN_TYPES = ("STITCHER", "IMAGE", "MASK")
|
| 1203 |
+
RETURN_NAMES = ("stitcher", "cropped_image", "cropped_mask")
|
| 1204 |
+
|
| 1205 |
+
'''
|
| 1206 |
+
|
| 1207 |
+
DEBUG_MODE = True
|
| 1208 |
+
RETURN_TYPES = ("STITCHER", "IMAGE", "MASK",
|
| 1209 |
+
# DEBUG
|
| 1210 |
+
"IMAGE",
|
| 1211 |
+
"MASK",
|
| 1212 |
+
"MASK",
|
| 1213 |
+
"MASK",
|
| 1214 |
+
"MASK",
|
| 1215 |
+
"MASK",
|
| 1216 |
+
"MASK",
|
| 1217 |
+
"IMAGE",
|
| 1218 |
+
"MASK",
|
| 1219 |
+
"MASK",
|
| 1220 |
+
"IMAGE",
|
| 1221 |
+
"MASK",
|
| 1222 |
+
"IMAGE",
|
| 1223 |
+
"MASK",
|
| 1224 |
+
"IMAGE",
|
| 1225 |
+
"MASK",
|
| 1226 |
+
"IMAGE",
|
| 1227 |
+
"IMAGE",
|
| 1228 |
+
"MASK",
|
| 1229 |
+
"IMAGE",
|
| 1230 |
+
"IMAGE",
|
| 1231 |
+
"IMAGE",
|
| 1232 |
+
"MASK",
|
| 1233 |
+
)
|
| 1234 |
+
RETURN_NAMES = ("stitcher", "cropped_image", "cropped_mask",
|
| 1235 |
+
# DEBUG
|
| 1236 |
+
"DEBUG_preresize_image",
|
| 1237 |
+
"DEBUG_preresize_mask",
|
| 1238 |
+
"DEBUG_fillholes_mask",
|
| 1239 |
+
"DEBUG_expand_mask",
|
| 1240 |
+
"DEBUG_invert_mask",
|
| 1241 |
+
"DEBUG_blur_mask",
|
| 1242 |
+
"DEBUG_hipassfilter_mask",
|
| 1243 |
+
"DEBUG_extend_image",
|
| 1244 |
+
"DEBUG_extend_mask",
|
| 1245 |
+
"DEBUG_context_from_mask",
|
| 1246 |
+
"DEBUG_context_from_mask_location",
|
| 1247 |
+
"DEBUG_context_expand",
|
| 1248 |
+
"DEBUG_context_expand_location",
|
| 1249 |
+
"DEBUG_context_with_context_mask",
|
| 1250 |
+
"DEBUG_context_with_context_mask_location",
|
| 1251 |
+
"DEBUG_context_to_target",
|
| 1252 |
+
"DEBUG_context_to_target_location",
|
| 1253 |
+
"DEBUG_context_to_target_image",
|
| 1254 |
+
"DEBUG_context_to_target_mask",
|
| 1255 |
+
"DEBUG_canvas_image",
|
| 1256 |
+
"DEBUG_orig_in_canvas_location",
|
| 1257 |
+
"DEBUG_cropped_in_canvas_location",
|
| 1258 |
+
"DEBUG_cropped_mask_blend",
|
| 1259 |
+
)
|
| 1260 |
+
#'''
|
| 1261 |
+
|
| 1262 |
+
def inpaint_crop(self, image, downscale_algorithm, upscale_algorithm, preresize, preresize_mode, preresize_min_width, preresize_min_height, preresize_max_width, preresize_max_height, extend_for_outpainting, extend_up_factor, extend_down_factor, extend_left_factor, extend_right_factor, mask_hipass_filter, mask_fill_holes, mask_expand_pixels, mask_invert, mask_blend_pixels, context_from_mask_extend_factor, output_resize_to_target_size, output_target_width, output_target_height, output_padding, device_mode, mask=None, optional_context_mask=None):
|
| 1263 |
+
image = image.clone()
|
| 1264 |
+
if mask is not None:
|
| 1265 |
+
mask = mask.clone()
|
| 1266 |
+
if optional_context_mask is not None:
|
| 1267 |
+
optional_context_mask = optional_context_mask.clone()
|
| 1268 |
+
|
| 1269 |
+
if device_mode == "gpu (much faster)":
|
| 1270 |
+
device = comfy.model_management.get_torch_device()
|
| 1271 |
+
image = image.to(device)
|
| 1272 |
+
if mask is not None: mask = mask.to(device)
|
| 1273 |
+
if optional_context_mask is not None: optional_context_mask = optional_context_mask.to(device)
|
| 1274 |
+
processor = GPUProcessorLogic()
|
| 1275 |
+
else:
|
| 1276 |
+
processor = CPUProcessorLogic()
|
| 1277 |
+
|
| 1278 |
+
output_padding = int(output_padding)
|
| 1279 |
+
|
| 1280 |
+
# Check that some parameters make sense
|
| 1281 |
+
if preresize and preresize_mode == "ensure minimum and maximum resolution":
|
| 1282 |
+
assert preresize_max_width >= preresize_min_width, "Preresize maximum width must be greater than or equal to minimum width"
|
| 1283 |
+
assert preresize_max_height >= preresize_min_height, "Preresize maximum height must be greater than or equal to minimum height"
|
| 1284 |
+
|
| 1285 |
+
if self.DEBUG_MODE:
|
| 1286 |
+
print('Inpaint Crop Batch input')
|
| 1287 |
+
print(image.shape, type(image), image.dtype)
|
| 1288 |
+
if mask is not None:
|
| 1289 |
+
print(mask.shape, type(mask), mask.dtype)
|
| 1290 |
+
if optional_context_mask is not None:
|
| 1291 |
+
print(optional_context_mask.shape, type(optional_context_mask), optional_context_mask.dtype)
|
| 1292 |
+
|
| 1293 |
+
if image.shape[0] > 1:
|
| 1294 |
+
assert output_resize_to_target_size, "output_resize_to_target_size must be enabled when input is a batch of images, given all images in the batch output have to be the same size"
|
| 1295 |
+
|
| 1296 |
+
# When a LoadImage node passes a mask without user editing, it may be the wrong shape.
|
| 1297 |
+
# Detect and fix that to avoid shape mismatch errors.
|
| 1298 |
+
if mask is not None and (image.shape[0] == 1 or mask.shape[0] == 1 or mask.shape[0] == image.shape[0]):
|
| 1299 |
+
if mask.shape[1] != image.shape[1] or mask.shape[2] != image.shape[2]:
|
| 1300 |
+
if torch.count_nonzero(mask) == 0:
|
| 1301 |
+
mask = torch.zeros((mask.shape[0], image.shape[1], image.shape[2]), device=image.device, dtype=image.dtype)
|
| 1302 |
+
|
| 1303 |
+
if optional_context_mask is not None and (image.shape[0] == 1 or optional_context_mask.shape[0] == 1 or optional_context_mask.shape[0] == image.shape[0]):
|
| 1304 |
+
if optional_context_mask.shape[1] != image.shape[1] or optional_context_mask.shape[2] != image.shape[2]:
|
| 1305 |
+
if torch.count_nonzero(optional_context_mask) == 0:
|
| 1306 |
+
optional_context_mask = torch.zeros((optional_context_mask.shape[0], image.shape[1], image.shape[2]), device=image.device, dtype=image.dtype)
|
| 1307 |
+
|
| 1308 |
+
# If no mask is provided, create one with the shape of the image
|
| 1309 |
+
if mask is None:
|
| 1310 |
+
mask = torch.zeros_like(image[:, :, :, 0])
|
| 1311 |
+
|
| 1312 |
+
# If there is only one image for many masks, replicate it for all masks
|
| 1313 |
+
if mask.shape[0] > 1 and image.shape[0] == 1:
|
| 1314 |
+
assert image.dim() == 4, f"Expected 4D BHWC image tensor, got {image.shape}"
|
| 1315 |
+
image = image.expand(mask.shape[0], -1, -1, -1).clone()
|
| 1316 |
+
|
| 1317 |
+
# If there is only one mask for many images, replicate it for all images
|
| 1318 |
+
if image.shape[0] > 1 and mask.shape[0] == 1:
|
| 1319 |
+
assert mask.dim() == 3, f"Expected 3D BHW mask tensor, got {mask.shape}"
|
| 1320 |
+
mask = mask.expand(image.shape[0], -1, -1).clone()
|
| 1321 |
+
|
| 1322 |
+
# If no optional_context_mask is provided, create one with the shape of the image
|
| 1323 |
+
if optional_context_mask is None:
|
| 1324 |
+
optional_context_mask = torch.zeros_like(image[:, :, :, 0])
|
| 1325 |
+
|
| 1326 |
+
# If there is only one optional_context_mask for many images, replicate it for all images
|
| 1327 |
+
if image.shape[0] > 1 and optional_context_mask.shape[0] == 1:
|
| 1328 |
+
assert optional_context_mask.dim() == 3, f"Expected 3D BHW optional_context_mask tensor, got {optional_context_mask.shape}"
|
| 1329 |
+
optional_context_mask = optional_context_mask.expand(image.shape[0], -1, -1).clone()
|
| 1330 |
+
|
| 1331 |
+
if self.DEBUG_MODE:
|
| 1332 |
+
print('Inpaint Crop Batch ready')
|
| 1333 |
+
print(image.shape, type(image), image.dtype)
|
| 1334 |
+
print(mask.shape, type(mask), mask.dtype)
|
| 1335 |
+
print(optional_context_mask.shape, type(optional_context_mask), optional_context_mask.dtype)
|
| 1336 |
+
|
| 1337 |
+
# Validate data
|
| 1338 |
+
assert image.ndimension() == 4, f"Expected 4 dimensions for image, got {image.ndimension()}"
|
| 1339 |
+
assert mask.ndimension() == 3, f"Expected 3 dimensions for mask, got {mask.ndimension()}"
|
| 1340 |
+
assert optional_context_mask.ndimension() == 3, f"Expected 3 dimensions for optional_context_mask, got {optional_context_mask.ndimension()}"
|
| 1341 |
+
assert mask.shape[1:] == image.shape[1:3], f"Mask dimensions do not match image dimensions. Expected {image.shape[1:3]}, got {mask.shape[1:]}"
|
| 1342 |
+
assert optional_context_mask.shape[1:] == image.shape[1:3], f"optional_context_mask dimensions do not match image dimensions. Expected {image.shape[1:3]}, got {optional_context_mask.shape[1:]}"
|
| 1343 |
+
assert mask.shape[0] == image.shape[0], f"Mask batch does not match image batch. Expected {image.shape[0]}, got {mask.shape[0]}"
|
| 1344 |
+
assert optional_context_mask.shape[0] == image.shape[0], f"Optional context mask batch does not match image batch. Expected {image.shape[0]}, got {optional_context_mask.shape[0]}"
|
| 1345 |
+
|
| 1346 |
+
# Results
|
| 1347 |
+
result_stitcher = {
|
| 1348 |
+
'downscale_algorithm': downscale_algorithm,
|
| 1349 |
+
'upscale_algorithm': upscale_algorithm,
|
| 1350 |
+
'blend_pixels': mask_blend_pixels,
|
| 1351 |
+
'canvas_to_orig_x': [],
|
| 1352 |
+
'canvas_to_orig_y': [],
|
| 1353 |
+
'canvas_to_orig_w': [],
|
| 1354 |
+
'canvas_to_orig_h': [],
|
| 1355 |
+
'canvas_image': [],
|
| 1356 |
+
'cropped_to_canvas_x': [],
|
| 1357 |
+
'cropped_to_canvas_y': [],
|
| 1358 |
+
'cropped_to_canvas_w': [],
|
| 1359 |
+
'cropped_to_canvas_h': [],
|
| 1360 |
+
'cropped_mask_for_blend': [],
|
| 1361 |
+
'device_mode': device_mode,
|
| 1362 |
+
}
|
| 1363 |
+
result_image = []
|
| 1364 |
+
result_mask = []
|
| 1365 |
+
debug_outputs = {name: [] for name in self.RETURN_NAMES if name.startswith("DEBUG_")}
|
| 1366 |
+
|
| 1367 |
+
batch_size = image.shape[0]
|
| 1368 |
+
|
| 1369 |
+
for i in range(batch_size):
|
| 1370 |
+
sub_image = image[i:i+1]
|
| 1371 |
+
sub_mask = mask[i:i+1]
|
| 1372 |
+
sub_opt_mask = optional_context_mask[i:i+1]
|
| 1373 |
+
|
| 1374 |
+
# Process individual image
|
| 1375 |
+
if preresize:
|
| 1376 |
+
sub_image, sub_mask, sub_opt_mask = processor.preresize_imm(sub_image, sub_mask, sub_opt_mask, downscale_algorithm, upscale_algorithm, preresize_mode, preresize_min_width, preresize_min_height, preresize_max_width, preresize_max_height)
|
| 1377 |
+
|
| 1378 |
+
sub_DEBUG_preresize_image = sub_image.clone() if self.DEBUG_MODE else None
|
| 1379 |
+
sub_DEBUG_preresize_mask = sub_mask.clone() if self.DEBUG_MODE else None
|
| 1380 |
+
|
| 1381 |
+
if mask_fill_holes:
|
| 1382 |
+
sub_mask = processor.fillholes_iterative_hipass_fill_m(sub_mask)
|
| 1383 |
+
sub_DEBUG_fillholes_mask = sub_mask.clone() if self.DEBUG_MODE else None
|
| 1384 |
+
|
| 1385 |
+
if mask_expand_pixels > 0:
|
| 1386 |
+
sub_mask = processor.expand_m(sub_mask, mask_expand_pixels)
|
| 1387 |
+
sub_DEBUG_expand_mask = sub_mask.clone() if self.DEBUG_MODE else None
|
| 1388 |
+
|
| 1389 |
+
if mask_invert:
|
| 1390 |
+
sub_mask = processor.invert_m(sub_mask)
|
| 1391 |
+
sub_DEBUG_invert_mask = sub_mask.clone() if self.DEBUG_MODE else None
|
| 1392 |
+
|
| 1393 |
+
if mask_blend_pixels > 0:
|
| 1394 |
+
sub_mask = processor.expand_m(sub_mask, mask_blend_pixels)
|
| 1395 |
+
sub_mask = processor.blur_m(sub_mask, mask_blend_pixels*0.5)
|
| 1396 |
+
sub_DEBUG_blur_mask = sub_mask.clone() if self.DEBUG_MODE else None
|
| 1397 |
+
|
| 1398 |
+
if mask_hipass_filter >= 0.01:
|
| 1399 |
+
sub_mask = processor.hipassfilter_m(sub_mask, mask_hipass_filter)
|
| 1400 |
+
sub_opt_mask = processor.hipassfilter_m(sub_opt_mask, mask_hipass_filter)
|
| 1401 |
+
sub_DEBUG_hipassfilter_mask = sub_mask.clone() if self.DEBUG_MODE else None
|
| 1402 |
+
|
| 1403 |
+
if extend_for_outpainting:
|
| 1404 |
+
sub_image, sub_mask, sub_opt_mask = processor.extend_imm(sub_image, sub_mask, sub_opt_mask, extend_up_factor, extend_down_factor, extend_left_factor, extend_right_factor)
|
| 1405 |
+
sub_DEBUG_extend_image = sub_image.clone() if self.DEBUG_MODE else None
|
| 1406 |
+
sub_DEBUG_extend_mask = sub_mask.clone() if self.DEBUG_MODE else None
|
| 1407 |
+
|
| 1408 |
+
# Find context area
|
| 1409 |
+
_, bx, by, bw, bh = processor.batched_findcontextarea_m(sub_mask)
|
| 1410 |
+
|
| 1411 |
+
# Use original image size as fallback for empty masks
|
| 1412 |
+
if bx[0] == -1:
|
| 1413 |
+
bx[0], by[0], bw[0], bh[0] = 0, 0, sub_image.shape[2], sub_image.shape[1]
|
| 1414 |
+
|
| 1415 |
+
# Growth
|
| 1416 |
+
if context_from_mask_extend_factor >= 1.01:
|
| 1417 |
+
_, bx, by, bw, bh = processor.batched_growcontextarea_m(sub_mask, bx, by, bw, bh, context_from_mask_extend_factor)
|
| 1418 |
+
|
| 1419 |
+
# Combine
|
| 1420 |
+
_, bx, by, bw, bh = processor.batched_combinecontextmask_m(sub_mask, bx, by, bw, bh, sub_opt_mask)
|
| 1421 |
+
|
| 1422 |
+
# Final check/fallback
|
| 1423 |
+
if bx[0] == -1:
|
| 1424 |
+
bx[0], by[0], bw[0], bh[0] = 0, 0, sub_image.shape[2], sub_image.shape[1]
|
| 1425 |
+
|
| 1426 |
+
# Crop logic
|
| 1427 |
+
cur_x, cur_y, cur_w, cur_h = bx[0].item(), by[0].item(), bw[0].item(), bh[0].item()
|
| 1428 |
+
|
| 1429 |
+
if output_resize_to_target_size:
|
| 1430 |
+
canvas_image, cto_x, cto_y, cto_w, cto_h, cropped_image, cropped_mask, ctc_x, ctc_y, ctc_w, ctc_h = processor.crop_magic_im(
|
| 1431 |
+
sub_image, sub_mask, cur_x, cur_y, cur_w, cur_h, output_target_width, output_target_height, output_padding, downscale_algorithm, upscale_algorithm, resize_output=True
|
| 1432 |
+
)
|
| 1433 |
+
else:
|
| 1434 |
+
canvas_image, cto_x, cto_y, cto_w, cto_h, cropped_image, cropped_mask, ctc_x, ctc_y, ctc_w, ctc_h = processor.crop_magic_im(
|
| 1435 |
+
sub_image, sub_mask, cur_x, cur_y, cur_w, cur_h, cur_w, cur_h, output_padding, downscale_algorithm, upscale_algorithm, resize_output=False
|
| 1436 |
+
)
|
| 1437 |
+
p_crop = cropped_image
|
| 1438 |
+
p_mask = cropped_mask
|
| 1439 |
+
|
| 1440 |
+
# Blending Blur
|
| 1441 |
+
p_mask_blend = p_mask
|
| 1442 |
+
if mask_blend_pixels > 0:
|
| 1443 |
+
p_mask_blend = processor.blur_m(p_mask_blend, mask_blend_pixels * 0.5)
|
| 1444 |
+
|
| 1445 |
+
# Collect Results
|
| 1446 |
+
result_stitcher['canvas_to_orig_x'].append(cto_x)
|
| 1447 |
+
result_stitcher['canvas_to_orig_y'].append(cto_y)
|
| 1448 |
+
result_stitcher['canvas_to_orig_w'].append(cto_w)
|
| 1449 |
+
result_stitcher['canvas_to_orig_h'].append(cto_h)
|
| 1450 |
+
result_stitcher['canvas_image'].append(canvas_image.cpu())
|
| 1451 |
+
result_stitcher['cropped_to_canvas_x'].append(ctc_x)
|
| 1452 |
+
result_stitcher['cropped_to_canvas_y'].append(ctc_y)
|
| 1453 |
+
result_stitcher['cropped_to_canvas_w'].append(ctc_w)
|
| 1454 |
+
result_stitcher['cropped_to_canvas_h'].append(ctc_h)
|
| 1455 |
+
result_stitcher['cropped_mask_for_blend'].append(p_mask_blend.cpu())
|
| 1456 |
+
|
| 1457 |
+
result_image.append(p_crop.squeeze(0).cpu())
|
| 1458 |
+
result_mask.append(p_mask.squeeze(0).cpu())
|
| 1459 |
+
|
| 1460 |
+
# Debugs
|
| 1461 |
+
if self.DEBUG_MODE:
|
| 1462 |
+
# Stages for debug
|
| 1463 |
+
co = (cur_x, cur_y, cur_w, cur_h) # This is combined coordinates actually, need stages if we want them.
|
| 1464 |
+
# However, processing is 1 by 1 now, so we can just track them.
|
| 1465 |
+
|
| 1466 |
+
# Re-calculate stages for individual debug accuracy
|
| 1467 |
+
_, b_orig_x, b_orig_y, b_orig_w, b_orig_h = processor.batched_findcontextarea_m(sub_mask)
|
| 1468 |
+
if b_orig_x[0] == -1: b_orig_x[0], b_orig_y[0], b_orig_w[0], b_orig_h[0] = 0, 0, sub_image.shape[2], sub_image.shape[1]
|
| 1469 |
+
|
| 1470 |
+
b_grown_x, b_grown_y, b_grown_w, b_grown_h = b_orig_x.clone(), b_orig_y.clone(), b_orig_w.clone(), b_orig_h.clone()
|
| 1471 |
+
if context_from_mask_extend_factor >= 1.01:
|
| 1472 |
+
_, b_grown_x, b_grown_y, b_grown_w, b_grown_h = processor.batched_growcontextarea_m(sub_mask, b_orig_x, b_orig_y, b_orig_w, b_orig_h, context_from_mask_extend_factor)
|
| 1473 |
+
|
| 1474 |
+
b_comb_x, b_comb_y, b_comb_w, b_comb_h = b_grown_x.clone(), b_grown_y.clone(), b_grown_w.clone(), b_grown_h.clone()
|
| 1475 |
+
_, b_comb_x, b_comb_y, b_comb_w, b_comb_h = processor.batched_combinecontextmask_m(sub_mask, b_grown_x, b_grown_y, b_grown_w, b_grown_h, sub_opt_mask)
|
| 1476 |
+
|
| 1477 |
+
p_co = (b_orig_x[0].item(), b_orig_y[0].item(), b_orig_w[0].item(), b_orig_h[0].item())
|
| 1478 |
+
p_cg = (b_grown_x[0].item(), b_grown_y[0].item(), b_grown_w[0].item(), b_grown_h[0].item())
|
| 1479 |
+
p_cc = (b_comb_x[0].item(), b_comb_y[0].item(), b_comb_w[0].item(), b_comb_h[0].item())
|
| 1480 |
+
p_cf = (cur_x, cur_y, cur_w, cur_h)
|
| 1481 |
+
|
| 1482 |
+
def get_debug_crop_cpu(m, c):
|
| 1483 |
+
crop = m[:, c[1]:c[1]+c[3], c[0]:c[0]+c[2]]
|
| 1484 |
+
if output_resize_to_target_size and (crop.shape[2] != output_target_width or crop.shape[1] != output_target_height):
|
| 1485 |
+
if isinstance(processor, GPUProcessorLogic):
|
| 1486 |
+
crop = processor.rescale_m(crop, output_target_width, output_target_height, 'nearest')
|
| 1487 |
+
else:
|
| 1488 |
+
crop = processor.rescale_m(crop, output_target_width, output_target_height, 'bilinear')
|
| 1489 |
+
return crop.cpu()
|
| 1490 |
+
|
| 1491 |
+
debug_outputs["DEBUG_preresize_image"].append(sub_DEBUG_preresize_image[0].cpu())
|
| 1492 |
+
debug_outputs["DEBUG_preresize_mask"].append(sub_DEBUG_preresize_mask[0].cpu())
|
| 1493 |
+
debug_outputs["DEBUG_fillholes_mask"].append(sub_DEBUG_fillholes_mask[0].cpu())
|
| 1494 |
+
debug_outputs["DEBUG_expand_mask"].append(sub_DEBUG_expand_mask[0].cpu())
|
| 1495 |
+
debug_outputs["DEBUG_invert_mask"].append(sub_DEBUG_invert_mask[0].cpu())
|
| 1496 |
+
debug_outputs["DEBUG_blur_mask"].append(sub_DEBUG_blur_mask[0].cpu())
|
| 1497 |
+
debug_outputs["DEBUG_hipassfilter_mask"].append(sub_DEBUG_hipassfilter_mask[0].cpu())
|
| 1498 |
+
debug_outputs["DEBUG_extend_image"].append(sub_DEBUG_extend_image[0].cpu())
|
| 1499 |
+
debug_outputs["DEBUG_extend_mask"].append(sub_DEBUG_extend_mask[0].cpu())
|
| 1500 |
+
|
| 1501 |
+
debug_outputs["DEBUG_context_from_mask"].append(get_debug_crop_cpu(sub_mask, p_co).squeeze(0))
|
| 1502 |
+
debug_outputs["DEBUG_context_from_mask_location"].append(processor.debug_context_location_in_image(sub_image, *p_co).squeeze(0).cpu())
|
| 1503 |
+
debug_outputs["DEBUG_context_expand"].append(get_debug_crop_cpu(sub_mask, p_cg).squeeze(0))
|
| 1504 |
+
debug_outputs["DEBUG_context_expand_location"].append(processor.debug_context_location_in_image(sub_image, *p_cg).squeeze(0).cpu())
|
| 1505 |
+
debug_outputs["DEBUG_context_with_context_mask"].append(get_debug_crop_cpu(sub_mask, p_cc).squeeze(0))
|
| 1506 |
+
debug_outputs["DEBUG_context_with_context_mask_location"].append(processor.debug_context_location_in_image(sub_image, *p_cc).squeeze(0).cpu())
|
| 1507 |
+
|
| 1508 |
+
debug_outputs["DEBUG_context_to_target"].append(p_mask.squeeze(0).cpu())
|
| 1509 |
+
debug_outputs["DEBUG_context_to_target_location"].append(processor.debug_context_location_in_image(sub_image, *p_cf).squeeze(0).cpu())
|
| 1510 |
+
debug_outputs["DEBUG_context_to_target_image"].append(p_crop.squeeze(0).cpu())
|
| 1511 |
+
debug_outputs["DEBUG_context_to_target_mask"].append(p_mask.squeeze(0).cpu())
|
| 1512 |
+
debug_outputs["DEBUG_canvas_image"].append(canvas_image.squeeze(0).cpu())
|
| 1513 |
+
debug_outputs["DEBUG_orig_in_canvas_location"].append(processor.debug_context_location_in_image(canvas_image, cto_x, cto_y, cto_w, cto_h).squeeze(0).cpu())
|
| 1514 |
+
debug_outputs["DEBUG_cropped_in_canvas_location"].append(processor.debug_context_location_in_image(canvas_image, ctc_x, ctc_y, ctc_w, ctc_h).squeeze(0).cpu())
|
| 1515 |
+
debug_outputs["DEBUG_cropped_mask_blend"].append(p_mask_blend.squeeze(0).cpu())
|
| 1516 |
+
|
| 1517 |
+
# Final stacking on CPU
|
| 1518 |
+
result_image = torch.stack(result_image, dim=0)
|
| 1519 |
+
result_mask = torch.stack(result_mask, dim=0)
|
| 1520 |
+
|
| 1521 |
+
if self.DEBUG_MODE:
|
| 1522 |
+
# Everything is already on CPU, stack will be memory-safe
|
| 1523 |
+
final_debug_outputs = []
|
| 1524 |
+
for name in self.RETURN_NAMES:
|
| 1525 |
+
if name.startswith("DEBUG_"):
|
| 1526 |
+
values = debug_outputs[name]
|
| 1527 |
+
if not values:
|
| 1528 |
+
count = result_image.shape[0]
|
| 1529 |
+
if name.endswith("_image") or name.endswith("_location"):
|
| 1530 |
+
final_debug_outputs.append(torch.zeros((count, 1, 1, 3), device="cpu"))
|
| 1531 |
+
else:
|
| 1532 |
+
final_debug_outputs.append(torch.zeros((count, 1, 1), device="cpu"))
|
| 1533 |
+
else:
|
| 1534 |
+
try:
|
| 1535 |
+
# Stacking happens on CPU
|
| 1536 |
+
final_debug_outputs.append(torch.stack(values, dim=0))
|
| 1537 |
+
except Exception as e:
|
| 1538 |
+
print(f"InpaintCropImproved: Failed to stack {name}. Error: {e}")
|
| 1539 |
+
count = result_image.shape[0]
|
| 1540 |
+
if name.endswith("_image") or name.endswith("_location"):
|
| 1541 |
+
final_debug_outputs.append(torch.zeros((count, 1, 1, 3), device="cpu"))
|
| 1542 |
+
else:
|
| 1543 |
+
final_debug_outputs.append(torch.zeros((count, 1, 1), device="cpu"))
|
| 1544 |
+
|
| 1545 |
+
return (result_stitcher, result_image, result_mask, *final_debug_outputs)
|
| 1546 |
+
else:
|
| 1547 |
+
return (result_stitcher, result_image, result_mask)
|
| 1548 |
+
|
| 1549 |
+
|
| 1550 |
+
class InpaintStitchImproved:
|
| 1551 |
+
"""
|
| 1552 |
+
ComfyUI-InpaintCropAndStitch
|
| 1553 |
+
https://github.com/lquesada/ComfyUI-InpaintCropAndStitch
|
| 1554 |
+
|
| 1555 |
+
This node stitches the inpainted image without altering unmasked areas.
|
| 1556 |
+
"""
|
| 1557 |
+
@classmethod
|
| 1558 |
+
def INPUT_TYPES(cls):
|
| 1559 |
+
return {
|
| 1560 |
+
"required": {
|
| 1561 |
+
"stitcher": ("STITCHER",),
|
| 1562 |
+
"inpainted_image": ("IMAGE",),
|
| 1563 |
+
}
|
| 1564 |
+
}
|
| 1565 |
+
|
| 1566 |
+
CATEGORY = "inpaint"
|
| 1567 |
+
DESCRIPTION = "Stitches an image cropped with Inpaint Crop back into the original image"
|
| 1568 |
+
|
| 1569 |
+
RETURN_TYPES = ("IMAGE",)
|
| 1570 |
+
RETURN_NAMES = ("image",)
|
| 1571 |
+
|
| 1572 |
+
FUNCTION = "inpaint_stitch"
|
| 1573 |
+
|
| 1574 |
+
|
| 1575 |
+
def inpaint_stitch(self, stitcher, inpainted_image):
|
| 1576 |
+
inpainted_image = inpainted_image.clone()
|
| 1577 |
+
results = []
|
| 1578 |
+
|
| 1579 |
+
device_mode = stitcher.get('device_mode', 'cpu (compatible)')
|
| 1580 |
+
|
| 1581 |
+
if device_mode == "gpu (much faster)":
|
| 1582 |
+
device = comfy.model_management.get_torch_device()
|
| 1583 |
+
inpainted_image = inpainted_image.to(device)
|
| 1584 |
+
processor = GPUProcessorLogic()
|
| 1585 |
+
else:
|
| 1586 |
+
device = torch.device("cpu")
|
| 1587 |
+
processor = CPUProcessorLogic()
|
| 1588 |
+
|
| 1589 |
+
# Pre-move stitcher data to device to avoid moving in loop
|
| 1590 |
+
for key in ['canvas_image', 'cropped_mask_for_blend']:
|
| 1591 |
+
if key in stitcher:
|
| 1592 |
+
stitcher[key] = [t.to(device) if torch.is_tensor(t) else t for t in stitcher[key]]
|
| 1593 |
+
|
| 1594 |
+
batch_size = inpainted_image.shape[0]
|
| 1595 |
+
assert len(stitcher['cropped_to_canvas_x']) == batch_size or len(stitcher['cropped_to_canvas_x']) == 1, "Stitch batch size doesn't match image batch size"
|
| 1596 |
+
override = False
|
| 1597 |
+
if len(stitcher['cropped_to_canvas_x']) != batch_size and len(stitcher['cropped_to_canvas_x']) == 1:
|
| 1598 |
+
override = True
|
| 1599 |
+
|
| 1600 |
+
for i in range(batch_size):
|
| 1601 |
+
one_image = inpainted_image[i:i+1]
|
| 1602 |
+
|
| 1603 |
+
one_stitcher = {}
|
| 1604 |
+
for key in ['downscale_algorithm', 'upscale_algorithm', 'blend_pixels']:
|
| 1605 |
+
one_stitcher[key] = stitcher[key]
|
| 1606 |
+
for key in ['canvas_to_orig_x', 'canvas_to_orig_y', 'canvas_to_orig_w', 'canvas_to_orig_h', 'canvas_image', 'cropped_to_canvas_x', 'cropped_to_canvas_y', 'cropped_to_canvas_w', 'cropped_to_canvas_h', 'cropped_mask_for_blend']:
|
| 1607 |
+
if override:
|
| 1608 |
+
one_stitcher[key] = stitcher[key][0]
|
| 1609 |
+
else:
|
| 1610 |
+
one_stitcher[key] = stitcher[key][i]
|
| 1611 |
+
|
| 1612 |
+
one_image, = self.inpaint_stitch_single_image(one_stitcher, one_image, processor)
|
| 1613 |
+
results.append(one_image.squeeze(0))
|
| 1614 |
+
|
| 1615 |
+
result_batch = torch.stack(results, dim=0)
|
| 1616 |
+
result_batch = result_batch.cpu()
|
| 1617 |
+
|
| 1618 |
+
return (result_batch,)
|
| 1619 |
+
|
| 1620 |
+
def inpaint_stitch_single_image(self, stitcher, inpainted_image, processor):
|
| 1621 |
+
downscale_algorithm = stitcher['downscale_algorithm']
|
| 1622 |
+
upscale_algorithm = stitcher['upscale_algorithm']
|
| 1623 |
+
canvas_image = stitcher['canvas_image']
|
| 1624 |
+
|
| 1625 |
+
ctc_x = stitcher['cropped_to_canvas_x']
|
| 1626 |
+
ctc_y = stitcher['cropped_to_canvas_y']
|
| 1627 |
+
ctc_w = stitcher['cropped_to_canvas_w']
|
| 1628 |
+
ctc_h = stitcher['cropped_to_canvas_h']
|
| 1629 |
+
|
| 1630 |
+
cto_x = stitcher['canvas_to_orig_x']
|
| 1631 |
+
cto_y = stitcher['canvas_to_orig_y']
|
| 1632 |
+
cto_w = stitcher['canvas_to_orig_w']
|
| 1633 |
+
cto_h = stitcher['canvas_to_orig_h']
|
| 1634 |
+
|
| 1635 |
+
mask = stitcher['cropped_mask_for_blend'] # shape: [1, H, W]
|
| 1636 |
+
|
| 1637 |
+
output_image = processor.stitch_magic_im(canvas_image, inpainted_image, mask, ctc_x, ctc_y, ctc_w, ctc_h, cto_x, cto_y, cto_w, cto_h, downscale_algorithm, upscale_algorithm)
|
| 1638 |
+
|
| 1639 |
+
return (output_image,)
|
| 1640 |
+
|
| 1641 |
+
# Mappings for ComfyUI
|
| 1642 |
+
NODE_CLASS_MAPPINGS = {
|
| 1643 |
+
"InpaintCropImproved": InpaintCropImproved,
|
| 1644 |
+
"InpaintStitchImproved": InpaintStitchImproved
|
| 1645 |
+
}
|
| 1646 |
+
|
| 1647 |
+
NODE_DISPLAY_NAME_MAPPINGS = {
|
| 1648 |
+
"InpaintCropImproved": "Inpaint Crop Improved",
|
| 1649 |
+
"InpaintStitchImproved": "Inpaint Stitch Improved"
|
| 1650 |
+
}
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/inpaint_flux.png
ADDED
|
Git LFS Details
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/inpaint_hires.png
ADDED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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { app } from "../../scripts/app.js";
|
| 2 |
+
|
| 3 |
+
// Some fragments of this code are from https://github.com/LucianoCirino/efficiency-nodes-comfyui
|
| 4 |
+
|
| 5 |
+
function inpaintCropAndStitchHandler(node) {
|
| 6 |
+
if (node.comfyClass == "InpaintCropImproved") {
|
| 7 |
+
toggleWidget(node, findWidgetByName(node, "preresize_mode"));
|
| 8 |
+
toggleWidget(node, findWidgetByName(node, "preresize_min_width"));
|
| 9 |
+
toggleWidget(node, findWidgetByName(node, "preresize_min_height"));
|
| 10 |
+
toggleWidget(node, findWidgetByName(node, "preresize_max_width"));
|
| 11 |
+
toggleWidget(node, findWidgetByName(node, "preresize_max_height"));
|
| 12 |
+
if (findWidgetByName(node, "preresize").value == true) {
|
| 13 |
+
toggleWidget(node, findWidgetByName(node, "preresize_mode"), true);
|
| 14 |
+
if (findWidgetByName(node, "preresize_mode").value == "ensure minimum resolution") {
|
| 15 |
+
toggleWidget(node, findWidgetByName(node, "preresize_min_width"), true);
|
| 16 |
+
toggleWidget(node, findWidgetByName(node, "preresize_min_height"), true);
|
| 17 |
+
}
|
| 18 |
+
else if (findWidgetByName(node, "preresize_mode").value == "ensure minimum and maximum resolution") {
|
| 19 |
+
toggleWidget(node, findWidgetByName(node, "preresize_min_width"), true);
|
| 20 |
+
toggleWidget(node, findWidgetByName(node, "preresize_min_height"), true);
|
| 21 |
+
toggleWidget(node, findWidgetByName(node, "preresize_max_width"), true);
|
| 22 |
+
toggleWidget(node, findWidgetByName(node, "preresize_max_height"), true);
|
| 23 |
+
}
|
| 24 |
+
else if (findWidgetByName(node, "preresize_mode").value == "ensure maximum resolution") {
|
| 25 |
+
toggleWidget(node, findWidgetByName(node, "preresize_max_width"), true);
|
| 26 |
+
toggleWidget(node, findWidgetByName(node, "preresize_max_height"), true);
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
toggleWidget(node, findWidgetByName(node, "extend_up_factor"));
|
| 30 |
+
toggleWidget(node, findWidgetByName(node, "extend_down_factor"));
|
| 31 |
+
toggleWidget(node, findWidgetByName(node, "extend_left_factor"));
|
| 32 |
+
toggleWidget(node, findWidgetByName(node, "extend_right_factor"));
|
| 33 |
+
if (findWidgetByName(node, "extend_for_outpainting").value == true) {
|
| 34 |
+
toggleWidget(node, findWidgetByName(node, "extend_up_factor"), true);
|
| 35 |
+
toggleWidget(node, findWidgetByName(node, "extend_down_factor"), true);
|
| 36 |
+
toggleWidget(node, findWidgetByName(node, "extend_left_factor"), true);
|
| 37 |
+
toggleWidget(node, findWidgetByName(node, "extend_right_factor"), true);
|
| 38 |
+
}
|
| 39 |
+
toggleWidget(node, findWidgetByName(node, "output_target_width"));
|
| 40 |
+
toggleWidget(node, findWidgetByName(node, "output_target_height"));
|
| 41 |
+
if (findWidgetByName(node, "output_resize_to_target_size").value == true) {
|
| 42 |
+
toggleWidget(node, findWidgetByName(node, "output_target_width"), true);
|
| 43 |
+
toggleWidget(node, findWidgetByName(node, "output_target_height"), true);
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
// OLD
|
| 48 |
+
if (node.comfyClass == "InpaintCrop") {
|
| 49 |
+
toggleWidget(node, findWidgetByName(node, "force_width"));
|
| 50 |
+
toggleWidget(node, findWidgetByName(node, "force_height"));
|
| 51 |
+
toggleWidget(node, findWidgetByName(node, "rescale_factor"));
|
| 52 |
+
toggleWidget(node, findWidgetByName(node, "min_width"));
|
| 53 |
+
toggleWidget(node, findWidgetByName(node, "min_height"));
|
| 54 |
+
toggleWidget(node, findWidgetByName(node, "max_width"));
|
| 55 |
+
toggleWidget(node, findWidgetByName(node, "max_height"));
|
| 56 |
+
toggleWidget(node, findWidgetByName(node, "padding"));
|
| 57 |
+
if (findWidgetByName(node, "mode").value == "free size") {
|
| 58 |
+
toggleWidget(node, findWidgetByName(node, "rescale_factor"), true);
|
| 59 |
+
toggleWidget(node, findWidgetByName(node, "padding"), true);
|
| 60 |
+
}
|
| 61 |
+
else if (findWidgetByName(node, "mode").value == "ranged size") {
|
| 62 |
+
toggleWidget(node, findWidgetByName(node, "min_width"), true);
|
| 63 |
+
toggleWidget(node, findWidgetByName(node, "min_height"), true);
|
| 64 |
+
toggleWidget(node, findWidgetByName(node, "max_width"), true);
|
| 65 |
+
toggleWidget(node, findWidgetByName(node, "max_height"), true);
|
| 66 |
+
toggleWidget(node, findWidgetByName(node, "padding"), true);
|
| 67 |
+
}
|
| 68 |
+
else if (findWidgetByName(node, "mode").value == "forced size") {
|
| 69 |
+
toggleWidget(node, findWidgetByName(node, "force_width"), true);
|
| 70 |
+
toggleWidget(node, findWidgetByName(node, "force_height"), true);
|
| 71 |
+
}
|
| 72 |
+
} else if (node.comfyClass == "InpaintExtendOutpaint") {
|
| 73 |
+
toggleWidget(node, findWidgetByName(node, "expand_up_pixels"));
|
| 74 |
+
toggleWidget(node, findWidgetByName(node, "expand_up_factor"));
|
| 75 |
+
toggleWidget(node, findWidgetByName(node, "expand_down_pixels"));
|
| 76 |
+
toggleWidget(node, findWidgetByName(node, "expand_down_factor"));
|
| 77 |
+
toggleWidget(node, findWidgetByName(node, "expand_left_pixels"));
|
| 78 |
+
toggleWidget(node, findWidgetByName(node, "expand_left_factor"));
|
| 79 |
+
toggleWidget(node, findWidgetByName(node, "expand_right_pixels"));
|
| 80 |
+
toggleWidget(node, findWidgetByName(node, "expand_right_factor"));
|
| 81 |
+
if (findWidgetByName(node, "mode").value == "factors") {
|
| 82 |
+
toggleWidget(node, findWidgetByName(node, "expand_up_factor"), true);
|
| 83 |
+
toggleWidget(node, findWidgetByName(node, "expand_down_factor"), true);
|
| 84 |
+
toggleWidget(node, findWidgetByName(node, "expand_left_factor"), true);
|
| 85 |
+
toggleWidget(node, findWidgetByName(node, "expand_right_factor"), true);
|
| 86 |
+
}
|
| 87 |
+
if (findWidgetByName(node, "mode").value == "pixels") {
|
| 88 |
+
toggleWidget(node, findWidgetByName(node, "expand_up_pixels"), true);
|
| 89 |
+
toggleWidget(node, findWidgetByName(node, "expand_down_pixels"), true);
|
| 90 |
+
toggleWidget(node, findWidgetByName(node, "expand_left_pixels"), true);
|
| 91 |
+
toggleWidget(node, findWidgetByName(node, "expand_right_pixels"), true);
|
| 92 |
+
}
|
| 93 |
+
} else if (node.comfyClass == "InpaintResize") {
|
| 94 |
+
toggleWidget(node, findWidgetByName(node, "min_width"));
|
| 95 |
+
toggleWidget(node, findWidgetByName(node, "min_height"));
|
| 96 |
+
toggleWidget(node, findWidgetByName(node, "rescale_factor"));
|
| 97 |
+
if (findWidgetByName(node, "mode").value == "ensure minimum size") {
|
| 98 |
+
toggleWidget(node, findWidgetByName(node, "min_width"), true);
|
| 99 |
+
toggleWidget(node, findWidgetByName(node, "min_height"), true);
|
| 100 |
+
}
|
| 101 |
+
else if (findWidgetByName(node, "mode").value == "factor") {
|
| 102 |
+
toggleWidget(node, findWidgetByName(node, "rescale_factor"), true);
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
return;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
const findWidgetByName = (node, name) => {
|
| 109 |
+
return node.widgets ? node.widgets.find((w) => w.name === name) : null;
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
// Toggle Widget + change size
|
| 113 |
+
function toggleWidget(node, widget, show = false, suffix = "") {
|
| 114 |
+
if (!widget) return;
|
| 115 |
+
widget.disabled = !show
|
| 116 |
+
widget.linkedWidgets?.forEach(w => toggleWidget(node, w, ":" + widget.name, show));
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
app.registerExtension({
|
| 120 |
+
name: "inpaint-cropandstitch.showcontrol",
|
| 121 |
+
nodeCreated(node) {
|
| 122 |
+
if (!node.comfyClass.startsWith("Inpaint")) {
|
| 123 |
+
return;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
inpaintCropAndStitchHandler(node);
|
| 127 |
+
for (const w of node.widgets || []) {
|
| 128 |
+
let widgetValue = w.value;
|
| 129 |
+
|
| 130 |
+
// Store the original descriptor if it exists
|
| 131 |
+
let originalDescriptor = Object.getOwnPropertyDescriptor(w, 'value') ||
|
| 132 |
+
Object.getOwnPropertyDescriptor(Object.getPrototypeOf(w), 'value');
|
| 133 |
+
if (!originalDescriptor) {
|
| 134 |
+
originalDescriptor = Object.getOwnPropertyDescriptor(w.constructor.prototype, 'value');
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
Object.defineProperty(w, 'value', {
|
| 138 |
+
get() {
|
| 139 |
+
// If there's an original getter, use it. Otherwise, return widgetValue.
|
| 140 |
+
let valueToReturn = originalDescriptor && originalDescriptor.get
|
| 141 |
+
? originalDescriptor.get.call(w)
|
| 142 |
+
: widgetValue;
|
| 143 |
+
|
| 144 |
+
return valueToReturn;
|
| 145 |
+
},
|
| 146 |
+
set(newVal) {
|
| 147 |
+
// If there's an original setter, use it. Otherwise, set widgetValue.
|
| 148 |
+
if (originalDescriptor && originalDescriptor.set) {
|
| 149 |
+
originalDescriptor.set.call(w, newVal);
|
| 150 |
+
} else {
|
| 151 |
+
widgetValue = newVal;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
inpaintCropAndStitchHandler(node);
|
| 155 |
+
}
|
| 156 |
+
});
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
});
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/pyproject.toml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "comfyui-inpaint-cropandstitch"
|
| 3 |
+
description = "The '✂️ Inpaint Crop' and '✂️ Inpaint Stitch' nodes enable inpainting only on masked area very easily: crop the image around the masked area with the Crop node, then use any standard workflow for sampling, then connect the sampled image to the Stitch node, which will put it back in place in the original image. These nodes enable faster sampling of smaller areas and take care of downsampling and upsampling to fit specific model and resource needs."
|
| 4 |
+
version = "3.0.9"
|
| 5 |
+
license = { file = "LICENSE" }
|
| 6 |
+
|
| 7 |
+
[project.urls]
|
| 8 |
+
Repository = "https://github.com/lquesada/ComfyUI-Inpaint-CropAndStitch"
|
| 9 |
+
# Used by Comfy Registry https://comfyregistry.org
|
| 10 |
+
|
| 11 |
+
[tool.comfy]
|
| 12 |
+
PublisherId = "lquesada"
|
| 13 |
+
DisplayName = "ComfyUI-Inpaint-CropAndStitch"
|
| 14 |
+
Icon = ""
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-105444.59999999404.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-1670481.1000000015.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-2116156.8999999985.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-213955.39999999944.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-219964.40000000596.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-225116.5.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-248882.59999999404.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-3225001.799999997.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-3255269.599999994.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-3492848.299999997.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-3535755.200000003.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-5472479.200000003.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-5485412.599999994.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-562340.6999999881.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-576288.900000006.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-588013.599999994.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-69973.90000000596.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-84438.39999999106.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/clipspace/clipspace-mask-991989.900000006.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testimgs/example.png
ADDED
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testscpu.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/testsgpu.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
v3-nodes/ComfyUI-Inpaint-CropAndStitch/windlereye.jpg
ADDED
|