o
    Zh}                     @   sl   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eZG d
d deZdgZdS )zVitMatte model configuration    N)List   )PretrainedConfig)logging) verify_backbone_config_arguments   )CONFIG_MAPPINGc                       sl   e Zd ZdZdZddddddddg dg d	f
d
ededededee dee f fddZ	dd Z
  ZS )VitMatteConfiga  
    This is the configuration class to store the configuration of [`VitMatteForImageMatting`]. It is used to
    instantiate a ViTMatte 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 ViTMatte
    [hustvl/vitmatte-small-composition-1k](https://huggingface.co/hustvl/vitmatte-small-composition-1k) 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 (`PretrainedConfig` or `dict`, *optional*, defaults to `VitDetConfig()`):
            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.
        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.
        hidden_size (`int`, *optional*, defaults to 384):
            The number of input channels of the decoder.
        batch_norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the batch norm layers.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        convstream_hidden_sizes (`List[int]`, *optional*, defaults to `[48, 96, 192]`):
            The output channels of the ConvStream module.
        fusion_hidden_sizes (`List[int]`, *optional*, defaults to `[256, 128, 64, 32]`):
            The output channels of the Fusion blocks.

    Example:

    ```python
    >>> from transformers import VitMatteConfig, VitMatteForImageMatting

    >>> # Initializing a ViTMatte hustvl/vitmatte-small-composition-1k style configuration
    >>> configuration = VitMatteConfig()

    >>> # Initializing a model (with random weights) from the hustvl/vitmatte-small-composition-1k style configuration
    >>> model = VitMatteForImageMatting(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```ZvitmatteNFi  gh㈵>g{Gz?)0   `      )      @       backbone_confighidden_sizebatch_norm_epsinitializer_rangeconvstream_hidden_sizesfusion_hidden_sizesc                    s   t  jdi | |d u r|d u rtd td dgd}nt|tr2|d}t| }||}t	|||||d || _
|| _|| _|| _|| _|| _|| _|| _|	| _|
| _d S )NzX`backbone_config` is `None`. Initializing the config with the default `VitDet` backbone.ZvitdetZstage4)Zout_features
model_type)use_timm_backboneuse_pretrained_backbonebackboner   backbone_kwargs )super__init__loggerinfor   
isinstancedictget	from_dictr   r   r   r   r   r   r   r   r   r   r   )selfr   r   r   r   r   r   r   r   r   r   kwargsZbackbone_model_typeZconfig_class	__class__r   b/var/www/auris/lib/python3.10/site-packages/transformers/models/vitmatte/configuration_vitmatte.pyr   R   s2   




zVitMatteConfig.__init__c                 C   s*   t | 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,
        r   r   )copydeepcopy__dict__r   to_dictr(   r   )r%   outputr   r   r)   r-   }   s   zVitMatteConfig.to_dict)__name__
__module____qualname____doc__r   r   intfloatr   r   r-   __classcell__r   r   r'   r)   r	      s6    2	
+r	   )r2   r*   typingr   Zconfiguration_utilsr   utilsr   Zutils.backbone_utilsr   Zauto.configuration_autor   Z
get_loggerr/   r   r	   __all__r   r   r   r)   <module>   s   

k