
    Z j7                     x    S SK Jr  SSKJr  SSKJr  SSKJr  SSKJ	r	  \" SS	9\ " S
 S\5      5       5       r
S/rg)    )strict   )%consolidate_backbone_kwargs_to_config)PreTrainedConfig)auto_docstring   )
AutoConfigz"Intellindust/DEIMv2_HGNetv2_N_COCO)
checkpointc                      ^  \ rS rSr% SrSrS\0rSS/rSSS	.r	S
r
\\S'   Sr\S-  \S'   Sr\\S'   Sr\\S'   Sr\\-  S-  \S'   Sr\\S'   Sr\\S'   Sr\\   \\S4   -  \S'   Sr\\   \\S4   -  \S'   Sr\\S'   Sr\\S'   Sr\\S'   Sr\\-  \S '   Sr\\-  \S!'   S"r \\   \\S4   -  \S#'   S$r!\\S%'   S&r"\#\S''   S(r$\#\S)'   Sr%\\   \\\4   -  S-  \S*'   S+r&\\S,'   S-r'\\S.'   Sr(\\S'   S/r)\\S0'   S1r*\\   \\S4   -  \S2'   Sr+\\S3'   S4r,\\S5'   S6r-\\\   -  \S7'   S8r.\\S9'   Sr/\\S:'   S;r0\#\S<'   Sr1\\-  \S='   S>r2\\S?'   S@r3\\SA'   S-r4\\SB'   S+r5\\SC'   Sr6\\\   -  S-  \SD'   Sr7\\SE'   SFr8\\SG'   SHr9\\SI'   SHr:\\SJ'   SKr;\\SL'   SHr<\\SM'   Sr=\\SN'   Sr>\\SO'   SPr?\\SQ'   SHr@\\SR'   S-rA\\SS'   SKrB\\ST'   SHrC\\SU'   SVrD\\SW'   SXrE\\SY'   SZrF\\S['   S\rG\\S]'   S-rH\\-  \S^'   S_rI\\S`'   SarJ\\Sb'   S-rK\\Sc'   S6rL\\Sd'   SerM\\Sf'   SgrN\\Sh'   S@rO\\Si'   SjrP\#\Sk'   S@rQ\\Sl'   SrR\\Sm'   SrS\\Sn'   S-rT\\So'   SrU\\Sp'   SrV\S-  \Sq'   SrrW\#\Ss'   StrX\\Su'   SvrY\#\Sw'   SrZ\\Sx'   S+r[\\Sy'   Sr\\\Sz'   U 4S{ jr]S| r^S}r_U =r`$ )~Deimv2Config   aS  
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{Gz?initializer_rangeNinitializer_bias_prior_probgh㈵>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_dropoutd   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                    > [        SU R                  SS/ SQ0S.UD6u  U l        nU R                  U R                  -  U l        [
        TU ]  " S0 UD6  g )Nhgnet_v2out_indices)r   r   r5   )r   default_config_typedefault_config_kwargs )r   r   r   r9   head_dimsuper__post_init__)selfkwargs	__class__s     ڀ/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/transformers/models/deimv2/configuration_deimv2.pyrv   Deimv2Config.__post_init__   s`    'L (
 00 *#0)"<(
 	(
$f (D(DD''    c                 ~   [        U R                  [        5      (       aR  [        U R                  5      U R                  :w  a/  [        S[        U R                  5       SU R                   S35      eU R                  U R                  -  U R                  :w  a%  [        SU R                   SU R                   35      eg)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)	
isinstancer6   listlenr4   
ValueErrorrt   r9   r   )rw   s    rz   validate_architecture"Deimv2Config.validate_architecture   s    d++T224(()T-D-DD 7D<Q<Q8R7SStuy  vM  vM  uN  NP  Q  ==47774<<G%dll^3abfb~b~a  A  Hr|   )r   rt   )a__name__
__module____qualname____firstlineno____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/   r0   r   r1   r2   r3   r4   r6   r8   r9   r;   r<   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rT   rU   rV   rW   rX   rY   r[   r\   r]   r_   r`   ra   rb   rc   rd   re   rg   rh   rj   rk   rl   rm   rv   r   __static_attributes____classcell__)ry   s   @rz   r   r      s   tl J$j1KL)K 8M
  $u#044 NE  NE 6:OT,,t3:(,, "!7HcU38_4H0;L$s)eCHo-;NCOS#$S$GUS[&))6:S	E#s(O3:+0#S0'--%%48ItCy5c?*T18"d"!e! GSK7FcU38_4FOS()cDIo)NC#$S$'--%(us{(M3"u" OU  %%04sT#Y-4 OT   M5M5 ##"u""u"NDND"e"!e! OU !e!!e!!OU! OU !OU!Hc"Ku"L#IuJOSNCJ"%%%#NC#BO $$## OU !%$%"Iut|" OS +-#S- L# K!OT!&*t*( r|   r   N)huggingface_hub.dataclassesr   backbone_utilsr   configuration_utilsr   utilsr   autor	   r   __all__rs   r|   rz   <module>r      sO   * / C 3 # 
 ?@f# f  AfR 
r|   