| # coding=utf-8 | |
| # Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. 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. | |
| """Qwen2VL model configuration""" | |
| from transformers.configuration_utils import PretrainedConfig | |
| from transformers.modeling_rope_utils import rope_config_validation | |
| from transformers.utils import logging | |
| logger = logging.get_logger(__name__) | |
| class Qwen2VLVisionConfig(PretrainedConfig): | |
| model_type = "qwen2_vl" | |
| base_config_key = "vision_config" | |
| def __init__( | |
| self, | |
| depth=32, | |
| embed_dim=1280, | |
| hidden_size=3584, | |
| hidden_act="quick_gelu", | |
| mlp_ratio=4, | |
| num_heads=16, | |
| in_channels=3, | |
| patch_size=14, | |
| spatial_merge_size=2, | |
| temporal_patch_size=2, | |
| initializer_range=0.02, | |
| **kwargs, | |
| ): | |
| super().__init__(**kwargs) | |
| self.depth = depth | |
| self.embed_dim = embed_dim | |
| self.hidden_size = hidden_size | |
| self.hidden_act = hidden_act | |
| self.mlp_ratio = mlp_ratio | |
| self.num_heads = num_heads | |
| self.in_channels = in_channels | |
| self.patch_size = patch_size | |
| self.spatial_merge_size = spatial_merge_size | |
| self.temporal_patch_size = temporal_patch_size | |
| self.initializer_range = initializer_range | |