Ë
    S^(hû9  ã                   óŒ   — d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 dd	l
mZ  ej                  e«      Z G d
„ de«      ZdgZy)zDPT model configurationé    Né   )ÚPretrainedConfig)Úlogging)Ú verify_backbone_config_argumentsé   )ÚCONFIG_MAPPING)Ú	BitConfigc            $       óš   ‡ — e Zd ZdZdZddddddddd	d
ddddg d¢dg d¢g d¢dddddddddg d¢ddgdddddddf$ˆ fd„	Zd„ Zed„ «       Zˆ xZ	S ) Ú	DPTConfigah  
    This is the configuration class to store the configuration of a [`DPTModel`]. It is used to instantiate an DPT
    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 DPT
    [Intel/dpt-large](https://huggingface.co/Intel/dpt-large) architecture.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.


    Args:
        hidden_size (`int`, *optional*, defaults to 768):
            Dimensionality of the encoder layers and the pooler layer.
        num_hidden_layers (`int`, *optional*, defaults to 12):
            Number of hidden layers in the Transformer encoder.
        num_attention_heads (`int`, *optional*, defaults to 12):
            Number of attention heads for each attention layer in the Transformer encoder.
        intermediate_size (`int`, *optional*, defaults to 3072):
            Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
        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.
        layer_norm_eps (`float`, *optional*, defaults to 1e-12):
            The epsilon used by the layer normalization layers.
        image_size (`int`, *optional*, defaults to 384):
            The size (resolution) of each image.
        patch_size (`int`, *optional*, defaults to 16):
            The size (resolution) of each patch.
        num_channels (`int`, *optional*, defaults to 3):
            The number of input channels.
        is_hybrid (`bool`, *optional*, defaults to `False`):
            Whether to use a hybrid backbone. Useful in the context of loading DPT-Hybrid models.
        qkv_bias (`bool`, *optional*, defaults to `True`):
            Whether to add a bias to the queries, keys and values.
        backbone_out_indices (`List[int]`, *optional*, defaults to `[2, 5, 8, 11]`):
            Indices of the intermediate hidden states to use from backbone.
        readout_type (`str`, *optional*, defaults to `"project"`):
            The readout type to use when processing the readout token (CLS token) of the intermediate hidden states of
            the ViT backbone. Can be one of [`"ignore"`, `"add"`, `"project"`].

            - "ignore" simply ignores the CLS token.
            - "add" passes the information from the CLS token to all other tokens by adding the representations.
            - "project" passes information to the other tokens by concatenating the readout to all other tokens before
              projecting the
            representation to the original feature dimension D using a linear layer followed by a GELU non-linearity.
        reassemble_factors (`List[int]`, *optional*, defaults to `[4, 2, 1, 0.5]`):
            The up/downsampling factors of the reassemble layers.
        neck_hidden_sizes (`List[str]`, *optional*, defaults to `[96, 192, 384, 768]`):
            The hidden sizes to project to for the feature maps of the backbone.
        fusion_hidden_size (`int`, *optional*, defaults to 256):
            The number of channels before fusion.
        head_in_index (`int`, *optional*, defaults to -1):
            The index of the features to use in the heads.
        use_batch_norm_in_fusion_residual (`bool`, *optional*, defaults to `False`):
            Whether to use batch normalization in the pre-activate residual units of the fusion blocks.
        use_bias_in_fusion_residual (`bool`, *optional*, defaults to `True`):
            Whether to use bias in the pre-activate residual units of the fusion blocks.
        add_projection (`bool`, *optional*, defaults to `False`):
            Whether to add a projection layer before the depth estimation head.
        use_auxiliary_head (`bool`, *optional*, defaults to `True`):
            Whether to use an auxiliary head during training.
        auxiliary_loss_weight (`float`, *optional*, defaults to 0.4):
            Weight of the cross-entropy loss of the auxiliary head.
        semantic_loss_ignore_index (`int`, *optional*, defaults to 255):
            The index that is ignored by the loss function of the semantic segmentation model.
        semantic_classifier_dropout (`float`, *optional*, defaults to 0.1):
            The dropout ratio for the semantic classification head.
        backbone_featmap_shape (`List[int]`, *optional*, defaults to `[1, 1024, 24, 24]`):
            Used only for the `hybrid` embedding type. The shape of the feature maps of the backbone.
        neck_ignore_stages (`List[int]`, *optional*, defaults to `[0, 1]`):
            Used only for the `hybrid` embedding type. The stages of the readout layers to ignore.
        backbone_config (`Union[Dict[str, Any], PretrainedConfig]`, *optional*):
            The configuration of the backbone model. Only used in case `is_hybrid` is `True` or in case you want to
            leverage the [`AutoBackbone`] API.
        backbone (`str`, *optional*):
            Name of backbone to use when `backbone_config` is `None`. If `use_pretrained_backbone` is `True`, this
            will load the corresponding pretrained weights from the timm or transformers library. If `use_pretrained_backbone`
            is `False`, this loads the backbone's config and uses that to initialize the backbone with random weights.
        use_pretrained_backbone (`bool`, *optional*, defaults to `False`):
            Whether to use pretrained weights for the backbone.
        use_timm_backbone (`bool`, *optional*, defaults to `False`):
            Whether to load `backbone` from the timm library. If `False`, the backbone is loaded from the transformers
            library.
        backbone_kwargs (`dict`, *optional*):
            Keyword arguments to be passed to AutoBackbone when loading from a checkpoint
            e.g. `{'out_indices': (0, 1, 2, 3)}`. Cannot be specified if `backbone_config` is set.
        pooler_output_size (`int`, *optional*):
           Dimensionality of the pooler layer. If None, defaults to `hidden_size`.
        pooler_act (`str`, *optional*, defaults to `"tanh"`):
           The activation function to be used by the pooler. Keys of ACT2FN are supported for Flax and
           Pytorch, and elements of https://www.tensorflow.org/api_docs/python/tf/keras/activations are
           supported for Tensorflow.

    Example:

    ```python
    >>> from transformers import DPTModel, DPTConfig

    >>> # Initializing a DPT dpt-large style configuration
    >>> configuration = DPTConfig()

    >>> # Initializing a model from the dpt-large style configuration
    >>> model = DPTModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Údpté   é   i   Úgelug        g{®Gáz”?gê-�™—q=é€  é   r   FT)r   é   é   é   Úproject)é   r   é   g      à?)é`   éÀ   r   r   é   éÿÿÿÿNgš™™™™™Ù?éÿ   gš™™™™™¹?)r   i   é   r   r   r   Útanhc%                 ób  •— t        ‰)| �  di |%¤Ž || _        || _        d}&| j                  r�|€ddg d¢g d¢ddœ}t	        |t
        «      r!t        j                  d«       t        di |¤Ž}n,t	        |t        «      r|}nt        d	|j                  › d
