Diffusers documentation
AuraFlow
AuraFlow
AuraFlow is inspired by Stable Diffusion 3 and is by far the largest text-to-image generation model that comes with an Apache 2.0 license. This model achieves state-of-the-art results on the GenEval benchmark.
It was developed by the Fal team and more details about it can be found in this blog post.
AuraFlow can be quite expensive to run on consumer hardware devices. However, you can perform a suite of optimizations to run it faster and in a more memory-friendly manner. Check out this section for more details.
AuraFlowPipeline
class diffusers.AuraFlowPipeline
< source >( tokenizer: T5Tokenizer text_encoder: UMT5EncoderModel vae: AutoencoderKL transformer: AuraFlowTransformer2DModel scheduler: FlowMatchEulerDiscreteScheduler )
Parameters
- tokenizer (
T5TokenizerFast) — Tokenizer of class T5Tokenizer. - text_encoder (
T5EncoderModel) — Frozen text-encoder. AuraFlow uses T5, specifically the EleutherAI/pile-t5-xl variant. - vae (AutoencoderKL) — Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.
- transformer (AuraFlowTransformer2DModel) — Conditional Transformer (MMDiT and DiT) architecture to denoise the encoded image latents.
- scheduler (FlowMatchEulerDiscreteScheduler) —
A scheduler to be used in combination with
transformerto denoise the encoded image latents.
__call__
< source >( prompt: typing.Union[str, typing.List[str]] = None negative_prompt: typing.Union[str, typing.List[str]] = None num_inference_steps: int = 50 sigmas: typing.List[float] = None guidance_scale: float = 3.5 num_images_per_prompt: typing.Optional[int] = 1 height: typing.Optional[int] = 1024 width: typing.Optional[int] = 1024 generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None latents: typing.Optional[torch.Tensor] = None prompt_embeds: typing.Optional[torch.Tensor] = None prompt_attention_mask: typing.Optional[torch.Tensor] = None negative_prompt_embeds: typing.Optional[torch.Tensor] = None negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None max_sequence_length: int = 256 output_type: typing.Optional[str] = 'pil' return_dict: bool = True )
Parameters
- prompt (
strorList[str], optional) — The prompt or prompts to guide the image generation. If not defined, one has to passprompt_embeds. instead. - negative_prompt (
strorList[str], optional) — The prompt or prompts not to guide the image generation. If not defined, one has to passnegative_prompt_embedsinstead. Ignored when not using guidance (i.e., ignored ifguidance_scaleis less than1). - height (
int, optional, defaults to self.transformer.config.sample_size * self.vae_scale_factor) — The height in pixels of the generated image. This is set to 1024 by default for best results. - width (
int, optional, defaults to self.transformer.config.sample_size * self.vae_scale_factor) — The width in pixels of the generated image. This is set to 1024 by default for best results. - num_inference_steps (
int, optional, defaults to 50) — The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference. - sigmas (
List[float], optional) — Custom sigmas used to override the timestep spacing strategy of the scheduler. Ifsigmasis passed,num_inference_stepsandtimestepsmust beNone. - guidance_scale (
float, optional, defaults to 5.0) — Guidance scale as defined in Classifier-Free Diffusion Guidance.guidance_scaleis defined aswof equation 2. of Imagen Paper. Guidance scale is enabled by settingguidance_scale > 1. Higher guidance scale encourages to generate images that are closely linked to the textprompt, usually at the expense of lower image quality. - num_images_per_prompt (
int, optional, defaults to 1) — The number of images to generate per prompt. - generator (
torch.GeneratororList[torch.Generator], optional) — One or a list of torch generator(s) to make generation deterministic. - latents (
torch.FloatTensor, optional) — Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for image generation. Can be used to tweak the same generation with different prompts. If not provided, a latents tensor will ge generated by sampling using the supplied randomgenerator. - prompt_embeds (
torch.FloatTensor, optional) — Pre-generated text embeddings. Can be used to easily tweak text inputs, e.g. prompt weighting. If not provided, text embeddings will be generated frompromptinput argument. - prompt_attention_mask (
torch.Tensor, optional) — Pre-generated attention mask for text embeddings. - negative_prompt_embeds (
torch.FloatTensor, optional) — Pre-generated negative text embeddings. Can be used to easily tweak text inputs, e.g. prompt weighting. If not provided, negative_prompt_embeds will be generated fromnegative_promptinput argument. - negative_prompt_attention_mask (
torch.Tensor, optional) — Pre-generated attention mask for negative text embeddings. - output_type (
str, optional, defaults to"pil") — The output format of the generate image. Choose between PIL:PIL.Image.Imageornp.array. - return_dict (
bool, optional, defaults toTrue) — Whether or not to return a~pipelines.stable_diffusion_xl.StableDiffusionXLPipelineOutputinstead of a plain tuple. - max_sequence_length (
intdefaults to 256) — Maximum sequence length to use with theprompt.
Function invoked when calling the pipeline for generation.
Examples:
>>> import torch
>>> from diffusers import AuraFlowPipeline
>>> pipe = AuraFlowPipeline.from_pretrained("fal/AuraFlow", torch_dtype=torch.float16)
>>> pipe = pipe.to("cuda")
>>> prompt = "A cat holding a sign that says hello world"
>>> image = pipe(prompt).images[0]
>>> image.save("aura_flow.png")Returns: ImagePipelineOutput or tuple:
If return_dict is True, ImagePipelineOutput is returned, otherwise a tuple is returned
where the first element is a list with the generated images.
encode_prompt
< source >( prompt: typing.Union[str, typing.List[str]] negative_prompt: typing.Union[str, typing.List[str]] = None do_classifier_free_guidance: bool = True num_images_per_prompt: int = 1 device: typing.Optional[torch.device] = None prompt_embeds: typing.Optional[torch.Tensor] = None negative_prompt_embeds: typing.Optional[torch.Tensor] = None prompt_attention_mask: typing.Optional[torch.Tensor] = None negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None max_sequence_length: int = 256 )
Parameters
- prompt (
strorList[str], optional) — prompt to be encoded - negative_prompt (
strorList[str], optional) — The prompt not to guide the image generation. If not defined, one has to passnegative_prompt_embedsinstead. Ignored when not using guidance (i.e., ignored ifguidance_scaleis less than1). - do_classifier_free_guidance (
bool, optional, defaults toTrue) — whether to use classifier free guidance or not - num_images_per_prompt (
int, optional, defaults to 1) — number of images that should be generated per prompt - device — (
torch.device, optional): torch device to place the resulting embeddings on - prompt_embeds (
torch.Tensor, optional) — Pre-generated text embeddings. Can be used to easily tweak text inputs, e.g. prompt weighting. If not provided, text embeddings will be generated frompromptinput argument. - prompt_attention_mask (
torch.Tensor, optional) — Pre-generated attention mask for text embeddings. - negative_prompt_embeds (
torch.Tensor, optional) — Pre-generated negative text embeddings. - negative_prompt_attention_mask (
torch.Tensor, optional) — Pre-generated attention mask for negative text embeddings. - max_sequence_length (
int, defaults to 256) — Maximum sequence length to use for the prompt.
Encodes the prompt into text encoder hidden states.