MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / __init__

Method __init__

diffusers/src/diffusers/models/autoencoders/vae.py:208–282  ·  view source on GitHub ↗
(
        self,
        in_channels: int = 3,
        out_channels: int = 3,
        up_block_types: Tuple[str, ...] = ("UpDecoderBlock2D",),
        block_out_channels: Tuple[int, ...] = (64,),
        layers_per_block: int = 2,
        norm_num_groups: int = 32,
        act_fn: str = "silu",
        norm_type: str = "group",  # group, spatial
        mid_block_add_attention=True,
    )

Source from the content-addressed store, hash-verified

206 """
207
208 def __init__(
209 self,
210 in_channels: int = 3,
211 out_channels: int = 3,
212 up_block_types: Tuple[str, ...] = ("UpDecoderBlock2D",),
213 block_out_channels: Tuple[int, ...] = (64,),
214 layers_per_block: int = 2,
215 norm_num_groups: int = 32,
216 act_fn: str = "silu",
217 norm_type: str = "group", # group, spatial
218 mid_block_add_attention=True,
219 ):
220 super().__init__()
221 self.layers_per_block = layers_per_block
222
223 self.conv_in = nn.Conv2d(
224 in_channels,
225 block_out_channels[-1],
226 kernel_size=3,
227 stride=1,
228 padding=1,
229 )
230
231 self.up_blocks = nn.ModuleList([])
232
233 temb_channels = in_channels if norm_type == "spatial" else None
234
235 # mid
236 self.mid_block = UNetMidBlock2D(
237 in_channels=block_out_channels[-1],
238 resnet_eps=1e-6,
239 resnet_act_fn=act_fn,
240 output_scale_factor=1,
241 resnet_time_scale_shift="default" if norm_type == "group" else norm_type,
242 attention_head_dim=block_out_channels[-1],
243 resnet_groups=norm_num_groups,
244 temb_channels=temb_channels,
245 add_attention=mid_block_add_attention,
246 )
247
248 # up
249 reversed_block_out_channels = list(reversed(block_out_channels))
250 output_channel = reversed_block_out_channels[0]
251 for i, up_block_type in enumerate(up_block_types):
252 prev_output_channel = output_channel
253 output_channel = reversed_block_out_channels[i]
254
255 is_final_block = i == len(block_out_channels) - 1
256
257 up_block = get_up_block(
258 up_block_type,
259 num_layers=self.layers_per_block + 1,
260 in_channels=prev_output_channel,
261 out_channels=output_channel,
262 prev_output_channel=None,
263 add_upsample=not is_final_block,
264 resnet_eps=1e-6,
265 resnet_act_fn=act_fn,

Callers

nothing calls this directly

Calls 4

UNetMidBlock2DClass · 0.85
SpatialNormClass · 0.85
get_up_blockFunction · 0.50
__init__Method · 0.45

Tested by

no test coverage detected