Skip to content

Commit 44e058c

Browse files
committed
up up
1 parent fa1a9cd commit 44e058c

File tree

12 files changed

+751
-75
lines changed

12 files changed

+751
-75
lines changed

src/diffusers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@
373373
"StableDiffusionXLModularPipeline",
374374
"WanAutoBlocks",
375375
"WanModularPipeline",
376+
"QwenImageModularPipeline",
376377
]
377378
)
378379
_import_structure["pipelines"].extend(
@@ -1012,6 +1013,7 @@
10121013
StableDiffusionXLModularPipeline,
10131014
WanAutoBlocks,
10141015
WanModularPipeline,
1016+
QwenImageModularPipeline,
10151017
)
10161018
from .pipelines import (
10171019
AllegroPipeline,

src/diffusers/guiders/classifier_free_guidance.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,25 @@
1414

1515
import math
1616
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
17+
from dataclasses import dataclass
1718

1819
import torch
1920

2021
from ..configuration_utils import register_to_config
2122
from .guider_utils import BaseGuidance, rescale_noise_cfg
23+
from ..utils import BaseOutput
2224

2325

2426
if TYPE_CHECKING:
2527
from ..modular_pipelines.modular_pipeline import BlockState
2628

29+
@dataclass
30+
class ClassifierFreeGuidanceOutput(BaseOutput):
31+
"""
32+
Output class for Classifier-free guidance.
33+
"""
34+
pred: torch.Tensor
35+
pred_cond: torch.Tensor
2736

2837
class ClassifierFreeGuidance(BaseGuidance):
2938
"""
@@ -109,7 +118,7 @@ def forward(self, pred_cond: torch.Tensor, pred_uncond: Optional[torch.Tensor] =
109118
if self.guidance_rescale > 0.0:
110119
pred = rescale_noise_cfg(pred, pred_cond, self.guidance_rescale)
111120

112-
return pred, {}
121+
return ClassifierFreeGuidanceOutput(pred=pred, pred_cond=pred_cond)
113122

114123
@property
115124
def is_conditional(self) -> bool:

src/diffusers/modular_pipelines/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
_import_structure["stable_diffusion_xl"] = ["StableDiffusionXLAutoBlocks", "StableDiffusionXLModularPipeline"]
4848
_import_structure["wan"] = ["WanAutoBlocks", "WanModularPipeline"]
4949
_import_structure["flux"] = ["FluxAutoBlocks", "FluxModularPipeline"]
50+
_import_structure["qwenimage"] = ["QwenImageModularPipeline"]
5051
_import_structure["components_manager"] = ["ComponentsManager"]
5152

5253
if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
@@ -70,6 +71,7 @@
7071
from .modular_pipeline_utils import ComponentSpec, ConfigSpec, InputParam, InsertableDict, OutputParam
7172
from .stable_diffusion_xl import StableDiffusionXLAutoBlocks, StableDiffusionXLModularPipeline
7273
from .wan import WanAutoBlocks, WanModularPipeline
74+
from .qwenimage import QwenImageModularPipeline
7375
else:
7476
import sys
7577

src/diffusers/modular_pipelines/modular_pipeline.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
("stable-diffusion-xl", "StableDiffusionXLModularPipeline"),
5757
("wan", "WanModularPipeline"),
5858
("flux", "FluxModularPipeline"),
59+
("qwenimage", "QwenImageModularPipeline"),
5960
]
6061
)
6162

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from typing import TYPE_CHECKING
2+
3+
from ...utils import (
4+
DIFFUSERS_SLOW_IMPORT,
5+
OptionalDependencyNotAvailable,
6+
_LazyModule,
7+
get_objects_from_module,
8+
is_torch_available,
9+
is_transformers_available,
10+
)
11+
12+
13+
_dummy_objects = {}
14+
_import_structure = {}
15+
16+
try:
17+
if not (is_transformers_available() and is_torch_available()):
18+
raise OptionalDependencyNotAvailable()
19+
except OptionalDependencyNotAvailable:
20+
from ...utils import dummy_torch_and_transformers_objects # noqa F403
21+
22+
_dummy_objects.update(get_objects_from_module(dummy_torch_and_transformers_objects))
23+
else:
24+
_import_structure["encoders"] = ["QwenImageTextEncoderStep"]
25+
_import_structure["modular_blocks"] = [
26+
"ALL_BLOCKS",
27+
"TEXT2IMAGE_BLOCKS",
28+
]
29+
_import_structure["modular_pipeline"] = ["QwenImageModularPipeline"]
30+
31+
if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
32+
try:
33+
if not (is_transformers_available() and is_torch_available()):
34+
raise OptionalDependencyNotAvailable()
35+
except OptionalDependencyNotAvailable:
36+
from ...utils.dummy_torch_and_transformers_objects import * # noqa F403
37+
else:
38+
from .encoders import (
39+
QwenImageTextEncoderStep,
40+
)
41+
from .modular_blocks import (
42+
ALL_BLOCKS,
43+
TEXT2IMAGE_BLOCKS,
44+
)
45+
from .modular_pipeline import QwenImageModularPipeline
46+
else:
47+
import sys
48+
49+
sys.modules[__name__] = _LazyModule(
50+
__name__,
51+
globals()["__file__"],
52+
_import_structure,
53+
module_spec=__spec__,
54+
)
55+
56+
for name, value in _dummy_objects.items():
57+
setattr(sys.modules[__name__], name, value)

0 commit comments

Comments
 (0)