text
stringlengths
0
5.54k
A CLIPTokenizer to tokenize text. unet (UNet2DConditionModel) β€”
A UNet2DConditionModel to denoise the encoded image latents. controlnet (ControlNetModel or List[ControlNetModel]) β€”
Provides additional conditioning to the unet during the denoising process. If you set multiple
ControlNets as a list, the outputs from each ControlNet are added together to create one combined
additional conditioning. 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. safety_checker (StableDiffusionSafetyChecker) β€”
Classification module that estimates whether generated images could be considered offensive or harmful.
Please refer to the model card for more details
about a model’s potential harms. feature_extractor (CLIPImageProcessor) β€”
A CLIPImageProcessor to extract features from generated images; used as inputs to the safety_checker. Pipeline for image inpainting using Stable Diffusion with ControlNet guidance. 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 from_single_file...
(runwayml/stable-diffusion-inpainting) as well as
default text-to-image Stable Diffusion checkpoints
(runwayml/stable-diffusion-v1-5). Default text-to-image
Stable Diffusion checkpoints might be preferable for ControlNets that have been fine-tuned on those, such as
lllyasviel/control_v11p_sd15_inpaint. __call__ < source > ( prompt: Union = None image: Union = None mask_image: Union = None control_image: Union = None height: Optional = None width: Optional = None padding_mask_crop: Optional = None strength: float = 1.0 num_inference_steps: int = 50 guidance_scale: float = 7.5 ne...
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, NumPy array or tensor representing an image batch to be used as the starting point. For both
NumPy array and PyTorch tensor, the expected value range is between [0, 1]. If it’s a tensor or a
list or tensors, the expected shape should be (B, C, H, W) or (C, H, W). If it is a NumPy array or
a list of arrays, the expected shape should be (B, H, W, C) or (H, W, C). It can also accept image
latents as image, but if passing latents directly it is not encoded again. mask_image (torch.FloatTensor, PIL.Image.Image, np.ndarray, List[torch.FloatTensor], β€”
List[PIL.Image.Image], or List[np.ndarray]):
Image, NumPy array or tensor representing an image batch to mask image. White pixels in the mask
are repainted while black pixels are preserved. If mask_image is a PIL image, it is converted to a
single channel (luminance) before use. If it’s a NumPy array or PyTorch tensor, it should contain one
color channel (L) instead of 3, so the expected shape for PyTorch tensor would be (B, 1, H, W), (B, H, W), (1, H, W), (H, W). And for NumPy array, it would be for (B, H, W, 1), (B, H, W), (H, W, 1), or (H, W). control_image (torch.FloatTensor, PIL.Image.Image, List[torch.FloatTensor], List[PIL.Image.Image], β€”
List[List[torch.FloatTensor]], or List[List[PIL.Image.Image]]):
The ControlNet input condition to provide guidance to the unet for generation. If the type is
specified as torch.FloatTensor, it is passed to ControlNet as is. PIL.Image.Image can also be
accepted as an image. The dimensions of the output image defaults to image’s dimensions. If height
and/or width are passed, image is resized accordingly. If multiple ControlNets are specified in
init, images must be passed as a list such that each element of the list can be correctly batched for
input to a single ControlNet. height (int, optional, defaults to self.unet.config.sample_size * self.vae_scale_factor) β€”
The height in pixels of the generated image. width (int, optional, defaults to self.unet.config.sample_size * self.vae_scale_factor) β€”
The width in pixels of the generated image. padding_mask_crop (int, optional, defaults to None) β€”
The size of margin in the crop to be applied to the image and masking. If None, no crop is applied to image and mask_image. If
padding_mask_crop is not None, it will first find a rectangular region with the same aspect ration of the image and
contains all masked area, and then expand that area based on padding_mask_crop. The image and mask_image will then be cropped based on
the expanded area before resizing to the original image size for inpainting. This is useful when the masked area is small while the image is large
and contain information inreleant for inpainging, such as background. strength (float, optional, defaults to 1.0) β€”
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. 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. 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 is generated by sampling using the supplied random generator. 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.
ip_adapter_image β€” (PipelineImageInput, optional): Optional image input to work with IP Adapters. ip_adapter_image_embeds (List[torch.FloatTensor], optional) β€”
Pre-generated image embeddings for IP-Adapter. It should be a list of length same as number of IP-adapters.
Each element should be a tensor of shape (batch_size, num_images, emb_dim). It should contain the negative image embedding
if do_classifier_free_guidance is set to True.
If not provided, embeddings are computed from the ip_adapter_image 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. controlnet_conditioning_scale (float or List[float], optional, defaults to 0.5) β€”
The outputs of the ControlNet are multiplied by controlnet_conditioning_scale before they are added
to the residual in the original unet. If multiple ControlNets are specified in init, you can set
the corresponding scale as a list. guess_mode (bool, optional, defaults to False) β€”
The ControlNet encoder tries to recognize the content of the input image even if you remove all
prompts. A guidance_scale value between 3.0 and 5.0 is recommended. control_guidance_start (float or List[float], optional, defaults to 0.0) β€”
The percentage of total steps at which the ControlNet starts applying. control_guidance_end (float or List[float], optional, defaults to 1.0) β€”
The percentage of total steps at which the ControlNet stops applying. 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 pipeine class. Returns
StableDiffusionPipelineOutput or tuple
If return_dict is True, StableDiffusionPipelineOutput is returned,
otherwise a tuple is returned where the first element is a list with the generated images and the
second element is a list of bools indicating whether the corresponding generated image contains
β€œnot-safe-for-work” (nsfw) content.
The call function to the pipeline for generation. Examples: Copied >>> # !pip install transformers accelerate
>>> from diffusers import StableDiffusionControlNetInpaintPipeline, ControlNetModel, DDIMScheduler
>>> from diffusers.utils import load_image