Skip to content

Commit 8d65382

Browse files
committed
make
1 parent 5930bcf commit 8d65382

File tree

10 files changed

+156
-103
lines changed

10 files changed

+156
-103
lines changed

src/diffusers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@
377377
"StableDiffusionXLControlNetPAGImg2ImgPipeline",
378378
"StableDiffusionXLControlNetPAGPipeline",
379379
"StableDiffusionXLControlNetPipeline",
380-
"StableDiffusionXLControlNetUnionPipeline",
381380
"StableDiffusionXLControlNetUnionImg2ImgPipeline",
382381
"StableDiffusionXLControlNetUnionInpaintPipeline",
382+
"StableDiffusionXLControlNetUnionPipeline",
383383
"StableDiffusionXLControlNetXSPipeline",
384384
"StableDiffusionXLImg2ImgPipeline",
385385
"StableDiffusionXLInpaintPipeline",

src/diffusers/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
]
4545
_import_structure["controlnets.controlnet_sd3"] = ["SD3ControlNetModel", "SD3MultiControlNetModel"]
4646
_import_structure["controlnets.controlnet_sparsectrl"] = ["SparseControlNetModel"]
47+
_import_structure["controlnets.controlnet_union"] = ["ControlNetUnionModel"]
4748
_import_structure["controlnets.controlnet_xs"] = ["ControlNetXSAdapter", "UNetControlNetXSModel"]
4849
_import_structure["controlnets.multicontrolnet"] = ["MultiControlNetModel"]
49-
_import_structure["controlnets.controlnet_union"] = ["ControlNetUnionModel"]
5050
_import_structure["embeddings"] = ["ImageProjection"]
5151
_import_structure["modeling_utils"] = ["ModelMixin"]
5252
_import_structure["transformers.auraflow_transformer_2d"] = ["AuraFlowTransformer2DModel"]

