Skip to content

Commit 22b1799

Browse files
committed
get ready.
1 parent c7c215a commit 22b1799

File tree

3 files changed

+7
-89
lines changed

3 files changed

+7
-89
lines changed

src/diffusers/modular_pipelines/qwenimage/before_denoise.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -640,50 +640,6 @@ def __call__(self, components: QwenImageModularPipeline, state: PipelineState) -
640640
return components, state
641641

642642

643-
class QwenImageEditPlusRoPEInputsStep(QwenImageEditRoPEInputsStep):
644-
model_name = "qwenimage-edit-plus"
645-
# TODO: Is there a better way to handle this name? It's used in
646-
# `QwenImageEditPlusProcessImagesInputStep` as well. We can later
647-
# keep these things as a module-level constant.
648-
_image_size_output_name = "vae_image_sizes"
649-
650-
@property
651-
def inputs(self) -> List[InputParam]:
652-
inputs_list = super().inputs
653-
return inputs_list + [
654-
InputParam(name=self._image_size_output_name, required=True),
655-
]
656-
657-
def __call__(self, components: QwenImageModularPipeline, state: PipelineState) -> PipelineState:
658-
block_state = self.get_block_state(state)
659-
vae_image_sizes = getattr(block_state, self._image_size_output_name)
660-
height, width = block_state.image_height, block_state.image_width
661-
662-
# for edit, image size can be different from the target size (height/width)
663-
block_state.img_shapes = [
664-
[
665-
(1, height // components.vae_scale_factor // 2, width // components.vae_scale_factor // 2),
666-
*[
667-
(1, vae_height // components.vae_scale_factor // 2, vae_width // components.vae_scale_factor // 2)
668-
for vae_width, vae_height in vae_image_sizes
669-
],
670-
]
671-
] * block_state.batch_size
672-
673-
block_state.txt_seq_lens = (
674-
block_state.prompt_embeds_mask.sum(dim=1).tolist() if block_state.prompt_embeds_mask is not None else None
675-
)
676-
block_state.negative_txt_seq_lens = (
677-
block_state.negative_prompt_embeds_mask.sum(dim=1).tolist()
678-
if block_state.negative_prompt_embeds_mask is not None
679-
else None
680-
)
681-
682-
self.set_block_state(state, block_state)
683-
684-
return components, state
685-
686-
687643
## ControlNet inputs for denoiser
688644
class QwenImageControlNetBeforeDenoiserStep(ModularPipelineBlocks):
689645
model_name = "qwenimage"

src/diffusers/modular_pipelines/qwenimage/encoders.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import Dict, List, Optional, Tuple, Union
15+
from typing import Dict, List, Optional, Union
1616

1717
import PIL
1818
import torch
@@ -855,12 +855,6 @@ def description(self) -> str:
855855
def inputs(self) -> List[InputParam]:
856856
return [InputParam("vae_image"), InputParam("image"), InputParam("height"), InputParam("width")]
857857

858-
@property
859-
def intermediate_outputs(self) -> List[OutputParam]:
860-
return super().intermediate_outputs + [
861-
OutputParam(name="vae_image_sizes", type_hint=List[Tuple[int, int]]),
862-
]
863-
864858
@torch.no_grad()
865859
def __call__(self, components: QwenImageModularPipeline, state: PipelineState):
866860
block_state = self.get_block_state(state)
@@ -879,18 +873,11 @@ def __call__(self, components: QwenImageModularPipeline, state: PipelineState):
879873
image=image, height=height, width=width
880874
)
881875
else:
882-
vae_image_sizes = []
876+
width, height = block_state.vae_image[0].size
883877
image = block_state.vae_image
884-
for img in image:
885-
width, height = img.size
886-
vae_width, vae_height, _ = calculate_dimensions(self.vae_image_size, width / height)
887-
vae_image_sizes.append((vae_width, vae_height))
888-
889-
block_state.vae_image_sizes = vae_image_sizes
890878

891-
width, height = block_state.vae_image[0].size
892879
block_state.processed_image = components.image_processor.preprocess(
893-
image=image, height=vae_height, width=vae_width
880+
image=image, height=height, width=width
894881
)
895882

896883
self.set_block_state(state, block_state)

src/diffusers/modular_pipelines/qwenimage/modular_blocks.py

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from .before_denoise import (
1919
QwenImageControlNetBeforeDenoiserStep,
2020
QwenImageCreateMaskLatentsStep,
21-
QwenImageEditPlusRoPEInputsStep,
2221
QwenImageEditRoPEInputsStep,
2322
QwenImagePrepareLatentsStep,
2423
QwenImagePrepareLatentsWithStrengthStep,
@@ -929,41 +928,17 @@ def description(self) -> str:
929928
("input", QwenImageEditInputStep()),
930929
("prepare_latents", QwenImagePrepareLatentsStep()),
931930
("set_timesteps", QwenImageSetTimestepsStep()),
932-
("prepare_rope_inputs", QwenImageEditPlusRoPEInputsStep()),
931+
("prepare_rope_inputs", QwenImageEditRoPEInputsStep()),
933932
("denoise", QwenImageEditDenoiseStep()),
934933
("decode", QwenImageDecodeStep()),
935934
]
936935
)
937936

938937

939-
## 3.2 QwenImage-Edit Plus/auto before denoise
940-
# compose the steps into a BeforeDenoiseStep for edit tasks before combining into an auto step
941-
942-
#### QwenImage-Edit/edit before denoise
943-
QwenImageEditPlusBeforeDenoiseBlocks = InsertableDict(
944-
[
945-
("prepare_latents", QwenImagePrepareLatentsStep()),
946-
("set_timesteps", QwenImageSetTimestepsStep()),
947-
# Different from QwenImage Edit.
948-
("prepare_rope_inputs", QwenImageEditPlusRoPEInputsStep()),
949-
]
950-
)
951-
952-
953-
class QwenImageEditPlusBeforeDenoiseStep(SequentialPipelineBlocks):
954-
model_name = "qwenimage"
955-
block_classes = QwenImageEditPlusBeforeDenoiseBlocks.values()
956-
block_names = QwenImageEditPlusBeforeDenoiseBlocks.keys()
957-
958-
@property
959-
def description(self):
960-
return "Before denoise step that prepare the inputs (timesteps, latents, rope inputs etc.) for the denoise step for edit task."
961-
962-
963938
# auto before_denoise step for edit tasks
964939
class QwenImageEditPlusAutoBeforeDenoiseStep(AutoPipelineBlocks):
965940
model_name = "qwenimage-edit-plus"
966-
block_classes = [QwenImageEditPlusBeforeDenoiseStep]
941+
block_classes = [QwenImageEditBeforeDenoiseStep]
967942
block_names = ["edit"]
968943
block_trigger_inputs = ["image_latents"]
969944

@@ -977,7 +952,7 @@ def description(self):
977952
)
978953

979954

980-
## 3.3 QwenImage-Edit Plus/auto encoders
955+
## 3.2 QwenImage-Edit Plus/auto encoders
981956

982957

983958
class QwenImageEditPlusAutoVaeEncoderStep(AutoPipelineBlocks):
@@ -997,7 +972,7 @@ def description(self):
997972
)
998973

999974

1000-
## 3.4 QwenImage-Edit/auto blocks & presets
975+
## 3.3 QwenImage-Edit/auto blocks & presets
1001976

1002977

1003978
class QwenImageEditPlusCoreDenoiseStep(SequentialPipelineBlocks):

0 commit comments

Comments
 (0)