Container to store AnimateDiff Motion Modules Args: block_out_channels (`Tuple[int]`, *optional*, defaults to `(320, 640, 1280, 1280)`): The tuple of output channels for each UNet block. motion_layers_per_block (`int`, *optional*, defaults to 2):
(
self,
block_out_channels: Tuple[int, ...] = (320, 640, 1280, 1280),
motion_layers_per_block: int = 2,
motion_mid_block_layers_per_block: int = 1,
motion_num_attention_heads: int = 8,
motion_norm_num_groups: int = 32,
motion_max_seq_length: int = 32,
use_motion_mid_block: bool = True,
conv_in_channels: Optional[int] = None,
)
| 82 | class MotionAdapter(ModelMixin, ConfigMixin): |
| 83 | @register_to_config |
| 84 | def __init__( |
| 85 | self, |
| 86 | block_out_channels: Tuple[int, ...] = (320, 640, 1280, 1280), |
| 87 | motion_layers_per_block: int = 2, |
| 88 | motion_mid_block_layers_per_block: int = 1, |
| 89 | motion_num_attention_heads: int = 8, |
| 90 | motion_norm_num_groups: int = 32, |
| 91 | motion_max_seq_length: int = 32, |
| 92 | use_motion_mid_block: bool = True, |
| 93 | conv_in_channels: Optional[int] = None, |
| 94 | ): |
| 95 | """Container to store AnimateDiff Motion Modules |
| 96 | |
| 97 | Args: |
| 98 | block_out_channels (`Tuple[int]`, *optional*, defaults to `(320, 640, 1280, 1280)`): |
| 99 | The tuple of output channels for each UNet block. |
| 100 | motion_layers_per_block (`int`, *optional*, defaults to 2): |
| 101 | The number of motion layers per UNet block. |
| 102 | motion_mid_block_layers_per_block (`int`, *optional*, defaults to 1): |
| 103 | The number of motion layers in the middle UNet block. |
| 104 | motion_num_attention_heads (`int`, *optional*, defaults to 8): |
| 105 | The number of heads to use in each attention layer of the motion module. |
| 106 | motion_norm_num_groups (`int`, *optional*, defaults to 32): |
| 107 | The number of groups to use in each group normalization layer of the motion module. |
| 108 | motion_max_seq_length (`int`, *optional*, defaults to 32): |
| 109 | The maximum sequence length to use in the motion module. |
| 110 | use_motion_mid_block (`bool`, *optional*, defaults to True): |
| 111 | Whether to use a motion module in the middle of the UNet. |
| 112 | """ |
| 113 | |
| 114 | super().__init__() |
| 115 | down_blocks = [] |
| 116 | up_blocks = [] |
| 117 | |
| 118 | if conv_in_channels: |
| 119 | # input |
| 120 | self.conv_in = nn.Conv2d(conv_in_channels, block_out_channels[0], kernel_size=3, padding=1) |
| 121 | else: |
| 122 | self.conv_in = None |
| 123 | |
| 124 | for i, channel in enumerate(block_out_channels): |
| 125 | output_channel = block_out_channels[i] |
| 126 | down_blocks.append( |
| 127 | MotionModules( |
| 128 | in_channels=output_channel, |
| 129 | norm_num_groups=motion_norm_num_groups, |
| 130 | cross_attention_dim=None, |
| 131 | activation_fn="geglu", |
| 132 | attention_bias=False, |
| 133 | num_attention_heads=motion_num_attention_heads, |
| 134 | max_seq_length=motion_max_seq_length, |
| 135 | layers_per_block=motion_layers_per_block, |
| 136 | ) |
| 137 | ) |
| 138 | |
| 139 | if use_motion_mid_block: |
| 140 | self.mid_block = MotionModules( |
| 141 | in_channels=block_out_channels[-1], |
nothing calls this directly
no test coverage detected