
    g1                     r    d Z ddlmZ ddlmZ ddlmZ  ej        e          Z	ddiZ
 G d d	e          Zd
S )zZoeDepth model configuration   )PretrainedConfig)logging   )CONFIG_MAPPINGzIntel/zoedepth-nyuzBhttps://huggingface.co/Intel/zoedepth-nyu/resolve/main/config.jsonc                   z     e Zd ZdZdZddddddddg d	g d
dddddddg ddddddddddddgddddf fd	Z xZS )ZoeDepthConfiga  
    This is the configuration class to store the configuration of a [`ZoeDepthForDepthEstimation`]. It is used to instantiate an ZoeDepth
    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 ZoeDepth
    [Intel/zoedepth-nyu](https://huggingface.co/Intel/zoedepth-nyu) architecture.

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

    Args:
        backbone_config (`Union[Dict[str, Any], PretrainedConfig]`, *optional*, defaults to `BeitConfig()`):
            The configuration of the backbone model.
        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.
        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.
        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.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        batch_norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the batch normalization layers.
        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.
        num_relative_features (`int`, *optional*, defaults to 32):
            The number of features to use in the relative depth estimation head.
        add_projection (`bool`, *optional*, defaults to `False`):
            Whether to add a projection layer before the depth estimation head.
        bottleneck_features (`int`, *optional*, defaults to 256):
            The number of features in the bottleneck layer.
        num_attractors (`List[int], *optional*, defaults to `[16, 8, 4, 1]`):
            The number of attractors to use in each stage.
        bin_embedding_dim (`int`, *optional*, defaults to 128):
            The dimension of the bin embeddings.
        attractor_alpha (`int`, *optional*, defaults to 1000):
            The alpha value to use in the attractor.
        attractor_gamma (`int`, *optional*, defaults to 2):
            The gamma value to use in the attractor.
        attractor_kind (`str`, *optional*, defaults to `"mean"`):
            The kind of attractor to use. Can be one of [`"mean"`, `"sum"`].
        min_temp (`float`, *optional*, defaults to 0.0212):
            The minimum temperature value to consider.
        max_temp (`float`, *optional*, defaults to 50.0):
            The maximum temperature value to consider.
        bin_centers_type (`str`, *optional*, defaults to `"softplus"`):
            Activation type used for bin centers. Can be "normed" or "softplus". For "normed" bin centers, linear normalization trick
            is applied. This results in bounded bin centers. For "softplus", softplus activation is used and thus are unbounded.
        bin_configurations (`List[dict]`, *optional*, defaults to `[{'n_bins': 64, 'min_depth': 0.001, 'max_depth': 10.0}]`):
            Configuration for each of the bin heads.
            Each configuration should consist of the following keys:
            - name (`str`): The name of the bin head - only required in case of multiple bin configurations.
            - `n_bins` (`int`): The number of bins to use.
            - `min_depth` (`float`): The minimum depth value to consider.
            - `max_depth` (`float`): The maximum depth value to consider.
            In case only a single configuration is passed, the model will use a single head with the specified configuration.
            In case multiple configurations are passed, the model will use multiple heads with the specified configurations.
        num_patch_transformer_layers (`int`, *optional*):
            The number of transformer layers to use in the patch transformer. Only used in case of multiple bin configurations.
        patch_transformer_hidden_size (`int`, *optional*):
            The hidden size to use in the patch transformer. Only used in case of multiple bin configurations.
        patch_transformer_intermediate_size (`int`, *optional*):
            The intermediate size to use in the patch transformer. Only used in case of multiple bin configurations.
        patch_transformer_num_attention_heads (`int`, *optional*):
            The number of attention heads to use in the patch transformer. Only used in case of multiple bin configurations.

    Example:

    ```python
    >>> from transformers import ZoeDepthConfig, ZoeDepthForDepthEstimation

    >>> # Initializing a ZoeDepth zoedepth-large style configuration
    >>> configuration = ZoeDepthConfig()

    >>> # Initializing a model from the zoedepth-large style configuration
    >>> model = ZoeDepthForDepthEstimation(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```zoedepthNFgelug{Gz?gh㈵>project)   r      g      ?)`        i          )      r   r      i  r   meanggs?g      I@softplus@   gMbP?g      $@)n_bins	min_depth	max_depthc                     t                      j        di | |dvrt          d          |dvrt          d          |rt          d          ||t          d          |<|:t                              d           t          d         d	d
dddddg d          }nLt          |t                    r7|                    d          } t
          |          }!|!	                    |          }||r|t          d          || _
        || _        || _        || _        || _        || _        || _        |	| _        |
| _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _         || _!        || _"        || _#        || _$        || _%        || _&        d S )N)ignoreaddr   z8Readout_type must be one of ['ignore', 'add', 'project'])r   sumz-Attractor_kind must be one of ['mean', 'sum']z+Pretrained backbones are not supported yet.z8You can't specify both `backbone` and `backbone_config`.zV`backbone_config` is `None`. Initializing the config with the default `BEiT` backbone.beitr      i   i   r   TF)stage6stage12stage18stage24)
image_sizenum_hidden_layershidden_sizeintermediate_sizenum_attention_headsuse_relative_position_biasreshape_hidden_statesout_features
model_typez?You can't specify both `backbone_kwargs` and `backbone_config`. )'super__init__
ValueErrorloggerinfor   
isinstancedictget	from_dictbackbone_configbackbone
hidden_actuse_pretrained_backboneinitializer_rangebatch_norm_epsreadout_typereassemble_factorsneck_hidden_sizesfusion_hidden_sizehead_in_index!use_batch_norm_in_fusion_residualuse_bias_in_fusion_residualnum_relative_featuresadd_projectionbottleneck_featuresnum_attractorsbin_embedding_dimattractor_alphaattractor_gammaattractor_kindmin_tempmax_tempbin_centers_typebin_configurationsnum_patch_transformer_layerspatch_transformer_hidden_size#patch_transformer_intermediate_size%patch_transformer_num_attention_heads)#selfr:   r;   r=   backbone_kwargsr<   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   kwargsbackbone_model_typeconfig_class	__class__s#                                     o/var/www/html/ai-engine/env/lib/python3.11/site-packages/transformers/models/zoedepth/configuration_zoedepth.pyr2   zZoeDepthConfig.__init__   s1   D 	""6""";;;WXXX00LMMM" 	LJKKK&8+?WXXX"x'7KKpqqq,V4"$ "&$&+/&+HHH	 	 	OO .. 	F"1"5"5l"C"C)*=>L*44_EEO&?&?Z^___. $'>$!2,("4!2"4*1R.+F(%:",#6 ,!2..,   0"4,H)-J*3V05Z222    )__name__
__module____qualname____doc__r/   r2   __classcell__)r\   s   @r]   r   r      s        g gR J  %)>>---*/$( $}}#')DQQR%)&*,0.2?a[ a[ a[ a[ a[ a[ a[ a[ a[ a[r^   r   N)rb   configuration_utilsr   utilsr   auto.configuration_autor   
get_loggerr_   r4   &ZOEDEPTH_PRETRAINED_CONFIG_ARCHIVE_MAPr   r0   r^   r]   <module>ri      s    # " 3 3 3 3 3 3       4 4 4 4 4 4 
	H	%	% ^* &
M[ M[ M[ M[ M[% M[ M[ M[ M[ M[r^   