Aluode/PerceptionLabPortable
0
1# coding=utf-82# Copyright 2022 KAIST and The HuggingFace Inc. team. All rights reserved.3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15"""GLPN model configuration"""16 17from ...configuration_utils import PretrainedConfig18from ...utils import logging19 20 21logger = logging.get_logger(__name__)22 23 24class GLPNConfig(PretrainedConfig):25 r"""26 This is the configuration class to store the configuration of a [`GLPNModel`]. It is used to instantiate an GLPN27 model according to the specified arguments, defining the model architecture. Instantiating a configuration with the28 defaults will yield a similar configuration to that of the GLPN29 [vinvino02/glpn-kitti](https://huggingface.co/vinvino02/glpn-kitti) architecture.30 31 Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the32 documentation from [`PretrainedConfig`] for more information.33 34 Args:35 num_channels (`int`, *optional*, defaults to 3):36 The number of input channels.37 num_encoder_blocks (`int`, *optional*, defaults to 4):38 The number of encoder blocks (i.e. stages in the Mix Transformer encoder).39 depths (`list[int]`, *optional*, defaults to `[2, 2, 2, 2]`):40 The number of layers in each encoder block.41 sr_ratios (`list[int]`, *optional*, defaults to `[8, 4, 2, 1]`):42 Sequence reduction ratios in each encoder block.43 hidden_sizes (`list[int]`, *optional*, defaults to `[32, 64, 160, 256]`):44 Dimension of each of the encoder blocks.45 patch_sizes (`list[int]`, *optional*, defaults to `[7, 3, 3, 3]`):46 Patch size before each encoder block.47 strides (`list[int]`, *optional*, defaults to `[4, 2, 2, 2]`):48 Stride before each encoder block.49 num_attention_heads (`list[int]`, *optional*, defaults to `[1, 2, 5, 8]`):50 Number of attention heads for each attention layer in each block of the Transformer encoder.51 mlp_ratios (`list[int]`, *optional*, defaults to `[4, 4, 4, 4]`):52 Ratio of the size of the hidden layer compared to the size of the input layer of the Mix FFNs in the53 encoder blocks.54 hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):55 The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,56 `"relu"`, `"selu"` and `"gelu_new"` are supported.57 hidden_dropout_prob (`float`, *optional*, defaults to 0.0):58 The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.59 attention_probs_dropout_prob (`float`, *optional*, defaults to 0.0):60 The dropout ratio for the attention probabilities.61 initializer_range (`float`, *optional*, defaults to 0.02):62 The standard deviation of the truncated_normal_initializer for initializing all weight matrices.63 drop_path_rate (`float`, *optional*, defaults to 0.1):64 The dropout probability for stochastic depth, used in the blocks of the Transformer encoder.65 layer_norm_eps (`float`, *optional*, defaults to 1e-06):66 The epsilon used by the layer normalization layers.67 decoder_hidden_size (`int`, *optional*, defaults to 64):68 The dimension of the decoder.69 max_depth (`int`, *optional*, defaults to 10):70 The maximum depth of the decoder.71 head_in_index (`int`, *optional*, defaults to -1):72 The index of the features to use in the head.73 74 Example:75 76 ```python77 >>> from transformers import GLPNModel, GLPNConfig78 79 >>> # Initializing a GLPN vinvino02/glpn-kitti style configuration80 >>> configuration = GLPNConfig()81 82 >>> # Initializing a model from the vinvino02/glpn-kitti style configuration83 >>> model = GLPNModel(configuration)84 85 >>> # Accessing the model configuration86 >>> configuration = model.config87 ```"""88 89 model_type = "glpn"90 91 def __init__(92 self,93 num_channels=3,94 num_encoder_blocks=4,95 depths=[2, 2, 2, 2],96 sr_ratios=[8, 4, 2, 1],97 hidden_sizes=[32, 64, 160, 256],98 patch_sizes=[7, 3, 3, 3],99 strides=[4, 2, 2, 2],100 num_attention_heads=[1, 2, 5, 8],101 mlp_ratios=[4, 4, 4, 4],102 hidden_act="gelu",103 hidden_dropout_prob=0.0,104 attention_probs_dropout_prob=0.0,105 initializer_range=0.02,106 drop_path_rate=0.1,107 layer_norm_eps=1e-6,108 decoder_hidden_size=64,109 max_depth=10,110 head_in_index=-1,111 **kwargs,112 ):113 super().__init__(**kwargs)114 115 self.num_channels = num_channels116 self.num_encoder_blocks = num_encoder_blocks117 self.depths = depths118 self.sr_ratios = sr_ratios119 self.hidden_sizes = hidden_sizes120 self.patch_sizes = patch_sizes121 self.strides = strides122 self.mlp_ratios = mlp_ratios123 self.num_attention_heads = num_attention_heads124 self.hidden_act = hidden_act125 self.hidden_dropout_prob = hidden_dropout_prob126 self.attention_probs_dropout_prob = attention_probs_dropout_prob127 self.initializer_range = initializer_range128 self.drop_path_rate = drop_path_rate129 self.layer_norm_eps = layer_norm_eps130 self.decoder_hidden_size = decoder_hidden_size131 self.max_depth = max_depth132 self.head_in_index = head_in_index133 134 135__all__ = ["GLPNConfig"]136 