__init__.py 6.66 KB
Newer Older
1
# Copyright 2024 The HuggingFace Team. All rights reserved.
2
3
4
5
6
7
8
9
10
11
12
13
14
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

15
16
from typing import TYPE_CHECKING

Suraj Patil's avatar
Suraj Patil committed
17
18
19
20
21
22
from ..utils import (
    DIFFUSERS_SLOW_IMPORT,
    _LazyModule,
    is_flax_available,
    is_torch_available,
)
23
24


Dhruv Nair's avatar
Dhruv Nair committed
25
26
_import_structure = {}

27
if is_torch_available():
Dhruv Nair's avatar
Dhruv Nair committed
28
    _import_structure["adapter"] = ["MultiAdapter", "T2IAdapter"]
29
30
    _import_structure["autoencoders.autoencoder_asym_kl"] = ["AsymmetricAutoencoderKL"]
    _import_structure["autoencoders.autoencoder_kl"] = ["AutoencoderKL"]
31
    _import_structure["autoencoders.autoencoder_kl_cogvideox"] = ["AutoencoderKLCogVideoX"]
32
    _import_structure["autoencoders.autoencoder_kl_temporal_decoder"] = ["AutoencoderKLTemporalDecoder"]
33
    _import_structure["autoencoders.autoencoder_oobleck"] = ["AutoencoderOobleck"]
34
35
    _import_structure["autoencoders.autoencoder_tiny"] = ["AutoencoderTiny"]
    _import_structure["autoencoders.consistency_decoder_vae"] = ["ConsistencyDecoderVAE"]
36
    _import_structure["autoencoders.vq_model"] = ["VQModel"]
Dhruv Nair's avatar
Dhruv Nair committed
37
    _import_structure["controlnet"] = ["ControlNetModel"]
38
    _import_structure["controlnet_flux"] = ["FluxControlNetModel", "FluxMultiControlNetModel"]
39
    _import_structure["controlnet_hunyuan"] = ["HunyuanDiT2DControlNetModel", "HunyuanDiT2DMultiControlNetModel"]
40
    _import_structure["controlnet_sd3"] = ["SD3ControlNetModel", "SD3MultiControlNetModel"]
Aryan's avatar
Aryan committed
41
    _import_structure["controlnet_sparsectrl"] = ["SparseControlNetModel"]
42
    _import_structure["controlnet_xs"] = ["ControlNetXSAdapter", "UNetControlNetXSModel"]
43
    _import_structure["embeddings"] = ["ImageProjection"]
44
    _import_structure["modeling_utils"] = ["ModelMixin"]
Sayak Paul's avatar
Sayak Paul committed
45
    _import_structure["transformers.auraflow_transformer_2d"] = ["AuraFlowTransformer2DModel"]
46
    _import_structure["transformers.cogvideox_transformer_3d"] = ["CogVideoXTransformer3DModel"]
47
    _import_structure["transformers.dit_transformer_2d"] = ["DiTTransformer2DModel"]
48
    _import_structure["transformers.dual_transformer_2d"] = ["DualTransformer2DModel"]
49
    _import_structure["transformers.hunyuan_transformer_2d"] = ["HunyuanDiT2DModel"]
50
    _import_structure["transformers.latte_transformer_3d"] = ["LatteTransformer3DModel"]
51
    _import_structure["transformers.lumina_nextdit2d"] = ["LuminaNextDiT2DModel"]
52
    _import_structure["transformers.pixart_transformer_2d"] = ["PixArtTransformer2DModel"]
53
    _import_structure["transformers.prior_transformer"] = ["PriorTransformer"]
54
    _import_structure["transformers.stable_audio_transformer"] = ["StableAudioDiTModel"]
55
56
    _import_structure["transformers.t5_film_transformer"] = ["T5FilmDecoder"]
    _import_structure["transformers.transformer_2d"] = ["Transformer2DModel"]
Yuxuan.Zhang's avatar
Yuxuan.Zhang committed
57
    _import_structure["transformers.transformer_cogview3plus"] = ["CogView3PlusTransformer2DModel"]
Sayak Paul's avatar
Sayak Paul committed
58
    _import_structure["transformers.transformer_flux"] = ["FluxTransformer2DModel"]
Dhruv Nair's avatar
Dhruv Nair committed
59
    _import_structure["transformers.transformer_sd3"] = ["SD3Transformer2DModel"]
