__init__.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Copyright 2023 The Intel Labs Team Authors, The Microsoft Research Team Authors and HuggingFace Inc. 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_torch_available, is_vision_available
  16. _import_structure = {
  17. "configuration_bridgetower": [
  18. "BridgeTowerConfig",
  19. "BridgeTowerTextConfig",
  20. "BridgeTowerVisionConfig",
  21. ],
  22. "processing_bridgetower": ["BridgeTowerProcessor"],
  23. }
  24. try:
  25. if not is_vision_available():
  26. raise OptionalDependencyNotAvailable()
  27. except OptionalDependencyNotAvailable:
  28. pass
  29. else:
  30. _import_structure["image_processing_bridgetower"] = ["BridgeTowerImageProcessor"]
  31. try:
  32. if not is_torch_available():
  33. raise OptionalDependencyNotAvailable()
  34. except OptionalDependencyNotAvailable:
  35. pass
  36. else:
  37. _import_structure["modeling_bridgetower"] = [
  38. "BridgeTowerForContrastiveLearning",
  39. "BridgeTowerForImageAndTextRetrieval",
  40. "BridgeTowerForMaskedLM",
  41. "BridgeTowerModel",
  42. "BridgeTowerPreTrainedModel",
  43. ]
  44. if TYPE_CHECKING:
  45. from .configuration_bridgetower import (
  46. BridgeTowerConfig,
  47. BridgeTowerTextConfig,
  48. BridgeTowerVisionConfig,
  49. )
  50. from .processing_bridgetower import BridgeTowerProcessor
  51. try:
  52. if not is_vision_available():
  53. raise OptionalDependencyNotAvailable()
  54. except OptionalDependencyNotAvailable:
  55. pass
  56. else:
  57. from .image_processing_bridgetower import BridgeTowerImageProcessor
  58. try:
  59. if not is_torch_available():
  60. raise OptionalDependencyNotAvailable()
  61. except OptionalDependencyNotAvailable:
  62. pass
  63. else:
  64. from .modeling_bridgetower import (
  65. BridgeTowerForContrastiveLearning,
  66. BridgeTowerForImageAndTextRetrieval,
  67. BridgeTowerForMaskedLM,
  68. BridgeTowerModel,
  69. BridgeTowerPreTrainedModel,
  70. )
  71. else:
  72. import sys
  73. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)