Ë
    S^(h|6  ã                   óf   — d 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DETA model configurationé   )ÚPretrainedConfig)Úloggingé   )ÚCONFIG_MAPPINGc                   ó´   ‡ — e Zd ZdZdZdddœZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d
ˆ fd„	Zedefd„«       Z	edefd	„«       Z
ˆ xZS )Ú
DetaConfigaŠ  
    This is the configuration class to store the configuration of a [`DetaModel`]. It is used to instantiate a DETA
    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 DETA
    [SenseTime/deformable-detr](https://huggingface.co/SenseTime/deformable-detr) 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 `ResNetConfig()`):
            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*, `False`):
            Whether to use pretrained weights for the backbone.
        use_timm_backbone (`bool`, *optional*, `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.
        num_queries (`int`, *optional*, defaults to 900):
            Number of object queries, i.e. detection slots. This is the maximal number of objects [`DetaModel`] can
            detect in a single image. In case `two_stage` is set to `True`, we use `two_stage_num_proposals` instead.
        d_model (`int`, *optional*, defaults to 256):
            Dimension of the layers.
        encoder_layers (`int`, *optional*, defaults to 6):
            Number of encoder layers.
        decoder_layers (`int`, *optional*, defaults to 6):
            Number of decoder layers.
        encoder_attention_heads (`int`, *optional*, defaults to 8):
            Number of attention heads for each attention layer in the Transformer encoder.
        decoder_attention_heads (`int`, *optional*, defaults to 8):
            Number of attention heads for each attention layer in the Transformer decoder.
        decoder_ffn_dim (`int`, *optional*, defaults to 2048):
            Dimension of the "intermediate" (often named feed-forward) layer in decoder.
        encoder_ffn_dim (`int`, *optional*, defaults to 2048):
            Dimension of the "intermediate" (often named feed-forward) layer in decoder.
        activation_function (`str` or `function`, *optional*, defaults to `"relu"`):
            The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
            `"relu"`, `"silu"` and `"gelu_new"` are supported.
        dropout (`float`, *optional*, defaults to 0.1):
            The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
        attention_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the attention probabilities.
        activation_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for activations inside the fully connected layer.
        init_std (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        init_xavier_std (`float`, *optional*, defaults to 1):
            The scaling factor used for the Xavier initialization gain in the HM Attention map module.
        encoder_layerdrop (`float`, *optional*, defaults to 0.0):
            The LayerDrop probability for the encoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556)
            for more details.
        auxiliary_loss (`bool`, *optional*, defaults to `False`):
            Whether auxiliary decoding losses (loss at each decoder layer) are to be used.
        position_embedding_type (`str`, *optional*, defaults to `"sine"`):
            Type of position embeddings to be used on top of the image features. One of `"sine"` or `"learned"`.
        class_cost (`float`, *optional*, defaults to 1):
            Relative weight of the classification error in the Hungarian matching cost.
        bbox_cost (`float`, *optional*, defaults to 5):
            Relative weight of the L1 error of the bounding box coordinates in the Hungarian matching cost.
        giou_cost (`float`, *optional*, defaults to 2):
            Relative weight of the generalized IoU loss of the bounding box in the Hungarian matching cost.
        mask_loss_coefficient (`float`, *optional*, defaults to 1):
            Relative weight of the Focal loss in the panoptic segmentation loss.
        dice_loss_coefficient (`float`, *optional*, defaults to 1):
            Relative weight of the DICE/F-1 loss in the panoptic segmentation loss.
        bbox_loss_coefficient (`float`, *optional*, defaults to 5):
            Relative weight of the L1 bounding box loss in the object detection loss.
        giou_loss_coefficient (`float`, *optional*, defaults to 2):
            Relative weight of the generalized IoU loss in the object detection loss.
        eos_coefficient (`float`, *optional*, defaults to 0.1):
            Relative classification weight of the 'no-object' class in the object detection loss.
        num_feature_levels (`int`, *optional*, defaults to 5):
            The number of input feature levels.
        encoder_n_points (`int`, *optional*, defaults to 4):
            The number of sampled keys in each feature level for each attention head in the encoder.
        decoder_n_points (`int`, *optional*, defaults to 4):
            The number of sampled keys in each feature level for each attention head in the decoder.
        two_stage (`bool`, *optional*, defaults to `True`):
            Whether to apply a two-stage deformable DETR, where the region proposals are also generated by a variant of
            DETA, which are further fed into the decoder for iterative bounding box refinement.
        two_stage_num_proposals (`int`, *optional*, defaults to 300):
            The number of region proposals to be generated, in case `two_stage` is set to `True`.
        with_box_refine (`bool`, *optional*, defaults to `True`):
            Whether to apply iterative bounding box refinement, where each decoder layer refines the bounding boxes
            based on the predictions from the previous layer.
        focal_alpha (`float`, *optional*, defaults to 0.25):
            Alpha parameter in the focal loss.
        assign_first_stage (`bool`, *optional*, defaults to `True`):
            Whether to assign each prediction i to the highest overlapping ground truth object if the overlap is larger than a threshold 0.7.
        assign_second_stage (`bool`, *optional*, defaults to `True`):
            Whether to assign second assignment procedure in the second stage closely follows the first stage assignment procedure.
        disable_custom_kernels (`bool`, *optional*, defaults to `True`):
            Disable the use of custom CUDA and CPU kernels. This option is necessary for the ONNX export, as custom
            kernels are not supported by PyTorch ONNX export.

    Examples:

    ```python
    >>> from transformers import DetaConfig, DetaModel

    >>> # Initializing a DETA SenseTime/deformable-detr style configuration
    >>> configuration = DetaConfig()

    >>> # Initializing a model (with random weights) from the SenseTime/deformable-detr style configuration
    >>> model = DetaModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```ÚdetaÚd_modelÚencoder_attention_heads)Úhidden_sizeÚnum_attention_headsc,                 ó²  •— |rt        d«      ‚|�|�t        d«      ‚|€)|€'t        j                  d«       t        d   g d¢¬«      }n;t	        |t
        «      r+|j                  d«      }-t        |-   }.|.j                  |«      }|�|r|�t        d«      ‚|| _        || _	        || _
        || _        || _        || _        || _        || _        |	| _        || _        |
| _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _         || _!        || _"        || _#        || _$        | | _%        |!| _&        |d	u r|d
u rt        d«      ‚|"| _'        |#| _(        |$| _)        |%| _*        |&| _+        |'| _,        |(| _-        |)| _.        |*| _/        |+| _0        tc        ‰/| �È  dd|i|,¤Ž y )Nz+Pretrained backbones are not supported yet.z8You can't specify both `backbone` and `backbone_config`.zX`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone.Úresnet)Ústage2Ústage3Ústage4)Úout_featuresÚ
model_typez?You can't specify both `backbone_kwargs` and `backbone_config`.TFz3If two_stage is True, with_box_refine must be True.Úis_encoder_decoder© )3Ú
ValueErrorÚloggerÚinfor   Ú
isinstanceÚdictÚpopÚ	from_dictÚbackbone_configÚbackboneÚuse_pretrained_backboneÚuse_timm_backboneÚbackbone_kwargsÚnum_queriesÚmax_position_embeddingsr
   Úencoder_ffn_dimÚencoder_layersr   Údecoder_ffn_dimÚdecoder_layersÚdecoder_attention_headsÚdropoutÚattention_dropoutÚactivation_dropoutÚactivation_functionÚinit_stdÚinit_xavier_stdÚencoder_layerdropÚauxiliary_lossÚposition_embedding_typeÚnum_feature_levelsÚencoder_n_pointsÚdecoder_n_pointsÚ	two_stageÚtwo_stage_num_proposalsÚwith_box_refineÚassign_first_stageÚassign_second_stageÚ
