text stringlengths 0 5.54k |
|---|
weighting. If not provided, negative_prompt_embeds will be generated from negative_prompt input |
argument. pooled_prompt_embeds (torch.FloatTensor, optional) — |
Pre-generated pooled text embeddings. Can be used to easily tweak text inputs, e.g. prompt weighting. |
If not provided, pooled text embeddings will be generated from prompt input argument. negative_pooled_prompt_embeds (torch.FloatTensor, optional) — |
Pre-generated negative pooled text embeddings. Can be used to easily tweak text inputs, e.g. prompt |
weighting. If not provided, pooled negative_prompt_embeds will be generated from negative_prompt |
input argument. lora_scale (float, optional) — |
A lora scale that will be applied to all LoRA layers of the text encoder if LoRA layers are loaded. 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. Encodes the prompt into text encoder hidden states. StableDiffusionPipelineOutput class diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput < source > ( images: Union nsfw_content_detected: Optional ) Parameters ... |
List of denoised PIL images of length batch_size or NumPy array of shape (batch_size, height, width, num_channels). nsfw_content_detected (List[bool]) — |
List indicating whether the corresponding generated image contains “not-safe-for-work” (nsfw) content or |
None if safety checking could not be performed. Output class for Stable Diffusion pipelines. |
DiffEdit DiffEdit: Diffusion-based semantic image editing with mask guidance is by Guillaume Couairon, Jakob Verbeek, Holger Schwenk, and Matthieu Cord. The abstract from the paper is: Image generation has recently seen tremendous advances, with diffusion models allowing to synthesize convincing images for a large vari... |
and a set of partially inverted latents (generated using invert()) must be provided as arguments when calling the pipeline to generate the final edited image. The function generate_mask() exposes two prompt arguments, source_prompt and target_prompt |
that let you control the locations of the semantic edits in the final image to be generated. Let’s say, |
you wanted to translate from “cat” to “dog”. In this case, the edit direction will be “cat -> dog”. To reflect |
this in the generated mask, you simply have to set the embeddings related to the phrases including “cat” to |
source_prompt and “dog” to target_prompt. When generating partially inverted latents using invert, assign a caption or text embedding describing the |
overall image to the prompt argument to help guide the inverse latent sampling process. In most cases, the |
source concept is sufficiently descriptive to yield good results, but feel free to explore alternatives. When calling the pipeline to generate the final edited image, assign the source concept to negative_prompt |
and the target concept to prompt. Taking the above example, you simply have to set the embeddings related to |
the phrases including “cat” to negative_prompt and “dog” to prompt. If you wanted to reverse the direction in the example above, i.e., “dog -> cat”, then it’s recommended to:Swap the source_prompt and target_prompt in the arguments to generate_mask. Change the input prompt in invert() to include “dog”. Swap the prompt ... |
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. inverse_scheduler (DDIMInverseScheduler) — |
A scheduler to be used in combination with unet to fill in the unmasked part of the input latents. 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. This is an experimental feature! Pipeline for text-guided image inpainting using Stable Diffusion and DiffEdit. 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 and saving methods: load_textual_inversion() for loading textual inversion embeddings load_lora_weights() for loading LoRA weights save_lora_weights() for saving LoRA weights gene... |
Image or tensor representing an image batch to be used for computing the mask. target_prompt (str or List[str], optional) — |
The prompt or prompts to guide semantic mask generation. If not defined, you need to pass |
prompt_embeds. target_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). target_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. target_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. source_prompt (str or List[str], optional) — |
The prompt or prompts to guide semantic mask generation using DiffEdit. If not defined, you need to |
pass source_prompt_embeds or source_image instead. source_negative_prompt (str or List[str], optional) — |
The prompt or prompts to guide semantic mask generation away from using DiffEdit. If not defined, you |
need to pass source_negative_prompt_embeds or source_image instead. source_prompt_embeds (torch.FloatTensor, optional) — |
Pre-generated text embeddings to guide the semantic mask generation. Can be used to easily tweak text |
inputs (prompt weighting). If not provided, text embeddings are generated from source_prompt input |
argument. source_negative_prompt_embeds (torch.FloatTensor, optional) — |
Pre-generated text embeddings to negatively guide the semantic mask generation. Can be used to easily |
tweak text inputs (prompt weighting). If not provided, text embeddings are generated from |
source_negative_prompt input argument. num_maps_per_mask (int, optional, defaults to 10) — |
The number of noise maps sampled to generate the semantic mask using DiffEdit. mask_encode_strength (float, optional, defaults to 0.5) — |
The strength of the noise maps sampled to generate the semantic mask using DiffEdit. Must be between 0 |
and 1. mask_thresholding_ratio (float, optional, defaults to 3.0) — |
The maximum multiple of the mean absolute difference used to clamp the semantic guidance map before |
mask binarization. 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. generator (torch.Generator or List[torch.Generator], optional) — |
A torch.Generator to make |
generation deterministic. output_type (str, optional, defaults to "pil") — |
The output format of the generated image. Choose between PIL.Image or np.array. cross_attention_kwargs (dict, optional) — |
A kwargs dictionary that if specified is passed along to the |
AttnProcessor as defined in |
self.processor. Returns |
List[PIL.Image.Image] or np.array |
When returning a List[PIL.Image.Image], the list consists of a batch of single-channel binary images |
with dimensions (height // self.vae_scale_factor, width // self.vae_scale_factor). If it’s |
np.array, the shape is (batch_size, height // self.vae_scale_factor, width // self.vae_scale_factor). |
Generate a latent mask given a mask prompt, a target prompt, and an image. Copied >>> import PIL |
>>> import requests |
>>> import torch |
>>> from io import BytesIO |
>>> from diffusers import StableDiffusionDiffEditPipeline |
>>> def download_image(url): |
... response = requests.get(url) |
... return PIL.Image.open(BytesIO(response.content)).convert("RGB") |
>>> img_url = "https://github.com/Xiang-cd/DiffEdit-stable-diffusion/raw/main/assets/origin.png" |
>>> init_image = download_image(img_url).resize((768, 768)) |
>>> pipe = StableDiffusionDiffEditPipeline.from_pretrained( |
... "stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16 |
... ) |
>>> pipe = pipe.to("cuda") |
>>> pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config) |
>>> pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config) |
>>> pipeline.enable_model_cpu_offload() |
>>> mask_prompt = "A bowl of fruits" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.