__init__.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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_flax_available,
  19. is_tf_available,
  20. is_tokenizers_available,
  21. is_torch_available,
  22. is_vision_available,
  23. )
  24. _import_structure = {
  25. "configuration_owlvit": [
  26. "OwlViTConfig",
  27. "OwlViTOnnxConfig",
  28. "OwlViTTextConfig",
  29. "OwlViTVisionConfig",
  30. ],
  31. "processing_owlvit": ["OwlViTProcessor"],
  32. }
  33. try:
  34. if not is_vision_available():
  35. raise OptionalDependencyNotAvailable()
  36. except OptionalDependencyNotAvailable:
  37. pass
  38. else:
  39. _import_structure["feature_extraction_owlvit"] = ["OwlViTFeatureExtractor"]
  40. _import_structure["image_processing_owlvit"] = ["OwlViTImageProcessor"]
  41. try:
  42. if not is_torch_available():
  43. raise OptionalDependencyNotAvailable()
  44. except OptionalDependencyNotAvailable:
  45. pass
  46. else:
  47. _import_structure["modeling_owlvit"] = [
  48. "OwlViTModel",
  49. "OwlViTPreTrainedModel",
  50. "OwlViTTextModel",
  51. "OwlViTVisionModel",
  52. "OwlViTForObjectDetection",
  53. ]
  54. if TYPE_CHECKING:
  55. from .configuration_owlvit import (
  56. OwlViTConfig,
  57. OwlViTOnnxConfig,
  58. OwlViTTextConfig,
  59. OwlViTVisionConfig,
  60. )
  61. from .processing_owlvit import OwlViTProcessor
  62. try:
  63. if not is_vision_available():
  64. raise OptionalDependencyNotAvailable()
  65. except OptionalDependencyNotAvailable:
  66. pass
  67. else:
  68. from .feature_extraction_owlvit import OwlViTFeatureExtractor
  69. from .image_processing_owlvit import OwlViTImageProcessor
  70. try:
  71. if not is_torch_available():
  72. raise OptionalDependencyNotAvailable()
  73. except OptionalDependencyNotAvailable:
  74. pass
  75. else:
  76. from .modeling_owlvit import (
  77. OwlViTForObjectDetection,
  78. OwlViTModel,
  79. OwlViTPreTrainedModel,
  80. OwlViTTextModel,
  81. OwlViTVisionModel,
  82. )
  83. else:
  84. import sys
  85. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)