__init__.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_tokenizers_available,
  19. is_torch_available,
  20. is_vision_available,
  21. )
  22. _import_structure = {
  23. "configuration_perceiver": ["PerceiverConfig", "PerceiverOnnxConfig"],
  24. "tokenization_perceiver": ["PerceiverTokenizer"],
  25. }
  26. try:
  27. if not is_vision_available():
  28. raise OptionalDependencyNotAvailable()
  29. except OptionalDependencyNotAvailable:
  30. pass
  31. else:
  32. _import_structure["feature_extraction_perceiver"] = ["PerceiverFeatureExtractor"]
  33. _import_structure["image_processing_perceiver"] = ["PerceiverImageProcessor"]
  34. try:
  35. if not is_torch_available():
  36. raise OptionalDependencyNotAvailable()
  37. except OptionalDependencyNotAvailable:
  38. pass
  39. else:
  40. _import_structure["modeling_perceiver"] = [
  41. "PerceiverForImageClassificationConvProcessing",
  42. "PerceiverForImageClassificationFourier",
  43. "PerceiverForImageClassificationLearned",
  44. "PerceiverForMaskedLM",
  45. "PerceiverForMultimodalAutoencoding",
  46. "PerceiverForOpticalFlow",
  47. "PerceiverForSequenceClassification",
  48. "PerceiverLayer",
  49. "PerceiverModel",
  50. "PerceiverPreTrainedModel",
  51. ]
  52. if TYPE_CHECKING:
  53. from .configuration_perceiver import PerceiverConfig, PerceiverOnnxConfig
  54. from .tokenization_perceiver import PerceiverTokenizer
  55. try:
  56. if not is_vision_available():
  57. raise OptionalDependencyNotAvailable()
  58. except OptionalDependencyNotAvailable:
  59. pass
  60. else:
  61. from .feature_extraction_perceiver import PerceiverFeatureExtractor
  62. from .image_processing_perceiver import PerceiverImageProcessor
  63. try:
  64. if not is_torch_available():
  65. raise OptionalDependencyNotAvailable()
  66. except OptionalDependencyNotAvailable:
  67. pass
  68. else:
  69. from .modeling_perceiver import (
  70. PerceiverForImageClassificationConvProcessing,
  71. PerceiverForImageClassificationFourier,
  72. PerceiverForImageClassificationLearned,
  73. PerceiverForMaskedLM,
  74. PerceiverForMultimodalAutoencoding,
  75. PerceiverForOpticalFlow,
  76. PerceiverForSequenceClassification,
  77. PerceiverLayer,
  78. PerceiverModel,
  79. PerceiverPreTrainedModel,
  80. )
  81. else:
  82. import sys
  83. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)