__init__.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Copyright 2023 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_torch_available,
  19. is_vision_available,
  20. )
  21. _import_structure = {
  22. "configuration_owlv2": [
  23. "Owlv2Config",
  24. "Owlv2TextConfig",
  25. "Owlv2VisionConfig",
  26. ],
  27. "processing_owlv2": ["Owlv2Processor"],
  28. }
  29. try:
  30. if not is_vision_available():
  31. raise OptionalDependencyNotAvailable()
  32. except OptionalDependencyNotAvailable:
  33. pass
  34. else:
  35. _import_structure["image_processing_owlv2"] = ["Owlv2ImageProcessor"]
  36. try:
  37. if not is_torch_available():
  38. raise OptionalDependencyNotAvailable()
  39. except OptionalDependencyNotAvailable:
  40. pass
  41. else:
  42. _import_structure["modeling_owlv2"] = [
  43. "Owlv2Model",
  44. "Owlv2PreTrainedModel",
  45. "Owlv2TextModel",
  46. "Owlv2VisionModel",
  47. "Owlv2ForObjectDetection",
  48. ]
  49. if TYPE_CHECKING:
  50. from .configuration_owlv2 import (
  51. Owlv2Config,
  52. Owlv2TextConfig,
  53. Owlv2VisionConfig,
  54. )
  55. from .processing_owlv2 import Owlv2Processor
  56. try:
  57. if not is_vision_available():
  58. raise OptionalDependencyNotAvailable()
  59. except OptionalDependencyNotAvailable:
  60. pass
  61. else:
  62. from .image_processing_owlv2 import Owlv2ImageProcessor
  63. try:
  64. if not is_torch_available():
  65. raise OptionalDependencyNotAvailable()
  66. except OptionalDependencyNotAvailable:
  67. pass
  68. else:
  69. from .modeling_owlv2 import (
  70. Owlv2ForObjectDetection,
  71. Owlv2Model,
  72. Owlv2PreTrainedModel,
  73. Owlv2TextModel,
  74. Owlv2VisionModel,
  75. )
  76. else:
  77. import sys
  78. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)