§
    ‚Štj7  ã                   ó˜   — 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d¬	¦  «        e G d
„ de¦  «        ¦   «         ¦   «         Z
dgZdS )é    )Ústricté   )Ú%consolidate_backbone_kwargs_to_config)ÚPreTrainedConfig)Úauto_docstringé   )Ú
AutoConfigz"Intellindust/DEIMv2_HGNetv2_N_COCO)Ú
checkpointc                   ó^  ‡ — e Zd ZU dZdZdeiZddgZdddœZd	Z	e
ed
<   dZe
dz  ed<   dZe
ed<   dZe
ed<   dZeez  dz  ed<   dZeed<   dZeed<   dZee         eedf         z  ed<   dZee         eedf         z  ed<   dZeed<   dZeed<   dZeed<   dZe
ez  ed<   dZe
ez  ed <   d!Zee         eedf         z  ed"<   d#Z eed$<   d%Z!e"ed&<   d'Z#e"ed(<   dZ$ee         eeef         z  dz  ed)<   d*Z%eed+<   d,Z&e
ed-<   dZ'eed<   d.Z(eed/<   d0Z)ee         eedf         z  ed1<   dZ*eed2<   d3Z+eed4<   d5Z,eee         z  ed6<   d7Z-eed8<   dZ.eed9<   d:Z/e"ed;<   dZ0e
ez  ed<<   d=Z1eed><   d?Z2e
ed@<   d,Z3e
edA<   d*Z4eedB<   dZ5eee         z  dz  edC<   dZ6eedD<   dEZ7e
edF<   dGZ8e
edH<   dGZ9e
edI<   dJZ:e
edK<   dGZ;e
edL<   dZ<eedM<   dZ=eedN<   dOZ>e
edP<   dGZ?e
edQ<   d,Z@e
edR<   dJZAe
edS<   dGZBe
edT<   dUZCe
edV<   dWZDe
edX<   dYZEe
edZ<   d[ZFeed\<   d,ZGee
z  ed]<   d^ZHeed_<   d`ZIe
eda<   d,ZJe
edb<   d5ZKeedc<   ddZLeede<   dfZMeedg<   d?ZNe
edh<   diZOe"edj<   d?ZPe
edk<   dZQeedl<   dZReedm<   d,ZSe
edn<   dZTeedo<   dZUe
dz  edp<   dqZVe"edr<   dsZWeedt<   duZXe"edv<   dZYeedw<   d*ZZeedx<   dZ[eedy<   ˆ fdz„Z\d{„ Z]ˆ xZ^S )|ÚDeimv2Configa#  
    initializer_bias_prior_prob (`float`, *optional*):
        The prior probability used by the bias initializer to initialize biases for `enc_score_head` and `class_embed`.
        If `None`, `prior_prob` computed as `prior_prob = 1 / (num_labels + 1)` while initializing model weights.
    freeze_backbone_batch_norms (`bool`, *optional*, defaults to `True`):
        Whether to freeze the batch normalization layers in the backbone.
    encoder_in_channels (`list`, *optional*, defaults to `[512, 1024, 2048]`):
        Multi level features input for encoder.
    feat_strides (`list[int]`, *optional*, defaults to `[8, 16, 32]`):
        Strides used in each feature map.
    encode_proj_layers (`list[int]`, *optional*, defaults to `[2]`):
        Indexes of the projected layers to be used in the encoder.
    positional_encoding_temperature (`int`, *optional*, defaults to 10000):
        The temperature parameter used to create the positional encodings.
    encoder_activation_function (`str`, *optional*, defaults to `"gelu"`):
        The non-linear activation function (function or string) in the encoder and pooler.
    eval_size (`list[int]` or `tuple[int, int]`, *optional*):
        Height and width used to computes the effective height and width of the position embeddings after taking
        into account the stride.
    normalize_before (`bool`, *optional*, defaults to `False`):
        Determine whether to apply layer normalization in the transformer encoder layer before self-attention and
        feed-forward modules.
    hidden_expansion (`float`, *optional*, defaults to 1.0):
        Expansion ratio to enlarge the dimension size of RepVGGBlock and CSPRepLayer.
    num_queries (`int`, *optional*, defaults to 300):
        Number of object queries.
    decoder_in_channels (`list`, *optional*, defaults to `[256, 256, 256]`):
        Multi level features dimension for decoder.
    num_feature_levels (`int`, *optional*, defaults to 3):
        The number of input feature levels.
    decoder_n_points (`int`, *optional*, defaults to 4):
        The number of sampled keys in each feature level for each attention head in the decoder.
    decoder_activation_function (`str`, *optional*, defaults to `"relu"`):
        The non-linear activation function (function or string) in the decoder.
    num_denoising (`int`, *optional*, defaults to 100):
        The total number of denoising tasks or queries to be used for contrastive denoising.
    label_noise_ratio (`float`, *optional*, defaults to 0.5):
        The fraction of denoising labels to which random noise should be added.
    box_noise_scale (`float`, *optional*, defaults to 1.0):
        Scale or magnitude of noise to be added to the bounding boxes.
    learn_initial_query (`bool`, *optional*, defaults to `False`):
        Indicates whether the initial query embeddings for the decoder should be learned during training.
    anchor_image_size (`tuple[int, int]`, *optional*):
        Height and width of the input image used during evaluation to generate the bounding box anchors.
    with_box_refine (`bool`, *optional*, defaults to `True`):
        Whether to apply iterative bounding box refinement.
    matcher_alpha (`float`, *optional*, defaults to 0.25):
        Parameter alpha used by the Hungarian Matcher.
    matcher_gamma (`float`, *optional*, defaults to 2.0):
        Parameter gamma used by the Hungarian Matcher.
    matcher_class_cost (`float`, *optional*, defaults to 2.0):
        The relative weight of the class loss used by the Hungarian Matcher.
    matcher_bbox_cost (`float`, *optional*, defaults to 5.0):
        The relative weight of the bounding box loss used by the Hungarian Matcher.
    matcher_giou_cost (`float`, *optional*, defaults to 2.0):
        The relative weight of the giou loss of used by the Hungarian Matcher.
    use_focal_loss (`bool`, *optional*, defaults to `True`):
        Parameter informing if focal loss should be used.
    focal_loss_alpha (`float`, *optional*, defaults to 0.75):
        Parameter alpha used to compute the focal loss.
    focal_loss_gamma (`float`, *optional*, defaults to 2.0):
        Parameter gamma used to compute the focal loss.
    weight_loss_vfl (`float`, *optional*, defaults to 1.0):
        Relative weight of the varifocal loss in the object detection loss.
    weight_loss_bbox (`float`, *optional*, defaults to 5.0):
        Relative weight of the L1 bounding box loss in the object detection loss.
    weight_loss_giou (`float`, *optional*, defaults to 2.0):
        Relative weight of the generalized IoU loss in the object detection loss.
    weight_loss_fgl (`float`, *optional*, defaults to 0.15):
        Relative weight of the fine-grained localization loss in the object detection loss.
    weight_loss_ddf (`float`, *optional*, defaults to 1.5):
        Relative weight of the decoupled distillation focal loss in the object detection loss.
    eval_idx (`int`, *optional*, defaults to -1):
        Index of the decoder layer to use for evaluation.
    layer_scale (`float`, *optional*, defaults to `1.0`):
        Scaling factor for the hidden dimension in later decoder layers.
    max_num_bins (`int`, *optional*, defaults to 32):
        Maximum number of bins for the distribution-guided bounding box refinement.
    reg_scale (`float`, *optional*, defaults to 4.0):
        Scale factor for the regression distribution.
    depth_mult (`float`, *optional*, defaults to 1.0):
        Multiplier for the number of blocks in RepNCSPELAN5 layers.
    top_prob_values (`int`, *optional*, defaults to 4):
        Number of top probability values to consider from each corner's distribution.
    lqe_hidden_dim (`int`, *optional*, defaults to 64):
        Hidden dimension size for the Location Quality Estimator (LQE) network.
    lqe_layers (`int`, *optional*, defaults to 2):
        Number of layers in the Location Quality Estimator MLP.
    decoder_offset_scale (`float`, *optional*, defaults to 0.5):
        Offset scale used in deformable attention.
    decoder_method (`str`, *optional*, defaults to `"default"`):
        The method to use for the decoder: `"default"` or `"discrete"`.
    up (`float`, *optional*, defaults to 0.5):
        Controls the upper bounds of the Weighting Function.
    weight_loss_mal (`float`, *optional*, defaults to 1.0):
        Relative weight of the matching auxiliary loss in the object detection loss.
    use_dense_one_to_one (`bool`, *optional*, defaults to `True`):
        Whether to use dense one-to-one matching across decoder layers.
    mal_alpha (`float`, *optional*):
        Alpha parameter for the Matching Auxiliary Loss (MAL). If `None`, uses `focal_loss_alpha`.
    encoder_fuse_op (`str`, *optional*, defaults to `"sum"`):
        Fusion operation used in the encoder FPN. DEIMv2 uses `"sum"` instead of D-FINE's `"cat"`.
    spatial_tuning_adapter_inplanes (`int`, *optional*, defaults to 16):
        Number of input planes for the STA convolutional stem.
    encoder_type (`str`, *optional*, defaults to `"hybrid"`):
        Type of encoder to use. `"hybrid"` uses the full HybridEncoder with AIFI, FPN, and PAN.
        `"lite"` uses the lightweight LiteEncoder with GAP fusion for smaller variants (Atto, Femto, Pico).
    use_gateway (`bool`, *optional*, defaults to `True`):
        Whether to use the gateway mechanism (cross-attention gating) in decoder layers. When `False`,
        uses RMSNorm on the encoder attention output instead.
    share_bbox_head (`bool`, *optional*, defaults to `False`):
        Whether to share the bounding box prediction head across all decoder layers.
    encoder_has_trailing_conv (`bool`, *optional*, defaults to `True`):
        Whether the encoder's CSP blocks include a trailing 3x3 convolution after the bottleneck path.
        `True` for RepNCSPELAN4 (used by HGNetV2 N and LiteEncoder variants).
        `False` for RepNCSPELAN5 (used by DINOv3 variants).
    Údeimv2Úbackbone_configÚbasicÚ
bottleneckÚd_modelÚencoder_attention_heads)Úhidden_sizeÚnum_attention_headsg{®Gáz„?Úinitializer_rangeNÚinitializer_bias_prior_probgñhãˆµøä>Úlayer_norm_epsÚbatch_norm_epsTÚfreeze_backbone_batch_normsé   Úencoder_hidden_dim)i   é   i   .Úencoder_in_channels)é   é   é    Úfeat_stridesé   Úencoder_layersr   Úencoder_ffn_dimr   g        ÚdropoutÚactivation_dropout)r   Úencode_proj_layersi'  Úpositional_encoding_temperatureÚgeluÚencoder_activation_functionÚsiluÚactivation_functionÚ	eval_sizeFÚnormalize_beforeg      ð?Úhidden_expansioni,  Únum_queries)r   r   r   Údecoder_in_channelsÚdecoder_ffn_dimr   Únum_feature_levelsé   Údecoder_n_pointsé   Údecoder_layersÚdecoder_attention_headsÚreluÚdecoder_activation_functionÚattention_dropoutéd   Únum_denoisingg      à?Úlabel_noise_ratioÚbox_noise_scaleÚlearn_initial_queryÚanchor_image_sizeÚwith_box_refineg      Ð?Úmatcher_alphag       @Úmatcher_gammaÚmatcher_class_costg      @Úmatcher_bbox_costÚmatcher_giou_costÚuse_focal_lossÚauxiliary_lossg      è?Úfocal_loss_alphaÚfocal_loss_gammaÚweight_loss_vflÚweight_loss_bboxÚweight_loss_gioug333333Ã?Úweight_loss_fglg      ø?Úweight_loss_ddfg-Cëâ6?Úeos_coefficientéÿÿÿÿÚeval_idxÚlayer_scaler    Úmax_num_binsg      @Ú	reg_scaleÚ
depth_multÚtop_prob_valuesé@   Úlqe_hidden_dimr   Ú
lqe_layersÚdecoder_offset_scaleÚdefaultÚdecoder_methodÚupÚtie_word_embeddingsÚis_encoder_decoderÚweight_loss_malÚuse_dense_one_to_oneÚ	mal_alphaÚsumÚencoder_fuse_opr   Úspatial_tuning_adapter_inplanesÚhybridÚencoder_typeÚuse_gatewayÚshare_bbox_headÚencoder_has_trailing_convc                 ó¤   •— t          d| j        ddg d¢idœ|¤Ž\  | _        }| j        | j        z  | _         t          ¦   «         j        di |¤Ž d S )NÚhgnet_v2Úout_indices)r   r   r4   )r   Údefault_config_typeÚdefault_config_kwargs© )r   r   r   r8   Úhead_dimÚsuperÚ__post_init__)ÚselfÚkwargsÚ	__class__s     €úm/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/models/deimv2/configuration_deimv2.pyru   zDeimv2Config.__post_init__ò   sy   ø€ Ý'Lð (
Ø Ô0Ø *Ø#0°)°)°)Ð"<ð(
ð (
ð ð	(
ð (
Ñ$ˆÔ˜fð œ¨Ô(DÑDˆŒØ�‰ŒÔÐ'Ð' Ð'Ð'Ð'Ð'Ð'ó    c                 ó<  — t          | j        t          ¦  «        rJt          | j        ¦  «        | j        k    r-t          dt          | j        ¦  «        › d| j        › d�¦  «        ‚| j        | j        z  | j        k    rt          d| j        › d| j        › �¦  «        ‚dS )zOPart of `@strict`-powered validation. Validates the architecture of the config.z!Length of decoder_n_points list (z!) must match num_feature_levels (z).zEmbedded dimension z. must be divisible by decoder_attention_heads N)	Ú
isinstancer5   ÚlistÚlenr3   Ú
ValueErrorrs   r8   r   )rv   s    ry   Úvalidate_architecturez"Deimv2Config.validate_architectureü   sÙ   € å�dÔ+­TÑ2Ô2ð 	Ý�4Ô(Ñ)Ô)¨TÔ-DÒDÐDÝ ð Q½¸DÔ<QÑ8RÔ8Rð  Qð  QÐuyô  vMð  Qð  Qð  Qñô ð ð Œ=˜4Ô7Ñ7¸4¼<ÒGÐGÝð A d¤lð  Að  AÐbfÔb~ð  Að  Añô ð ð HÐGrz   )_Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typer	   Úsub_configsÚlayer_typesÚattribute_mapr   ÚfloatÚ__annotations__r   r   r   r   Údictr   r   Úboolr   Úintr   r}   Útupler!   r#   r$   r   r%   r&   r'   r(   r*   Ústrr,   r-   r.   r/   r   r0   r1   r2   r3   r5   r7   r8   r:   r;   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rS   rT   rU   rV   rW   rX   rZ   r[   r\   r^   r_   r`   ra   rb   rc   rd   rf   rg   ri   rj   rk   rl   ru   r€   Ú__classcell__)rx   s   @ry   r   r      sÝ  ø€ € € € € € ðtð tðl €JØ$ jÐ1€KØ˜LÐ)€Kà Ø8ðð €Mð
  $Ð�uÐ#Ð#Ñ#Ø04Ð ¨¡Ð4Ð4Ñ4Ø €N�EÐ Ð Ñ Ø €N�EÐ Ð Ñ Ø6:€O�TÐ,Ñ,¨tÑ3Ð:Ð:Ñ:Ø(,Ð Ð,Ð,Ñ,ð "Ð˜Ð!Ð!Ñ!Ø7HÐ˜˜cœ U¨3°¨8¤_Ñ4ÐHÐHÑHØ0;€L�$�s”)˜e C¨ HœoÑ-Ð;Ð;Ñ;Ø€N�CÐÐÑØ€O�SÐÐÑØ#$Ð˜SÐ$Ð$Ñ$Ø€GˆU�S‰[ÐÐÑØ&)Ð˜ ™Ð)Ð)Ñ)Ø6:Ð˜˜Sœ	 E¨#¨s¨(¤OÑ3Ð:Ð:Ñ:Ø+0Ð# SÐ0Ð0Ñ0Ø'-Ð Ð-Ð-Ñ-Ø%Ð˜Ð%Ð%Ñ%à48€Iˆt�CŒy˜5  c œ?Ñ*¨TÑ1Ð8Ð8Ñ8Ø"Ð�dÐ"Ð"Ñ"Ø!Ð�eÐ!Ð!Ñ!ð €GˆSÐÐÑØ€K�ÐÐÑØ7FÐ˜˜cœ U¨3°¨8¤_Ñ4ÐFÐFÑFØ€O�SÐÐÑØÐ˜ÐÐÑØ()Ð�c˜D œI‘oÐ)Ð)Ñ)Ø€N�CÐÐÑØ#$Ð˜SÐ$Ð$Ñ$Ø'-Ð Ð-Ð-Ñ-Ø%(Ð�u˜s‘{Ð(Ð(Ñ(Ø€M�3ÐÐÑØ"Ð�uÐ"Ð"Ñ"Ø €O�UÐ Ð Ñ Ø %Ð˜Ð%Ð%Ñ%Ø04Ð�s˜T #œY‘¨Ñ-Ð4Ð4Ñ4Ø €O�TÐ Ð Ñ ð  €M�5ÐÐÑØ€M�5ÐÐÑØ #Ð˜Ð#Ð#Ñ#Ø"Ð�uÐ"Ð"Ñ"Ø"Ð�uÐ"Ð"Ñ"Ø€N�DÐÐÑØ€N�DÐÐÑØ"Ð�eÐ"Ð"Ñ"Ø!Ð�eÐ!Ð!Ñ!Ø €O�UÐ Ð Ñ Ø!Ð�eÐ!Ð!Ñ!Ø!Ð�eÐ!Ð!Ñ!Ø!€O�UÐ!Ð!Ñ!Ø €O�UÐ Ð Ñ Ø!€O�UÐ!Ð!Ñ!Ø€HˆcÐÐÑØ"€K��u‘Ð"Ð"Ñ"Ø€L�#ÐÐÑØ€IˆuÐÐÑØ€J�ÐÐÑØ€O�SÐÐÑØ€N�CÐÐÑØ€J�ÐÐÑØ"%Ð˜%Ð%Ð%Ñ%Ø#€N�CÐ#Ð#Ñ#Ø€Bˆ€O€O�OØ $Ð˜Ð$Ð$Ñ$Ø#Ð˜Ð#Ð#Ñ#Ø €O�UÐ Ð Ñ Ø!%Ð˜$Ð%Ð%Ñ%Ø"€Iˆu�t‰|Ð"Ð"Ñ"Ø €O�SÐ Ð Ñ Ø+-Ð# SÐ-Ð-Ñ-Ø €L�#Ð Ð Ñ Ø€K�ÐÐÑØ!€O�TÐ!Ð!Ñ!Ø&*Ð˜tÐ*Ð*Ñ*ð(ð (ð (ð (ð (ðð ð ð ð ð ð rz   r   N)Úhuggingface_hub.dataclassesr   Úbackbone_utilsr   Úconfiguration_utilsr   Úutilsr   Úautor	   r   Ú__all__rr   rz   ry   ú<module>r—      sÉ   ðð* /Ð .Ð .Ð .Ð .Ð .à CÐ CÐ CÐ CÐ CÐ CØ 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð ð
 €Ð?Ð@Ñ@Ô@Øðfð fð fð fð fÐ#ñ fô fñ „ñ AÔ@ðfðR Ð
€€€rz   