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
4ae1515f
Commit
4ae1515f
authored
May 19, 2024
by
comfyanonymous
Browse files
Slightly faster latent2rgb previews.
parent
f37a4711
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
latent_preview.py
latent_preview.py
+3
-2
No files found.
latent_preview.py
View file @
4ae1515f
...
@@ -37,12 +37,13 @@ class Latent2RGBPreviewer(LatentPreviewer):
...
@@ -37,12 +37,13 @@ class Latent2RGBPreviewer(LatentPreviewer):
self
.
latent_rgb_factors
=
torch
.
tensor
(
latent_rgb_factors
,
device
=
"cpu"
)
self
.
latent_rgb_factors
=
torch
.
tensor
(
latent_rgb_factors
,
device
=
"cpu"
)
def
decode_latent_to_preview
(
self
,
x0
):
def
decode_latent_to_preview
(
self
,
x0
):
latent_image
=
x0
[
0
].
permute
(
1
,
2
,
0
).
cpu
()
@
self
.
latent_rgb_factors
self
.
latent_rgb_factors
=
self
.
latent_rgb_factors
.
to
(
dtype
=
x0
.
dtype
,
device
=
x0
.
device
)
latent_image
=
x0
[
0
].
permute
(
1
,
2
,
0
)
@
self
.
latent_rgb_factors
latents_ubyte
=
(((
latent_image
+
1
)
/
2
)
latents_ubyte
=
(((
latent_image
+
1
)
/
2
)
.
clamp
(
0
,
1
)
# change scale from -1..1 to 0..1
.
clamp
(
0
,
1
)
# change scale from -1..1 to 0..1
.
mul
(
0xFF
)
# to 0..255
.
mul
(
0xFF
)
# to 0..255
.
byte
()).
cpu
(
)
).
to
(
device
=
"cpu"
,
dtype
=
torch
.
uint8
,
non_blocking
=
True
)
return
Image
.
fromarray
(
latents_ubyte
.
numpy
())
return
Image
.
fromarray
(
latents_ubyte
.
numpy
())
...
...
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