Skip to content

Commit

Permalink
add the option of upsample function for tiny vae (#7604)
Browse files Browse the repository at this point in the history
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: YiYi Xu <yixu310@gmail.com>
  • Loading branch information
3 people authored Apr 10, 2024
1 parent 3e4a6bd commit b99b161
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_tiny.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def __init__(
encoder_block_out_channels: Tuple[int, ...] = (64, 64, 64, 64),
decoder_block_out_channels: Tuple[int, ...] = (64, 64, 64, 64),
act_fn: str = "relu",
upsample_fn: str = "nearest",
latent_channels: int = 4,
upsampling_scaling_factor: int = 2,
num_encoder_blocks: Tuple[int, ...] = (1, 3, 3, 3),
Expand Down Expand Up @@ -133,6 +134,7 @@ def __init__(
block_out_channels=decoder_block_out_channels,
upsampling_scaling_factor=upsampling_scaling_factor,
act_fn=act_fn,
upsample_fn=upsample_fn,
)

self.latent_magnitude = latent_magnitude
Expand Down
3 changes: 2 additions & 1 deletion src/diffusers/models/autoencoders/vae.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ def __init__(
block_out_channels: Tuple[int, ...],
upsampling_scaling_factor: int,
act_fn: str,
upsample_fn: str,
):
super().__init__()

Expand All @@ -942,7 +943,7 @@ def __init__(
layers.append(AutoencoderTinyBlock(num_channels, num_channels, act_fn))

if not is_final_block:
layers.append(nn.Upsample(scale_factor=upsampling_scaling_factor))
layers.append(nn.Upsample(scale_factor=upsampling_scaling_factor, mode=upsample_fn))

conv_out_channel = num_channels if not is_final_block else out_channels
layers.append(
Expand Down

0 comments on commit b99b161

Please sign in to comment.