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
6f7852bc
Commit
6f7852bc
authored
Apr 17, 2023
by
comfyanonymous
Browse files
Add a LatentFromBatch node to pick a single latent from a batch.
Works before and after sampling.
parent
884ea653
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
1 deletion
+26
-1
nodes.py
nodes.py
+26
-1
No files found.
nodes.py
View file @
6f7852bc
...
...
@@ -510,6 +510,24 @@ class EmptyLatentImage:
return
({
"samples"
:
latent
},
)
class
LatentFromBatch
:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"samples"
:
(
"LATENT"
,),
"batch_index"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
63
}),
}}
RETURN_TYPES
=
(
"LATENT"
,)
FUNCTION
=
"rotate"
CATEGORY
=
"latent"
def
rotate
(
self
,
samples
,
batch_index
):
s
=
samples
.
copy
()
s_in
=
samples
[
"samples"
]
batch_index
=
min
(
s_in
.
shape
[
0
]
-
1
,
batch_index
)
s
[
"samples"
]
=
s_in
[
batch_index
:
batch_index
+
1
].
clone
()
s
[
"batch_index"
]
=
batch_index
return
(
s
,)
class
LatentUpscale
:
upscale_methods
=
[
"nearest-exact"
,
"bilinear"
,
"area"
]
...
...
@@ -685,7 +703,13 @@ def common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive,
if
disable_noise
:
noise
=
torch
.
zeros
(
latent_image
.
size
(),
dtype
=
latent_image
.
dtype
,
layout
=
latent_image
.
layout
,
device
=
"cpu"
)
else
:
noise
=
torch
.
randn
(
latent_image
.
size
(),
dtype
=
latent_image
.
dtype
,
layout
=
latent_image
.
layout
,
generator
=
torch
.
manual_seed
(
seed
),
device
=
"cpu"
)
batch_index
=
0
if
"batch_index"
in
latent
:
batch_index
=
latent
[
"batch_index"
]
generator
=
torch
.
manual_seed
(
seed
)
for
i
in
range
(
batch_index
+
1
):
noise
=
torch
.
randn
([
1
]
+
list
(
latent_image
.
size
())[
1
:],
dtype
=
latent_image
.
dtype
,
layout
=
latent_image
.
layout
,
generator
=
generator
,
device
=
"cpu"
)
if
"noise_mask"
in
latent
:
noise_mask
=
latent
[
'noise_mask'
]
...
...
@@ -1073,6 +1097,7 @@ NODE_CLASS_MAPPINGS = {
"VAELoader"
:
VAELoader
,
"EmptyLatentImage"
:
EmptyLatentImage
,
"LatentUpscale"
:
LatentUpscale
,
"LatentFromBatch"
:
LatentFromBatch
,
"SaveImage"
:
SaveImage
,
"PreviewImage"
:
PreviewImage
,
"LoadImage"
:
LoadImage
,
...
...
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