__init__.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_tf_available,
  19. is_torch_available,
  20. is_vision_available,
  21. )
  22. _import_structure = {"configuration_idefics": ["IdeficsConfig"]}
  23. try:
  24. if not is_vision_available():
  25. raise OptionalDependencyNotAvailable()
  26. except OptionalDependencyNotAvailable:
  27. pass
  28. else:
  29. _import_structure["image_processing_idefics"] = ["IdeficsImageProcessor"]
  30. try:
  31. if not is_torch_available():
  32. raise OptionalDependencyNotAvailable()
  33. except OptionalDependencyNotAvailable:
  34. pass
  35. else:
  36. _import_structure["modeling_idefics"] = [
  37. "IdeficsForVisionText2Text",
  38. "IdeficsModel",
  39. "IdeficsPreTrainedModel",
  40. ]
  41. _import_structure["processing_idefics"] = ["IdeficsProcessor"]
  42. try:
  43. if not is_tf_available():
  44. raise OptionalDependencyNotAvailable()
  45. except OptionalDependencyNotAvailable:
  46. pass
  47. else:
  48. _import_structure["modeling_tf_idefics"] = [
  49. "TFIdeficsForVisionText2Text",
  50. "TFIdeficsModel",
  51. "TFIdeficsPreTrainedModel",
  52. ]
  53. if TYPE_CHECKING:
  54. from .configuration_idefics import IdeficsConfig
  55. try:
  56. if not is_vision_available():
  57. raise OptionalDependencyNotAvailable()
  58. except OptionalDependencyNotAvailable:
  59. pass
  60. else:
  61. from .image_processing_idefics import IdeficsImageProcessor
  62. try:
  63. if not is_torch_available():
  64. raise OptionalDependencyNotAvailable()
  65. except OptionalDependencyNotAvailable:
  66. pass
  67. else:
  68. from .modeling_idefics import (
  69. IdeficsForVisionText2Text,
  70. IdeficsModel,
  71. IdeficsPreTrainedModel,
  72. )
  73. from .processing_idefics import IdeficsProcessor
  74. try:
  75. if not is_tf_available():
  76. raise OptionalDependencyNotAvailable()
  77. except OptionalDependencyNotAvailable:
  78. pass
  79. else:
  80. from .modeling_tf_idefics import (
  81. TFIdeficsForVisionText2Text,
  82. TFIdeficsModel,
  83. TFIdeficsPreTrainedModel,
  84. )
  85. else:
  86. import sys
  87. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)