60
    _import_structure["transformers.transformer_temporal"] = ["TransformerTemporalModel"]
61
62
63
64
    _import_structure["unets.unet_1d"] = ["UNet1DModel"]
    _import_structure["unets.unet_2d"] = ["UNet2DModel"]
    _import_structure["unets.unet_2d_condition"] = ["UNet2DConditionModel"]
    _import_structure["unets.unet_3d_condition"] = ["UNet3DConditionModel"]
65
    _import_structure["unets.unet_i2vgen_xl"] = ["I2VGenXLUNet"]
66
67
68
    _import_structure["unets.unet_kandinsky3"] = ["Kandinsky3UNet"]
    _import_structure["unets.unet_motion_model"] = ["MotionAdapter", "UNetMotionModel"]
    _import_structure["unets.unet_spatio_temporal_condition"] = ["UNetSpatioTemporalConditionModel"]
69
    _import_structure["unets.unet_stable_cascade"] = ["StableCascadeUNet"]
70
    _import_structure["unets.uvit_2d"] = ["UVit2DModel"]
71
72

if is_flax_available():
Dhruv Nair's avatar
Dhruv Nair committed
73
    _import_structure["controlnet_flax"] = ["FlaxControlNetModel"]
74
    _import_structure["unets.unet_2d_condition_flax"] = ["FlaxUNet2DConditionModel"]
Dhruv Nair's avatar
Dhruv Nair committed
75
76
77
    _import_structure["vae_flax"] = ["FlaxAutoencoderKL"]


78
if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
79
80
    if is_torch_available():
        from .adapter import MultiAdapter, T2IAdapter
81
82
83
        from .autoencoders import (
            AsymmetricAutoencoderKL,
            AutoencoderKL,
84
            AutoencoderKLCogVideoX,
85
            AutoencoderKLTemporalDecoder,
86
            AutoencoderOobleck,
87
88
            AutoencoderTiny,
            ConsistencyDecoderVAE,
89
            VQModel,
90
        )
91
        from .controlnet import ControlNetModel
92
        from .controlnet_flux import FluxControlNetModel, FluxMultiControlNetModel
93
        from .controlnet_hunyuan import HunyuanDiT2DControlNetModel, HunyuanDiT2DMultiControlNetModel
94
        from .controlnet_sd3 import SD3ControlNetModel, SD3MultiControlNetModel
Aryan's avatar
Aryan committed
95
        from .controlnet_sparsectrl import SparseControlNetModel
96
        from .controlnet_xs import ControlNetXSAdapter, UNetControlNetXSModel
97
        from .embeddings import ImageProjection
98
        from .modeling_utils import ModelMixin
99
        from .transformers import (
Sayak Paul's avatar
Sayak Paul committed
100
            AuraFlowTransformer2DModel,
101
            CogVideoXTransformer3DModel,
Yuxuan.Zhang's avatar
Yuxuan.Zhang committed
102
            CogView3PlusTransformer2DModel,
103
            DiTTransformer2DModel,
104
            DualTransformer2DModel,
Sayak Paul's avatar
Sayak Paul committed
105
            FluxTransformer2DModel,
106
            HunyuanDiT2DModel,
107
            LatteTransformer3DModel,
108
            LuminaNextDiT2DModel,
109
            PixArtTransformer2DModel,
110
            PriorTransformer,
Dhruv Nair's avatar
Dhruv Nair committed
111
            SD3Transformer2DModel,
112
            StableAudioDiTModel,
113
114
115
116
            T5FilmDecoder,
            Transformer2DModel,
            TransformerTemporalModel,
        )
117
        from .unets import (
118
            I2VGenXLUNet,
119
120
            Kandinsky3UNet,
            MotionAdapter,
121
            StableCascadeUNet,
122
123
124
125
126
127
128
129
            UNet1DModel,
            UNet2DConditionModel,
            UNet2DModel,
            UNet3DConditionModel,
            UNetMotionModel,
            UNetSpatioTemporalConditionModel,
            UVit2DModel,
        )
130
131
132

    if is_flax_available():
        from .controlnet_flax import FlaxControlNetModel
133
        from .unets import FlaxUNet2DConditionModel
134
135
136
137
        from .vae_flax import FlaxAutoencoderKL

else:
    import sys
Dhruv Nair's avatar
Dhruv Nair committed
138

139
    sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)