__init__.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Copyright 2020 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 = {"configuration_imagegpt": ["ImageGPTConfig", "ImageGPTOnnxConfig"]}
  17. try:
  18. if not is_vision_available():
  19. raise OptionalDependencyNotAvailable()
  20. except OptionalDependencyNotAvailable:
  21. pass
  22. else:
  23. _import_structure["feature_extraction_imagegpt"] = ["ImageGPTFeatureExtractor"]
  24. _import_structure["image_processing_imagegpt"] = ["ImageGPTImageProcessor"]
  25. try:
  26. if not is_torch_available():
  27. raise OptionalDependencyNotAvailable()
  28. except OptionalDependencyNotAvailable:
  29. pass
  30. else:
  31. _import_structure["modeling_imagegpt"] = [
  32. "ImageGPTForCausalImageModeling",
  33. "ImageGPTForImageClassification",
  34. "ImageGPTModel",
  35. "ImageGPTPreTrainedModel",
  36. "load_tf_weights_in_imagegpt",
  37. ]
  38. if TYPE_CHECKING:
  39. from .configuration_imagegpt import ImageGPTConfig, ImageGPTOnnxConfig
  40. try:
  41. if not is_vision_available():
  42. raise OptionalDependencyNotAvailable()
  43. except OptionalDependencyNotAvailable:
  44. pass
  45. else:
  46. from .feature_extraction_imagegpt import ImageGPTFeatureExtractor
  47. from .image_processing_imagegpt import ImageGPTImageProcessor
  48. try:
  49. if not is_torch_available():
  50. raise OptionalDependencyNotAvailable()
  51. except OptionalDependencyNotAvailable:
  52. pass
  53. else:
  54. from .modeling_imagegpt import (
  55. ImageGPTForCausalImageModeling,
  56. ImageGPTForImageClassification,
  57. ImageGPTModel,
  58. ImageGPTPreTrainedModel,
  59. load_tf_weights_in_imagegpt,
  60. )
  61. else:
  62. import sys
  63. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)