Skip to content

Commit dbe4f95

Browse files
committed
fix(qwen): fix CFG failing when passing neg prompt embeds with none mask
1 parent 514bba0 commit dbe4f95

9 files changed

Lines changed: 9 additions & 27 deletions

src/diffusers/pipelines/qwenimage/pipeline_qwenimage.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,7 @@ def __call__(
584584

585585
device = self._execution_device
586586

587-
has_neg_prompt = negative_prompt is not None or (
588-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
589-
)
587+
has_neg_prompt = negative_prompt is not None or negative_prompt_embeds is not None
590588

591589
if true_cfg_scale > 1 and not has_neg_prompt:
592590
logger.warning(

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_controlnet.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,7 @@ def __call__(
700700

701701
device = self._execution_device
702702

703-
has_neg_prompt = negative_prompt is not None or (
704-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
705-
)
703+
has_neg_prompt = negative_prompt is not None or negative_prompt_embeds is not None
706704

707705
if true_cfg_scale > 1 and not has_neg_prompt:
708706
logger.warning(

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_controlnet_inpaint.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,9 +739,7 @@ def __call__(
739739

740740
device = self._execution_device
741741

742-
has_neg_prompt = negative_prompt is not None or (
743-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
744-
)
742+
has_neg_prompt = negative_prompt is not None or negative_prompt_embeds is not None
745743
do_true_cfg = true_cfg_scale > 1 and has_neg_prompt
746744
prompt_embeds, prompt_embeds_mask = self.encode_prompt(
747745
prompt=prompt,

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_edit.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,9 +705,7 @@ def __call__(
705705
image = self.image_processor.preprocess(image, calculated_height, calculated_width)
706706
image = image.unsqueeze(2)
707707

708-
has_neg_prompt = negative_prompt is not None or (
709-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
710-
)
708+
has_neg_prompt = negative_prompt is not None or negative_prompt_embeds is not None
711709

712710
if true_cfg_scale > 1 and not has_neg_prompt:
713711
logger.warning(

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_edit_inpaint.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,7 @@ def __call__(
878878
)
879879
image = image.to(dtype=torch.float32)
880880

881-
has_neg_prompt = negative_prompt is not None or (
882-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
883-
)
881+
has_neg_prompt = negative_prompt is not None or negative_prompt_embeds is not None
884882

885883
if true_cfg_scale > 1 and not has_neg_prompt:
886884
logger.warning(

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_edit_plus.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,9 +693,7 @@ def __call__(
693693
condition_images.append(self.image_processor.resize(img, condition_height, condition_width))
694694
vae_images.append(self.image_processor.preprocess(img, vae_height, vae_width).unsqueeze(2))
695695

696-
has_neg_prompt = negative_prompt is not None or (
697-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
698-
)
696+
has_neg_prompt = negative_prompt is not None or negative_prompt_embeds is not None
699697

700698
if true_cfg_scale > 1 and not has_neg_prompt:
701699
logger.warning(

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_img2img.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,7 @@ def __call__(
677677

678678
device = self._execution_device
679679

680-
has_neg_prompt = negative_prompt is not None or (
681-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
682-
)
680+
has_neg_prompt = negative_prompt is not None or negative_prompt_embeds is not None
683681

684682
if true_cfg_scale > 1 and not has_neg_prompt:
685683
logger.warning(

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_inpaint.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,7 @@ def __call__(
822822

823823
device = self._execution_device
824824

825-
has_neg_prompt = negative_prompt is not None or (
826-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
827-
)
825+
has_neg_prompt = negative_prompt is not None or negative_prompt_embeds is not None
828826

829827
if true_cfg_scale > 1 and not has_neg_prompt:
830828
logger.warning(

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_layered.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,7 @@ def __call__(
697697
else:
698698
batch_size = prompt_embeds.shape[0]
699699

700-
has_neg_prompt = negative_prompt is not None or (
701-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
702-
)
700+
has_neg_prompt = negative_prompt is not None or negative_prompt_embeds is not None
703701

704702
if true_cfg_scale > 1 and not has_neg_prompt:
705703
logger.warning(

0 commit comments

Comments
 (0)