__init__.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Copyright 2024 Meta Inc. and The HuggingFace Inc. 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_sentencepiece_available,
  19. is_tokenizers_available,
  20. is_torch_available,
  21. is_vision_available,
  22. )
  23. _import_structure = {
  24. "configuration_chameleon": ["ChameleonConfig", "ChameleonVQVAEConfig"],
  25. "processing_chameleon": ["ChameleonProcessor"],
  26. }
  27. try:
  28. if not is_torch_available():
  29. raise OptionalDependencyNotAvailable()
  30. except OptionalDependencyNotAvailable:
  31. pass
  32. else:
  33. _import_structure["modeling_chameleon"] = [
  34. "ChameleonForConditionalGeneration",
  35. "ChameleonModel",
  36. "ChameleonPreTrainedModel",
  37. "ChameleonVQVAE",
  38. ]
  39. try:
  40. if not is_vision_available():
  41. raise OptionalDependencyNotAvailable()
  42. except OptionalDependencyNotAvailable:
  43. pass
  44. else:
  45. _import_structure["image_processing_chameleon"] = ["ChameleonImageProcessor"]
  46. if TYPE_CHECKING:
  47. from .configuration_chameleon import ChameleonConfig, ChameleonVQVAEConfig
  48. from .processing_chameleon import ChameleonProcessor
  49. try:
  50. if not is_torch_available():
  51. raise OptionalDependencyNotAvailable()
  52. except OptionalDependencyNotAvailable:
  53. pass
  54. else:
  55. from .modeling_chameleon import (
  56. ChameleonForConditionalGeneration,
  57. ChameleonModel,
  58. ChameleonPreTrainedModel,
  59. ChameleonVQVAE,
  60. )
  61. try:
  62. if not is_vision_available():
  63. raise OptionalDependencyNotAvailable()
  64. except OptionalDependencyNotAvailable:
  65. pass
  66. else:
  67. from .image_processing_chameleon import ChameleonImageProcessor
  68. else:
  69. import sys
  70. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)