__init__.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
  16. _import_structure = {
  17. "configuration_donut_swin": ["DonutSwinConfig"],
  18. "processing_donut": ["DonutProcessor"],
  19. }
  20. try:
  21. if not is_torch_available():
  22. raise OptionalDependencyNotAvailable()
  23. except OptionalDependencyNotAvailable:
  24. pass
  25. else:
  26. _import_structure["modeling_donut_swin"] = [
  27. "DonutSwinModel",
  28. "DonutSwinPreTrainedModel",
  29. ]
  30. try:
  31. if not is_vision_available():
  32. raise OptionalDependencyNotAvailable()
  33. except OptionalDependencyNotAvailable:
  34. pass
  35. else:
  36. _import_structure["feature_extraction_donut"] = ["DonutFeatureExtractor"]
  37. _import_structure["image_processing_donut"] = ["DonutImageProcessor"]
  38. if TYPE_CHECKING:
  39. from .configuration_donut_swin import DonutSwinConfig
  40. from .processing_donut import DonutProcessor
  41. try:
  42. if not is_torch_available():
  43. raise OptionalDependencyNotAvailable()
  44. except OptionalDependencyNotAvailable:
  45. pass
  46. else:
  47. from .modeling_donut_swin import (
  48. DonutSwinModel,
  49. DonutSwinPreTrainedModel,
  50. )
  51. try:
  52. if not is_vision_available():
  53. raise OptionalDependencyNotAvailable()
  54. except OptionalDependencyNotAvailable:
  55. pass
  56. else:
  57. from .feature_extraction_donut import DonutFeatureExtractor
  58. from .image_processing_donut import DonutImageProcessor
  59. else:
  60. import sys
  61. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)