Unverified Commit b99b1617 authored by IDKiro's avatar IDKiro Committed by GitHub
Browse files

add the option of upsample function for tiny vae (#7604)


Co-authored-by: default avatarSayak Paul <spsayakpaul@gmail.com>
Co-authored-by: default avatarYiYi Xu <yixu310@gmail.com>
parent 3e4a6bd2
...@@ -102,6 +102,7 @@ class AutoencoderTiny(ModelMixin, ConfigMixin): ...@@ -102,6 +102,7 @@ class AutoencoderTiny(ModelMixin, ConfigMixin):
encoder_block_out_channels: Tuple[int, ...] = (64, 64, 64, 64), encoder_block_out_channels: Tuple[int, ...] = (64, 64, 64, 64),
decoder_block_out_channels: Tuple[int, ...] = (64, 64, 64, 64), decoder_block_out_channels: Tuple[int, ...] = (64, 64, 64, 64),
act_fn: str = "relu", act_fn: str = "relu",
upsample_fn: str = "nearest",
latent_channels: int = 4, latent_channels: int = 4,
upsampling_scaling_factor: int = 2, upsampling_scaling_factor: int = 2,
num_encoder_blocks: Tuple[int, ...] = (1, 3, 3, 3), num_encoder_blocks: Tuple[int, ...] = (1, 3, 3, 3),
...@@ -133,6 +134,7 @@ class AutoencoderTiny(ModelMixin, ConfigMixin): ...@@ -133,6 +134,7 @@ class AutoencoderTiny(ModelMixin, ConfigMixin):
block_out_channels=decoder_block_out_channels, block_out_channels=decoder_block_out_channels,
upsampling_scaling_factor=upsampling_scaling_factor, upsampling_scaling_factor=upsampling_scaling_factor,
act_fn=act_fn, act_fn=act_fn,
upsample_fn=upsample_fn,
) )
self.latent_magnitude = latent_magnitude self.latent_magnitude = latent_magnitude
......
...@@ -926,6 +926,7 @@ class DecoderTiny(nn.Module): ...@@ -926,6 +926,7 @@ class DecoderTiny(nn.Module):
block_out_channels: Tuple[int, ...], block_out_channels: Tuple[int, ...],
upsampling_scaling_factor: int, upsampling_scaling_factor: int,
act_fn: str, act_fn: str,
upsample_fn: str,
): ):
super().__init__() super().__init__()
...@@ -942,7 +943,7 @@ class DecoderTiny(nn.Module): ...@@ -942,7 +943,7 @@ class DecoderTiny(nn.Module):
layers.append(AutoencoderTinyBlock(num_channels, num_channels, act_fn)) layers.append(AutoencoderTinyBlock(num_channels, num_channels, act_fn))
if not is_final_block: 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 conv_out_channel = num_channels if not is_final_block else out_channels
layers.append( layers.append(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment