__init__.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # Copyright 2021 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 = {"configuration_deit": ["DeiTConfig", "DeiTOnnxConfig"]}
  23. try:
  24. if not is_vision_available():
  25. raise OptionalDependencyNotAvailable()
  26. except OptionalDependencyNotAvailable:
  27. pass
  28. else:
  29. _import_structure["feature_extraction_deit"] = ["DeiTFeatureExtractor"]
  30. _import_structure["image_processing_deit"] = ["DeiTImageProcessor"]
  31. try:
  32. if not is_torch_available():
  33. raise OptionalDependencyNotAvailable()
  34. except OptionalDependencyNotAvailable:
  35. pass
  36. else:
  37. _import_structure["modeling_deit"] = [
  38. "DeiTForImageClassification",
  39. "DeiTForImageClassificationWithTeacher",
  40. "DeiTForMaskedImageModeling",
  41. "DeiTModel",
  42. "DeiTPreTrainedModel",
  43. ]
  44. try:
  45. if not is_tf_available():
  46. raise OptionalDependencyNotAvailable()
  47. except OptionalDependencyNotAvailable:
  48. pass
  49. else:
  50. _import_structure["modeling_tf_deit"] = [
  51. "TFDeiTForImageClassification",
  52. "TFDeiTForImageClassificationWithTeacher",
  53. "TFDeiTForMaskedImageModeling",
  54. "TFDeiTModel",
  55. "TFDeiTPreTrainedModel",
  56. ]
  57. if TYPE_CHECKING:
  58. from .configuration_deit import DeiTConfig, DeiTOnnxConfig
  59. try:
  60. if not is_vision_available():
  61. raise OptionalDependencyNotAvailable()
  62. except OptionalDependencyNotAvailable:
  63. pass
  64. else:
  65. from .feature_extraction_deit import DeiTFeatureExtractor
  66. from .image_processing_deit import DeiTImageProcessor
  67. try:
  68. if not is_torch_available():
  69. raise OptionalDependencyNotAvailable()
  70. except OptionalDependencyNotAvailable:
  71. pass
  72. else:
  73. from .modeling_deit import (
  74. DeiTForImageClassification,
  75. DeiTForImageClassificationWithTeacher,
  76. DeiTForMaskedImageModeling,
  77. DeiTModel,
  78. DeiTPreTrainedModel,
  79. )
  80. try:
  81. if not is_tf_available():
  82. raise OptionalDependencyNotAvailable()
  83. except OptionalDependencyNotAvailable:
  84. pass
  85. else:
  86. from .modeling_tf_deit import (
  87. TFDeiTForImageClassification,
  88. TFDeiTForImageClassificationWithTeacher,
  89. TFDeiTForMaskedImageModeling,
  90. TFDeiTModel,
  91. TFDeiTPreTrainedModel,
  92. )
  93. else:
  94. import sys
  95. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)