codingutf8 2022 kaist and the huggingface inc team 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 orglicenseslicense2 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 glpn model configuration from configurationutils import pretrainedconfig from utils import logging logger logging getloggername glpnpretrainedconfigarchivemap vinvino02glpnkitti https huggingface covinvino02glpnkittiresolvemainconfig json see all glpn models at https huggingface comodels filterglpn class glpnconfigpretrainedconfig r this is the configuration class to store the configuration of a glpnmodel it is used to instantiate an glpn model according to the specified arguments defining the model architecture instantiating a configuration with the defaults will yield a similar configuration to that of the glpn vinvino02glpnkittihttps huggingface covinvino02glpnkitti architecture configuration objects inherit from pretrainedconfig and can be used to control the model outputs read the documentation from pretrainedconfig for more information args numchannels int optional defaults to 3 the number of input channels numencoderblocks int optional defaults to 4 the number of encoder blocks i e stages in the mix transformer encoder depths listint optional defaults to 2 2 2 2 the number of layers in each encoder block srratios listint optional defaults to 8 4 2 1 sequence reduction ratios in each encoder block hiddensizes listint optional defaults to 32 64 160 256 dimension of each of the encoder blocks patchsizes listint optional defaults to 7 3 3 3 patch size before each encoder block strides listint optional defaults to 4 2 2 2 stride before each encoder block numattentionheads listint optional defaults to 1 2 5 8 number of attention heads for each attention layer in each block of the transformer encoder mlpratios listint optional defaults to 4 4 4 4 ratio of the size of the hidden layer compared to the size of the input layer of the mix ffns in the encoder blocks hiddenact str or function optional defaults to gelu the nonlinear activation function function or string in the encoder and pooler if string gelu relu selu and gelunew are supported hiddendropoutprob float optional defaults to 0 0 the dropout probability for all fully connected layers in the embeddings encoder and pooler attentionprobsdropoutprob float optional defaults to 0 0 the dropout ratio for the attention probabilities initializerrange float optional defaults to 0 02 the standard deviation of the truncatednormalinitializer for initializing all weight matrices droppathrate float optional defaults to 0 1 the dropout probability for stochastic depth used in the blocks of the transformer encoder layernormeps float optional defaults to 1e06 the epsilon used by the layer normalization layers decoderhiddensize int optional defaults to 64 the dimension of the decoder maxdepth int optional defaults to 10 the maximum depth of the decoder headinindex int optional defaults to 1 the index of the features to use in the head example python from transformers import glpnmodel glpnconfig initializing a glpn vinvino02glpnkitti style configuration configuration glpnconfig initializing a model from the vinvino02glpnkitti style configuration model glpnmodelconfiguration accessing the model configuration configuration model config modeltype glpn def init self numchannels3 numencoderblocks4 depths2 2 2 2 srratios8 4 2 1 hiddensizes32 64 160 256 patchsizes7 3 3 3 strides4 2 2 2 numattentionheads1 2 5 8 mlpratios4 4 4 4 hiddenactgelu hiddendropoutprob0 0 attentionprobsdropoutprob0 0 initializerrange0 02 droppathrate0 1 layernormeps1e6 decoderhiddensize64 maxdepth10 headinindex1 kwargs super initkwargs self numchannels numchannels self numencoderblocks numencoderblocks self depths depths self srratios srratios self hiddensizes hiddensizes self patchsizes patchsizes self strides strides self mlpratios mlpratios self numattentionheads numattentionheads self hiddenact hiddenact self hiddendropoutprob hiddendropoutprob self attentionprobsdropoutprob attentionprobsdropoutprob self initializerrange initializerrange self droppathrate droppathrate self layernormeps layernormeps self decoderhiddensize decoderhiddensize self maxdepth maxdepth self headinindex headinindex coding utf 8 2022 kaist and the huggingface inc team 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 glpn model configuration see all glpn models at https huggingface co models filter glpn this is the configuration class to store the configuration of a glpnmodel it is used to instantiate an glpn model according to the specified arguments defining the model architecture instantiating a configuration with the defaults will yield a similar configuration to that of the glpn vinvino02 glpn kitti https huggingface co vinvino02 glpn kitti architecture configuration objects inherit from pretrainedconfig and can be used to control the model outputs read the documentation from pretrainedconfig for more information args num_channels int optional defaults to 3 the number of input channels num_encoder_blocks int optional defaults to 4 the number of encoder blocks i e stages in the mix transformer encoder depths list int optional defaults to 2 2 2 2 the number of layers in each encoder block sr_ratios list int optional defaults to 8 4 2 1 sequence reduction ratios in each encoder block hidden_sizes list int optional defaults to 32 64 160 256 dimension of each of the encoder blocks patch_sizes list int optional defaults to 7 3 3 3 patch size before each encoder block strides list int optional defaults to 4 2 2 2 stride before each encoder block num_attention_heads list int optional defaults to 1 2 5 8 number of attention heads for each attention layer in each block of the transformer encoder mlp_ratios list int optional defaults to 4 4 4 4 ratio of the size of the hidden layer compared to the size of the input layer of the mix ffns in the encoder blocks hidden_act str or function optional defaults to gelu the non linear activation function function or string in the encoder and pooler if string gelu relu selu and gelu_new are supported hidden_dropout_prob float optional defaults to 0 0 the dropout probability for all fully connected layers in the embeddings encoder and pooler attention_probs_dropout_prob float optional defaults to 0 0 the dropout ratio for the attention probabilities initializer_range float optional defaults to 0 02 the standard deviation of the truncated_normal_initializer for initializing all weight matrices drop_path_rate float optional defaults to 0 1 the dropout probability for stochastic depth used in the blocks of the transformer encoder layer_norm_eps float optional defaults to 1e 06 the epsilon used by the layer normalization layers decoder_hidden_size int optional defaults to 64 the dimension of the decoder max_depth int optional defaults to 10 the maximum depth of the decoder head_in_index int optional defaults to 1 the index of the features to use in the head example python from transformers import glpnmodel glpnconfig initializing a glpn vinvino02 glpn kitti style configuration configuration glpnconfig initializing a model from the vinvino02 glpn kitti style configuration model glpnmodel configuration accessing the model configuration configuration model config
from ...configuration_utils import PretrainedConfig
from ...utils import logging


