__init__.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_tf_available,
  19. is_torch_available,
  20. is_vision_available,
  21. )
  22. _import_structure = {"configuration_convnext": ["ConvNextConfig", "ConvNextOnnxConfig"]}
  23. try:
  24. if not is_vision_available():
  25. raise OptionalDependencyNotAvailable()
  26. except OptionalDependencyNotAvailable:
  27. pass
  28. else:
  29. _import_structure["feature_extraction_convnext"] = ["ConvNextFeatureExtractor"]
  30. _import_structure["image_processing_convnext"] = ["ConvNextImageProcessor"]
  31. try:
  32. if not is_torch_available():
  33. raise OptionalDependencyNotAvailable()
  34. except OptionalDependencyNotAvailable:
  35. pass
  36. else:
  37. _import_structure["modeling_convnext"] = [
  38. "ConvNextForImageClassification",
  39. "ConvNextModel",
  40. "ConvNextPreTrainedModel",
  41. "ConvNextBackbone",
  42. ]
  43. try:
  44. if not is_tf_available():
  45. raise OptionalDependencyNotAvailable()
  46. except OptionalDependencyNotAvailable:
  47. pass
  48. else:
  49. _import_structure["modeling_tf_convnext"] = [
  50. "TFConvNextForImageClassification",
  51. "TFConvNextModel",
  52. "TFConvNextPreTrainedModel",
  53. ]
  54. if TYPE_CHECKING:
  55. from .configuration_convnext import ConvNextConfig, ConvNextOnnxConfig
  56. try:
  57. if not is_vision_available():
  58. raise OptionalDependencyNotAvailable()
  59. except OptionalDependencyNotAvailable:
  60. pass
  61. else:
  62. from .feature_extraction_convnext import ConvNextFeatureExtractor
  63. from .image_processing_convnext import ConvNextImageProcessor
  64. try:
  65. if not is_torch_available():
  66. raise OptionalDependencyNotAvailable()
  67. except OptionalDependencyNotAvailable:
  68. pass
  69. else:
  70. from .modeling_convnext import (
  71. ConvNextBackbone,
  72. ConvNextForImageClassification,
  73. ConvNextModel,
  74. ConvNextPreTrainedModel,
  75. )
  76. try:
  77. if not is_tf_available():
  78. raise OptionalDependencyNotAvailable()
  79. except OptionalDependencyNotAvailable:
  80. pass
  81. else:
  82. from .modeling_tf_convnext import TFConvNextForImageClassification, TFConvNextModel, TFConvNextPreTrainedModel
  83. else:
  84. import sys
  85. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)