__init__.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 ...utils import (
  16. OptionalDependencyNotAvailable,
  17. _LazyModule,
  18. is_tf_available,
  19. is_torch_available,
  20. is_vision_available,
  21. )
  22. _import_structure = {
  23. "configuration_mobilevit": ["MobileViTConfig", "MobileViTOnnxConfig"],
  24. }
  25. try:
  26. if not is_vision_available():
  27. raise OptionalDependencyNotAvailable()
  28. except OptionalDependencyNotAvailable:
  29. pass
  30. else:
  31. _import_structure["feature_extraction_mobilevit"] = ["MobileViTFeatureExtractor"]
  32. _import_structure["image_processing_mobilevit"] = ["MobileViTImageProcessor"]
  33. try:
  34. if not is_torch_available():
  35. raise OptionalDependencyNotAvailable()
  36. except OptionalDependencyNotAvailable:
  37. pass
  38. else:
  39. _import_structure["modeling_mobilevit"] = [
  40. "MobileViTForImageClassification",
  41. "MobileViTForSemanticSegmentation",
  42. "MobileViTModel",
  43. "MobileViTPreTrainedModel",
  44. ]
  45. try:
  46. if not is_tf_available():
  47. raise OptionalDependencyNotAvailable()
  48. except OptionalDependencyNotAvailable:
  49. pass
  50. else:
  51. _import_structure["modeling_tf_mobilevit"] = [
  52. "TFMobileViTForImageClassification",
  53. "TFMobileViTForSemanticSegmentation",
  54. "TFMobileViTModel",
  55. "TFMobileViTPreTrainedModel",
  56. ]
  57. if TYPE_CHECKING:
  58. from .configuration_mobilevit import MobileViTConfig, MobileViTOnnxConfig
  59. try:
  60. if not is_vision_available():
  61. raise OptionalDependencyNotAvailable()
  62. except OptionalDependencyNotAvailable:
  63. pass
  64. else:
  65. from .feature_extraction_mobilevit import MobileViTFeatureExtractor
  66. from .image_processing_mobilevit import MobileViTImageProcessor
  67. try:
  68. if not is_torch_available():
  69. raise OptionalDependencyNotAvailable()
  70. except OptionalDependencyNotAvailable:
  71. pass
  72. else:
  73. from .modeling_mobilevit import (
  74. MobileViTForImageClassification,
  75. MobileViTForSemanticSegmentation,
  76. MobileViTModel,
  77. MobileViTPreTrainedModel,
  78. )
  79. try:
  80. if not is_tf_available():
  81. raise OptionalDependencyNotAvailable()
  82. except OptionalDependencyNotAvailable:
  83. pass
  84. else:
  85. from .modeling_tf_mobilevit import (
  86. TFMobileViTForImageClassification,
  87. TFMobileViTForSemanticSegmentation,
  88. TFMobileViTModel,
  89. TFMobileViTPreTrainedModel,
  90. )
  91. else:
  92. import sys
  93. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)