__init__.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_vivit": ["VivitConfig"],
  22. }
  23. try:
  24. if not is_vision_available():
  25. raise OptionalDependencyNotAvailable()
  26. except OptionalDependencyNotAvailable:
  27. pass
  28. else:
  29. _import_structure["image_processing_vivit"] = ["VivitImageProcessor"]
  30. try:
  31. if not is_torch_available():
  32. raise OptionalDependencyNotAvailable()
  33. except OptionalDependencyNotAvailable:
  34. pass
  35. else:
  36. _import_structure["modeling_vivit"] = [
  37. "VivitModel",
  38. "VivitPreTrainedModel",
  39. "VivitForVideoClassification",
  40. ]
  41. if TYPE_CHECKING:
  42. from .configuration_vivit import VivitConfig
  43. try:
  44. if not is_vision_available():
  45. raise OptionalDependencyNotAvailable()
  46. except OptionalDependencyNotAvailable:
  47. pass
  48. else:
  49. from .image_processing_vivit import VivitImageProcessor
  50. try:
  51. if not is_torch_available():
  52. raise OptionalDependencyNotAvailable()
  53. except OptionalDependencyNotAvailable:
  54. pass
  55. else:
  56. from .modeling_vivit import (
  57. VivitForVideoClassification,
  58. VivitModel,
  59. VivitPreTrainedModel,
  60. )
  61. else:
  62. import sys
  63. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)