__init__.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # flake8: noqa
  2. # There's no way to ignore "F401 '...' imported but unused" warnings in this
  3. # module, but to preserve other warnings. So, don't check this module at all.
  4. # Copyright 2023 The HuggingFace Team. 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. # rely on isort to merge the imports
  19. from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
  20. _import_structure = {
  21. "configuration_efficientnet": [
  22. "EfficientNetConfig",
  23. "EfficientNetOnnxConfig",
  24. ]
  25. }
  26. try:
  27. if not is_vision_available():
  28. raise OptionalDependencyNotAvailable()
  29. except OptionalDependencyNotAvailable:
  30. pass
  31. else:
  32. _import_structure["image_processing_efficientnet"] = ["EfficientNetImageProcessor"]
  33. try:
  34. if not is_torch_available():
  35. raise OptionalDependencyNotAvailable()
  36. except OptionalDependencyNotAvailable:
  37. pass
  38. else:
  39. _import_structure["modeling_efficientnet"] = [
  40. "EfficientNetForImageClassification",
  41. "EfficientNetModel",
  42. "EfficientNetPreTrainedModel",
  43. ]
  44. if TYPE_CHECKING:
  45. from .configuration_efficientnet import (
  46. EfficientNetConfig,
  47. EfficientNetOnnxConfig,
  48. )
  49. try:
  50. if not is_vision_available():
  51. raise OptionalDependencyNotAvailable()
  52. except OptionalDependencyNotAvailable:
  53. pass
  54. else:
  55. from .image_processing_efficientnet import EfficientNetImageProcessor
  56. try:
  57. if not is_torch_available():
  58. raise OptionalDependencyNotAvailable()
  59. except OptionalDependencyNotAvailable:
  60. pass
  61. else:
  62. from .modeling_efficientnet import (
  63. EfficientNetForImageClassification,
  64. EfficientNetModel,
  65. EfficientNetPreTrainedModel,
  66. )
  67. else:
  68. import sys
  69. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)