src/diffusers/models/controlnets/controlnet_union.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,8 @@ def forward(
690690
controlnet_cond (`Union[ControlNetUnionInput, ControlNetUnionInputProMax]`):
691691
The conditional input tensors.
692692
control_type (`torch.Tensor`):
693-
A tensor of shape `(batch, num_control_type)` with values `0` or `1` depending on whether the
694-
control type is used.
693+
A tensor of shape `(batch, num_control_type)` with values `0` or `1` depending on whether the control
694+
type is used.
695695
conditioning_scale (`float`, defaults to `1.0`):
696696
The scale factor for ControlNet outputs.
697697
class_labels (`torch.Tensor`, *optional*, defaults to `None`):
Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,86 @@
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_flax_available,
9-
is_torch_available,
10-
is_transformers_available,
11-
)
12-
13-
14-
_dummy_objects = {}
15-
_import_structure = {}
16-
17-
try:
18-
if not (is_transformers_available() and is_torch_available()):
19-
raise OptionalDependencyNotAvailable()
20-
except OptionalDependencyNotAvailable:
21-
from ...utils import dummy_torch_and_transformers_objects # noqa F403
22-
23-
_dummy_objects.update(get_objects_from_module(dummy_torch_and_transformers_objects))
24-
else:
25-
_import_structure["multicontrolnet"] = ["MultiControlNetModel"]
26-
_import_structure["pipeline_controlnet"] = ["StableDiffusionControlNetPipeline"]
27-
_import_structure["pipeline_controlnet_blip_diffusion"] = ["BlipDiffusionControlNetPipeline"]
28-
_import_structure["pipeline_controlnet_img2img"] = ["StableDiffusionControlNetImg2ImgPipeline"]
29-
_import_structure["pipeline_controlnet_inpaint"] = ["StableDiffusionControlNetInpaintPipeline"]
30-
_import_structure["pipeline_controlnet_inpaint_sd_xl"] = ["StableDiffusionXLControlNetInpaintPipeline"]
31-
_import_structure["pipeline_controlnet_sd_xl"] = ["StableDiffusionXLControlNetPipeline"]
32-
_import_structure["pipeline_controlnet_sd_xl_img2img"] = ["StableDiffusionXLControlNetImg2ImgPipeline"]
33-
_import_structure["pipeline_controlnet_union_sd_xl"] = ["StableDiffusionXLControlNetUnionPipeline"]
34-
_import_structure["pipeline_controlnet_union_sd_xl_img2img"] = ["StableDiffusionXLControlNetUnionImg2ImgPipeline"]
35-
_import_structure["pipeline_controlnet_union_inpaint_sd_xl"] = ["StableDiffusionXLControlNetUnionInpaintPipeline"]
36-
try:
37-
if not (is_transformers_available() and is_flax_available()):
38-
raise OptionalDependencyNotAvailable()
39-
except OptionalDependencyNotAvailable:
40-
from ...utils import dummy_flax_and_transformers_objects # noqa F403
41-
42-
_dummy_objects.update(get_objects_from_module(dummy_flax_and_transformers_objects))
43-
else:
44-
_import_structure["pipeline_flax_controlnet"] = ["FlaxStableDiffusionControlNetPipeline"]
45-
46-
47-
if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
48-
try:
49-
if not (is_transformers_available() and is_torch_available()):
50-
raise OptionalDependencyNotAvailable()
51-
52-
except OptionalDependencyNotAvailable:
53-
from ...utils.dummy_torch_and_transformers_objects import *
54-
else:
55-
from .multicontrolnet import MultiControlNetModel
56-
from .pipeline_controlnet import StableDiffusionControlNetPipeline
57-
from .pipeline_controlnet_blip_diffusion import BlipDiffusionControlNetPipeline
58-
from .pipeline_controlnet_img2img import StableDiffusionControlNetImg2ImgPipeline
59-
from .pipeline_controlnet_inpaint import StableDiffusionControlNetInpaintPipeline
60-
from .pipeline_controlnet_inpaint_sd_xl import StableDiffusionXLControlNetInpaintPipeline
61-
from .pipeline_controlnet_sd_xl import StableDiffusionXLControlNetPipeline
62-
from .pipeline_controlnet_sd_xl_img2img import StableDiffusionXLControlNetImg2ImgPipeline
63-
from .pipeline_controlnet_union_inpaint_sd_xl import StableDiffusionXLControlNetUnionInpaintPipeline
64-
from .pipeline_controlnet_union_sd_xl import StableDiffusionXLControlNetUnionPipeline
65-
from .pipeline_controlnet_union_sd_xl_img2img import StableDiffusionXLControlNetUnionImg2ImgPipeline
66-
67-
try:
68-
if not (is_transformers_available() and is_flax_available()):
69-
raise OptionalDependencyNotAvailable()
70-
except OptionalDependencyNotAvailable:
71-
from ...utils.dummy_flax_and_transformers_objects import * # noqa F403
72-
else:
73-
from .pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline
74-
75-
76-
else:
77-
import sys
78-
79-
sys.modules[__name__] = _LazyModule(
80-
__name__,
81-
globals()["__file__"],
82-
_import_structure,
83-
module_spec=__spec__,
84-
)
85-
for name, value in _dummy_objects.items():
86-
setattr(sys.modules[__name__], name, value)
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_flax_available,
9+
is_torch_available,
10+
is_transformers_available,
11+
)
12+
13+
14+
_dummy_objects = {}
15+
_import_structure = {}
16+
17+
try:
18+
if not (is_transformers_available() and is_torch_available()):
19+
raise OptionalDependencyNotAvailable()
20+
except OptionalDependencyNotAvailable:
21+
from ...utils import dummy_torch_and_transformers_objects # noqa F403
22+
23+
_dummy_objects.update(get_objects_from_module(dummy_torch_and_transformers_objects))
24+
else:
25+
_import_structure["multicontrolnet"] = ["MultiControlNetModel"]
26+
_import_structure["pipeline_controlnet"] = ["StableDiffusionControlNetPipeline"]
27+
_import_structure["pipeline_controlnet_blip_diffusion"] = ["BlipDiffusionControlNetPipeline"]
28+
_import_structure["pipeline_controlnet_img2img"] = ["StableDiffusionControlNetImg2ImgPipeline"]
29+
_import_structure["pipeline_controlnet_inpaint"] = ["StableDiffusionControlNetInpaintPipeline"]
30+
_import_structure["pipeline_controlnet_inpaint_sd_xl"] = ["StableDiffusionXLControlNetInpaintPipeline"]
31+
_import_structure["pipeline_controlnet_sd_xl"] = ["StableDiffusionXLControlNetPipeline"]
32+
_import_structure["pipeline_controlnet_sd_xl_img2img"] = ["StableDiffusionXLControlNetImg2ImgPipeline"]
33+
_import_structure["pipeline_controlnet_union_inpaint_sd_xl"] = ["StableDiffusionXLControlNetUnionInpaintPipeline"]
34+
_import_structure["pipeline_controlnet_union_sd_xl"] = ["StableDiffusionXLControlNetUnionPipeline"]
35+
_import_structure["pipeline_controlnet_union_sd_xl_img2img"] = ["StableDiffusionXLControlNetUnionImg2ImgPipeline"]
36+
try:
37+
if not (is_transformers_available() and is_flax_available()):
38+
raise OptionalDependencyNotAvailable()
39+
except OptionalDependencyNotAvailable:
40+
from ...utils import dummy_flax_and_transformers_objects # noqa F403
41+
42+
_dummy_objects.update(get_objects_from_module(dummy_flax_and_transformers_objects))
43+
else:
44+
_import_structure["pipeline_flax_controlnet"] = ["FlaxStableDiffusionControlNetPipeline"]
45+
46+
47+
if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
48+
try:
49+
if not (is_transformers_available() and is_torch_available()):
50+
raise OptionalDependencyNotAvailable()
51+
52+
except OptionalDependencyNotAvailable:
53+
from ...utils.dummy_torch_and_transformers_objects import *
54+
else:
55+
from .multicontrolnet import MultiControlNetModel
56+
from .pipeline_controlnet import StableDiffusionControlNetPipeline
57+
from .pipeline_controlnet_blip_diffusion import BlipDiffusionControlNetPipeline
58+
from .pipeline_controlnet_img2img import StableDiffusionControlNetImg2ImgPipeline
59+
from .pipeline_controlnet_inpaint import StableDiffusionControlNetInpaintPipeline
60+
from .pipeline_controlnet_inpaint_sd_xl import StableDiffusionXLControlNetInpaintPipeline
61+
from .pipeline_controlnet_sd_xl import StableDiffusionXLControlNetPipeline
62+
from .pipeline_controlnet_sd_xl_img2img import StableDiffusionXLControlNetImg2ImgPipeline
63+
from .pipeline_controlnet_union_inpaint_sd_xl import StableDiffusionXLControlNetUnionInpaintPipeline
64+
from .pipeline_controlnet_union_sd_xl import StableDiffusionXLControlNetUnionPipeline
65+
from .pipeline_controlnet_union_sd_xl_img2img import StableDiffusionXLControlNetUnionImg2ImgPipeline
66+
67+
try:
68+
if not (is_transformers_available() and is_flax_available()):
69+
raise OptionalDependencyNotAvailable()
70+
except OptionalDependencyNotAvailable:
71+
from ...utils.dummy_flax_and_transformers_objects import * # noqa F403
72+
else:
73+
from .pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline
74+
75+
76+
else:
77+
import sys
78+
79+
sys.modules[__name__] = _LazyModule(
80+
__name__,
81+
globals()["__file__"],
82+
_import_structure,
83+
module_spec=__spec__,
84+
)
85+
for name, value in _dummy_objects.items():
86+
setattr(sys.modules[__name__], name, value)

