blocks¶
Modules for generator blocks.
- class mfai.pytorch.models.dgmr.blocks.ContextConditioningStack(input_channels=1, output_channels=768, num_context_steps=4, conv_type='standard')[source]¶
Bases:
ModuleContext conditioning stack.
- Parameters:
- class mfai.pytorch.models.dgmr.blocks.DBlock(input_channels, output_channels, conv_type='standard', first_relu=True, keep_same_output=False)[source]¶
Bases:
ModuleD block class.
- Parameters:
- class mfai.pytorch.models.dgmr.blocks.GBlock(input_channels=12, output_channels=12, conv_type='standard', spectral_normalized_eps=0.0001)[source]¶
Bases:
ModuleResidual generator block without upsampling.
- Parameters:
- class mfai.pytorch.models.dgmr.blocks.LBlock(input_channels=12, output_channels=12, kernel_size=3, conv_type='standard')[source]¶
Bases:
ModuleResidual block for the Latent Stack.
- Parameters:
- class mfai.pytorch.models.dgmr.blocks.LatentConditioningStack(input_channels=8, output_channels=768, use_attention=True)[source]¶
Bases:
ModuleLatent conditioning stack class.
- forward(x)[source]¶
Apply convolution, L blocks, and spatial attention module to the input tensor.
- Parameters:
x (
Tensor) – Input tensor with shape (batch_size, channels, height, width) where height and width must be divisible by 32. The tensor must be on the correct device and will be moved to the latent distribution.- Returns:
- Output tensor after processing through convolution, L blocks, and
optional attention module. The output shape depends on the specific implementation of the layers but maintains the batch dimension.
- Return type:
Tensor
- Raises:
ValueError – If the height or width of the input tensor is not divisible by 32. This constraint is required for proper processing through the network’s downsampling operations.