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
67833c83
Commit
67833c83
authored
Jun 12, 2023
by
comfyanonymous
Browse files
Add ImageScaleBy node.
parent
f8c59310
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
nodes.py
nodes.py
+22
-0
No files found.
nodes.py
View file @
67833c83
...
@@ -1192,6 +1192,26 @@ class ImageScale:
...
@@ -1192,6 +1192,26 @@ class ImageScale:
s
=
s
.
movedim
(
1
,
-
1
)
s
=
s
.
movedim
(
1
,
-
1
)
return
(
s
,)
return
(
s
,)
class
ImageScaleBy
:
upscale_methods
=
[
"nearest-exact"
,
"bilinear"
,
"area"
]
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"image"
:
(
"IMAGE"
,),
"upscale_method"
:
(
s
.
upscale_methods
,),
"scale_by"
:
(
"FLOAT"
,
{
"default"
:
1.0
,
"min"
:
0.01
,
"max"
:
8.0
,
"step"
:
0.01
}),}}
RETURN_TYPES
=
(
"IMAGE"
,)
FUNCTION
=
"upscale"
CATEGORY
=
"image/upscaling"
def
upscale
(
self
,
image
,
upscale_method
,
scale_by
):
samples
=
image
.
movedim
(
-
1
,
1
)
width
=
round
(
samples
.
shape
[
3
]
*
scale_by
)
height
=
round
(
samples
.
shape
[
2
]
*
scale_by
)
s
=
comfy
.
utils
.
common_upscale
(
samples
,
width
,
height
,
upscale_method
,
"disabled"
)
s
=
s
.
movedim
(
1
,
-
1
)
return
(
s
,)
class
ImageInvert
:
class
ImageInvert
:
@
classmethod
@
classmethod
...
@@ -1290,6 +1310,7 @@ NODE_CLASS_MAPPINGS = {
...
@@ -1290,6 +1310,7 @@ NODE_CLASS_MAPPINGS = {
"LoadImage"
:
LoadImage
,
"LoadImage"
:
LoadImage
,
"LoadImageMask"
:
LoadImageMask
,
"LoadImageMask"
:
LoadImageMask
,
"ImageScale"
:
ImageScale
,
"ImageScale"
:
ImageScale
,
"ImageScaleBy"
:
ImageScaleBy
,
"ImageInvert"
:
ImageInvert
,
"ImageInvert"
:
ImageInvert
,
"ImagePadForOutpaint"
:
ImagePadForOutpaint
,
"ImagePadForOutpaint"
:
ImagePadForOutpaint
,
"ConditioningAverage "
:
ConditioningAverage
,
"ConditioningAverage "
:
ConditioningAverage
,
...
@@ -1371,6 +1392,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
...
@@ -1371,6 +1392,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"LoadImage"
:
"Load Image"
,
"LoadImage"
:
"Load Image"
,
"LoadImageMask"
:
"Load Image (as Mask)"
,
"LoadImageMask"
:
"Load Image (as Mask)"
,
"ImageScale"
:
"Upscale Image"
,
"ImageScale"
:
"Upscale Image"
,
"ImageScaleBy"
:
"Upscale Image By"
,
"ImageUpscaleWithModel"
:
"Upscale Image (using Model)"
,
"ImageUpscaleWithModel"
:
"Upscale Image (using Model)"
,
"ImageInvert"
:
"Invert Image"
,
"ImageInvert"
:
"Invert Image"
,
"ImagePadForOutpaint"
:
"Pad Image for Outpainting"
,
"ImagePadForOutpaint"
:
"Pad Image for Outpainting"
,
...
...
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