Skip to content

Commit a2dd559

Browse files
committed
all tests pass
1 parent 2f6462b commit a2dd559

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/diffusers/models/unet_1d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class UNet1DModel(ModelMixin, ConfigMixin):
4444
implements for all the model (such as downloading or saving, etc.)
4545
4646
Parameters:
47-
sample_size (`int`, *optionl*): Default length of sample. Should be adaptable at runtime.
47+
sample_size (`int`, *optional*): Default length of sample. Should be adaptable at runtime.
4848
in_channels (`int`, *optional*, defaults to 2): Number of channels in the input sample.
4949
out_channels (`int`, *optional*, defaults to 2): Number of channels in the output.
5050
time_embedding_type (`str`, *optional*, defaults to `"fourier"`): Type of time embedding to use.
@@ -78,7 +78,7 @@ def __init__(
7878
down_block_types: Tuple[str] = ("DownResnetBlock1D", "DownResnetBlock1D", "DownResnetBlock1D"),
7979
up_block_types: Tuple[str] = ("UpResnetBlock1D", "UpResnetBlock1D"),
8080
mid_block_type: Tuple[str] = "MidResTemporalBlock1D",
81-
out_block_type: str = "OutConv1DBlock",
81+
out_block_type: str = None,
8282
block_out_channels: Tuple[int] = (32, 128, 256),
8383
act_fn: str = "mish",
8484
norm_num_groups: int = 8,
@@ -211,7 +211,7 @@ def forward(
211211
timesteps = timesteps[None].to(sample.device)
212212

213213
timestep_embed = self.time_proj(timesteps)
214-
if self.time_mlp:
214+
if self.config.use_timestep_embedding:
215215
timestep_embed = self.time_mlp(timestep_embed)
216216
else:
217217
timestep_embed = timestep_embed[..., None]

src/diffusers/models/unet_1d_blocks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def __init__(self, kernel="linear", pad_mode="reflect"):
312312
self.pad = kernel_1d.shape[0] // 2 - 1
313313
self.register_buffer("kernel", kernel_1d)
314314

315-
def forward(self, hidden_states):
315+
def forward(self, hidden_states, temb=None):
316316
hidden_states = F.pad(hidden_states, ((self.pad + 1) // 2,) * 2, self.pad_mode)
317317
weight = hidden_states.new_zeros([hidden_states.shape[1], hidden_states.shape[1], self.kernel.shape[0]])
318318
indices = torch.arange(hidden_states.shape[1], device=hidden_states.device)
@@ -441,7 +441,7 @@ def __init__(self, mid_channels, in_channels, out_channels=None):
441441
self.attentions = nn.ModuleList(attentions)
442442
self.resnets = nn.ModuleList(resnets)
443443

444-
def forward(self, hidden_states):
444+
def forward(self, hidden_states, temb=None):
445445
hidden_states = self.down(hidden_states)
446446
for attn, resnet in zip(self.attentions, self.resnets):
447447
hidden_states = resnet(hidden_states)
@@ -546,7 +546,7 @@ def __init__(self, in_channels, out_channels, mid_channels=None):
546546
self.resnets = nn.ModuleList(resnets)
547547
self.up = Upsample1d(kernel="cubic")
548548

549-
def forward(self, hidden_states, res_hidden_states_tuple):
549+
def forward(self, hidden_states, res_hidden_states_tuple, temb=None):
550550
res_hidden_states = res_hidden_states_tuple[-1]
551551
hidden_states = torch.cat([hidden_states, res_hidden_states], dim=1)
552552

@@ -573,7 +573,7 @@ def __init__(self, in_channels, out_channels, mid_channels=None):
573573
self.resnets = nn.ModuleList(resnets)
574574
self.up = Upsample1d(kernel="cubic")
575575

576-
def forward(self, hidden_states, res_hidden_states_tuple):
576+
def forward(self, hidden_states, res_hidden_states_tuple, temb=None):
577577
res_hidden_states = res_hidden_states_tuple[-1]
578578
hidden_states = torch.cat([hidden_states, res_hidden_states], dim=1)
579579

@@ -598,7 +598,7 @@ def __init__(self, in_channels, out_channels, mid_channels=None):
598598

599599
self.resnets = nn.ModuleList(resnets)
600600

601-
def forward(self, hidden_states, res_hidden_states_tuple):
601+
def forward(self, hidden_states, res_hidden_states_tuple, temb=None):
602602
res_hidden_states = res_hidden_states_tuple[-1]
603603
hidden_states = torch.cat([hidden_states, res_hidden_states], dim=1)
604604

tests/test_models_unet_1d.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def prepare_init_args_and_inputs_for_common(self):
6060
"in_channels": 14,
6161
"out_channels": 14,
6262
"time_embedding_type": "positional",
63+
"use_timestep_embedding": True,
64+
"out_block_type": "OutConv1DBlock",
6365
}
6466
inputs_dict = self.dummy_input
6567
return init_dict, inputs_dict
@@ -159,6 +161,7 @@ def prepare_init_args_and_inputs_for_common(self):
159161
"block_out_channels": [32, 64, 128, 256],
160162
"layers_per_block": 1,
161163
"always_downsample": True,
164+
"use_timestep_embedding": True
162165
}
163166
inputs_dict = self.dummy_input
164167
return init_dict, inputs_dict

0 commit comments

Comments
 (0)