text stringlengths 0 5.54k |
|---|
Please refer to the mirror site for more information. |
Load pretrained attention processor layers into UNet2DConditionModel. Attention processor layers have to be |
defined in |
cross_attention.py |
and be a torch.nn.Module class. |
This function is experimental and might change in the future |
It is required to be logged in (huggingface-cli login) when you want to use private or gated |
models. |
Activate the special “offline-mode” to use |
this method in a firewalled environment. |
save_attn_procs |
< |
source |
> |
( |
save_directory: typing.Union[str, os.PathLike] |
is_main_process: bool = True |
weights_name: str = 'pytorch_lora_weights.bin' |
save_function: typing.Callable = None |
) |
Parameters |
save_directory (str or os.PathLike) — |
Directory to which to save. Will be created if it doesn’t exist. |
is_main_process (bool, optional, defaults to True) — |
Whether the process calling this is the main process or not. Useful when in distributed training like |
TPUs and need to call this function on all processes. In this case, set is_main_process=True only on |
the main process to avoid race conditions. |
save_function (Callable) — |
The function to use to save the state dictionary. Useful on distributed training like TPUs when one |
need to replace torch.save by another method. Can be configured with the environment variable |
DIFFUSERS_SAVE_MODE. |
Save an attention procesor to a directory, so that it can be re-loaded using the |
[load_attn_procs()](/docs/diffusers/v0.12.0/en/api/loaders#diffusers.loaders.UNet2DConditionLoadersMixin.load_attn_procs) method. |
Prior Transformer The Prior Transformer was originally introduced in Hierarchical Text-Conditional Image Generation with CLIP Latents by Ramesh et al. It is used to predict CLIP image embeddings from CLIP text embeddings; image embeddings are predicted through a denoising diffusion process. The abstract from the paper ... |
The number of embeddings of the model input hidden_states additional_embeddings (int, optional, defaults to 4) — The number of additional tokens appended to the |
projected hidden_states. The actual length of the used hidden_states is num_embeddings + additional_embeddings. dropout (float, optional, defaults to 0.0) — The dropout probability to use. time_embed_act_fn (str, optional, defaults to ‘silu’) — |
The activation function to use to create timestep embeddings. norm_in_type (str, optional, defaults to None) — The normalization layer to apply on hidden states before |
passing to Transformer blocks. Set it to None if normalization is not needed. embedding_proj_norm_type (str, optional, defaults to None) — |
The normalization layer to apply on the input proj_embedding. Set it to None if normalization is not |
needed. encoder_hid_proj_type (str, optional, defaults to linear) — |
The projection layer to apply on the input encoder_hidden_states. Set it to None if |
encoder_hidden_states is None. added_emb_type (str, optional, defaults to prd) — Additional embeddings to condition the model. |
Choose from prd or None. if choose prd, it will prepend a token indicating the (quantized) dot |
product between the text embedding and image embedding as proposed in the unclip paper |
https://arxiv.org/abs/2204.06125 If it is None, no additional embeddings will be prepended. time_embed_dim (int, *optional*, defaults to None) -- The dimension of timestep embeddings. If None, will be set to num_attention_heads * attention_head_dim` embedding_proj_dim (int, optional, default to None) — |
The dimension of proj_embedding. If None, will be set to embedding_dim. clip_embed_dim (int, optional, default to None) — |
The dimension of the output. If None, will be set to embedding_dim. A Prior Transformer model. forward < source > ( hidden_states timestep: Union proj_embedding: FloatTensor encoder_hidden_states: Optional = None attention_mask: Optional = None return_dict: bool = True ) → ~models.prior_transformer.PriorTransform... |
The currently predicted image embeddings. timestep (torch.LongTensor) — |
Current denoising step. proj_embedding (torch.FloatTensor of shape (batch_size, embedding_dim)) — |
Projected embedding vector the denoising process is conditioned on. encoder_hidden_states (torch.FloatTensor of shape (batch_size, num_embeddings, embedding_dim)) — |
Hidden states of the text embeddings the denoising process is conditioned on. attention_mask (torch.BoolTensor of shape (batch_size, num_embeddings)) — |
Text mask for the text embeddings. return_dict (bool, optional, defaults to True) — |
Whether or not to return a ~models.prior_transformer.PriorTransformerOutput instead of a plain |
tuple. Returns |
~models.prior_transformer.PriorTransformerOutput or tuple |
If return_dict is True, a ~models.prior_transformer.PriorTransformerOutput is returned, otherwise a |
tuple is returned where the first element is the sample tensor. |
The PriorTransformer forward method. set_attn_processor < source > ( processor: Union ) Parameters processor (dict of AttentionProcessor or only AttentionProcessor) — |
The instantiated processor class or a dictionary of processor classes that will be set as the processor |
for all Attention layers. |
If processor is a dict, the key needs to define the path to the corresponding cross attention |
processor. This is strongly recommended when setting trainable attention processors. Sets the attention processor to use to compute attention. set_default_attn_processor < source > ( ) Disables custom attention processors and sets the default attention implementation. PriorTransformerOutput class diffusers.mo... |
The predicted CLIP image embedding conditioned on the CLIP text embedding input. The output of PriorTransformer. |
DDIM Denoising Diffusion Implicit Models (DDIM) by Jiaming Song, Chenlin Meng and Stefano Ermon. The abstract from the paper is: Denoising diffusion probabilistic models (DDPMs) have achieved high quality image generation without adversarial training, yet they require simulating a Markov chain for many steps to produce... |
A UNet2DModel to denoise the encoded image latents. scheduler (SchedulerMixin) — |
A scheduler to be used in combination with unet to denoise the encoded image. Can be one of |
DDPMScheduler, or DDIMScheduler. Pipeline for image generation. This model inherits from DiffusionPipeline. Check the superclass documentation for the generic methods |
implemented for all pipelines (downloading, saving, running on a particular device, etc.). __call__ < source > ( batch_size: int = 1 generator: Union = None eta: float = 0.0 num_inference_steps: int = 50 use_clipped_model_output: Optional = None output_type: Optional = 'pil' return_dict: bool = True ) → ImagePipelin... |
The number of images to generate. generator (torch.Generator, optional) — |
A torch.Generator to make |
generation deterministic. eta (float, optional, defaults to 0.0) — |
Corresponds to parameter eta (η) from the DDIM paper. Only applies |
to the DDIMScheduler, and is ignored in other schedulers. A value of 0 corresponds to |
DDIM and 1 corresponds to DDPM. 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. use_clipped_model_output (bool, optional, defaults to None) — |
If True or False, see documentation for DDIMScheduler.step(). If None, nothing is passed |
downstream to the scheduler (use None for schedulers which don’t support this argument). output_type (str, optional, defaults to "pil") — |
The output format of the generated image. Choose between PIL.Image or np.array. return_dict (bool, optional, defaults to True) — |
Whether or not to return a ImagePipelineOutput instead of a plain tuple. Returns |
ImagePipelineOutput or tuple |
If return_dict is True, ImagePipelineOutput is returned, otherwise a tuple is |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.