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
593b7069
Commit
593b7069
authored
Sep 24, 2023
by
Jairo Correa
Browse files
Proportional scale latent and image
parent
76cdc809
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
9 deletions
+32
-9
nodes.py
nodes.py
+32
-9
No files found.
nodes.py
View file @
593b7069
...
...
@@ -967,8 +967,8 @@ class LatentUpscale:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"samples"
:
(
"LATENT"
,),
"upscale_method"
:
(
s
.
upscale_methods
,),
"width"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"height"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"width"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"height"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"crop"
:
(
s
.
crop_methods
,)}}
RETURN_TYPES
=
(
"LATENT"
,)
FUNCTION
=
"upscale"
...
...
@@ -976,7 +976,21 @@ class LatentUpscale:
CATEGORY
=
"latent"
def
upscale
(
self
,
samples
,
upscale_method
,
width
,
height
,
crop
):
if
width
==
0
and
height
==
0
:
s
=
samples
else
:
s
=
samples
.
copy
()
if
width
==
0
:
height
=
max
(
64
,
height
)
width
=
max
(
64
,
round
(
samples
[
"samples"
].
shape
[
3
]
*
height
/
samples
[
"samples"
].
shape
[
2
]))
elif
height
==
0
:
width
=
max
(
64
,
width
)
height
=
max
(
64
,
round
(
samples
[
"samples"
].
shape
[
2
]
*
width
/
samples
[
"samples"
].
shape
[
3
]))
else
:
width
=
max
(
64
,
width
)
height
=
max
(
64
,
height
)
s
[
"samples"
]
=
comfy
.
utils
.
common_upscale
(
samples
[
"samples"
],
width
//
8
,
height
//
8
,
upscale_method
,
crop
)
return
(
s
,)
...
...
@@ -1429,8 +1443,8 @@ class ImageScale:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"image"
:
(
"IMAGE"
,),
"upscale_method"
:
(
s
.
upscale_methods
,),
"width"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
1
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
"height"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
1
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
"width"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
"height"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
"crop"
:
(
s
.
crop_methods
,)}}
RETURN_TYPES
=
(
"IMAGE"
,)
FUNCTION
=
"upscale"
...
...
@@ -1438,7 +1452,16 @@ class ImageScale:
CATEGORY
=
"image/upscaling"
def
upscale
(
self
,
image
,
upscale_method
,
width
,
height
,
crop
):
if
width
==
0
and
height
==
0
:
s
=
image
else
:
samples
=
image
.
movedim
(
-
1
,
1
)
if
width
==
0
:
width
=
max
(
1
,
round
(
samples
.
shape
[
3
]
*
height
/
samples
.
shape
[
2
]))
elif
height
==
0
:
height
=
max
(
1
,
round
(
samples
.
shape
[
2
]
*
width
/
samples
.
shape
[
3
]))
s
=
comfy
.
utils
.
common_upscale
(
samples
,
width
,
height
,
upscale_method
,
crop
)
s
=
s
.
movedim
(
1
,
-
1
)
return
(
s
,)
...
...
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