Skip to content

Commit 6141ae2

Browse files
yiyixuxuyiyi@huggingface.co
andauthored
[Modular] add different pipeine blocks to init (#13145)
* up * style + copies * fix --------- Co-authored-by: yiyi@huggingface.co <yiyi@ip-26-0-160-103.ec2.internal>
1 parent 3c1c62e commit 6141ae2

3 files changed

Lines changed: 127 additions & 1 deletion

File tree

src/diffusers/__init__.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,17 @@
294294
)
295295
_import_structure["modular_pipelines"].extend(
296296
[
297+
"AutoPipelineBlocks",
297298
"ComponentsManager",
298299
"ComponentSpec",
300+
"ConditionalPipelineBlocks",
301+
"ConfigSpec",
302+
"InputParam",
303+
"LoopSequentialPipelineBlocks",
299304
"ModularPipeline",
300305
"ModularPipelineBlocks",
306+
"OutputParam",
307+
"SequentialPipelineBlocks",
301308
]
302309
)
303310
_import_structure["optimization"] = [
@@ -1063,7 +1070,19 @@
10631070
ZImageTransformer2DModel,
10641071
attention_backend,
10651072
)
1066-
from .modular_pipelines import ComponentsManager, ComponentSpec, ModularPipeline, ModularPipelineBlocks
1073+
from .modular_pipelines import (
1074+
AutoPipelineBlocks,
1075+
ComponentsManager,
1076+
ComponentSpec,
1077+
ConditionalPipelineBlocks,
1078+
ConfigSpec,
1079+
InputParam,
1080+
LoopSequentialPipelineBlocks,
1081+
ModularPipeline,
1082+
ModularPipelineBlocks,
1083+
OutputParam,
1084+
SequentialPipelineBlocks,
1085+
)
10671086
from .optimization import (
10681087
get_constant_schedule,
10691088
get_constant_schedule_with_warmup,

src/diffusers/modular_pipelines/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"ModularPipeline",
3434
"AutoPipelineBlocks",
3535
"SequentialPipelineBlocks",
36+
"ConditionalPipelineBlocks",
3637
"LoopSequentialPipelineBlocks",
3738
"PipelineState",
3839
"BlockState",
@@ -105,6 +106,7 @@
105106
from .modular_pipeline import (
106107
AutoPipelineBlocks,
107108
BlockState,
109+
ConditionalPipelineBlocks,
108110
LoopSequentialPipelineBlocks,
109111
ModularPipeline,
110112
ModularPipelineBlocks,

src/diffusers/utils/dummy_pt_objects.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,6 +1905,21 @@ def attention_backend(*args, **kwargs):
19051905
requires_backends(attention_backend, ["torch"])
19061906

19071907

1908+
class AutoPipelineBlocks(metaclass=DummyObject):
1909+
_backends = ["torch"]
1910+
1911+
def __init__(self, *args, **kwargs):
1912+
requires_backends(self, ["torch"])
1913+
1914+
@classmethod
1915+
def from_config(cls, *args, **kwargs):
1916+
requires_backends(cls, ["torch"])
1917+
1918+
@classmethod
1919+
def from_pretrained(cls, *args, **kwargs):
1920+
requires_backends(cls, ["torch"])
1921+
1922+
19081923
class ComponentsManager(metaclass=DummyObject):
19091924
_backends = ["torch"]
19101925

@@ -1935,6 +1950,66 @@ def from_pretrained(cls, *args, **kwargs):
19351950
requires_backends(cls, ["torch"])
19361951

19371952

1953+
class ConditionalPipelineBlocks(metaclass=DummyObject):
1954+
_backends = ["torch"]
1955+
1956+
def __init__(self, *args, **kwargs):
1957+
requires_backends(self, ["torch"])
1958+
1959+
@classmethod
1960+
def from_config(cls, *args, **kwargs):
1961+
requires_backends(cls, ["torch"])
1962+
1963+
@classmethod
1964+
def from_pretrained(cls, *args, **kwargs):
1965+
requires_backends(cls, ["torch"])
1966+
1967+
1968+
class ConfigSpec(metaclass=DummyObject):
1969+
_backends = ["torch"]
1970+
1971+
def __init__(self, *args, **kwargs):
1972+
requires_backends(self, ["torch"])
1973+
1974+
@classmethod
1975+
def from_config(cls, *args, **kwargs):
1976+
requires_backends(cls, ["torch"])
1977+
1978+
@classmethod
1979+
def from_pretrained(cls, *args, **kwargs):
1980+
requires_backends(cls, ["torch"])
1981+
1982+
1983+
class InputParam(metaclass=DummyObject):
1984+
_backends = ["torch"]
1985+
1986+
def __init__(self, *args, **kwargs):
1987+
requires_backends(self, ["torch"])
1988+
1989+
@classmethod
1990+
def from_config(cls, *args, **kwargs):
1991+
requires_backends(cls, ["torch"])
1992+
1993+
@classmethod
1994+
def from_pretrained(cls, *args, **kwargs):
1995+
requires_backends(cls, ["torch"])
1996+
1997+
1998+
class LoopSequentialPipelineBlocks(metaclass=DummyObject):
1999+
_backends = ["torch"]
2000+
2001+
def __init__(self, *args, **kwargs):
2002+
requires_backends(self, ["torch"])
2003+
2004+
@classmethod
2005+
def from_config(cls, *args, **kwargs):
2006+
requires_backends(cls, ["torch"])
2007+
2008+
@classmethod
2009+
def from_pretrained(cls, *args, **kwargs):
2010+
requires_backends(cls, ["torch"])
2011+
2012+
19382013
class ModularPipeline(metaclass=DummyObject):
19392014
_backends = ["torch"]
19402015

@@ -1965,6 +2040,36 @@ def from_pretrained(cls, *args, **kwargs):
19652040
requires_backends(cls, ["torch"])
19662041

19672042

2043+
class OutputParam(metaclass=DummyObject):
2044+
_backends = ["torch"]
2045+
2046+
def __init__(self, *args, **kwargs):
2047+
requires_backends(self, ["torch"])
2048+
2049+
@classmethod
2050+
def from_config(cls, *args, **kwargs):
2051+
requires_backends(cls, ["torch"])
2052+
2053+
@classmethod
2054+
def from_pretrained(cls, *args, **kwargs):
2055+
requires_backends(cls, ["torch"])
2056+
2057+
2058+
class SequentialPipelineBlocks(metaclass=DummyObject):
2059+
_backends = ["torch"]
2060+
2061+
def __init__(self, *args, **kwargs):
2062+
requires_backends(self, ["torch"])
2063+
2064+
@classmethod
2065+
def from_config(cls, *args, **kwargs):
2066+
requires_backends(cls, ["torch"])
2067+
2068+
@classmethod
2069+
def from_pretrained(cls, *args, **kwargs):
2070+
requires_backends(cls, ["torch"])
2071+
2072+
19682073
def get_constant_schedule(*args, **kwargs):
19692074
requires_backends(get_constant_schedule, ["torch"])
19702075

0 commit comments

Comments
 (0)