Skip to content

Commit 0e9c496

Browse files
committed
docstring etc
1 parent 6bf38c8 commit 0e9c496

File tree

6 files changed

+64
-35
lines changed

6 files changed

+64
-35
lines changed

src/diffusers/image_processor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,6 @@ def resize(
523523
size=(height, width),
524524
)
525525
image = self.pt_to_numpy(image)
526-
else:
527-
raise ValueError(f"Unsupported image type: {type(image)}")
528526

529527
return image
530528

src/diffusers/modular_pipelines/qwenimage/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
_import_structure["modular_blocks"] = [
2626
"ALL_BLOCKS",
2727
"AUTO_BLOCKS",
28+
"EDIT_AUTO_BLOCKS",
2829
"CONTROLNET_BLOCKS",
2930
"EDIT_BLOCKS",
3031
"EDIT_INPAINT_BLOCKS",
@@ -48,6 +49,8 @@
4849
)
4950
from .modular_blocks import (
5051
ALL_BLOCKS,
52+
AUTO_BLOCKS,
53+
EDIT_AUTO_BLOCKS,
5154
CONTROLNET_BLOCKS,
5255
EDIT_BLOCKS,
5356
EDIT_INPAINT_BLOCKS,

src/diffusers/modular_pipelines/qwenimage/before_denoise.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ def check_inputs(image_latents, latents, batch_size):
263263
if image_latents.ndim != 3:
264264
raise ValueError(f"`image_latents` must have 3 dimensions (patchified), but got {image_latents.ndim}")
265265

266-
267266
@torch.no_grad()
268267
def __call__(self, components: QwenImageModularPipeline, state: PipelineState) -> PipelineState:
269268
block_state = self.get_block_state(state)
@@ -294,7 +293,7 @@ class QwenImageCreateMaskLatentsStep(ModularPipelineBlocks):
294293

295294
@property
296295
def description(self) -> str:
297-
return "Step that creates mask latents from preprocessed mask_image by interpolating to latent space. Output is not patchified."
296+
return "Step that creates mask latents from preprocessed mask_image by interpolating to latent space."
298297

299298
@property
300299
def expected_components(self) -> List[ComponentSpec]:
@@ -572,7 +571,7 @@ class QwenImageEditRoPEInputsStep(ModularPipelineBlocks):
572571

573572
@property
574573
def description(self) -> str:
575-
return "Step that prepares the RoPE inputs for the text-to-image generation process. This is used in QwenImage Edit. Should be place after prepare_latents step"
574+
return "Step that prepares the RoPE inputs for denoising process. This is used in QwenImage Edit. Should be place after prepare_latents step"
576575

577576
@property
578577
def inputs(self) -> List[InputParam]:

src/diffusers/modular_pipelines/qwenimage/denoise.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def description(self) -> str:
539539
" - `QwenImageLoopBeforeDenoiser`\n"
540540
" - `QwenImageLoopDenoiser`\n"
541541
" - `QwenImageLoopAfterDenoiser`\n"
542-
"This block supports text2img tasks."
542+
"This block supports text2image and image2image tasks for QwenImage."
543543
)
544544

545545

@@ -563,7 +563,7 @@ def description(self) -> str:
563563
" - `QwenImageLoopDenoiser`\n"
564564
" - `QwenImageLoopAfterDenoiser`\n"
565565
" - `QwenImageLoopAfterDenoiserInpaint`\n"
566-
"This block supports inpainting tasks."
566+
"This block supports inpainting tasks for QwenImage."
567567
)
568568

569569

@@ -587,7 +587,7 @@ def description(self) -> str:
587587
" - `QwenImageLoopBeforeDenoiserControlNet`\n"
588588
" - `QwenImageLoopDenoiser`\n"
589589
" - `QwenImageLoopAfterDenoiser`\n"
590-
"This block supports text2img tasks."
590+
"This block supports text2img/img2img tasks with controlnet for QwenImage."
591591
)
592592

593593

@@ -619,7 +619,7 @@ def description(self) -> str:
619619
" - `QwenImageLoopDenoiser`\n"
620620
" - `QwenImageLoopAfterDenoiser`\n"
621621
" - `QwenImageLoopAfterDenoiserInpaint`\n"
622-
"This block supports inpainting tasks with controlnet."
622+
"This block supports inpainting tasks with controlnet for QwenImage."
623623
)
624624

625625

@@ -641,7 +641,7 @@ def description(self) -> str:
641641
" - `QwenImageEditLoopBeforeDenoiser`\n"
642642
" - `QwenImageEditLoopDenoiser`\n"
643643
" - `QwenImageLoopAfterDenoiser`\n"
644-
"This block supports image-to-image tasks for QwenImage Edit."
644+
"This block supports QwenImage Edit."
645645
)
646646

647647

src/diffusers/modular_pipelines/qwenimage/encoders.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,22 @@ def encode_vae_image(
186186
return image_latents
187187

188188

189-
# YiYi TODO: Check if this step need to be dynamic
190189
class QwenImageEditResizeDynamicStep(ModularPipelineBlocks):
191190
model_name = "qwenimage"
192191

193192
def __init__(self, input_name: str = "image", output_name: str = "resized_image"):
193+
"""Create a configurable step for resizing images to the target area (1024 * 1024) while maintaining the aspect ratio.
194+
195+
This block resizes an input image tensor and exposes the resized result
196+
under configurable input and output names. Use this when you need to wire the
197+
resize step to different image fields (e.g., "image", "control_image")
198+
199+
Args:
200+
input_name (str, optional): Name of the image field to read from the
201+
pipeline state. Defaults to "image".
202+
output_name (str, optional): Name of the resized image field to write
203+
back to the pipeline state. Defaults to "resized_image".
204+
"""
194205
if not isinstance(input_name, str) or not isinstance(output_name, str):
195206
raise ValueError(
196207
f"input_name and output_name must be strings but are {type(input_name)} and {type(output_name)}"
@@ -505,7 +516,7 @@ class QwenImageInpaintProcessImagesInputStep(ModularPipelineBlocks):
505516

506517
@property
507518
def description(self) -> str:
508-
return "Image Preprocess step for inpainting task. This processes the image and mask inputs together. Images need to be resized first using either the QwenImageResizeStep or QwenImageEditResizeStep."
519+
return "Image Preprocess step for inpainting task. This processes the image and mask inputs together. Images can be resized first using QwenImageEditResizeDynamicStep."
509520

510521
@property
511522
def expected_components(self) -> List[ComponentSpec]:
@@ -586,7 +597,7 @@ class QwenImageProcessImagesInputStep(ModularPipelineBlocks):
586597

587598
@property
588599
def description(self) -> str:
589-
return "Image Preprocess step. Images need to be resized first using either the QwenImageResizeStep or QwenImageEditResizeStep."
600+
return "Image Preprocess step. Images can be resized first using QwenImageEditResizeDynamicStep."
590601

591602
@property
592603
def expected_components(self) -> List[ComponentSpec]:
@@ -658,7 +669,11 @@ def __init__(
658669
input_name: str = "processed_image",
659670
output_name: str = "image_latents",
660671
):
661-
"""Initialize a dynamic VAE encoder step for converting images to latent representations.
672+
"""Initialize a VAE encoder step for converting images to latent representations.
673+
674+
Both the input and output names are configurable so this block can be
675+
configured to process to different image inputs (e.g., "processed_image" -> "image_latents",
676+
"processed_control_image" -> "control_image_latents").
662677
663678
Args:
664679
input_name (str, optional): Name of the input image tensor. Defaults to "processed_image".

0 commit comments

Comments
 (0)