The [`FluxTransformer2DModel`] forward method. Args: hidden_states (`torch.FloatTensor` of shape `(batch size, channel, height, width)`): Input `hidden_states`. controlnet_cond (`torch.Tensor`): The conditional input tensor of
(
self,
hidden_states: torch.Tensor,
controlnet_cond: torch.Tensor,
controlnet_mode: torch.Tensor = None,
conditioning_scale: float = 1.0,
encoder_hidden_states: torch.Tensor = None,
pooled_projections: torch.Tensor = None,
timestep: torch.LongTensor = None,
img_ids: torch.Tensor = None,
txt_ids: torch.Tensor = None,
guidance: torch.Tensor = None,
joint_attention_kwargs: Optional[Dict[str, Any]] = None,
return_dict: bool = True,
)
| 214 | return controlnet |
| 215 | |
| 216 | def forward( |
| 217 | self, |
| 218 | hidden_states: torch.Tensor, |
| 219 | controlnet_cond: torch.Tensor, |
| 220 | controlnet_mode: torch.Tensor = None, |
| 221 | conditioning_scale: float = 1.0, |
| 222 | encoder_hidden_states: torch.Tensor = None, |
| 223 | pooled_projections: torch.Tensor = None, |
| 224 | timestep: torch.LongTensor = None, |
| 225 | img_ids: torch.Tensor = None, |
| 226 | txt_ids: torch.Tensor = None, |
| 227 | guidance: torch.Tensor = None, |
| 228 | joint_attention_kwargs: Optional[Dict[str, Any]] = None, |
| 229 | return_dict: bool = True, |
| 230 | ) -> Union[torch.FloatTensor, Transformer2DModelOutput]: |
| 231 | """ |
| 232 | The [`FluxTransformer2DModel`] forward method. |
| 233 | |
| 234 | Args: |
| 235 | hidden_states (`torch.FloatTensor` of shape `(batch size, channel, height, width)`): |
| 236 | Input `hidden_states`. |
| 237 | controlnet_cond (`torch.Tensor`): |
| 238 | The conditional input tensor of shape `(batch_size, sequence_length, hidden_size)`. |
| 239 | controlnet_mode (`torch.Tensor`): |
| 240 | The mode tensor of shape `(batch_size, 1)`. |
| 241 | conditioning_scale (`float`, defaults to `1.0`): |
| 242 | The scale factor for ControlNet outputs. |
| 243 | encoder_hidden_states (`torch.FloatTensor` of shape `(batch size, sequence_len, embed_dims)`): |
| 244 | Conditional embeddings (embeddings computed from the input conditions such as prompts) to use. |
| 245 | pooled_projections (`torch.FloatTensor` of shape `(batch_size, projection_dim)`): Embeddings projected |
| 246 | from the embeddings of input conditions. |
| 247 | timestep ( `torch.LongTensor`): |
| 248 | Used to indicate denoising step. |
| 249 | block_controlnet_hidden_states: (`list` of `torch.Tensor`): |
| 250 | A list of tensors that if specified are added to the residuals of transformer blocks. |
| 251 | joint_attention_kwargs (`dict`, *optional*): |
| 252 | A kwargs dictionary that if specified is passed along to the `AttentionProcessor` as defined under |
| 253 | `self.processor` in |
| 254 | [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py). |
| 255 | return_dict (`bool`, *optional*, defaults to `True`): |
| 256 | Whether or not to return a [`~models.transformer_2d.Transformer2DModelOutput`] instead of a plain |
| 257 | tuple. |
| 258 | |
| 259 | Returns: |
| 260 | If `return_dict` is True, an [`~models.transformer_2d.Transformer2DModelOutput`] is returned, otherwise a |
| 261 | `tuple` where the first element is the sample tensor. |
| 262 | """ |
| 263 | if joint_attention_kwargs is not None: |
| 264 | joint_attention_kwargs = joint_attention_kwargs.copy() |
| 265 | lora_scale = joint_attention_kwargs.pop("scale", 1.0) |
| 266 | else: |
| 267 | lora_scale = 1.0 |
| 268 | |
| 269 | if USE_PEFT_BACKEND: |
| 270 | # weight the lora layers by setting `lora_scale` for each PEFT layer |
| 271 | scale_lora_layers(self, lora_scale) |
| 272 | else: |
| 273 | if joint_attention_kwargs is not None and joint_attention_kwargs.get("scale", None) is not None: |
nothing calls this directly
no test coverage detected