configuration_vivit.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Copyright 2023 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. """ViViT model configuration"""
  15. from huggingface_hub.dataclasses import strict
  16. from ...configuration_utils import PreTrainedConfig
  17. from ...utils import auto_docstring
  18. @auto_docstring(checkpoint="google/vivit-b-16x2-kinetics400")
  19. @strict
  20. class VivitConfig(PreTrainedConfig):
  21. r"""
  22. num_frames (`int`, *optional*, defaults to 32):
  23. The number of frames in each video.
  24. tubelet_size (`list[int]`, *optional*, defaults to `[2, 16, 16]`):
  25. The size (resolution) of each tubelet.
  26. Example:
  27. ```python
  28. >>> from transformers import VivitConfig, VivitModel
  29. >>> # Initializing a ViViT google/vivit-b-16x2-kinetics400 style configuration
  30. >>> configuration = VivitConfig()
  31. >>> # Initializing a model (with random weights) from the google/vivit-b-16x2-kinetics400 style configuration
  32. >>> model = VivitModel(configuration)
  33. >>> # Accessing the model configuration
  34. >>> configuration = model.config
  35. ```"""
  36. model_type = "vivit"
  37. image_size: int | list[int] | tuple[int, int] = 224
  38. num_frames: int = 32
  39. tubelet_size: list[int] | tuple[int, ...] = (2, 16, 16)
  40. num_channels: int = 3
  41. hidden_size: int = 768
  42. num_hidden_layers: int = 12
  43. num_attention_heads: int = 12
  44. intermediate_size: int = 3072
  45. hidden_act: str = "gelu_fast"
  46. hidden_dropout_prob: float | int = 0.0
  47. attention_probs_dropout_prob: float | int = 0.0
  48. initializer_range: float = 0.02
  49. layer_norm_eps: float = 1e-06
  50. qkv_bias: bool = True
  51. __all__ = ["VivitConfig"]