Skip to content

Commit 27acef8

Browse files
committed
check inputs
1 parent bf2e149 commit 27acef8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/diffusers/pipelines/flux/pipeline_flux_prior_redux.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def check_inputs(
146146
self,
147147
prompt,
148148
prompt_2,
149+
image,
149150
prompt_embeds=None,
150151
pooled_prompt_embeds=None,
151152
):
@@ -164,7 +165,8 @@ def check_inputs(
164165
raise ValueError(f"`prompt` has to be of type `str` or `list` but is {type(prompt)}")
165166
elif prompt_2 is not None and (not isinstance(prompt_2, str) and not isinstance(prompt_2, list)):
166167
raise ValueError(f"`prompt_2` has to be of type `str` or `list` but is {type(prompt_2)}")
167-
168+
if prompt is not None and (isinstance(prompt, list) and isinstance(image, list) and len(prompt) != len(image)):
169+
raise ValueError(f"number of prompts must be equal to number of images, but {len(prompt)} prompts were provided and {batch_size} images")
168170
if prompt_embeds is not None and pooled_prompt_embeds is None:
169171
raise ValueError(
170172
"If `prompt_embeds` are provided, `pooled_prompt_embeds` also have to be passed. Make sure to generate `pooled_prompt_embeds` from the same text encoder that was used to generate `prompt_embeds`."
@@ -388,6 +390,15 @@ def __call__(
388390
returning a tuple, the first element is a list with the generated images.
389391
"""
390392

393+
# 1. Check inputs. Raise error if not correct
394+
self.check_inputs(
395+
prompt,
396+
prompt_2,
397+
image,
398+
prompt_embeds=prompt_embeds,
399+
pooled_prompt_embeds=pooled_prompt_embeds,
400+
)
401+
391402
# 2. Define call parameters
392403
if image is not None and isinstance(image, Image.Image):
393404
batch_size = 1
@@ -398,8 +409,6 @@ def __call__(
398409
if prompt is not None and isinstance(prompt, str):
399410
prompt = batch_size * [prompt]
400411

401-
402-
403412
device = self._execution_device
404413

405414
# 3. Prepare image embeddings

0 commit comments

Comments
 (0)