text stringlengths 0 5.54k |
|---|
Whether to include the bias parameter in train_q_out. dropout (float, optional, defaults to 0.0) β |
The dropout probability to use. Processor for implementing attention for the Custom Diffusion method using PyTorch 2.0βs memory-efficient scaled |
dot-product attention. CustomDiffusionXFormersAttnProcessor class diffusers.models.attention_processor.CustomDiffusionXFormersAttnProcessor < source > ( train_kv: bool = True train_q_out: bool = False hidden_size: Optional = None cross_attention_dim: Optional = None out_bias: bool = True dropout: float = 0.0 attenti... |
Whether to newly train the key and value matrices corresponding to the text features. train_q_out (bool, defaults to True) β |
Whether to newly train query matrices corresponding to the latent image features. hidden_size (int, optional, defaults to None) β |
The hidden size of the attention layer. cross_attention_dim (int, optional, defaults to None) β |
The number of channels in the encoder_hidden_states. out_bias (bool, defaults to True) β |
Whether to include the bias parameter in train_q_out. dropout (float, optional, defaults to 0.0) β |
The dropout probability to use. attention_op (Callable, optional, defaults to None) β |
The base |
operator to use |
as the attention operator. It is recommended to set to None, and allow xFormers to choose the best operator. Processor for implementing memory efficient attention using xFormers for the Custom Diffusion method. FusedAttnProcessor2_0 class diffusers.models.attention_processor.FusedAttnProcessor2_0 < source > ( ) ... |
It uses fused projection layers. For self-attention modules, all projection matrices (i.e., query, |
key, value) are fused. For cross-attention modules, key and value projection matrices are fused. This API is currently π§ͺ experimental in nature and can change in future. LoRAAttnAddedKVProcessor class diffusers.models.attention_processor.LoRAAttnAddedKVProcessor < source > ( hidden_size: int cross_attention_dim: Op... |
The hidden size of the attention layer. cross_attention_dim (int, optional, defaults to None) β |
The number of channels in the encoder_hidden_states. rank (int, defaults to 4) β |
The dimension of the LoRA update matrices. network_alpha (int, optional) β |
Equivalent to alpha but itβs usage is specific to Kohya (A1111) style LoRAs. kwargs (dict) β |
Additional keyword arguments to pass to the LoRALinearLayer layers. Processor for implementing the LoRA attention mechanism with extra learnable key and value matrices for the text |
encoder. LoRAXFormersAttnProcessor class diffusers.models.attention_processor.LoRAXFormersAttnProcessor < source > ( hidden_size: int cross_attention_dim: int rank: int = 4 attention_op: Optional = None network_alpha: Optional = None **kwargs ) Parameters hidden_size (int, optional) β |
The hidden size of the attention layer. cross_attention_dim (int, optional) β |
The number of channels in the encoder_hidden_states. rank (int, defaults to 4) β |
The dimension of the LoRA update matrices. attention_op (Callable, optional, defaults to None) β |
The base |
operator to |
use as the attention operator. It is recommended to set to None, and allow xFormers to choose the best |
operator. network_alpha (int, optional) β |
Equivalent to alpha but itβs usage is specific to Kohya (A1111) style LoRAs. kwargs (dict) β |
Additional keyword arguments to pass to the LoRALinearLayer layers. Processor for implementing the LoRA attention mechanism with memory efficient attention using xFormers. SlicedAttnProcessor class diffusers.models.attention_processor.SlicedAttnProcessor < source > ( slice_size: int ) Parameters slice_size (... |
The number of steps to compute attention. Uses as many slices as attention_head_dim // slice_size, and |
attention_head_dim must be a multiple of the slice_size. Processor for implementing sliced attention. SlicedAttnAddedKVProcessor class diffusers.models.attention_processor.SlicedAttnAddedKVProcessor < source > ( slice_size ) Parameters slice_size (int, optional) β |
The number of steps to compute attention. Uses as many slices as attention_head_dim // slice_size, and |
attention_head_dim must be a multiple of the slice_size. Processor for implementing sliced attention with extra learnable key and value matrices for the text encoder. XFormersAttnProcessor class diffusers.models.attention_processor.XFormersAttnProcessor < source > ( attention_op: Optional = None ) Parameters ... |
The base |
operator to |
use as the attention operator. It is recommended to set to None, and allow xFormers to choose the best |
operator. Processor for implementing memory efficient attention using xFormers. |
Text-guided depth-to-image generation The StableDiffusionDepth2ImgPipeline lets you pass a text prompt and an initial image to condition the generation of new images. In addition, you can also pass a depth_map to preserve the image structure. If no depth_map is provided, the pipeline automatically predicts t... |
from diffusers import StableDiffusionDepth2ImgPipeline |
from diffusers.utils import load_image, make_image_grid |
pipeline = StableDiffusionDepth2ImgPipeline.from_pretrained( |
"stabilityai/stable-diffusion-2-depth", |
torch_dtype=torch.float16, |
use_safetensors=True, |
).to("cuda") Now pass your prompt to the pipeline. You can also pass a negative_prompt to prevent certain words from guiding how an image is generated: Copied url = "http://images.cocodataset.org/val2017/000000039769.jpg" |
init_image = load_image(url) |
prompt = "two tigers" |
negative_prompt = "bad, deformed, ugly, bad anatomy" |
image = pipeline(prompt=prompt, image=init_image, negative_prompt=negative_prompt, strength=0.7).images[0] |
make_image_grid([init_image, image], rows=1, cols=2) Input Output |
Depth-to-image The Stable Diffusion model can also infer depth based on an image using MiDaS. This allows you to pass a text prompt and an initial image to condition the generation of new images as well as a depth_map to preserve the image structure. Make sure to check out the Stable Diffusion Tips section to learn how... |
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations. text_encoder (CLIPTextModel) β |
Frozen text-encoder (clip-vit-large-patch14). tokenizer (CLIPTokenizer) β |
A CLIPTokenizer to tokenize text. unet (UNet2DConditionModel) β |
A UNet2DConditionModel to denoise the encoded image latents. scheduler (SchedulerMixin) β |
A scheduler to be used in combination with unet to denoise the encoded image latents. Can be one of |
DDIMScheduler, LMSDiscreteScheduler, or PNDMScheduler. Pipeline for text-guided depth-based image-to-image generation using Stable Diffusion. 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.). The pipeline also inherits the following loading methods: load_textual_inversion() for loading textual inversion embeddings load_lora_weights() for loading LoRA weights save_lora_weights() for saving LoRA weights __call__ < sou... |
The prompt or prompts to guide image generation. If not defined, you need to pass prompt_embeds. image (torch.FloatTensor, PIL.Image.Image, np.ndarray, List[torch.FloatTensor], List[PIL.Image.Image], or List[np.ndarray]) β |
Image or tensor representing an image batch to be used as the starting point. Can accept image |
latents as image only if depth_map is not None. depth_map (torch.FloatTensor, optional) β |
Depth prediction to be used as additional conditioning for the image generation process. If not |
defined, it automatically predicts the depth with self.depth_estimator. strength (float, optional, defaults to 0.8) β |
Indicates extent to transform the reference image. Must be between 0 and 1. image is used as a |
starting point and more noise is added the higher the strength. The number of denoising steps depends |
on the amount of noise initially added. When strength is 1, added noise is maximum and the denoising |
process runs for the full number of iterations specified in num_inference_steps. A value of 1 |
essentially ignores image. 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. This parameter is modulated by strength. guidance_scale (float, optional, defaults to 7.5) β |
A higher guidance scale value encourages the model to generate images closely linked to the text |
prompt at the expense of lower image quality. Guidance scale is enabled when guidance_scale > 1. negative_prompt (str or List[str], optional) β |
The prompt or prompts to guide what to not include in image generation. If not defined, you need to |
pass negative_prompt_embeds instead. Ignored when not using guidance (guidance_scale < 1). num_images_per_prompt (int, optional, defaults to 1) β |
The number of images to generate per prompt. 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. generator (torch.Generator or List[torch.Generator], optional) β |
A torch.Generator to make |
generation deterministic. prompt_embeds (torch.FloatTensor, optional) β |
Pre-generated text embeddings. Can be used to easily tweak text inputs (prompt weighting). If not |
provided, text embeddings are generated from the prompt input argument. negative_prompt_embeds (torch.FloatTensor, optional) β |
Pre-generated negative text embeddings. Can be used to easily tweak text inputs (prompt weighting). If |
not provided, negative_prompt_embeds are generated from the negative_prompt input 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 StableDiffusionPipelineOutput instead of a |
plain tuple. cross_attention_kwargs (dict, optional) β |
A kwargs dictionary that if specified is passed along to the AttentionProcessor as defined in |
self.processor. clip_skip (int, optional) β |
Number of layers to be skipped from CLIP while computing the prompt embeddings. A value of 1 means that |
the output of the pre-final layer will be used for computing the prompt embeddings. 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. Returns |
StableDiffusionPipelineOutput or tuple |
If return_dict is True, StableDiffusionPipelineOutput is returned, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.