Skip to content

Commit 9c23aed

Browse files
authored
Merge branch 'main' into patch-1
2 parents cff1e06 + f1f542b commit 9c23aed

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ def check_inputs(
513513
pooled_prompt_embeds=None,
514514
negative_pooled_prompt_embeds=None,
515515
callback_on_step_end_tensor_inputs=None,
516+
max_sequence_length=None,
516517
):
517518
if height % 8 != 0 or width % 8 != 0:
518519
raise ValueError(f"`height` and `width` have to be divisible by 8 but are {height} and {width}.")
@@ -584,6 +585,9 @@ def check_inputs(
584585
"If `negative_prompt_embeds` are provided, `negative_pooled_prompt_embeds` also have to be passed. Make sure to generate `negative_pooled_prompt_embeds` from the same text encoder that was used to generate `negative_prompt_embeds`."
585586
)
586587

588+
if max_sequence_length is not None and max_sequence_length > 512:
589+
raise ValueError(f"`max_sequence_length` cannot be greater than 512 but is {max_sequence_length}")
590+
587591
# Copied from diffusers.pipelines.stable_diffusion_3.pipeline_stable_diffusion_3.StableDiffusion3Pipeline.prepare_latents
588592
def prepare_latents(
589593
self,
@@ -710,6 +714,7 @@ def __call__(
710714
clip_skip: Optional[int] = None,
711715
callback_on_step_end: Optional[Callable[[int, int, Dict], None]] = None,
712716
callback_on_step_end_tensor_inputs: List[str] = ["latents"],
717+
max_sequence_length: int = 256,
713718
):
714719
r"""
715720
Function invoked when calling the pipeline for generation.
@@ -811,6 +816,7 @@ def __call__(
811816
The list of tensor inputs for the `callback_on_step_end` function. The tensors specified in the list
812817
will be passed as `callback_kwargs` argument. You will only be able to include variables listed in the
813818
`._callback_tensor_inputs` attribute of your pipeline class.
819+
max_sequence_length (`int` defaults to 256): Maximum sequence length to use with the `prompt`.
814820
815821
Examples:
816822
@@ -850,6 +856,7 @@ def __call__(
850856
pooled_prompt_embeds=pooled_prompt_embeds,
851857
negative_pooled_prompt_embeds=negative_pooled_prompt_embeds,
852858
callback_on_step_end_tensor_inputs=callback_on_step_end_tensor_inputs,
859+
max_sequence_length=max_sequence_length,
853860
)
854861

855862
self._guidance_scale = guidance_scale
@@ -888,6 +895,7 @@ def __call__(
888895
device=device,
889896
clip_skip=self.clip_skip,
890897
num_images_per_prompt=num_images_per_prompt,
898+
max_sequence_length=max_sequence_length,
891899
)
892900

893901
if self.do_classifier_free_guidance:

0 commit comments

Comments
 (0)