src/diffusers/pipelines/controlnet/pipeline_controlnet_union_inpaint_sd_xl.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -837,14 +837,10 @@ def prepare_control_image(
837837
num_images_per_prompt,
838838
device,
839839
dtype,
840-
crops_coords,
841-
resize_mode,
842840
do_classifier_free_guidance=False,
843841
guess_mode=False,
844842
):
845-
image = self.control_image_processor.preprocess(
846-
image, height=height, width=width, crops_coords=crops_coords, resize_mode=resize_mode
847-
).to(dtype=torch.float32)
843+
image = self.control_image_processor.preprocess(image, height=height, width=width).to(dtype=torch.float32)
848844
image_batch_size = image.shape[0]
849845

850846
if image_batch_size == 1:

src/diffusers/pipelines/controlnet/pipeline_controlnet_union_sd_xl.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -835,11 +835,9 @@ def prepare_image(
835835

836836
if image_batch_size == 1:
837837
repeat_by = batch_size
838-
elif image_batch_size == batch_size:
838+
else:
839839
# image batch size is the same as prompt batch size
840840
repeat_by = num_images_per_prompt
841-
else:
842-
raise ValueError(f"Expected image batch size == 1 or `batch_size`, got {image_batch_size}.")
843841

844842
image = image.repeat_interleave(repeat_by, dim=0)
845843

@@ -1028,8 +1026,8 @@ def __call__(
10281026
used in both text-encoders.
10291027
image (`Union[ControlNetUnionInput, ControlNetUnionInputProMax]`):
10301028
In turn this supports (`torch.FloatTensor`, `PIL.Image.Image`, `np.ndarray`, `List[torch.FloatTensor]`,
1031-
`List[PIL.Image.Image]`, `List[np.ndarray]`, `List[List[torch.FloatTensor]]`, `List[List[np.ndarray]]`
1032-
or `List[List[PIL.Image.Image]]`):
1029+
`List[PIL.Image.Image]`, `List[np.ndarray]`, `List[List[torch.FloatTensor]]`,
1030+
`List[List[np.ndarray]]` or `List[List[PIL.Image.Image]]`):
10331031
The ControlNet input condition to provide guidance to the `unet` for generation. If the type is
10341032
specified as `torch.Tensor`, it is passed to ControlNet as is. `PIL.Image.Image` can also be accepted
10351033
as an image. The dimensions of the output image defaults to `image`'s dimensions. If height and/or

src/diffusers/pipelines/controlnet/pipeline_controlnet_union_sd_xl_img2img.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,8 @@ def __call__(
10991099
image latents as `image`, if passing latents directly, it will not be encoded again.
11001100
control_image_list (`Union[ControlNetUnionInput, ControlNetUnionInputProMax]`):
11011101
In turn this supports (`torch.FloatTensor`, `PIL.Image.Image`, `np.ndarray`, `List[torch.FloatTensor]`,
1102-
`List[PIL.Image.Image]`, `List[np.ndarray]`, `List[List[torch.FloatTensor]]`, `List[List[np.ndarray]]`
1103-
or `List[List[PIL.Image.Image]]`)::
1102+
`List[PIL.Image.Image]`, `List[np.ndarray]`, `List[List[torch.FloatTensor]]`,
1103+
`List[List[np.ndarray]]` or `List[List[PIL.Image.Image]]`)::
11041104
The ControlNet input condition. ControlNet uses this input condition to generate guidance to Unet. If
11051105
the type is specified as `torch.Tensor`, it is passed to ControlNet as is. `PIL.Image.Image` can also
11061106
be accepted as an image. The dimensions of the output image defaults to `image`'s dimensions. If height

src/diffusers/utils/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
is_xformers_available,
9696
requires_backends,
9797
)
98-
from .inputs import BaseInput
9998
from .loading_utils import get_module_from_name, load_image, load_video
10099
from .logging import get_logger
101100
from .outputs import BaseOutput

