configuration_videomae.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Copyright 2022 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. """VideoMAE 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="MCG-NJU/videomae-base")
  19. @strict
  20. class VideoMAEConfig(PreTrainedConfig):
  21. r"""
  22. num_frames (`int`, *optional*, defaults to 16):
  23. The number of frames in each video.
  24. tubelet_size (`int`, *optional*, defaults to 2):
  25. The number of tubelets.
  26. use_mean_pooling (`bool`, *optional*, defaults to `True`):
  27. Whether to mean pool the final hidden states instead of using the final hidden state of the [CLS] token.
  28. decoder_num_attention_heads (`int`, *optional*, defaults to 6):
  29. Number of attention heads for each attention layer in the decoder.
  30. decoder_hidden_size (`int`, *optional*, defaults to 384):
  31. Dimensionality of the decoder.
  32. decoder_num_hidden_layers (`int`, *optional*, defaults to 4):
  33. Number of hidden layers in the decoder.
  34. decoder_intermediate_size (`int`, *optional*, defaults to 1536):
  35. Dimensionality of the "intermediate" (i.e., feed-forward) layer in the decoder.
  36. norm_pix_loss (`bool`, *optional*, defaults to `True`):
  37. Whether to normalize the target patch pixels.
  38. Example:
  39. ```python
  40. >>> from transformers import VideoMAEConfig, VideoMAEModel
  41. >>> # Initializing a VideoMAE videomae-base style configuration
  42. >>> configuration = VideoMAEConfig()
  43. >>> # Randomly initializing a model from the configuration
  44. >>> model = VideoMAEModel(configuration)
  45. >>> # Accessing the model configuration
  46. >>> configuration = model.config
  47. ```"""
  48. model_type = "videomae"
  49. image_size: int | list[int] | tuple[int, int] = 224
  50. patch_size: int | list[int] | tuple[int, int] = 16
  51. num_channels: int = 3
  52. num_frames: int = 16
  53. tubelet_size: int = 2
  54. hidden_size: int = 768
  55. num_hidden_layers: int = 12
  56. num_attention_heads: int = 12
  57. intermediate_size: int = 3072
  58. hidden_act: str = "gelu"
  59. hidden_dropout_prob: float | int = 0.0
  60. attention_probs_dropout_prob: float | int = 0.0
  61. initializer_range: float = 0.02
  62. layer_norm_eps: float = 1e-12
  63. qkv_bias: bool = True
  64. use_mean_pooling: bool = True
  65. decoder_num_attention_heads: int = 6
  66. decoder_hidden_size: int = 384
  67. decoder_num_hidden_layers: int = 4
  68. decoder_intermediate_size: int = 1536
  69. norm_pix_loss: bool = True
  70. __all__ = ["VideoMAEConfig"]