configuration_mlcd.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  2. # This file was automatically generated from src/transformers/models/mlcd/modular_mlcd.py.
  3. # Do NOT edit this file manually as any edits will be overwritten by the generation of
  4. # the file from the modular. If any change should be done, please apply the change to the
  5. # modular_mlcd.py file directly. One of our CI enforces this.
  6. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  7. # coding=utf-8
  8. # Copyright 2025 The HuggingFace Inc. team.
  9. #
  10. # Licensed under the Apache License, Version 2.0 (the "License");
  11. # you may not use this file except in compliance with the License.
  12. # You may obtain a copy of the License at
  13. #
  14. # http://www.apache.org/licenses/LICENSE-2.0
  15. #
  16. # Unless required by applicable law or agreed to in writing, software
  17. # distributed under the License is distributed on an "AS IS" BASIS,
  18. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. # See the License for the specific language governing permissions and
  20. # limitations under the License.
  21. from ...configuration_utils import PretrainedConfig
  22. class MLCDVisionConfig(PretrainedConfig):
  23. r"""
  24. This is the configuration class to store the configuration of a [`MLCDVisionModel`]. It is used to instantiate a MLCD
  25. vision encoder according to the specified arguments, defining the model architecture. Instantiating a configuration
  26. with the defaults will yield a similar configuration to that of the vision encoder of the MLCD
  27. [DeepGlint-AI/mlcd-vit-bigG-patch14-336](https://huggingface.co/DeepGlint-AI/mlcd-vit-bigG-patch14-336) architecture.
  28. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
  29. documentation from [`PretrainedConfig`] for more information.
  30. Args:
  31. hidden_size (`int`, *optional*, defaults to 1664):
  32. Dimensionality of the encoder layers and the pooler layer.
  33. intermediate_size (`int`, *optional*, defaults to 8192):
  34. Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
  35. projection_dim (`int`, *optional*, defaults to 1024):
  36. Dimensionality of text and vision projection layers.
  37. num_hidden_layers (`int`, *optional*, defaults to 48):
  38. Number of hidden layers in the Transformer encoder.
  39. num_attention_heads (`int`, *optional*, defaults to 16):
  40. Number of attention heads for each attention layer in the Transformer encoder.
  41. num_channels (`int`, *optional*, defaults to 3):
  42. The number of input channels.
  43. image_size (`int`, *optional*, defaults to 336):
  44. The size (resolution) of each image.
  45. patch_size (`int`, *optional*, defaults to 14):
  46. The size (resolution) of each patch.
  47. hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
  48. The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
  49. `"relu"`, `"selu"` and `"gelu_new"` `"quick_gelu"` are supported.
  50. layer_norm_eps (`float`, *optional*, defaults to 1e-05):
  51. The epsilon used by the layer normalization layers.
  52. attention_dropout (`float`, *optional*, defaults to 0.0):
  53. The dropout ratio for the attention probabilities.
  54. initializer_range (`float`, *optional*, defaults to 0.02):
  55. The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
  56. initializer_factor (`float`, *optional*, defaults to 1.0):
  57. A factor for initializing all weight matrices (should be kept to 1, used internally for initialization
  58. testing).
  59. Example:
  60. ```python
  61. >>> from transformers import MLCDVisionConfig, MLCDVisionModel
  62. >>> # Initializing a MLCDVisionConfig with DeepGlint-AI/mlcd-vit-bigG-patch14-336 style configuration
  63. >>> configuration = MLCDVisionConfig()
  64. >>> # Initializing a MLCDVisionModel (with random weights) from the DeepGlint-AI/mlcd-vit-bigG-patch14-336 style configuration
  65. >>> model = MLCDVisionModel(configuration)
  66. >>> # Accessing the model configuration
  67. >>> configuration = model.config
  68. ```"""
  69. model_type = "mlcd_vision_model"
  70. base_config_key = "vision_config"
  71. def __init__(
  72. self,
  73. hidden_size=1664,
  74. intermediate_size=8192,
  75. num_hidden_layers=48,
  76. num_attention_heads=16,
  77. num_key_value_groups=1,
  78. num_channels=3,
  79. image_size=336,
  80. patch_size=14,
  81. hidden_act="gelu",
  82. layer_norm_eps=1e-5,
  83. attention_dropout=0.0,
  84. initializer_range=0.02,
  85. initializer_factor=1.0,
  86. **kwargs,
  87. ):
  88. super().__init__(**kwargs)
  89. self.hidden_size = hidden_size
  90. self.intermediate_size = intermediate_size
  91. self.num_hidden_layers = num_hidden_layers
  92. self.num_attention_heads = num_attention_heads
  93. self.num_key_value_groups = num_key_value_groups
  94. self.num_channels = num_channels
  95. self.patch_size = patch_size
  96. self.image_size = image_size
  97. self.initializer_range = initializer_range
  98. self.initializer_factor = initializer_factor
  99. self.attention_dropout = attention_dropout
  100. self.layer_norm_eps = layer_norm_eps
  101. self.hidden_act = hidden_act
  102. __all__ = ["MLCDVisionConfig"]