(
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 = 1024,
width: int = 1024,
original_height: int = None,
original_width: int = None,
original_height_negative: int = None,
original_width_negative: int = None,
crop_top: int = 0,
crop_left: int = 0,
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_guide_images=None,
emb_normalize_mode: str = "original",
force_scheduler_zero_steps_offset: bool = False,
**kwargs,
)
| 405 | |
| 406 | @torch.no_grad() |
| 407 | def __call__( |
| 408 | self, |
| 409 | prompt: Union[str, List[str]], |
| 410 | negative_prompt: Optional[Union[str, List[str]]] = None, |
| 411 | init_image: Union[torch.FloatTensor, PIL.Image.Image, List[PIL.Image.Image]] = None, |
| 412 | mask_image: Union[torch.FloatTensor, PIL.Image.Image, List[PIL.Image.Image]] = None, |
| 413 | height: int = 1024, |
| 414 | width: int = 1024, |
| 415 | original_height: int = None, |
| 416 | original_width: int = None, |
| 417 | original_height_negative: int = None, |
| 418 | original_width_negative: int = None, |
| 419 | crop_top: int = 0, |
| 420 | crop_left: int = 0, |
| 421 | num_inference_steps: int = 50, |
| 422 | guidance_scale: float = 7.5, |
| 423 | negative_scale: float = None, |
| 424 | strength: float = 0.8, |
| 425 | # num_images_per_prompt: Optional[int] = 1, |
| 426 | eta: float = 0.0, |
| 427 | generator: Optional[torch.Generator] = None, |
| 428 | latents: Optional[torch.FloatTensor] = None, |
| 429 | max_embeddings_multiples: Optional[int] = 3, |
| 430 | output_type: Optional[str] = "pil", |
| 431 | vae_batch_size: float = None, |
| 432 | return_latents: bool = False, |
| 433 | # return_dict: bool = True, |
| 434 | callback: Optional[Callable[[int, int, torch.FloatTensor], None]] = None, |
| 435 | is_cancelled_callback: Optional[Callable[[], bool]] = None, |
| 436 | callback_steps: Optional[int] = 1, |
| 437 | img2img_noise=None, |
| 438 | clip_guide_images=None, |
| 439 | emb_normalize_mode: str = "original", |
| 440 | force_scheduler_zero_steps_offset: bool = False, |
| 441 | **kwargs, |
| 442 | ): |
| 443 | # TODO support secondary prompt |
| 444 | num_images_per_prompt = 1 # fixed because already prompt is repeated |
| 445 | |
| 446 | if isinstance(prompt, str): |
| 447 | batch_size = 1 |
| 448 | prompt = [prompt] |
| 449 | elif isinstance(prompt, list): |
| 450 | batch_size = len(prompt) |
| 451 | else: |
| 452 | raise ValueError(f"`prompt` has to be of type `str` or `list` but is {type(prompt)}") |
| 453 | regional_network = " AND " in prompt[0] |
| 454 | |
| 455 | vae_batch_size = ( |
| 456 | batch_size |
| 457 | if vae_batch_size is None |
| 458 | else (int(vae_batch_size) if vae_batch_size >= 1 else max(1, int(batch_size * vae_batch_size))) |
| 459 | ) |
| 460 | |
| 461 | if strength < 0 or strength > 1: |
| 462 | raise ValueError(f"The value of strength should in [0.0, 1.0] but is {strength}") |
| 463 | |
| 464 | if height % 8 != 0 or width % 8 != 0: |
nothing calls this directly
no test coverage detected