| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
- # This file was automatically generated from src/transformers/models/aimv2/modular_aimv2.py.
- # Do NOT edit this file manually as any edits will be overwritten by the generation of
- # the file from the modular. If any change should be done, please apply the change to the
- # modular_aimv2.py file directly. One of our CI enforces this.
- # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
- # Copyright 2025 Apple Inc. and The HuggingFace Team. All rights reserved.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- from huggingface_hub.dataclasses import strict
- from ...configuration_utils import PreTrainedConfig
- from ...utils import auto_docstring, logging
- logger = logging.get_logger(__name__)
- @auto_docstring(checkpoint="apple/aimv2-large-patch14-224-lit")
- @strict
- class Aimv2VisionConfig(PreTrainedConfig):
- r"""
- use_head (`str`, *optional*, defaults to `True`):
- Whether to use Attention Pooling Head or Not.
- is_native (`str`, *optional*, defaults to `False`):
- Whether to use ckpt trained for image native resolution or not.
- Example:
- ```python
- >>> from transformers import SiglipVisionConfig, SiglipVisionModel
- >>> # Initializing a Aimv2VisionConfig with apple/aimv2-large-patch14-224 style configuration
- >>> configuration = Aimv2VisionConfig()
- >>> # Initializing a Aimv2VisionModel (with random weights) from the apple/aimv2-large-patch14-224 style configuration
- >>> model = Aimv2VisionModel(configuration)
- >>> # Accessing the model configuration
- >>> configuration = model.config
- ```"""
- model_type = "aimv2_vision_model"
- base_config_key = "vision_config"
- hidden_size: int = 1024
- intermediate_size: int = 2816
- num_hidden_layers: int = 24
- num_attention_heads: int = 8
- num_channels: int = 3
- image_size: int | list[int] | tuple[int, int] = 224
- patch_size: int | list[int] | tuple[int, int] = 14
- hidden_act: str = "silu"
- attention_dropout: float | int = 0.0
- rms_norm_eps: float = 1e-5
- qkv_bias: bool = False
- mlp_bias: bool = False
- initializer_range: float = 0.02
- use_head: bool = True
- is_native: bool = False
- @auto_docstring(checkpoint="apple/aimv2-large-patch14-224-lit")
- @strict
- class Aimv2TextConfig(PreTrainedConfig):
- r"""
- Example:
- ```python
- >>> from transformers import Aimv2TextConfig, Aimv2TextModel
- >>> # Initializing a Aimv2TextConfig with google/aimv2-base-patch16-224 style configuration
- >>> configuration = Aimv2TextConfig()
- >>> # Initializing a Aimv2TextModel (with random weights) from the google/aimv2-base-patch16-224 style configuration
- >>> model = Aimv2TextModel(configuration)
- >>> # Accessing the model configuration
- >>> configuration = model.config
- ```"""
- model_type = "aimv2_text_model"
- base_config_key = "text_config"
- vocab_size: int = 49408
- hidden_size: int = 768
- intermediate_size: int = 2048
- num_hidden_layers: int = 12
- num_attention_heads: int = 6
- max_position_embeddings: int = 77
- hidden_act: str = "silu"
- attention_dropout: float | int = 0.0
- eos_token_id: int | list[int] | None = 49407
- rms_norm_eps: float = 1e-5
- qkv_bias: bool = False
- mlp_bias: bool = False
- initializer_range: float = 0.02
- def __post_init__(self, **kwargs):
- super().__post_init__(**kwargs)
- @auto_docstring(checkpoint="apple/aimv2-large-patch14-224-lit")
- @strict
- class Aimv2Config(PreTrainedConfig):
- r"""
- max_logit_scale (`float`, *optional*, defaults to `100.0`):
- The maximum logit scale to use
- Example:
- ```python
- >>> from transformers import Aimv2Config, Aimv2Model
- >>> # Initializing a Aimv2Config with apple/aimv2-large-patch14-224-lit style configuration
- >>> configuration = Aimv2Config()
- >>> # Initializing a Aimv2Model (with random weights) from the apple/aimv2-large-patch14-224-lit style configuration
- >>> model = Aimv2Model(configuration)
- >>> # Accessing the model configuration
- >>> configuration = model.config
- >>> # We can also initialize a Aimv2Config from a Aimv2TextConfig and a Aimv2VisionConfig
- >>> from transformers import Aimv2TextConfig, Aimv2VisionConfig
- >>> # Initializing a AIMv2Text and AIMv2Vision configuration
- >>> config_text = Aimv2TextConfig()
- >>> config_vision = Aimv2VisionConfig()
- >>> config = Aimv2Config(text_config=config_text, vision_config=config_vision)
- ```"""
- model_type = "aimv2"
- sub_configs = {"text_config": Aimv2TextConfig, "vision_config": Aimv2VisionConfig}
- text_config: dict | PreTrainedConfig | None = None
- vision_config: dict | PreTrainedConfig | None = None
- initializer_factor: float = 1.0
- projection_dim: int = 512
- logit_scale_init_value: float = 2.6592
- max_logit_scale: float = 100.0
- def __post_init__(self, **kwargs):
- if self.text_config is None:
- self.text_config = Aimv2TextConfig()
- logger.info("`text_config` is `None`. Initializing the `Aimv2TextConfig` with default values.")
- elif isinstance(self.text_config, dict):
- self.text_config = Aimv2TextConfig(**self.text_config)
- if self.vision_config is None:
- self.vision_config = Aimv2VisionConfig()
- logger.info("`vision_config` is `None`. initializing the `Aimv2VisionConfig` with default values.")
- elif isinstance(self.vision_config, dict):
- self.vision_config = Aimv2VisionConfig(**self.vision_config)
- super().__post_init__(**kwargs)
- __all__ = ["Aimv2Config", "Aimv2VisionConfig", "Aimv2TextConfig"]
|