class_costÚ	bbox_costÚ	giou_costÚmask_loss_coefficientÚdice_loss_coefficientÚbbox_loss_coefficientÚgiou_loss_coefficientÚeos_coefficientÚfocal_alphaÚdisable_custom_kernelsÚsuperÚ__init__)0Úselfr   r   r    r!   r"   r#   r$   r&   r%   r   r(   r'   r)   r0   r   r-   r
   r*   r+   r,   r.   r/   Úreturn_intermediater1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   ÚkwargsÚbackbone_model_typeÚconfig_classÚ	__class__s0                                                  €út/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/deprecated/deta/configuration_deta.pyrF   zDetaConfig.__init__”   s  ø€ ñ^ #ÜÐJÓKÐKàÐ&¨8Ð+?ÜÐWÓXÐXàÐ" xÐ'7Ü�K‰KÐrÔsÜ,¨XÑ6ÒDbÔc‰Oä˜/¬4Ô0Ø&5×&9Ñ&9¸,Ó&GÐ#Ü-Ð.AÑB�Ø".×"8Ñ"8¸Ó"I�àÐ&©?¸Ð?ZÜÐ^Ó_Ð_à.ˆÔØ ˆŒØ'>ˆÔ$Ø!2ˆÔØ.ˆÔØ&ˆÔØ'>ˆÔ$ØˆŒØ.ˆÔØ,ˆÔØ'>ˆÔ$Ø.ˆÔØ,ˆÔØ'>ˆÔ$ØˆŒØ!2ˆÔØ"4ˆÔØ#6ˆÔ Ø ˆŒØ.ˆÔØ!2ˆÔØ,ˆÔØ'>ˆÔ$à"4ˆÔØ 0ˆÔØ 0ˆÔØ"ˆŒØ'>ˆÔ$Ø.ˆÔØ"4ˆÔØ#6ˆÔ Ø˜Ñ °EÑ!9ÜÐRÓSÐSà$ˆŒØ"ˆŒØ"ˆŒà%:ˆÔ"Ø%:ˆÔ"Ø%:ˆÔ"Ø%:ˆÔ"Ø.ˆÔØ&ˆÔØ&<ˆÔ#Ü‰ÑÑIÐ,>ÐIÀ&ÓIó    Úreturnc                 ó   — | j                   S ©N)r   ©rG   s    rM   r   zDetaConfig.num_attention_heads  s   € à×+Ñ+Ð+rN   c                 ó   — | j                   S rQ   )r
   rR   s    rM   r   zDetaConfig.hidden_size	  s   € à�|‰|ÐrN   )+NNFFNi„  é   é   rT   é   rU   i   rV   ç        TÚrelué   çš™™™™™¹?rW   rW   g{®Gáz”?g      ð?TFÚsineé   r   r   Ti,  TTTé   r\   é   r]   r]   r\   r^   rZ   g      Ð?T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úattribute_maprF   ÚpropertyÚintr   r   Ú__classcell__)rL   s   @rM   r   r      sà   ø„ ñrðh €Jà Ø8ñ€Mð ØØ %ØØØØ $ØØØ !ØØØ !ØØØ"ØØØØØØØ ØØ &ØØØØØ #ØØØ ØØØØØØØØØØ#õYoJðb ð, Sò ,ó ð,ð ð˜Sò ó ôrN   r   N)rb   Úconfiguration_utilsr   Úutilsr   Úautor   Ú
get_loggerr_   r   r   r   rN   rM   ú<module>rk      s6   ðñ å 4Ý Ý "ð 
ˆ×	Ñ	˜HÓ	%€ôrÐ!õ rrN   