text
stringlengths
0
5.54k
A scheduler to be used in combination with prior to generate image embedding. latent_dim_scale (float, optional, defaults to 10.67) β€”
Multiplier to determine the VQ latent space size from the image embeddings. If the image embeddings are
height=24 and width=24, the VQ latent shape needs to be height=int(2410.67)=256 and
width=int(2410.67)=256 in order to match the training conditions. Pipeline for generating images from the Stable Cascade model. This model inherits from DiffusionPipeline. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.) __call__ < source > ( image_embeddings: Union prompt: Union = None num_inference_steps: int = 10 guidance_scale: float = 0.0 negative_prompt: Union = None prompt_embeds: Optional = None negative_prompt_embed...
Image Embeddings either extracted from an image or generated by a Prior Model. prompt (str or List[str]) β€”
The prompt or prompts to guide the image generation. num_inference_steps (int, optional, defaults to 12) β€”
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference. guidance_scale (float, optional, defaults to 0.0) β€”
Guidance scale as defined in Classifier-Free Diffusion Guidance.
decoder_guidance_scale is defined as w of equation 2. of Imagen
Paper. Guidance scale is enabled by setting
decoder_guidance_scale > 1. Higher guidance scale encourages to generate images that are closely
linked to the text prompt, usually at the expense of lower image quality. negative_prompt (str or List[str], optional) β€”
The prompt or prompts not to guide the image generation. Ignored when not using guidance (i.e., ignored
if decoder_guidance_scale is less than 1). 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 from prompt input argument. 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 from negative_prompt input
argument. num_images_per_prompt (int, optional, defaults to 1) β€”
The number of images to generate per prompt. generator (torch.Generator or List[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 random generator. output_type (str, optional, defaults to "pil") β€”
The output format of the generate image. Choose between: "pil" (PIL.Image.Image), "np"
(np.array) or "pt" (torch.Tensor). return_dict (bool, optional, defaults to True) β€”
Whether or not to return a ImagePipelineOutput instead of a plain tuple. callback_on_step_end (Callable, optional) β€”
A function that calls at the end of each denoising steps during the inference. The function is called
with the following arguments: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict). callback_kwargs will include a list of all tensors as specified by
callback_on_step_end_tensor_inputs. callback_on_step_end_tensor_inputs (List, optional) β€”
The list of tensor inputs for the callback_on_step_end function. The tensors specified in the list
will be passed as callback_kwargs argument. You will only be able to include variables listed in the
._callback_tensor_inputs attribute of your pipeline class. Function invoked when calling the pipeline for generation. Examples: Copied >>> import torch
>>> from diffusers import StableCascadePriorPipeline, StableCascadeDecoderPipeline
>>> prior_pipe = StableCascadePriorPipeline.from_pretrained(
... "stabilityai/stable-cascade-prior", torch_dtype=torch.bfloat16
... ).to("cuda")
>>> gen_pipe = StableCascadeDecoderPipeline.from_pretrain(
... "stabilityai/stable-cascade", torch_dtype=torch.float16
... ).to("cuda")
>>> prompt = "an image of a shiba inu, donning a spacesuit and helmet"
>>> prior_output = pipe(prompt)
>>> images = gen_pipe(prior_output.image_embeddings, prompt=prompt)
DeepCache DeepCache accelerates StableDiffusionPipeline and StableDiffusionXLPipeline by strategically caching and reusing high-level features while efficiently updating low-level features by taking advantage of the U-Net architecture. Start by installing DeepCache: Copied pip install DeepCache Then load and enable t...
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained('runwayml/stable-diffusion-v1-5', torch_dtype=torch.float16).to("cuda")
+ from DeepCache import DeepCacheSDHelper
+ helper = DeepCacheSDHelper(pipe=pipe)
+ helper.set_params(
+ cache_interval=3,
+ cache_branch_id=0,
+ )
+ helper.enable()
image = pipe("a photo of an astronaut on a moon").images[0] The set_params method accepts two arguments: cache_interval and cache_branch_id. cache_interval means the frequency of feature caching, specified as the number of steps between each cache operation. cache_branch_id identifies which branch of the network (ord...
Opting for a lower cache_branch_id or a larger cache_interval can lead to faster inference speed at the expense of reduced image quality (ablation experiments of these two hyperparameters can be found in the paper). Once those arguments are set, use the enable or disable methods to activate or deactivate the DeepCacheS...
Transformer Temporal A Transformer model for video-like data. TransformerTemporalModel class diffusers.models.TransformerTemporalModel < source > ( num_attention_heads: int = 16 attention_head_dim: int = 88 in_channels: Optional = None out_channels: Optional = None num_layers: int = 1 dropout: float = 0.0 norm_num_g...
The number of channels in the input and output (specify if the input is continuous). num_layers (int, optional, defaults to 1) β€” The number of layers of Transformer blocks to use. dropout (float, optional, defaults to 0.0) β€” The dropout probability to use. cross_attention_dim (int, optional) β€” The number of encod...
Configure if the TransformerBlock attention should contain a bias parameter. sample_size (int, optional) β€” The width of the latent images (specify if the input is discrete).
This is fixed during training since it is used to learn a number of position embeddings. activation_fn (str, optional, defaults to "geglu") β€”
Activation function to use in feed-forward. See diffusers.models.activations.get_activation for supported
activation functions. norm_elementwise_affine (bool, optional) β€”
Configure if the TransformerBlock should use learnable elementwise affine parameters for normalization. double_self_attention (bool, optional) β€”
Configure if each TransformerBlock should contain two self-attention layers.
positional_embeddings β€” (str, optional):
The type of positional embeddings to apply to the sequence input before passing use.
num_positional_embeddings β€” (int, optional):
The maximum length of the sequence over which to apply positional embeddings. A Transformer model for video-like data. forward < source > ( hidden_states: FloatTensor encoder_hidden_states: Optional = None timestep: Optional = None class_labels: LongTensor = None num_frames: int = 1 cross_attention_kwargs: Optiona...
Input hidden_states. encoder_hidden_states ( torch.LongTensor of shape (batch size, encoder_hidden_states dim), optional) β€”
Conditional embeddings for cross attention layer. If not given, cross-attention defaults to
self-attention. timestep ( torch.LongTensor, optional) β€”
Used to indicate denoising step. Optional timestep to be applied as an embedding in AdaLayerNorm. class_labels ( torch.LongTensor of shape (batch size, num classes), optional) β€”
Used to indicate class labels conditioning. Optional class labels to be applied as an embedding in
AdaLayerZeroNorm. num_frames (int, optional, defaults to 1) β€”
The number of frames to be processed per batch. This is used to reshape the hidden states. cross_attention_kwargs (dict, optional) β€”
A kwargs dictionary that if specified is passed along to the AttentionProcessor as defined under
self.processor in
diffusers.models.attention_processor. return_dict (bool, optional, defaults to True) β€”
Whether or not to return a UNet2DConditionOutput instead of a plain
tuple. Returns
TransformerTemporalModelOutput or tuple
If return_dict is True, an TransformerTemporalModelOutput is
returned, otherwise a tuple where the first element is the sample tensor.
The TransformerTemporal forward method. TransformerTemporalModelOutput class diffusers.models.transformer_temporal.TransformerTemporalModelOutput < source > ( sample: FloatTensor ) Parameters sample (torch.FloatTensor of shape (batch_size x num_frames, num_channels, height, width)) β€”
The hidden states output conditioned on encoder_hidden_states input. The output of TransformerTemporalModel.
Stable unCLIP Stable unCLIP checkpoints are finetuned from Stable Diffusion 2.1 checkpoints to condition on CLIP image embeddings.
Stable unCLIP still conditions on text embeddings. Given the two separate conditionings, stable unCLIP can be used
for text guided image variation. When combined with an unCLIP prior, it can also be used for full text to image generation. The abstract from the paper is: Contrastive models like CLIP have been shown to learn robust representations of images that capture both semantics and style. To leverage these representations for ...
from diffusers import UnCLIPScheduler, DDPMScheduler, StableUnCLIPPipeline
from diffusers.models import PriorTransformer
from transformers import CLIPTokenizer, CLIPTextModelWithProjection
prior_model_id = "kakaobrain/karlo-v1-alpha"