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
renzhc
diffusers_dcu
Commits
8d7771d8
Commit
8d7771d8
authored
Jul 01, 2022
by
Patrick von Platen
Browse files
make work with first resnet
parent
9da575d6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
18 deletions
+17
-18
src/diffusers/models/resnet.py
src/diffusers/models/resnet.py
+7
-6
src/diffusers/models/unet_sde_score_estimation.py
src/diffusers/models/unet_sde_score_estimation.py
+10
-12
No files found.
src/diffusers/models/resnet.py
View file @
8d7771d8
...
...
@@ -436,10 +436,9 @@ class ResnetBlock(nn.Module):
self
.
upsample
=
Upsample
(
in_channels
,
use_conv
=
False
,
dims
=
2
)
if
self
.
up
else
None
self
.
downsample
=
Downsample
(
in_channels
,
use_conv
=
False
,
dims
=
2
,
padding
=
1
,
name
=
"op"
)
if
self
.
down
else
None
self
.
nin_shortcut
=
use_nin_shortcut
if
self
.
use_nin_shortcut
is
None
:
self
.
use_nin_shortcut
=
self
.
in_channels
!=
self
.
out_channels
self
.
use_nin_shortcut
=
self
.
in_channels
!=
self
.
out_channels
if
use_nin_shortcut
is
None
else
use_nin_shortcut
self
.
nin_shortcut
=
None
if
self
.
use_nin_shortcut
:
self
.
nin_shortcut
=
torch
.
nn
.
Conv2d
(
in_channels
,
out_channels
,
kernel_size
=
1
,
stride
=
1
,
padding
=
0
)
...
...
@@ -526,7 +525,9 @@ class ResnetBlock(nn.Module):
self
.
out_ch
=
out_ch
# TODO(Patrick) - move to main init
if
self
.
up
:
self
.
upsample
=
functools
.
partial
(
upsample_2d
,
k
=
self
.
fir_kernel
)
if
self
.
down
:
self
.
downsample
=
functools
.
partial
(
downsample_2d
,
k
=
self
.
fir_kernel
)
self
.
is_overwritten
=
False
...
...
@@ -647,7 +648,7 @@ class ResnetBlock(nn.Module):
if
self
.
nin_shortcut
is
not
None
:
x
=
self
.
nin_shortcut
(
x
)
return
x
+
h
return
(
x
+
h
)
/
self
.
output_scale_factor
# TODO(Patrick) - just there to convert the weights; can delete afterward
...
...
src/diffusers/models/unet_sde_score_estimation.py
View file @
8d7771d8
...
...
@@ -348,8 +348,7 @@ class NCSNpp(ModelMixin, ConfigMixin):
for
i_block
in
range
(
num_res_blocks
):
out_ch
=
nf
*
ch_mult
[
i_level
]
# modules.append(ResnetBlock(in_ch=in_ch, out_ch=out_ch))
modules
.
append
(
ResnetNew
(
modules
.
append
(
ResnetNew
(
in_channels
=
in_ch
,
out_channels
=
out_ch
,
temb_channels
=
4
*
nf
,
...
...
@@ -358,8 +357,7 @@ class NCSNpp(ModelMixin, ConfigMixin):
groups
=
min
(
in_ch
//
4
,
32
),
groups_out
=
min
(
out_ch
//
4
,
32
),
overwrite_for_score_vde
=
True
,
)
)
))
in_ch
=
out_ch
if
all_resolutions
[
i_level
]
in
attn_resolutions
:
...
...
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