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
d0165d81
Commit
d0165d81
authored
Dec 24, 2023
by
comfyanonymous
Browse files
Fix SVD lowvram mode.
parent
a252963f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
comfy/ldm/modules/diffusionmodules/util.py
comfy/ldm/modules/diffusionmodules/util.py
+3
-3
comfy/ldm/modules/temporal_ae.py
comfy/ldm/modules/temporal_ae.py
+4
-4
No files found.
comfy/ldm/modules/diffusionmodules/util.py
View file @
d0165d81
...
...
@@ -51,9 +51,9 @@ class AlphaBlender(nn.Module):
if
self
.
merge_strategy
==
"fixed"
:
# make shape compatible
# alpha = repeat(self.mix_factor, '1 -> b () t () ()', t=t, b=bs)
alpha
=
self
.
mix_factor
alpha
=
self
.
mix_factor
.
to
(
image_only_indicator
.
device
)
elif
self
.
merge_strategy
==
"learned"
:
alpha
=
torch
.
sigmoid
(
self
.
mix_factor
)
alpha
=
torch
.
sigmoid
(
self
.
mix_factor
.
to
(
image_only_indicator
.
device
)
)
# make shape compatible
# alpha = repeat(alpha, '1 -> s () ()', s = t * bs)
elif
self
.
merge_strategy
==
"learned_with_images"
:
...
...
@@ -61,7 +61,7 @@ class AlphaBlender(nn.Module):
alpha
=
torch
.
where
(
image_only_indicator
.
bool
(),
torch
.
ones
(
1
,
1
,
device
=
image_only_indicator
.
device
),
rearrange
(
torch
.
sigmoid
(
self
.
mix_factor
),
"... -> ... 1"
),
rearrange
(
torch
.
sigmoid
(
self
.
mix_factor
.
to
(
image_only_indicator
.
device
)
),
"... -> ... 1"
),
)
alpha
=
rearrange
(
alpha
,
self
.
rearrange_pattern
)
# make shape compatible
...
...
comfy/ldm/modules/temporal_ae.py
View file @
d0165d81
...
...
@@ -82,14 +82,14 @@ class VideoResBlock(ResnetBlock):
x
=
self
.
time_stack
(
x
,
temb
)
alpha
=
self
.
get_alpha
(
bs
=
b
//
timesteps
)
alpha
=
self
.
get_alpha
(
bs
=
b
//
timesteps
)
.
to
(
x
.
device
)
x
=
alpha
*
x
+
(
1.0
-
alpha
)
*
x_mix
x
=
rearrange
(
x
,
"b c t h w -> (b t) c h w"
)
return
x
class
AE3DConv
(
torch
.
nn
.
Conv2d
):
class
AE3DConv
(
ops
.
Conv2d
):
def
__init__
(
self
,
in_channels
,
out_channels
,
video_kernel_size
=
3
,
*
args
,
**
kwargs
):
super
().
__init__
(
in_channels
,
out_channels
,
*
args
,
**
kwargs
)
if
isinstance
(
video_kernel_size
,
Iterable
):
...
...
@@ -97,7 +97,7 @@ class AE3DConv(torch.nn.Conv2d):
else
:
padding
=
int
(
video_kernel_size
//
2
)
self
.
time_mix_conv
=
torch
.
nn
.
Conv3d
(
self
.
time_mix_conv
=
ops
.
Conv3d
(
in_channels
=
out_channels
,
out_channels
=
out_channels
,
kernel_size
=
video_kernel_size
,
...
...
@@ -167,7 +167,7 @@ class AttnVideoBlock(AttnBlock):
emb
=
emb
[:,
None
,
:]
x_mix
=
x_mix
+
emb
alpha
=
self
.
get_alpha
()
alpha
=
self
.
get_alpha
()
.
to
(
x
.
device
)
x_mix
=
self
.
time_mix_block
(
x_mix
,
timesteps
=
timesteps
)
x
=
alpha
*
x
+
(
1.0
-
alpha
)
*
x_mix
# alpha merge
...
...
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