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
bc72d297
Commit
bc72d297
authored
Jun 13, 2022
by
patil-suraj
Browse files
make Diffwave subclass of ModelMixin
parent
86da45bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
6 deletions
+29
-6
src/diffusers/pipelines/pipeline_bddm.py
src/diffusers/pipelines/pipeline_bddm.py
+29
-6
No files found.
src/diffusers/pipelines/pipeline_bddm.py
View file @
bc72d297
...
@@ -19,6 +19,8 @@ import torch.nn as nn
...
@@ -19,6 +19,8 @@ import torch.nn as nn
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
import
tqdm
import
tqdm
from
..modeling_utils
import
ModelMixin
from
..configuration_utils
import
ConfigMixin
from
..pipeline_utils
import
DiffusionPipeline
from
..pipeline_utils
import
DiffusionPipeline
...
@@ -209,14 +211,35 @@ class ResidualGroup(nn.Module):
...
@@ -209,14 +211,35 @@ class ResidualGroup(nn.Module):
return
skip
*
math
.
sqrt
(
1.0
/
self
.
num_res_layers
)
return
skip
*
math
.
sqrt
(
1.0
/
self
.
num_res_layers
)
class
DiffWave
(
nn
.
Module
):
class
DiffWave
(
ModelMixin
,
ConfigMixin
):
def
__init__
(
self
,
in_channels
,
res_channels
,
skip_channels
,
out_channels
,
def
__init__
(
num_res_layers
,
dilation_cycle
,
self
,
diffusion_step_embed_dim_in
,
in_channels
=
1
,
diffusion_step_embed_dim_mid
,
res_channels
=
128
,
diffusion_step_embed_dim_out
):
skip_channels
=
128
,
out_channels
=
1
,
num_res_layers
=
30
,
dilation_cycle
=
10
,
diffusion_step_embed_dim_in
=
128
,
diffusion_step_embed_dim_mid
=
512
,
diffusion_step_embed_dim_out
=
512
,
):
super
().
__init__
()
super
().
__init__
()
# register all init arguments with self.register
self
.
register
(
in_channels
=
in_channels
,
res_channels
=
res_channels
,
skip_channels
=
skip_channels
,
out_channels
=
out_channels
,
num_res_layers
=
num_res_layers
,
dilation_cycle
=
dilation_cycle
,
diffusion_step_embed_dim_in
=
diffusion_step_embed_dim_in
,
diffusion_step_embed_dim_mid
=
diffusion_step_embed_dim_mid
,
diffusion_step_embed_dim_out
=
diffusion_step_embed_dim_out
,
)
# Initial conv1x1 with relu
# Initial conv1x1 with relu
self
.
init_conv
=
nn
.
Sequential
(
Conv
(
in_channels
,
res_channels
,
kernel_size
=
1
),
nn
.
ReLU
(
inplace
=
False
))
self
.
init_conv
=
nn
.
Sequential
(
Conv
(
in_channels
,
res_channels
,
kernel_size
=
1
),
nn
.
ReLU
(
inplace
=
False
))
# All residual layers
# All residual layers
...
...
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