__init__.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # coding=utf-8
  2. # Copyright 2023 Microsoft Research and The HuggingFace Inc. team. All rights reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. from typing import TYPE_CHECKING
  16. from ...utils import (
  17. OptionalDependencyNotAvailable,
  18. _LazyModule,
  19. is_torch_available,
  20. is_vision_available,
  21. )
  22. _import_structure = {
  23. "configuration_kosmos2": ["Kosmos2Config"],
  24. "processing_kosmos2": ["Kosmos2Processor"],
  25. }
  26. try:
  27. if not is_torch_available():
  28. raise OptionalDependencyNotAvailable()
  29. except OptionalDependencyNotAvailable:
  30. pass
  31. else:
  32. _import_structure["modeling_kosmos2"] = [
  33. "Kosmos2ForConditionalGeneration",
  34. "Kosmos2Model",
  35. "Kosmos2PreTrainedModel",
  36. ]
  37. if TYPE_CHECKING:
  38. from .configuration_kosmos2 import Kosmos2Config
  39. from .processing_kosmos2 import Kosmos2Processor
  40. try:
  41. if not is_torch_available():
  42. raise OptionalDependencyNotAvailable()
  43. except OptionalDependencyNotAvailable:
  44. pass
  45. else:
  46. from .modeling_kosmos2 import (
  47. Kosmos2ForConditionalGeneration,
  48. Kosmos2Model,
  49. Kosmos2PreTrainedModel,
  50. )
  51. else:
  52. import sys
  53. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)