�«      ‚|| _        || _        || _        |dk7  r‡t        d«      ‚|€|�cd}&t	        |t
        «      r+|j                  d«      }'t         |'   }(|(j#                  |«      }|| _        d | _        g | _        t%        |!| |||"¬«       nd | _        d | _        g | _        || _        | | _        |!| _        |"| _        || _        || _        || _        || _        || _        |	| _        |
| _        || _        || _        || _         |&| _!        |&rd n|| _"        |dvrt        d«      ‚|| _#        || _$        || _%        || _&        || _'        || _(        || _)        || _*        || _+        || _,        || _-        || _.        || _/        || _0        |#r|#n|| _1        |$| _2        y )NFÚsameÚ
bottleneck)r   r   é	   )Ústage1Ústage2Ústage3T)Úglobal_paddingÚ
layer_typeÚdepthsÚout_featuresÚembedding_dynamic_paddingz.Initializing the config with a `BiT` backbone.zBbackbone_config must be a dictionary or a `PretrainedConfig`, got ú.r   z<Readout type must be 'project' when using `DPT-hybrid` mode.Ú
model_type)Úuse_timm_backboneÚuse_pretrained_backboneÚbackboneÚbackbone_configÚbackbone_kwargs)ÚignoreÚaddr   z8Readout_type must be one of ['ignore', 'add', 'project']© )3ÚsuperÚ__init__Úhidden_sizeÚ	is_hybridÚ
isinstanceÚdictÚloggerÚinfor	   r   Ú
ValueErrorÚ	__class__r0   Úbackbone_featmap_shapeÚneck_ignore_stagesÚgetr   Ú	from_dictr   r/   r.   r-   r1   Únum_hidden_layersÚnum_attention_headsÚintermediate_sizeÚhidden_dropout_probÚattention_probs_dropout_probÚlayer_norm_epsÚ
image_sizeÚ
patch_sizeÚnum_channelsÚqkv_biasÚuse_autobackboneÚbackbone_out_indicesÚ
hidden_actÚinitializer_rangeÚreadout_typeÚreassemble_factorsÚneck_hidden_sizesÚfusion_hidden_sizeÚhead_in_indexÚ!use_batch_norm_in_fusion_residualÚuse_bias_in_fusion_residualÚadd_projectionÚuse_auxiliary_headÚauxiliary_loss_weightÚsemantic_loss_ignore_indexÚsemantic_classifier_dropoutÚpooler_output_sizeÚ
pooler_act)*Úselfr7   rC   rD   rE   rO   rF   rG   rP   rH   rI   rJ   rK   r8   rL   rN   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r?   r@   r0   r/   r.   r-   r1   r]   r^   ÚkwargsrM   Úbackbone_model_typeÚconfig_classr>   s*                                            €úg/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/dpt/configuration_dpt.pyr6   zDPTConfig.__init__’   s„  ø€ ôP 	‰ÑÑ"˜6Ò"à&ˆÔØ"ˆŒà ÐØ�>Š>ØÐ&à&,Ø".Ú'Ú$BØ15ñ#�ô ˜/¬4Ô0Ü—‘ÐLÔMÜ"+Ñ">¨oÑ">‘Ü˜OÔ-=Ô>Ø"1‘ä ØXÐYh×YrÑYrÐXsÐstÐuóð ð $3ˆDÔ Ø*@ˆDÔ'Ø&8ˆDÔ#à˜yÒ(Ü Ð!_Ó`Ð`àÐ! _Ð%@Ø#ÐÜ˜/¬4Ô0Ø&5×&9Ñ&9¸,Ó&GÐ#Ü-Ð.AÑB�Ø".×"8Ñ"8¸Ó"I�à#2ˆDÔ Ø*.ˆDÔ'Ø&(ˆDÔ#ô -Ø"3Ø(?Ø!Ø /Ø /öð $(ˆDÔ Ø*.ˆDÔ'Ø&(ˆDÔ#à ˆŒØ'>ˆÔ$Ø!2ˆÔØ.ˆÔð "3ˆÔØ#6ˆÔ Ø!2ˆÔØ#6ˆÔ Ø,HˆÔ)Ø,ˆÔØ$ˆŒØ$ˆŒØ(ˆÔØ ˆŒØ 0ˆÔÙ,<¡DÐBVˆÔ!àÐ;Ñ;ÜÐWÓXÐXØ$ˆŒØ!2ˆÔØ(ˆÔØ"4ˆÔØ!2ˆÔØ"4ˆÔØ*ˆÔØ1RˆÔ.Ø+FˆÔ(Ø,ˆÔð #5ˆÔØ%:ˆÔ"Ø*DˆÔ'Ø+FˆÔ(Ù8JÑ"4ÐP[ˆÔØ$ˆ�ó    c                 óº   — t        j                  | j                  «      }|d   �| j                  j	                  «       |d<   | j
                  j                  |d<   |S )zè
        Serializes this instance to a Python dictionary. Override the default [`~PretrainedConfig.to_dict`]. Returns:
            `Dict[str, any]`: Dictionary of all the attributes that make up this configuration instance,
        r0   r,   )ÚcopyÚdeepcopyÚ__dict__r0   Úto_dictr>   r,   )r_   Úoutputs     rc   ri   zDPTConfig.to_dict  sU   € ô
 —‘˜tŸ}™}Ó-ˆàÐ#Ñ$Ð0Ø(,×(<Ñ(<×(DÑ(DÓ(FˆFÐ$Ñ%à#Ÿ~™~×8Ñ8ˆˆ|ÑØˆrd   c                 óL   — | j                   �dt        | j                   «      iS i S )Nr0   )r0   Útype)r_   s    rc   Úsub_configszDPTConfig.sub_configs'  s*   € àBF×BVÑBVÐBbÐ!¤4¨×(<Ñ(<Ó#=Ð>ÐjÐhjÐjrd   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r,   r6   ri   Úpropertyrm   Ú__classcell__)r>   s   @rc   r   r      s¦   ø„ ñpðd €Jð ØØØØØØ%(ØØØØØØØÚ*ØÚ)Ú-ØØØ*/Ø$(ØØØ!Ø#&Ø$'Ú0Ø˜q˜6ØØØ %ØØØØõKF%òPð ñkó ôkrd   r   )rq   rf   Úconfiguration_utilsr   Úutilsr   Úutils.backbone_utilsr   Úauto.configuration_autor   Úbitr	   Ú
get_loggerrn   r;   r   Ú__all__r4   rd   rc   ú<module>r{      sK   ðñ ã å 3Ý Ý DÝ 4Ý ð 
ˆ×	Ñ	˜HÓ	%€ôLkÐ ô Lkð^ ˆ-�rd   