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
a3115249
Commit
a3115249
authored
Feb 19, 2024
by
comfyanonymous
Browse files
Node to make stable cascade image to image easier.
parent
88f30040
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
comfy_extras/nodes_stable_cascade.py
comfy_extras/nodes_stable_cascade.py
+35
-0
No files found.
comfy_extras/nodes_stable_cascade.py
View file @
a3115249
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
import
torch
import
torch
import
nodes
import
nodes
import
comfy.utils
class
StableCascade_EmptyLatentImage
:
class
StableCascade_EmptyLatentImage
:
...
@@ -47,6 +48,39 @@ class StableCascade_EmptyLatentImage:
...
@@ -47,6 +48,39 @@ class StableCascade_EmptyLatentImage:
"samples"
:
b_latent
,
"samples"
:
b_latent
,
})
})
class
StableCascade_StageC_VAEEncode
:
def
__init__
(
self
,
device
=
"cpu"
):
self
.
device
=
device
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"image"
:
(
"IMAGE"
,),
"vae"
:
(
"VAE"
,
),
"compression"
:
(
"INT"
,
{
"default"
:
42
,
"min"
:
4
,
"max"
:
128
,
"step"
:
1
}),
}}
RETURN_TYPES
=
(
"LATENT"
,
"LATENT"
)
RETURN_NAMES
=
(
"stage_c"
,
"stage_b"
)
FUNCTION
=
"generate"
CATEGORY
=
"_for_testing/stable_cascade"
def
generate
(
self
,
image
,
vae
,
compression
):
width
=
image
.
shape
[
-
2
]
height
=
image
.
shape
[
-
3
]
out_width
=
(
width
//
compression
)
*
vae
.
downscale_ratio
out_height
=
(
height
//
compression
)
*
vae
.
downscale_ratio
s
=
comfy
.
utils
.
common_upscale
(
image
.
movedim
(
-
1
,
1
),
out_width
,
out_height
,
"bicubic"
,
"center"
).
movedim
(
1
,
-
1
)
c_latent
=
vae
.
encode
(
s
[:,:,:,:
3
])
b_latent
=
torch
.
zeros
([
c_latent
.
shape
[
0
],
4
,
height
//
4
,
width
//
4
])
return
({
"samples"
:
c_latent
,
},
{
"samples"
:
b_latent
,
})
class
StableCascade_StageB_Conditioning
:
class
StableCascade_StageB_Conditioning
:
@
classmethod
@
classmethod
def
INPUT_TYPES
(
s
):
def
INPUT_TYPES
(
s
):
...
@@ -71,4 +105,5 @@ class StableCascade_StageB_Conditioning:
...
@@ -71,4 +105,5 @@ class StableCascade_StageB_Conditioning:
NODE_CLASS_MAPPINGS
=
{
NODE_CLASS_MAPPINGS
=
{
"StableCascade_EmptyLatentImage"
:
StableCascade_EmptyLatentImage
,
"StableCascade_EmptyLatentImage"
:
StableCascade_EmptyLatentImage
,
"StableCascade_StageB_Conditioning"
:
StableCascade_StageB_Conditioning
,
"StableCascade_StageB_Conditioning"
:
StableCascade_StageB_Conditioning
,
"StableCascade_StageC_VAEEncode"
:
StableCascade_StageC_VAEEncode
,
}
}
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