|
| 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"] = [ |
| 25 | + "Flux2TextEncoderStep", |
| 26 | + "Flux2RemoteTextEncoderStep", |
| 27 | + "Flux2VaeEncoderStep", |
| 28 | + ] |
| 29 | + _import_structure["before_denoise"] = [ |
| 30 | + "Flux2SetTimestepsStep", |
| 31 | + "Flux2PrepareLatentsStep", |
| 32 | + "Flux2RoPEInputsStep", |
| 33 | + "Flux2PrepareImageLatentsStep", |
| 34 | + ] |
| 35 | + _import_structure["denoise"] = [ |
| 36 | + "Flux2LoopDenoiser", |
| 37 | + "Flux2LoopAfterDenoiser", |
| 38 | + "Flux2DenoiseLoopWrapper", |
| 39 | + "Flux2DenoiseStep", |
| 40 | + ] |
| 41 | + _import_structure["decoders"] = ["Flux2DecodeStep"] |
| 42 | + _import_structure["inputs"] = [ |
| 43 | + "Flux2ProcessImagesInputStep", |
| 44 | + "Flux2TextInputStep", |
| 45 | + ] |
| 46 | + _import_structure["modular_blocks"] = [ |
| 47 | + "ALL_BLOCKS", |
| 48 | + "AUTO_BLOCKS", |
| 49 | + "REMOTE_AUTO_BLOCKS", |
| 50 | + "TEXT2IMAGE_BLOCKS", |
| 51 | + "IMAGE_CONDITIONED_BLOCKS", |
| 52 | + "Flux2AutoBlocks", |
| 53 | + "Flux2AutoVaeEncoderStep", |
| 54 | + "Flux2BeforeDenoiseStep", |
| 55 | + "Flux2VaeEncoderSequentialStep", |
| 56 | + ] |
| 57 | + _import_structure["modular_pipeline"] = ["Flux2ModularPipeline"] |
| 58 | + |
| 59 | +if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT: |
| 60 | + try: |
| 61 | + if not (is_transformers_available() and is_torch_available()): |
| 62 | + raise OptionalDependencyNotAvailable() |
| 63 | + except OptionalDependencyNotAvailable: |
| 64 | + from ...utils.dummy_torch_and_transformers_objects import * # noqa F403 |
| 65 | + else: |
| 66 | + from .before_denoise import ( |
| 67 | + Flux2PrepareImageLatentsStep, |
| 68 | + Flux2PrepareLatentsStep, |
| 69 | + Flux2RoPEInputsStep, |
| 70 | + Flux2SetTimestepsStep, |
| 71 | + ) |
| 72 | + from .decoders import Flux2DecodeStep |
| 73 | + from .denoise import ( |
| 74 | + Flux2DenoiseLoopWrapper, |
| 75 | + Flux2DenoiseStep, |
| 76 | + Flux2LoopAfterDenoiser, |
| 77 | + Flux2LoopDenoiser, |
| 78 | + ) |
| 79 | + from .encoders import ( |
| 80 | + Flux2RemoteTextEncoderStep, |
| 81 | + Flux2TextEncoderStep, |
| 82 | + Flux2VaeEncoderStep, |
| 83 | + ) |
| 84 | + from .inputs import ( |
| 85 | + Flux2ProcessImagesInputStep, |
| 86 | + Flux2TextInputStep, |
| 87 | + ) |
| 88 | + from .modular_blocks import ( |
| 89 | + ALL_BLOCKS, |
| 90 | + AUTO_BLOCKS, |
| 91 | + IMAGE_CONDITIONED_BLOCKS, |
| 92 | + REMOTE_AUTO_BLOCKS, |
| 93 | + TEXT2IMAGE_BLOCKS, |
| 94 | + Flux2AutoBlocks, |
| 95 | + Flux2AutoVaeEncoderStep, |
| 96 | + Flux2BeforeDenoiseStep, |
| 97 | + Flux2VaeEncoderSequentialStep, |
| 98 | + ) |
| 99 | + from .modular_pipeline import Flux2ModularPipeline |
| 100 | +else: |
| 101 | + import sys |
| 102 | + |
| 103 | + sys.modules[__name__] = _LazyModule( |
| 104 | + __name__, |
| 105 | + globals()["__file__"], |
| 106 | + _import_structure, |
| 107 | + module_spec=__spec__, |
| 108 | + ) |
| 109 | + |
| 110 | + for name, value in _dummy_objects.items(): |
| 111 | + setattr(sys.modules[__name__], name, value) |
0 commit comments