__init__.py 1.39 KB
Newer Older
1
2
from typing import TYPE_CHECKING

Sanchit Gandhi's avatar
Sanchit Gandhi committed
3
from ...utils import (
4
    DIFFUSERS_SLOW_IMPORT,
Sanchit Gandhi's avatar
Sanchit Gandhi committed
5
    OptionalDependencyNotAvailable,
Dhruv Nair's avatar
Dhruv Nair committed
6
    _LazyModule,
Sanchit Gandhi's avatar
Sanchit Gandhi committed
7
8
9
10
11
12
    is_torch_available,
    is_transformers_available,
    is_transformers_version,
)


Dhruv Nair's avatar
Dhruv Nair committed
13
_dummy_objects = {}
14
_import_structure = {}
Dhruv Nair's avatar
Dhruv Nair committed
15

Sanchit Gandhi's avatar
Sanchit Gandhi committed
16
17
18
19
20
21
22
try:
    if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.27.0")):
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    from ...utils.dummy_torch_and_transformers_objects import (
        AudioLDMPipeline,
    )
Dhruv Nair's avatar
Dhruv Nair committed
23
24

    _dummy_objects.update({"AudioLDMPipeline": AudioLDMPipeline})
Sanchit Gandhi's avatar
Sanchit Gandhi committed
25
else:
Dhruv Nair's avatar
Dhruv Nair committed
26
27
28
    _import_structure["pipeline_audioldm"] = ["AudioLDMPipeline"]


29
if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
30
31
32
33
34
35
36
    try:
        if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.27.0")):
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        from ...utils.dummy_torch_and_transformers_objects import (
            AudioLDMPipeline,
        )
Dhruv Nair's avatar
Dhruv Nair committed
37

38
39
40
41
42
43
44
45
46
47
48
    else:
        from .pipeline_audioldm import AudioLDMPipeline
else:
    import sys

    sys.modules[__name__] = _LazyModule(
        __name__,
        globals()["__file__"],
        _import_structure,
        module_spec=__spec__,
    )
Dhruv Nair's avatar
Dhruv Nair committed
49

50
51
    for name, value in _dummy_objects.items():
        setattr(sys.modules[__name__], name, value)