r""" The Flux pipeline for text-to-image generation. Reference: https://blackforestlabs.ai/announcing-black-forest-labs/ Args: transformer ([`FluxTransformer2DModel`]): Conditional Transformer (MMDiT) architecture to denoise the encoded image latents. schedu
| 161 | |
| 162 | |
| 163 | class FluxControlNetPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleFileMixin): |
| 164 | r""" |
| 165 | The Flux pipeline for text-to-image generation. |
| 166 | |
| 167 | Reference: https://blackforestlabs.ai/announcing-black-forest-labs/ |
| 168 | |
| 169 | Args: |
| 170 | transformer ([`FluxTransformer2DModel`]): |
| 171 | Conditional Transformer (MMDiT) architecture to denoise the encoded image latents. |
| 172 | scheduler ([`FlowMatchEulerDiscreteScheduler`]): |
| 173 | A scheduler to be used in combination with `transformer` to denoise the encoded image latents. |
| 174 | vae ([`AutoencoderKL`]): |
| 175 | Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations. |
| 176 | text_encoder ([`CLIPTextModel`]): |
| 177 | [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel), specifically |
| 178 | the [clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14) variant. |
| 179 | text_encoder_2 ([`T5EncoderModel`]): |
| 180 | [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel), specifically |
| 181 | the [google/t5-v1_1-xxl](https://huggingface.co/google/t5-v1_1-xxl) variant. |
| 182 | tokenizer (`CLIPTokenizer`): |
| 183 | Tokenizer of class |
| 184 | [CLIPTokenizer](https://huggingface.co/docs/transformers/en/model_doc/clip#transformers.CLIPTokenizer). |
| 185 | tokenizer_2 (`T5TokenizerFast`): |
| 186 | Second Tokenizer of class |
| 187 | [T5TokenizerFast](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5TokenizerFast). |
| 188 | """ |
| 189 | |
| 190 | model_cpu_offload_seq = "text_encoder->text_encoder_2->transformer->vae" |
| 191 | _optional_components = [] |
| 192 | _callback_tensor_inputs = ["latents", "prompt_embeds"] |
| 193 | |
| 194 | def __init__( |
| 195 | self, |
| 196 | scheduler: FlowMatchEulerDiscreteScheduler, |
| 197 | vae: AutoencoderKL, |
| 198 | text_encoder: CLIPTextModel, |
| 199 | tokenizer: CLIPTokenizer, |
| 200 | text_encoder_2: T5EncoderModel, |
| 201 | tokenizer_2: T5TokenizerFast, |
| 202 | transformer: FluxTransformer2DModel, |
| 203 | controlnet: Union[ |
| 204 | FluxControlNetModel, List[FluxControlNetModel], Tuple[FluxControlNetModel], FluxMultiControlNetModel |
| 205 | ], |
| 206 | ): |
| 207 | super().__init__() |
| 208 | |
| 209 | self.register_modules( |
| 210 | vae=vae, |
| 211 | text_encoder=text_encoder, |
| 212 | text_encoder_2=text_encoder_2, |
| 213 | tokenizer=tokenizer, |
| 214 | tokenizer_2=tokenizer_2, |
| 215 | transformer=transformer, |
| 216 | scheduler=scheduler, |
| 217 | controlnet=controlnet, |
| 218 | ) |
| 219 | self.vae_scale_factor = ( |
| 220 | 2 ** (len(self.vae.config.block_out_channels)) if hasattr(self, "vae") and self.vae is not None else 16 |
nothing calls this directly
no outgoing calls
no test coverage detected