logger = logging.get_logger(__name__)

GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP = {
    "vinvino02/glpn-kitti": "https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json",
    
}


class GLPNConfig(PretrainedConfig):
    r

    model_type = "glpn"

    def __init__(
        self,
        num_channels=3,
        num_encoder_blocks=4,
        depths=[2, 2, 2, 2],
        sr_ratios=[8, 4, 2, 1],
        hidden_sizes=[32, 64, 160, 256],
        patch_sizes=[7, 3, 3, 3],
        strides=[4, 2, 2, 2],
        num_attention_heads=[1, 2, 5, 8],
        mlp_ratios=[4, 4, 4, 4],
        hidden_act="gelu",
        hidden_dropout_prob=0.0,
        attention_probs_dropout_prob=0.0,
        initializer_range=0.02,
        drop_path_rate=0.1,
        layer_norm_eps=1e-6,
        decoder_hidden_size=64,
        max_depth=10,
        head_in_index=-1,
        **kwargs,
    ):
        super().__init__(**kwargs)

        self.num_channels = num_channels
        self.num_encoder_blocks = num_encoder_blocks
        self.depths = depths
        self.sr_ratios = sr_ratios
        self.hidden_sizes = hidden_sizes
        self.patch_sizes = patch_sizes
        self.strides = strides
        self.mlp_ratios = mlp_ratios
        self.num_attention_heads = num_attention_heads
        self.hidden_act = hidden_act
        self.hidden_dropout_prob = hidden_dropout_prob
        self.attention_probs_dropout_prob = attention_probs_dropout_prob
        self.initializer_range = initializer_range
        self.drop_path_rate = drop_path_rate
        self.layer_norm_eps = layer_norm_eps
        self.decoder_hidden_size = decoder_hidden_size
        self.max_depth = max_depth
        self.head_in_index = head_in_index