Skip to content

Commit 42587ae

Browse files
committed
fix(qwen): add warnings for missing prompt and negative prompt masks in pipelines
1 parent eb86a2e commit 42587ae

9 files changed

Lines changed: 81 additions & 0 deletions

src/diffusers/pipelines/qwenimage/pipeline_qwenimage.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,15 @@ def check_inputs(
310310
f"Cannot forward both `negative_prompt`: {negative_prompt} and `negative_prompt_embeds`:"
311311
f" {negative_prompt_embeds}. Please make sure to only forward one of the two."
312312
)
313+
if prompt_embeds is not None and prompt_embeds_mask is None:
314+
logger.warning(
315+
"If `prompt_embeds` are provided, `prompt_embeds_mask` also have to be passed. Make sure to generate `prompt_embeds_mask` from the same text encoder that was used to generate `prompt_embeds`."
316+
)
317+
318+
if negative_prompt_embeds is not None and negative_prompt_embeds_mask is None:
319+
logger.warning(
320+
"If `negative_prompt_embeds` are provided, `negative_prompt_embeds_mask` also have to be passed. Make sure to generate `negative_prompt_embeds_mask` from the same text encoder that was used to generate `negative_prompt_embeds`."
321+
)
313322

314323
if max_sequence_length is not None and max_sequence_length > 1024:
315324
raise ValueError(f"`max_sequence_length` cannot be greater than 1024 but is {max_sequence_length}")

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_controlnet.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,15 @@ def check_inputs(
375375
f"Cannot forward both `negative_prompt`: {negative_prompt} and `negative_prompt_embeds`:"
376376
f" {negative_prompt_embeds}. Please make sure to only forward one of the two."
377377
)
378+
if prompt_embeds is not None and prompt_embeds_mask is None:
379+
logger.warning(
380+
"If `prompt_embeds` are provided, `prompt_embeds_mask` also have to be passed. Make sure to generate `prompt_embeds_mask` from the same text encoder that was used to generate `prompt_embeds`."
381+
)
382+
383+
if negative_prompt_embeds is not None and negative_prompt_embeds_mask is None:
384+
logger.warning(
385+
"If `negative_prompt_embeds` are provided, `negative_prompt_embeds_mask` also have to be passed. Make sure to generate `negative_prompt_embeds_mask` from the same text encoder that was used to generate `negative_prompt_embeds`."
386+
)
378387

379388
if max_sequence_length is not None and max_sequence_length > 1024:
380389
raise ValueError(f"`max_sequence_length` cannot be greater than 1024 but is {max_sequence_length}")

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_controlnet_inpaint.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ def check_inputs(
357357
f"Cannot forward both `negative_prompt`: {negative_prompt} and `negative_prompt_embeds`:"
358358
f" {negative_prompt_embeds}. Please make sure to only forward one of the two."
359359
)
360+
if prompt_embeds is not None and prompt_embeds_mask is None:
361+
logger.warning(
362+
"If `prompt_embeds` are provided, `prompt_embeds_mask` also have to be passed. Make sure to generate `prompt_embeds_mask` from the same text encoder that was used to generate `prompt_embeds`."
363+
)
364+
365+
if negative_prompt_embeds is not None and negative_prompt_embeds_mask is None:
366+
logger.warning(
367+
"If `negative_prompt_embeds` are provided, `negative_prompt_embeds_mask` also have to be passed. Make sure to generate `negative_prompt_embeds_mask` from the same text encoder that was used to generate `negative_prompt_embeds`."
368+
)
360369

361370
if max_sequence_length is not None and max_sequence_length > 1024:
362371
raise ValueError(f"`max_sequence_length` cannot be greater than 1024 but is {max_sequence_length}")

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_edit.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,15 @@ def check_inputs(
358358
f"Cannot forward both `negative_prompt`: {negative_prompt} and `negative_prompt_embeds`:"
359359
f" {negative_prompt_embeds}. Please make sure to only forward one of the two."
360360
)
361+
if prompt_embeds is not None and prompt_embeds_mask is None:
362+
logger.warning(
363+
"If `prompt_embeds` are provided, `prompt_embeds_mask` also have to be passed. Make sure to generate `prompt_embeds_mask` from the same text encoder that was used to generate `prompt_embeds`."
364+
)
365+
366+
if negative_prompt_embeds is not None and negative_prompt_embeds_mask is None:
367+
logger.warning(
368+
"If `negative_prompt_embeds` are provided, `negative_prompt_embeds_mask` also have to be passed. Make sure to generate `negative_prompt_embeds_mask` from the same text encoder that was used to generate `negative_prompt_embeds`."
369+
)
361370

362371
if max_sequence_length is not None and max_sequence_length > 1024:
363372
raise ValueError(f"`max_sequence_length` cannot be greater than 1024 but is {max_sequence_length}")

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_edit_inpaint.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,15 @@ def check_inputs(
392392
)
393393
if output_type != "pil":
394394
raise ValueError(f"The output type should be PIL when inpainting mask crop, but is {output_type}.")
395+
if prompt_embeds is not None and prompt_embeds_mask is None:
396+
logger.warning(
397+
"If `prompt_embeds` are provided, `prompt_embeds_mask` also have to be passed. Make sure to generate `prompt_embeds_mask` from the same text encoder that was used to generate `prompt_embeds`."
398+
)
399+
400+
if negative_prompt_embeds is not None and negative_prompt_embeds_mask is None:
401+
logger.warning(
402+
"If `negative_prompt_embeds` are provided, `negative_prompt_embeds_mask` also have to be passed. Make sure to generate `negative_prompt_embeds_mask` from the same text encoder that was used to generate `negative_prompt_embeds`."
403+
)
395404

