__init__.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # coding=utf-8
  2. # Copyright 2023 Authors: Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan,
  3. # Kaitao Song, Ding Liang, Tong Lu, Ping Luo, Ling Shao and The HuggingFace Inc. team.
  4. # All rights reserved.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. from typing import TYPE_CHECKING
  18. from ...utils import (
  19. OptionalDependencyNotAvailable,
  20. _LazyModule,
  21. is_torch_available,
  22. is_vision_available,
  23. )
  24. _import_structure = {
  25. "configuration_pvt": ["PvtConfig", "PvtOnnxConfig"],
  26. }
  27. try:
  28. if not is_vision_available():
  29. raise OptionalDependencyNotAvailable()
  30. except OptionalDependencyNotAvailable:
  31. pass
  32. else:
  33. _import_structure["image_processing_pvt"] = ["PvtImageProcessor"]
  34. try:
  35. if not is_torch_available():
  36. raise OptionalDependencyNotAvailable()
  37. except OptionalDependencyNotAvailable:
  38. pass
  39. else:
  40. _import_structure["modeling_pvt"] = [
  41. "PvtForImageClassification",
  42. "PvtModel",
  43. "PvtPreTrainedModel",
  44. ]
  45. if TYPE_CHECKING:
  46. from .configuration_pvt import PvtConfig, PvtOnnxConfig
  47. try:
  48. if not is_vision_available():
  49. raise OptionalDependencyNotAvailable()
  50. except OptionalDependencyNotAvailable:
  51. pass
  52. else:
  53. from .image_processing_pvt import PvtImageProcessor
  54. try:
  55. if not is_torch_available():
  56. raise OptionalDependencyNotAvailable()
  57. except OptionalDependencyNotAvailable:
  58. pass
  59. else:
  60. from .modeling_pvt import (
  61. PvtForImageClassification,
  62. PvtModel,
  63. PvtPreTrainedModel,
  64. )
  65. else:
  66. import sys
  67. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)