src/diffusers/utils/dummy_pt_objects.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,21 @@ def from_pretrained(cls, *args, **kwargs):
212212
requires_backends(cls, ["torch"])
213213

214214

215+
class ControlNetUnionModel(metaclass=DummyObject):
216+
_backends = ["torch"]
217+
218+
def __init__(self, *args, **kwargs):
219+
requires_backends(self, ["torch"])
220+
221+
@classmethod
222+
def from_config(cls, *args, **kwargs):
223+
requires_backends(cls, ["torch"])
224+
225+
@classmethod
226+
def from_pretrained(cls, *args, **kwargs):
227+
requires_backends(cls, ["torch"])
228+
229+
215230
class ControlNetXSAdapter(metaclass=DummyObject):
216231
_backends = ["torch"]
217232

src/diffusers/utils/dummy_torch_and_transformers_objects.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,6 +1967,51 @@ def from_pretrained(cls, *args, **kwargs):
19671967
requires_backends(cls, ["torch", "transformers"])
19681968

19691969

1970+
class StableDiffusionXLControlNetUnionImg2ImgPipeline(metaclass=DummyObject):
1971+
_backends = ["torch", "transformers"]
1972+
1973+
def __init__(self, *args, **kwargs):
1974+
requires_backends(self, ["torch", "transformers"])
1975+
1976+
@classmethod
1977+
def from_config(cls, *args, **kwargs):
1978+
requires_backends(cls, ["torch", "transformers"])
1979+
1980+
@classmethod
1981+
def from_pretrained(cls, *args, **kwargs):
1982+
requires_backends(cls, ["torch", "transformers"])
1983+
1984+
1985+
class StableDiffusionXLControlNetUnionInpaintPipeline(metaclass=DummyObject):
1986+
_backends = ["torch", "transformers"]
1987+
1988+
def __init__(self, *args, **kwargs):
1989+
requires_backends(self, ["torch", "transformers"])
1990+
1991+
@classmethod
1992+
def from_config(cls, *args, **kwargs):
1993+
requires_backends(cls, ["torch", "transformers"])
1994+
1995+
@classmethod
1996+
def from_pretrained(cls, *args, **kwargs):
1997+
requires_backends(cls, ["torch", "transformers"])
1998+
1999+
2000+
class StableDiffusionXLControlNetUnionPipeline(metaclass=DummyObject):
2001+
_backends = ["torch", "transformers"]
2002+
2003+
def __init__(self, *args, **kwargs):
2004+
requires_backends(self, ["torch", "transformers"])
2005+
2006+
@classmethod
2007+
def from_config(cls, *args, **kwargs):
2008+
requires_backends(cls, ["torch", "transformers"])
2009+
2010+
@classmethod
2011+
def from_pretrained(cls, *args, **kwargs):
2012+
requires_backends(cls, ["torch", "transformers"])
2013+
2014+
19702015
class StableDiffusionXLControlNetXSPipeline(metaclass=DummyObject):
19712016
_backends = ["torch", "transformers"]
19722017

0 commit comments

Comments
 (0)