396405
if max_sequence_length is not None and max_sequence_length > 1024:
397406
raise ValueError(f"`max_sequence_length` cannot be greater than 1024 but is {max_sequence_length}")

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_edit_plus.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,15 @@ def check_inputs(
373373
f"Cannot forward both `negative_prompt`: {negative_prompt} and `negative_prompt_embeds`:"
374374
f" {negative_prompt_embeds}. Please make sure to only forward one of the two."
375375
)
376+
if prompt_embeds is not None and prompt_embeds_mask is None:
377+
logger.warning(
378+
"If `prompt_embeds` are provided, `prompt_embeds_mask` also have to be passed. Make sure to generate `prompt_embeds_mask` from the same text encoder that was used to generate `prompt_embeds`."
379+
)
380+
381+
if negative_prompt_embeds is not None and negative_prompt_embeds_mask is None:
382+
logger.warning(
383+
"If `negative_prompt_embeds` are provided, `negative_prompt_embeds_mask` also have to be passed. Make sure to generate `negative_prompt_embeds_mask` from the same text encoder that was used to generate `negative_prompt_embeds`."
384+
)
376385

377386
if max_sequence_length is not None and max_sequence_length > 1024:
378387
raise ValueError(f"`max_sequence_length` cannot be greater than 1024 but is {max_sequence_length}")

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_img2img.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ def check_inputs(
357357
f"Cannot forward both `negative_prompt`: {negative_prompt} and `negative_prompt_embeds`:"
358358
f" {negative_prompt_embeds}. Please make sure to only forward one of the two."
359359
)
360+
if prompt_embeds is not None and prompt_embeds_mask is None:
361+
logger.warning(
362+
"If `prompt_embeds` are provided, `prompt_embeds_mask` also have to be passed. Make sure to generate `prompt_embeds_mask` from the same text encoder that was used to generate `prompt_embeds`."
363+
)
364+
365+
if negative_prompt_embeds is not None and negative_prompt_embeds_mask is None:
366+
logger.warning(
367+
"If `negative_prompt_embeds` are provided, `negative_prompt_embeds_mask` also have to be passed. Make sure to generate `negative_prompt_embeds_mask` from the same text encoder that was used to generate `negative_prompt_embeds`."
368+
)
360369

361370
if max_sequence_length is not None and max_sequence_length > 1024:
362371
raise ValueError(f"`max_sequence_length` cannot be greater than 1024 but is {max_sequence_length}")

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_inpaint.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,15 @@ def check_inputs(
385385
)
386386
if output_type != "pil":
387387
raise ValueError(f"The output type should be PIL when inpainting mask crop, but is {output_type}.")
388+
if prompt_embeds is not None and prompt_embeds_mask is None:
389+
logger.warning(
390+
"If `prompt_embeds` are provided, `prompt_embeds_mask` also have to be passed. Make sure to generate `prompt_embeds_mask` from the same text encoder that was used to generate `prompt_embeds`."
391+
)
392+
393+
if negative_prompt_embeds is not None and negative_prompt_embeds_mask is None:
394+
logger.warning(
395+
"If `negative_prompt_embeds` are provided, `negative_prompt_embeds_mask` also have to be passed. Make sure to generate `negative_prompt_embeds_mask` from the same text encoder that was used to generate `negative_prompt_embeds`."
396+
)
388397

389398
if max_sequence_length is not None and max_sequence_length > 1024:
390399
raise ValueError(f"`max_sequence_length` cannot be greater than 1024 but is {max_sequence_length}")

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_layered.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,15 @@ def check_inputs(
383383
f"Cannot forward both `negative_prompt`: {negative_prompt} and `negative_prompt_embeds`:"
384384
f" {negative_prompt_embeds}. Please make sure to only forward one of the two."
385385
)
386+
if prompt_embeds is not None and prompt_embeds_mask is None:
387+
logger.warning(
388+
"If `prompt_embeds` are provided, `prompt_embeds_mask` also have to be passed. Make sure to generate `prompt_embeds_mask` from the same text encoder that was used to generate `prompt_embeds`."
389+
)
390+
391+
if negative_prompt_embeds is not None and negative_prompt_embeds_mask is None:
392+
logger.warning(
393+
"If `negative_prompt_embeds` are provided, `negative_prompt_embeds_mask` also have to be passed. Make sure to generate `negative_prompt_embeds_mask` from the same text encoder that was used to generate `negative_prompt_embeds`."
394+
)
386395

387396
if max_sequence_length is not None and max_sequence_length > 1024:
388397
raise ValueError(f"`max_sequence_length` cannot be greater than 1024 but is {max_sequence_length}")

0 commit comments

Comments
 (0)