text stringlengths 0 5.54k |
|---|
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" |
>>> prompt = "A bowl of pears" |
>>> mask_image = pipe.generate_mask(image=init_image, source_prompt=prompt, target_prompt=mask_prompt) |
>>> image_latents = pipe.invert(image=init_image, prompt=mask_prompt).latents |
>>> image = pipe(prompt=prompt, mask_image=mask_image, image_latents=image_latents).images[0] invert < source > ( prompt: Union = None image: Union = None num_inference_steps: int = 50 inpaint_strength: float = 0.8 guidance_scale: float = 7.5 negative_prompt: Union = None generator: Union = None prompt_embeds: Optional = None negative_prompt_embeds: Optional = None decode_latents: bool = False output_type: Optional = 'pil' return_dict: bool = True callback: Optional = None callback_steps: Optional = 1 cross_attention_kwargs: Optional = None lambda_auto_corr: float = 20.0 lambda_kl: float = 20.0 num_reg_steps: int = 0 num_auto_corr_rolls: int = 5 ) Parameters prompt (str or List[str], optional) β |
The prompt or prompts to guide image generation. If not defined, you need to pass prompt_embeds. image (PIL.Image.Image) β |
Image or tensor representing an image batch to produce the inverted latents guided by prompt. inpaint_strength (float, optional, defaults to 0.8) β |
Indicates extent of the noising process to run latent inversion. Must be between 0 and 1. When |
inpaint_strength is 1, the inversion process is run for the full number of iterations specified in |
num_inference_steps. image is used as a reference for the inversion process, and adding more noise |
increases inpaint_strength. If inpaint_strength is 0, no inpainting occurs. 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). generator (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. decode_latents (bool, optional, defaults to False) β |
Whether or not to decode the inverted latents into a generated image. Setting this argument to True |
decodes all inverted latents for each timestep into a list of generated images. 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 ~pipelines.stable_diffusion.DiffEditInversionPipelineOutput instead of a |
plain tuple. callback (Callable, optional) β |
A function that calls every callback_steps steps during inference. The function is called with the |
following arguments: callback(step: int, timestep: int, latents: torch.FloatTensor). callback_steps (int, optional, defaults to 1) β |
The frequency at which the callback function is called. If not specified, the callback is called at |
every step. cross_attention_kwargs (dict, optional) β |
A kwargs dictionary that if specified is passed along to the |
AttnProcessor as defined in |
self.processor. lambda_auto_corr (float, optional, defaults to 20.0) β |
Lambda parameter to control auto correction. lambda_kl (float, optional, defaults to 20.0) β |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.