__init__.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Copyright 2022 The HuggingFace Team. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from typing import TYPE_CHECKING
  15. from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available
  16. from ...utils import OptionalDependencyNotAvailable
  17. _import_structure = {"configuration_dpt": ["DPTConfig"]}
  18. try:
  19. if not is_vision_available():
  20. raise OptionalDependencyNotAvailable()
  21. except OptionalDependencyNotAvailable:
  22. pass
  23. else:
  24. _import_structure["feature_extraction_dpt"] = ["DPTFeatureExtractor"]
  25. _import_structure["image_processing_dpt"] = ["DPTImageProcessor"]
  26. try:
  27. if not is_torch_available():
  28. raise OptionalDependencyNotAvailable()
  29. except OptionalDependencyNotAvailable:
  30. pass
  31. else:
  32. _import_structure["modeling_dpt"] = [
  33. "DPTForDepthEstimation",
  34. "DPTForSemanticSegmentation",
  35. "DPTModel",
  36. "DPTPreTrainedModel",
  37. ]
  38. if TYPE_CHECKING:
  39. from .configuration_dpt import DPTConfig
  40. try:
  41. if not is_vision_available():
  42. raise OptionalDependencyNotAvailable()
  43. except OptionalDependencyNotAvailable:
  44. pass
  45. else:
  46. from .feature_extraction_dpt import DPTFeatureExtractor
  47. from .image_processing_dpt import DPTImageProcessor
  48. try:
  49. if not is_torch_available():
  50. raise OptionalDependencyNotAvailable()
  51. except OptionalDependencyNotAvailable:
  52. pass
  53. else:
  54. from .modeling_dpt import (
  55. DPTForDepthEstimation,
  56. DPTForSemanticSegmentation,
  57. DPTModel,
  58. DPTPreTrainedModel,
  59. )
  60. else:
  61. import sys
  62. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)