__init__.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available
  16. _import_structure = {
  17. "configuration_data2vec_audio": ["Data2VecAudioConfig"],
  18. "configuration_data2vec_text": [
  19. "Data2VecTextConfig",
  20. "Data2VecTextOnnxConfig",
  21. ],
  22. "configuration_data2vec_vision": [
  23. "Data2VecVisionConfig",
  24. "Data2VecVisionOnnxConfig",
  25. ],
  26. }
  27. try:
  28. if not is_torch_available():
  29. raise OptionalDependencyNotAvailable()
  30. except OptionalDependencyNotAvailable:
  31. pass
  32. else:
  33. _import_structure["modeling_data2vec_audio"] = [
  34. "Data2VecAudioForAudioFrameClassification",
  35. "Data2VecAudioForCTC",
  36. "Data2VecAudioForSequenceClassification",
  37. "Data2VecAudioForXVector",
  38. "Data2VecAudioModel",
  39. "Data2VecAudioPreTrainedModel",
  40. ]
  41. _import_structure["modeling_data2vec_text"] = [
  42. "Data2VecTextForCausalLM",
  43. "Data2VecTextForMaskedLM",
  44. "Data2VecTextForMultipleChoice",
  45. "Data2VecTextForQuestionAnswering",
  46. "Data2VecTextForSequenceClassification",
  47. "Data2VecTextForTokenClassification",
  48. "Data2VecTextModel",
  49. "Data2VecTextPreTrainedModel",
  50. ]
  51. _import_structure["modeling_data2vec_vision"] = [
  52. "Data2VecVisionForImageClassification",
  53. "Data2VecVisionForMaskedImageModeling",
  54. "Data2VecVisionForSemanticSegmentation",
  55. "Data2VecVisionModel",
  56. "Data2VecVisionPreTrainedModel",
  57. ]
  58. if is_tf_available():
  59. _import_structure["modeling_tf_data2vec_vision"] = [
  60. "TFData2VecVisionForImageClassification",
  61. "TFData2VecVisionForSemanticSegmentation",
  62. "TFData2VecVisionModel",
  63. "TFData2VecVisionPreTrainedModel",
  64. ]
  65. if TYPE_CHECKING:
  66. from .configuration_data2vec_audio import Data2VecAudioConfig
  67. from .configuration_data2vec_text import (
  68. Data2VecTextConfig,
  69. Data2VecTextOnnxConfig,
  70. )
  71. from .configuration_data2vec_vision import (
  72. Data2VecVisionConfig,
  73. Data2VecVisionOnnxConfig,
  74. )
  75. try:
  76. if not is_torch_available():
  77. raise OptionalDependencyNotAvailable()
  78. except OptionalDependencyNotAvailable:
  79. pass
  80. else:
  81. from .modeling_data2vec_audio import (
  82. Data2VecAudioForAudioFrameClassification,
  83. Data2VecAudioForCTC,
  84. Data2VecAudioForSequenceClassification,
  85. Data2VecAudioForXVector,
  86. Data2VecAudioModel,
  87. Data2VecAudioPreTrainedModel,
  88. )
  89. from .modeling_data2vec_text import (
  90. Data2VecTextForCausalLM,
  91. Data2VecTextForMaskedLM,
  92. Data2VecTextForMultipleChoice,
  93. Data2VecTextForQuestionAnswering,
  94. Data2VecTextForSequenceClassification,
  95. Data2VecTextForTokenClassification,
  96. Data2VecTextModel,
  97. Data2VecTextPreTrainedModel,
  98. )
  99. from .modeling_data2vec_vision import (
  100. Data2VecVisionForImageClassification,
  101. Data2VecVisionForMaskedImageModeling,
  102. Data2VecVisionForSemanticSegmentation,
  103. Data2VecVisionModel,
  104. Data2VecVisionPreTrainedModel,
  105. )
  106. if is_tf_available():
  107. from .modeling_tf_data2vec_vision import (
  108. TFData2VecVisionForImageClassification,
  109. TFData2VecVisionForSemanticSegmentation,
  110. TFData2VecVisionModel,
  111. TFData2VecVisionPreTrainedModel,
  112. )
  113. else:
  114. import sys
  115. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)