__init__.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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_flax_available,
  19. is_tf_available,
  20. is_torch_available,
  21. )
  22. _import_structure = {"configuration_resnet": ["ResNetConfig", "ResNetOnnxConfig"]}
  23. try:
  24. if not is_torch_available():
  25. raise OptionalDependencyNotAvailable()
  26. except OptionalDependencyNotAvailable:
  27. pass
  28. else:
  29. _import_structure["modeling_resnet"] = [
  30. "ResNetForImageClassification",
  31. "ResNetModel",
  32. "ResNetPreTrainedModel",
  33. "ResNetBackbone",
  34. ]
  35. try:
  36. if not is_tf_available():
  37. raise OptionalDependencyNotAvailable()
  38. except OptionalDependencyNotAvailable:
  39. pass
  40. else:
  41. _import_structure["modeling_tf_resnet"] = [
  42. "TFResNetForImageClassification",
  43. "TFResNetModel",
  44. "TFResNetPreTrainedModel",
  45. ]
  46. try:
  47. if not is_flax_available():
  48. raise OptionalDependencyNotAvailable()
  49. except OptionalDependencyNotAvailable:
  50. pass
  51. else:
  52. _import_structure["modeling_flax_resnet"] = [
  53. "FlaxResNetForImageClassification",
  54. "FlaxResNetModel",
  55. "FlaxResNetPreTrainedModel",
  56. ]
  57. if TYPE_CHECKING:
  58. from .configuration_resnet import ResNetConfig, ResNetOnnxConfig
  59. try:
  60. if not is_torch_available():
  61. raise OptionalDependencyNotAvailable()
  62. except OptionalDependencyNotAvailable:
  63. pass
  64. else:
  65. from .modeling_resnet import (
  66. ResNetBackbone,
  67. ResNetForImageClassification,
  68. ResNetModel,
  69. ResNetPreTrainedModel,
  70. )
  71. try:
  72. if not is_tf_available():
  73. raise OptionalDependencyNotAvailable()
  74. except OptionalDependencyNotAvailable:
  75. pass
  76. else:
  77. from .modeling_tf_resnet import (
  78. TFResNetForImageClassification,
  79. TFResNetModel,
  80. TFResNetPreTrainedModel,
  81. )
  82. try:
  83. if not is_flax_available():
  84. raise OptionalDependencyNotAvailable()
  85. except OptionalDependencyNotAvailable:
  86. pass
  87. else:
  88. from .modeling_flax_resnet import FlaxResNetForImageClassification, FlaxResNetModel, FlaxResNetPreTrainedModel
  89. else:
  90. import sys
  91. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)