Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/source/en/api/pipelines/qwenimage21.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,28 @@ the terminal sigma, which the scheduler appends. Explicit `sigmas` override the
list determines the number of steps instead of `num_inference_steps`. If neither is provided, the pipeline uses
`num_inference_steps` to generate the schedule. The scheduler applies its configured processing to either grid.

## Modular

Qwen-Image 2.1 is also available as a [modular pipeline](../../modular_diffusers/overview). The same blocks run
text-to-image and image-conditioned generation: pass `image` to condition on one or more images. Classifier-free
guidance is configured through the `guider` component rather than a `true_cfg_scale` call argument, and the prefix KV
cache is on by default (`use_kv_cache=False` turns it off).

```python
import torch
from diffusers import ClassifierFreeGuidance, ModularPipeline

pipe = ModularPipeline.from_pretrained("Qwen/Qwen-Image-2.1")
pipe.load_components(dtype=torch.bfloat16)
pipe.to("cuda")

image = pipe(prompt="A capybara wearing a wizard hat, oil painting").images[0]

# Turn classifier-free guidance on for an edit.
pipe.update_components(guider=ClassifierFreeGuidance(guidance_scale=4.0))
edited = pipe(prompt="Move it to a snowy mountain top", negative_prompt="blurry", image=image).images[0]
```

## QwenImage21Pipeline

[[autodoc]] QwenImage21Pipeline
Expand All @@ -106,3 +128,11 @@ list determines the number of steps instead of `num_inference_steps`. If neither
## QwenImagePipelineOutput

[[autodoc]] pipelines.qwenimage.pipeline_output.QwenImagePipelineOutput

## QwenImage21ModularPipeline

[[autodoc]] QwenImage21ModularPipeline

## QwenImage21AutoBlocks

[[autodoc]] QwenImage21AutoBlocks
4 changes: 4 additions & 0 deletions src/diffusers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@
"MiniMaxH3ModularPipeline",
"MiniMaxMusic3Blocks",
"MiniMaxMusic3ModularPipeline",
"QwenImage21AutoBlocks",
"QwenImage21ModularPipeline",
"QwenImageAutoBlocks",
"QwenImageEditAutoBlocks",
"QwenImageEditModularPipeline",
Expand Down Expand Up @@ -1438,6 +1440,8 @@
MiniMaxH3ModularPipeline,
MiniMaxMusic3Blocks,
MiniMaxMusic3ModularPipeline,
QwenImage21AutoBlocks,
QwenImage21ModularPipeline,
QwenImageAutoBlocks,
QwenImageEditAutoBlocks,
QwenImageEditModularPipeline,
Expand Down
2 changes: 2 additions & 0 deletions src/diffusers/modular_pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"QwenImageLayeredModularPipeline",
"QwenImageLayeredAutoBlocks",
]
_import_structure["qwenimage21"] = ["QwenImage21AutoBlocks", "QwenImage21ModularPipeline"]
_import_structure["anima"] = [
"AnimaAutoBlocks",
"AnimaModularPipeline",
Expand Down Expand Up @@ -226,6 +227,7 @@
QwenImageLayeredModularPipeline,
QwenImageModularPipeline,
)
from .qwenimage21 import QwenImage21AutoBlocks, QwenImage21ModularPipeline
from .stable_diffusion_3 import StableDiffusion3AutoBlocks, StableDiffusion3ModularPipeline
from .stable_diffusion_xl import StableDiffusionXLAutoBlocks, StableDiffusionXLModularPipeline
from .wan import (
Expand Down
1 change: 1 addition & 0 deletions src/diffusers/modular_pipelines/modular_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def _helios_pyramid_map_fn(config_dict=None):
("qwenimage-edit", _create_default_map_fn("QwenImageEditModularPipeline")),
("qwenimage-edit-plus", _create_default_map_fn("QwenImageEditPlusModularPipeline")),
("qwenimage-layered", _create_default_map_fn("QwenImageLayeredModularPipeline")),
("qwenimage21", _create_default_map_fn("QwenImage21ModularPipeline")),
("anima", _create_default_map_fn("AnimaModularPipeline")),
("z-image", _create_default_map_fn("ZImageModularPipeline")),
("cosmos3-omni", _create_default_map_fn("Cosmos3OmniModularPipeline")),
Expand Down
47 changes: 47 additions & 0 deletions src/diffusers/modular_pipelines/qwenimage21/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from typing import TYPE_CHECKING

from ...utils import (
DIFFUSERS_SLOW_IMPORT,
OptionalDependencyNotAvailable,
_LazyModule,
get_objects_from_module,
is_torch_available,
is_transformers_available,
)


_dummy_objects = {}
_import_structure = {}

try:
if not (is_transformers_available() and is_torch_available()):
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
from ...utils import dummy_torch_and_transformers_objects # noqa F403

_dummy_objects.update(get_objects_from_module(dummy_torch_and_transformers_objects))
else:
_import_structure["modular_blocks_qwenimage21"] = ["QwenImage21AutoBlocks"]
_import_structure["modular_pipeline"] = ["QwenImage21ModularPipeline"]

if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
try:
if not (is_transformers_available() and is_torch_available()):
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
from ...utils.dummy_torch_and_transformers_objects import * # noqa F403
else:
from .modular_blocks_qwenimage21 import QwenImage21AutoBlocks
from .modular_pipeline import QwenImage21ModularPipeline
else:
import sys

sys.modules[__name__] = _LazyModule(
__name__,
globals()["__file__"],
_import_structure,
module_spec=__spec__,
)

for name, value in _dummy_objects.items():
setattr(sys.modules[__name__], name, value)
Loading
Loading