Skip to content

Commit 0acb5e1

Browse files
committed
made a modular_pipelines folder!
1 parent 462429b commit 0acb5e1

File tree

11 files changed

+8047
-0
lines changed

11 files changed

+8047
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
# These modules contain pipelines from multiple libraries/frameworks
14+
_dummy_objects = {}
15+
_import_structure = {}
16+
17+
try:
18+
if not is_torch_available():
19+
raise OptionalDependencyNotAvailable()
20+
except OptionalDependencyNotAvailable:
21+
from ..utils import dummy_pt_objects # noqa F403
22+
23+
_dummy_objects.update(get_objects_from_module(dummy_pt_objects))
24+
else:
25+
_import_structure["modular_pipeline"] = [
26+
"ModularPipelineMixin",
27+
"PipelineBlock",
28+
"AutoPipelineBlocks",
29+
"SequentialPipelineBlocks",
30+
"LoopSequentialPipelineBlocks",
31+
"ModularLoader",
32+
"PipelineState",
33+
"BlockState",
34+
]
35+
_import_structure["modular_pipeline_utils"] = [
36+
"ComponentSpec",
37+
"ConfigSpec",
38+
"InputParam",
39+
"OutputParam",
40+
]
41+
_import_structure["stable_diffusion_xl"] = ["StableDiffusionXLAutoPipeline", "StableDiffusionXLModularLoader"]
42+
_import_structure["components_manager"] = ["ComponentsManager"]
43+
44+
if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
45+
try:
46+
if not is_torch_available():
47+
raise OptionalDependencyNotAvailable()
48+
except OptionalDependencyNotAvailable:
49+
from ..utils.dummy_pt_objects import * # noqa F403
50+
else:
51+
from .modular_pipeline import (
52+
AutoPipelineBlocks,
53+
BlockState,
54+
LoopSequentialPipelineBlocks,
55+
ModularLoader,
56+
ModularPipelineMixin,
57+
PipelineBlock,
58+
PipelineState,
59+
SequentialPipelineBlocks,
60+
)
61+
from .modular_pipeline_utils import (
62+
ComponentSpec,
63+
ConfigSpec,
64+
InputParam,
65+
OutputParam,
66+
)
67+
from .stable_diffusion_xl import (
68+
StableDiffusionXLAutoPipeline,
69+
StableDiffusionXLModularLoader,
70+
)
71+
from .components_manager import ComponentsManager
72+
else:
73+
import sys
74+
75+
sys.modules[__name__] = _LazyModule(
76+
__name__,
77+
globals()["__file__"],
78+
_import_structure,
79+
module_spec=__spec__,
80+
)
81+
for name, value in _dummy_objects.items():
82+
setattr(sys.modules[__name__], name, value)

0 commit comments

Comments
 (0)