r""" Pipeline for custom diffusion model. This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.). Args: vae
| 501 | |
| 502 | |
| 503 | class CustomDiffusionXLPipeline(StableDiffusionXLPipeline): |
| 504 | r""" |
| 505 | Pipeline for custom diffusion model. |
| 506 | |
| 507 | This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the |
| 508 | library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.). |
| 509 | |
| 510 | Args: |
| 511 | vae ([`AutoencoderKL`]): |
| 512 | Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations. |
| 513 | text_encoder ([`CLIPTextModel`]): |
| 514 | Frozen text-encoder. Stable Diffusion XL uses the text portion of |
| 515 | [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel), specifically |
| 516 | the [clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14) variant. |
| 517 | text_encoder_2 ([` CLIPTextModelWithProjection`]): |
| 518 | Second frozen text-encoder. Stable Diffusion XL uses the text and pool portion of |
| 519 | [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModelWithProjection), |
| 520 | specifically the |
| 521 | [laion/CLIP-ViT-bigG-14-laion2B-39B-b160k](https://huggingface.co/laion/CLIP-ViT-bigG-14-laion2B-39B-b160k) |
| 522 | variant. |
| 523 | tokenizer (`CLIPTokenizer`): |
| 524 | Tokenizer of class |
| 525 | [CLIPTokenizer](https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer). |
| 526 | tokenizer_2 (`CLIPTokenizer`): |
| 527 | Second Tokenizer of class |
| 528 | [CLIPTokenizer](https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer). |
| 529 | unet ([`UNet2DConditionModel`]): Conditional U-Net architecture to denoise the encoded image latents. |
| 530 | scheduler ([`SchedulerMixin`]): |
| 531 | A scheduler to be used in combination with `unet` to denoise the encoded image latents. Can be one of |
| 532 | [`DDIMScheduler`], [`LMSDiscreteScheduler`], or [`PNDMScheduler`]. |
| 533 | force_zeros_for_empty_prompt (`bool`, *optional*, defaults to `"True"`): |
| 534 | Whether the negative prompt embeddings shall be forced to always be set to 0. Also see the config of |
| 535 | `stabilityai/stable-diffusion-xl-base-1-0`. |
| 536 | add_watermarker (`bool`, *optional*): |
| 537 | Whether to use the [invisible_watermark library](https://github.com/ShieldMnt/invisible-watermark/) to |
| 538 | watermark output images. If not defined, it will default to True if the package is installed, otherwise no |
| 539 | watermarker will be used. |
| 540 | modifier_token: list of new modifier tokens added or to be added to text_encoder |
| 541 | modifier_token_id: list of id of new modifier tokens added or to be added to text_encoder |
| 542 | modifier_token_id_2: list of id of new modifier tokens added or to be added to text_encoder_2 |
| 543 | """ |
| 544 | |
| 545 | def __init__( |
| 546 | self, |
| 547 | vae: AutoencoderKL, |
| 548 | text_encoder: CLIPTextModel, |
| 549 | text_encoder_2: CLIPTextModelWithProjection, |
| 550 | tokenizer: CLIPTokenizer, |
| 551 | tokenizer_2: CLIPTokenizer, |
| 552 | unet: UNet2DConditionModel, |
| 553 | scheduler: KarrasDiffusionSchedulers, |
| 554 | force_zeros_for_empty_prompt: bool = True, |
| 555 | add_watermarker: Optional[bool] = None, |
| 556 | modifier_token: list = [], |
| 557 | modifier_token_id: list = [], |
| 558 | modifier_token_id_2: list = [] |
| 559 | ): |
| 560 | super().__init__(vae, |
nothing calls this directly
no outgoing calls
no test coverage detected