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
ba8a4c36
"mmdet3d/models/vscode:/vscode.git/clone" did not exist on "333536f696264082813b404656eb3c2f0aca1c20"
Commit
ba8a4c36
authored
May 02, 2023
by
comfyanonymous
Browse files
Change latent resolution step to 8.
parent
66c8aa5c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
40 deletions
+33
-40
comfy/ldm/modules/diffusionmodules/openaimodel.py
comfy/ldm/modules/diffusionmodules/openaimodel.py
+0
-1
nodes.py
nodes.py
+33
-39
No files found.
comfy/ldm/modules/diffusionmodules/openaimodel.py
View file @
ba8a4c36
...
...
@@ -108,7 +108,6 @@ class Upsample(nn.Module):
self
.
conv
=
conv_nd
(
dims
,
self
.
channels
,
self
.
out_channels
,
3
,
padding
=
padding
)
def
forward
(
self
,
x
,
output_shape
=
None
):
print
(
"upsample"
,
output_shape
)
assert
x
.
shape
[
1
]
==
self
.
channels
if
self
.
dims
==
3
:
shape
=
[
x
.
shape
[
2
],
x
.
shape
[
3
]
*
2
,
x
.
shape
[
4
]
*
2
]
...
...
nodes.py
View file @
ba8a4c36
...
...
@@ -94,10 +94,10 @@ class ConditioningSetArea:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"conditioning"
:
(
"CONDITIONING"
,
),
"width"
:
(
"INT"
,
{
"default"
:
64
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"height"
:
(
"INT"
,
{
"default"
:
64
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"x"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"y"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"width"
:
(
"INT"
,
{
"default"
:
64
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"height"
:
(
"INT"
,
{
"default"
:
64
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"x"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"y"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"strength"
:
(
"FLOAT"
,
{
"default"
:
1.0
,
"min"
:
0.0
,
"max"
:
10.0
,
"step"
:
0.01
}),
}}
RETURN_TYPES
=
(
"CONDITIONING"
,)
...
...
@@ -188,16 +188,21 @@ class VAEEncode:
CATEGORY
=
"latent"
def
encode
(
self
,
vae
,
pixels
):
x
=
(
pixels
.
shape
[
1
]
//
64
)
*
64
y
=
(
pixels
.
shape
[
2
]
//
64
)
*
64
@
staticmethod
def
vae_encode_crop_pixels
(
pixels
):
x
=
(
pixels
.
shape
[
1
]
//
8
)
*
8
y
=
(
pixels
.
shape
[
2
]
//
8
)
*
8
if
pixels
.
shape
[
1
]
!=
x
or
pixels
.
shape
[
2
]
!=
y
:
pixels
=
pixels
[:,:
x
,:
y
,:]
t
=
vae
.
encode
(
pixels
[:,:,:,:
3
])
x_offset
=
(
pixels
.
shape
[
1
]
%
8
)
//
2
y_offset
=
(
pixels
.
shape
[
2
]
%
8
)
//
2
pixels
=
pixels
[:,
x_offset
:
x
+
x_offset
,
y_offset
:
y
+
y_offset
,
:]
return
pixels
def
encode
(
self
,
vae
,
pixels
):
pixels
=
self
.
vae_encode_crop_pixels
(
pixels
)
t
=
vae
.
encode
(
pixels
[:,:,:,:
3
])
return
({
"samples"
:
t
},
)
class
VAEEncodeTiled
:
def
__init__
(
self
,
device
=
"cpu"
):
self
.
device
=
device
...
...
@@ -211,13 +216,10 @@ class VAEEncodeTiled:
CATEGORY
=
"_for_testing"
def
encode
(
self
,
vae
,
pixels
):
x
=
(
pixels
.
shape
[
1
]
//
64
)
*
64
y
=
(
pixels
.
shape
[
2
]
//
64
)
*
64
if
pixels
.
shape
[
1
]
!=
x
or
pixels
.
shape
[
2
]
!=
y
:
pixels
=
pixels
[:,:
x
,:
y
,:]
pixels
=
VAEEncode
.
vae_encode_crop_pixels
(
pixels
)
t
=
vae
.
encode_tiled
(
pixels
[:,:,:,:
3
])
return
({
"samples"
:
t
},
)
class
VAEEncodeForInpaint
:
def
__init__
(
self
,
device
=
"cpu"
):
self
.
device
=
device
...
...
@@ -231,14 +233,16 @@ class VAEEncodeForInpaint:
CATEGORY
=
"latent/inpaint"
def
encode
(
self
,
vae
,
pixels
,
mask
,
grow_mask_by
=
6
):
x
=
(
pixels
.
shape
[
1
]
//
64
)
*
64
y
=
(
pixels
.
shape
[
2
]
//
64
)
*
64
x
=
(
pixels
.
shape
[
1
]
//
8
)
*
8
y
=
(
pixels
.
shape
[
2
]
//
8
)
*
8
mask
=
torch
.
nn
.
functional
.
interpolate
(
mask
.
reshape
((
-
1
,
1
,
mask
.
shape
[
-
2
],
mask
.
shape
[
-
1
])),
size
=
(
pixels
.
shape
[
1
],
pixels
.
shape
[
2
]),
mode
=
"bilinear"
)
pixels
=
pixels
.
clone
()
if
pixels
.
shape
[
1
]
!=
x
or
pixels
.
shape
[
2
]
!=
y
:
pixels
=
pixels
[:,:
x
,:
y
,:]
mask
=
mask
[:,:,:
x
,:
y
]
x_offset
=
(
pixels
.
shape
[
1
]
%
8
)
//
2
y_offset
=
(
pixels
.
shape
[
2
]
%
8
)
//
2
pixels
=
pixels
[:,
x_offset
:
x
+
x_offset
,
y_offset
:
y
+
y_offset
,:]
mask
=
mask
[:,:,
x_offset
:
x
+
x_offset
,
y_offset
:
y
+
y_offset
]
#grow mask by a few pixels to keep things seamless in latent space
if
grow_mask_by
==
0
:
...
...
@@ -610,8 +614,8 @@ class EmptyLatentImage:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"width"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"height"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
return
{
"required"
:
{
"width"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"height"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"batch_size"
:
(
"INT"
,
{
"default"
:
1
,
"min"
:
1
,
"max"
:
64
})}}
RETURN_TYPES
=
(
"LATENT"
,)
FUNCTION
=
"generate"
...
...
@@ -649,8 +653,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"
:
64
}),
"height"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"width"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"height"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"crop"
:
(
s
.
crop_methods
,)}}
RETURN_TYPES
=
(
"LATENT"
,)
FUNCTION
=
"upscale"
...
...
@@ -752,8 +756,8 @@ class LatentCrop:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"samples"
:
(
"LATENT"
,),
"width"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"height"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"width"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"height"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
64
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"x"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"y"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
}}
...
...
@@ -778,16 +782,6 @@ class LatentCrop:
new_width
=
width
//
8
to_x
=
new_width
+
x
to_y
=
new_height
+
y
def
enforce_image_dim
(
d
,
to_d
,
max_d
):
if
to_d
>
max_d
:
leftover
=
(
to_d
-
max_d
)
%
8
to_d
=
max_d
d
-=
leftover
return
(
d
,
to_d
)
#make sure size is always multiple of 64
x
,
to_x
=
enforce_image_dim
(
x
,
to_x
,
samples
.
shape
[
3
])
y
,
to_y
=
enforce_image_dim
(
y
,
to_y
,
samples
.
shape
[
2
])
s
[
'samples'
]
=
samples
[:,:,
y
:
to_y
,
x
:
to_x
]
return
(
s
,)
...
...
@@ -1105,10 +1099,10 @@ class ImagePadForOutpaint:
return
{
"required"
:
{
"image"
:
(
"IMAGE"
,),
"left"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"top"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"right"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"bottom"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
64
}),
"left"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"top"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"right"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"bottom"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
8
}),
"feathering"
:
(
"INT"
,
{
"default"
:
40
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
}
}
...
...
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