Skip to content

Commit

Permalink
Added Error when len(gligen_images ) is not equal to len(gligen_phras…
Browse files Browse the repository at this point in the history
…es) in StableDiffusionGLIGENTextImagePipeline (#10176)

* added check value error

* fix style
  • Loading branch information
SahilCarterr authored and sayakpaul committed Dec 23, 2024
1 parent d38bca7 commit d1411b3
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,14 @@ def prepare_extra_step_kwargs(self, generator, eta):
extra_step_kwargs["generator"] = generator
return extra_step_kwargs

# Copied from diffusers.pipelines.stable_diffusion_k_diffusion.pipeline_stable_diffusion_k_diffusion.StableDiffusionKDiffusionPipeline.check_inputs
def check_inputs(
self,
prompt,
height,
width,
callback_steps,
gligen_images,
gligen_phrases,
negative_prompt=None,
prompt_embeds=None,
negative_prompt_embeds=None,
Expand Down Expand Up @@ -499,6 +500,13 @@ def check_inputs(
f" {negative_prompt_embeds.shape}."
)

if gligen_images is not None and gligen_phrases is not None:
if len(gligen_images) != len(gligen_phrases):
raise ValueError(
"`gligen_images` and `gligen_phrases` must have the same length when both are provided, but"
f" got: `gligen_images` with length {len(gligen_images)} != `gligen_phrases` with length {len(gligen_phrases)}."
)

# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.prepare_latents
def prepare_latents(self, batch_size, num_channels_latents, height, width, dtype, device, generator, latents=None):
shape = (
Expand Down Expand Up @@ -814,6 +822,8 @@ def __call__(
height,
width,
callback_steps,
gligen_images,
gligen_phrases,
negative_prompt,
prompt_embeds,
negative_prompt_embeds,
Expand Down

0 comments on commit d1411b3

Please sign in to comment.