__init__.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Copyright 2022 Meta Platforms authors and 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_torch_available, is_vision_available
  16. _import_structure = {
  17. "configuration_flava": [
  18. "FlavaConfig",
  19. "FlavaImageCodebookConfig",
  20. "FlavaImageConfig",
  21. "FlavaMultimodalConfig",
  22. "FlavaTextConfig",
  23. ],
  24. }
  25. try:
  26. if not is_vision_available():
  27. raise OptionalDependencyNotAvailable()
  28. except OptionalDependencyNotAvailable:
  29. pass
  30. else:
  31. _import_structure["feature_extraction_flava"] = ["FlavaFeatureExtractor"]
  32. _import_structure["image_processing_flava"] = ["FlavaImageProcessor"]
  33. _import_structure["processing_flava"] = ["FlavaProcessor"]
  34. try:
  35. if not is_torch_available():
  36. raise OptionalDependencyNotAvailable()
  37. except OptionalDependencyNotAvailable:
  38. pass
  39. else:
  40. _import_structure["modeling_flava"] = [
  41. "FlavaForPreTraining",
  42. "FlavaImageCodebook",
  43. "FlavaImageModel",
  44. "FlavaModel",
  45. "FlavaMultimodalModel",
  46. "FlavaPreTrainedModel",
  47. "FlavaTextModel",
  48. ]
  49. if TYPE_CHECKING:
  50. from .configuration_flava import (
  51. FlavaConfig,
  52. FlavaImageCodebookConfig,
  53. FlavaImageConfig,
  54. FlavaMultimodalConfig,
  55. FlavaTextConfig,
  56. )
  57. try:
  58. if not is_vision_available():
  59. raise OptionalDependencyNotAvailable()
  60. except OptionalDependencyNotAvailable:
  61. pass
  62. else:
  63. from .feature_extraction_flava import FlavaFeatureExtractor
  64. from .image_processing_flava import FlavaImageProcessor
  65. from .processing_flava import FlavaProcessor
  66. try:
  67. if not is_torch_available():
  68. raise OptionalDependencyNotAvailable()
  69. except OptionalDependencyNotAvailable:
  70. pass
  71. else:
  72. from .modeling_flava import (
  73. FlavaForPreTraining,
  74. FlavaImageCodebook,
  75. FlavaImageModel,
  76. FlavaModel,
  77. FlavaMultimodalModel,
  78. FlavaPreTrainedModel,
  79. FlavaTextModel,
  80. )
  81. else:
  82. import sys
  83. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)