Skip to content

Commit b99b161

Browse files
IDKirosayakpaulyiyixuxu
authored
add the option of upsample function for tiny vae (#7604)
Co-authored-by: Sayak Paul <[email protected]> Co-authored-by: YiYi Xu <[email protected]>
1 parent 3e4a6bd commit b99b161

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/diffusers/models/autoencoders/autoencoder_tiny.py

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def __init__(
102102
encoder_block_out_channels: Tuple[int, ...] = (64, 64, 64, 64),
103103
decoder_block_out_channels: Tuple[int, ...] = (64, 64, 64, 64),
104104
act_fn: str = "relu",
105+
upsample_fn: str = "nearest",
105106
latent_channels: int = 4,
106107
upsampling_scaling_factor: int = 2,
107108
num_encoder_blocks: Tuple[int, ...] = (1, 3, 3, 3),
@@ -133,6 +134,7 @@ def __init__(
133134
block_out_channels=decoder_block_out_channels,
134135
upsampling_scaling_factor=upsampling_scaling_factor,
135136
act_fn=act_fn,
137+
upsample_fn=upsample_fn,
136138
)
137139

138140
self.latent_magnitude = latent_magnitude

src/diffusers/models/autoencoders/vae.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ def __init__(
926926
block_out_channels: Tuple[int, ...],
927927
upsampling_scaling_factor: int,
928928
act_fn: str,
929+
upsample_fn: str,
929930
):
930931
super().__init__()
931932

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

944945
if not is_final_block:
945-
layers.append(nn.Upsample(scale_factor=upsampling_scaling_factor))
946+
layers.append(nn.Upsample(scale_factor=upsampling_scaling_factor, mode=upsample_fn))
946947

947948
conv_out_channel = num_channels if not is_final_block else out_channels
948949
layers.append(

0 commit comments

Comments
 (0)