r""" Function invoked when calling the pipeline for generation. Args: prompt (`str` or `List[str]`): The prompt or prompts to guide the image generation. negative_prompt (`str` or `List[str]`, *optional*): The prompt or prompts
(
self,
prompt: Union[str, List[str]],
negative_prompt: Optional[Union[str, List[str]]] = None,
init_image: Union[torch.FloatTensor, PIL.Image.Image, List[PIL.Image.Image]] = None,
mask_image: Union[torch.FloatTensor, PIL.Image.Image, List[PIL.Image.Image]] = None,
height: int = 512,
width: int = 512,
num_inference_steps: int = 50,
guidance_scale: float = 7.5,
negative_scale: float = None,
strength: float = 0.8,
# num_images_per_prompt: Optional[int] = 1,
eta: float = 0.0,
generator: Optional[torch.Generator] = None,
latents: Optional[torch.FloatTensor] = None,
max_embeddings_multiples: Optional[int] = 3,
output_type: Optional[str] = "pil",
vae_batch_size: float = None,
return_latents: bool = False,
# return_dict: bool = True,
callback: Optional[Callable[[int, int, torch.FloatTensor], None]] = None,
is_cancelled_callback: Optional[Callable[[], bool]] = None,
callback_steps: Optional[int] = 1,
img2img_noise=None,
clip_prompts=None,
clip_guide_images=None,
networks: Optional[List[LoRANetwork]] = None,
**kwargs,
)
| 724 | |
| 725 | @torch.no_grad() |
| 726 | def __call__( |
| 727 | self, |
| 728 | prompt: Union[str, List[str]], |
| 729 | negative_prompt: Optional[Union[str, List[str]]] = None, |
| 730 | init_image: Union[torch.FloatTensor, PIL.Image.Image, List[PIL.Image.Image]] = None, |
| 731 | mask_image: Union[torch.FloatTensor, PIL.Image.Image, List[PIL.Image.Image]] = None, |
| 732 | height: int = 512, |
| 733 | width: int = 512, |
| 734 | num_inference_steps: int = 50, |
| 735 | guidance_scale: float = 7.5, |
| 736 | negative_scale: float = None, |
| 737 | strength: float = 0.8, |
| 738 | # num_images_per_prompt: Optional[int] = 1, |
| 739 | eta: float = 0.0, |
| 740 | generator: Optional[torch.Generator] = None, |
| 741 | latents: Optional[torch.FloatTensor] = None, |
| 742 | max_embeddings_multiples: Optional[int] = 3, |
| 743 | output_type: Optional[str] = "pil", |
| 744 | vae_batch_size: float = None, |
| 745 | return_latents: bool = False, |
| 746 | # return_dict: bool = True, |
| 747 | callback: Optional[Callable[[int, int, torch.FloatTensor], None]] = None, |
| 748 | is_cancelled_callback: Optional[Callable[[], bool]] = None, |
| 749 | callback_steps: Optional[int] = 1, |
| 750 | img2img_noise=None, |
| 751 | clip_prompts=None, |
| 752 | clip_guide_images=None, |
| 753 | networks: Optional[List[LoRANetwork]] = None, |
| 754 | **kwargs, |
| 755 | ): |
| 756 | r""" |
| 757 | Function invoked when calling the pipeline for generation. |
| 758 | Args: |
| 759 | prompt (`str` or `List[str]`): |
| 760 | The prompt or prompts to guide the image generation. |
| 761 | negative_prompt (`str` or `List[str]`, *optional*): |
| 762 | The prompt or prompts not to guide the image generation. Ignored when not using guidance (i.e., ignored |
| 763 | if `guidance_scale` is less than `1`). |
| 764 | init_image (`torch.FloatTensor` or `PIL.Image.Image`): |
| 765 | `Image`, or tensor representing an image batch, that will be used as the starting point for the |
| 766 | process. |
| 767 | mask_image (`torch.FloatTensor` or `PIL.Image.Image`): |
| 768 | `Image`, or tensor representing an image batch, to mask `init_image`. White pixels in the mask will be |
| 769 | replaced by noise and therefore repainted, while black pixels will be preserved. If `mask_image` is a |
| 770 | PIL image, it will be converted to a single channel (luminance) before use. If it's a tensor, it should |
| 771 | contain one color channel (L) instead of 3, so the expected shape would be `(B, H, W, 1)`. |
| 772 | height (`int`, *optional*, defaults to 512): |
| 773 | The height in pixels of the generated image. |
| 774 | width (`int`, *optional*, defaults to 512): |
| 775 | The width in pixels of the generated image. |
| 776 | num_inference_steps (`int`, *optional*, defaults to 50): |
| 777 | The number of denoising steps. More denoising steps usually lead to a higher quality image at the |
| 778 | expense of slower inference. |
| 779 | guidance_scale (`float`, *optional*, defaults to 7.5): |
| 780 | Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598). |
| 781 | `guidance_scale` is defined as `w` of equation 2. of [Imagen |
| 782 | Paper](https://arxiv.org/pdf/2205.11487.pdf). Guidance scale is enabled by setting `guidance_scale > |
| 783 | 1`. Higher guidance scale encourages to generate images that are closely linked to the text `prompt`, |
no test coverage detected