r""" A ControlNet model. This model inherits from [`FlaxModelMixin`]. Check the superclass documentation for it’s generic methods implemented for all models (such as downloading or saving). This model is also a Flax Linen [`flax.linen.Module`](https://flax.readthedocs.io/en/latest/
| 102 | |
| 103 | @flax_register_to_config |
| 104 | class FlaxControlNetModel(nn.Module, FlaxModelMixin, ConfigMixin): |
| 105 | r""" |
| 106 | A ControlNet model. |
| 107 | |
| 108 | This model inherits from [`FlaxModelMixin`]. Check the superclass documentation for it’s generic methods |
| 109 | implemented for all models (such as downloading or saving). |
| 110 | |
| 111 | This model is also a Flax Linen [`flax.linen.Module`](https://flax.readthedocs.io/en/latest/flax.linen.html#module) |
| 112 | subclass. Use it as a regular Flax Linen module and refer to the Flax documentation for all matters related to its |
| 113 | general usage and behavior. |
| 114 | |
| 115 | Inherent JAX features such as the following are supported: |
| 116 | |
| 117 | - [Just-In-Time (JIT) compilation](https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit) |
| 118 | - [Automatic Differentiation](https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation) |
| 119 | - [Vectorization](https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap) |
| 120 | - [Parallelization](https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap) |
| 121 | |
| 122 | Parameters: |
| 123 | sample_size (`int`, *optional*): |
| 124 | The size of the input sample. |
| 125 | in_channels (`int`, *optional*, defaults to 4): |
| 126 | The number of channels in the input sample. |
| 127 | down_block_types (`Tuple[str]`, *optional*, defaults to `("FlaxCrossAttnDownBlock2D", "FlaxCrossAttnDownBlock2D", "FlaxCrossAttnDownBlock2D", "FlaxDownBlock2D")`): |
| 128 | The tuple of downsample blocks to use. |
| 129 | block_out_channels (`Tuple[int]`, *optional*, defaults to `(320, 640, 1280, 1280)`): |
| 130 | The tuple of output channels for each block. |
| 131 | layers_per_block (`int`, *optional*, defaults to 2): |
| 132 | The number of layers per block. |
| 133 | attention_head_dim (`int` or `Tuple[int]`, *optional*, defaults to 8): |
| 134 | The dimension of the attention heads. |
| 135 | num_attention_heads (`int` or `Tuple[int]`, *optional*): |
| 136 | The number of attention heads. |
| 137 | cross_attention_dim (`int`, *optional*, defaults to 768): |
| 138 | The dimension of the cross attention features. |
| 139 | dropout (`float`, *optional*, defaults to 0): |
| 140 | Dropout probability for down, up and bottleneck blocks. |
| 141 | flip_sin_to_cos (`bool`, *optional*, defaults to `True`): |
| 142 | Whether to flip the sin to cos in the time embedding. |
| 143 | freq_shift (`int`, *optional*, defaults to 0): The frequency shift to apply to the time embedding. |
| 144 | controlnet_conditioning_channel_order (`str`, *optional*, defaults to `rgb`): |
| 145 | The channel order of conditional image. Will convert to `rgb` if it's `bgr`. |
| 146 | conditioning_embedding_out_channels (`tuple`, *optional*, defaults to `(16, 32, 96, 256)`): |
| 147 | The tuple of output channel for each block in the `conditioning_embedding` layer. |
| 148 | """ |
| 149 | |
| 150 | sample_size: int = 32 |
| 151 | in_channels: int = 4 |
| 152 | down_block_types: Tuple[str, ...] = ( |
| 153 | "CrossAttnDownBlock2D", |
| 154 | "CrossAttnDownBlock2D", |
| 155 | "CrossAttnDownBlock2D", |
| 156 | "DownBlock2D", |
| 157 | ) |
| 158 | only_cross_attention: Union[bool, Tuple[bool, ...]] = False |
| 159 | block_out_channels: Tuple[int, ...] = (320, 640, 1280, 1280) |
| 160 | layers_per_block: int = 2 |
| 161 | attention_head_dim: Union[int, Tuple[int, ...]] = 8 |