Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
1f8d8e6c
Commit
1f8d8e6c
authored
Apr 04, 2024
by
comfyanonymous
Browse files
Add InstructPixToPixConditioning node.
parent
5272fd4b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
comfy_extras/nodes_ip2p.py
comfy_extras/nodes_ip2p.py
+45
-0
nodes.py
nodes.py
+1
-0
No files found.
comfy_extras/nodes_ip2p.py
0 → 100644
View file @
1f8d8e6c
import
torch
class
InstructPixToPixConditioning
:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"positive"
:
(
"CONDITIONING"
,
),
"negative"
:
(
"CONDITIONING"
,
),
"vae"
:
(
"VAE"
,
),
"pixels"
:
(
"IMAGE"
,
),
}}
RETURN_TYPES
=
(
"CONDITIONING"
,
"CONDITIONING"
,
"LATENT"
)
RETURN_NAMES
=
(
"positive"
,
"negative"
,
"latent"
)
FUNCTION
=
"encode"
CATEGORY
=
"conditioning/instructpix2pix"
def
encode
(
self
,
positive
,
negative
,
pixels
,
vae
):
x
=
(
pixels
.
shape
[
1
]
//
8
)
*
8
y
=
(
pixels
.
shape
[
2
]
//
8
)
*
8
if
pixels
.
shape
[
1
]
!=
x
or
pixels
.
shape
[
2
]
!=
y
:
x_offset
=
(
pixels
.
shape
[
1
]
%
8
)
//
2
y_offset
=
(
pixels
.
shape
[
2
]
%
8
)
//
2
pixels
=
pixels
[:,
x_offset
:
x
+
x_offset
,
y_offset
:
y
+
y_offset
,:]
concat_latent
=
vae
.
encode
(
pixels
)
out_latent
=
{}
out_latent
[
"samples"
]
=
torch
.
zeros_like
(
concat_latent
)
out
=
[]
for
conditioning
in
[
positive
,
negative
]:
c
=
[]
for
t
in
conditioning
:
d
=
t
[
1
].
copy
()
d
[
"concat_latent_image"
]
=
concat_latent
n
=
[
t
[
0
],
d
]
c
.
append
(
n
)
out
.
append
(
c
)
return
(
out
[
0
],
out
[
1
],
out_latent
)
NODE_CLASS_MAPPINGS
=
{
"InstructPixToPixConditioning"
:
InstructPixToPixConditioning
,
}
nodes.py
View file @
1f8d8e6c
...
@@ -1965,6 +1965,7 @@ def init_custom_nodes():
...
@@ -1965,6 +1965,7 @@ def init_custom_nodes():
"nodes_morphology.py"
,
"nodes_morphology.py"
,
"nodes_stable_cascade.py"
,
"nodes_stable_cascade.py"
,
"nodes_differential_diffusion.py"
,
"nodes_differential_diffusion.py"
,
"nodes_ip2p.py"
,
]
]
import_failed
=
[]
import_failed
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment