
    sg^                         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y)zVitMatte model configuration    N)List   )PretrainedConfig)logging) verify_backbone_config_arguments   )CONFIG_MAPPINGc                   p     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Z	d Z
 x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
    ```vitmatteNFi  gh㈵>g{Gz?)0   `      )      @       backbone_confighidden_sizebatch_norm_epsinitializer_rangeconvstream_hidden_sizesfusion_hidden_sizesc                    t        |   di | |(|&t        j                  d       t	        d   dg      }n;t        |t              r+|j                  d      }t        |   }|j                  |      }t        |||||       || _
        || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _        y )NzX`backbone_config` is `None`. Initializing the config with the default `VitDet` backbone.vitdetstage4)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   kwargsbackbone_model_typeconfig_class	__class__s                 f/var/www/html/venv/lib/python3.12/site-packages/transformers/models/vitmatte/configuration_vitmatte.pyr%   zVitMatteConfig.__init__R   s     	"6""x'7KKrs,X6XJOO."1"5"5l"C)*=>L*44_EO(/$;++	
  / '>$!2.,&!2'>$#6     c                     t        j                  | j                        }| 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_dictr0   r   )r,   outputs     r1   r7   zVitMatteConfig.to_dict}   sI    
 t}}-$($8$8$@$@$B !#~~88|r2   )__name__
__module____qualname____doc__r   r   intfloatr   r%   r7   __classcell__)r0   s   @r1   r   r      s}    0d J -1 % $#'-:);)7))7 )7 )7 !)7 "&c)7 "#Y)7Vr2   r   )r<   r4   typingr   configuration_utilsr   utilsr   utils.backbone_utilsr   auto.configuration_autor	   
get_loggerr9   r&   r   r#   r2   r1   <module>rF      s?    #   3  D 4 
		H	%h% hr2   