Ë
    ÜÓ^j†4  ã                   ó®   — 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 ed
¬«      e G d„ dee«      «       «       Z	dd	gZ
y)é    )Ústricté   )ÚBackboneConfigMixin)ÚPreTrainedConfig)Úauto_docstringzfacebook/sapiens2-seg-0.4b)Ú
checkpointc                   ó€  ‡ — e Zd ZU dZdZdZdZee   dz  e	d<   dZ
ee   dz  e	d<   dZee	d<   dZedz  e	d	<   dZee   dz  e	d
<   dZee   dz  e	d<   dZee	d<   dZee   dz  e	d<   dZee   dz  e	d<   dZee	d<   dZedz  e	d<   dZee   dz  e	d<   ˆ fd„Zdeee   z  eeef   z  deee   z  eeef   z  ddfd„Zˆ xZS )ÚSapiens2HeadConfigal	  
    upsample_out_channels (`list[int]`, *optional*):
        Output channel counts for each upsample block.
        The first block takes `hidden_size` channels as input; subsequent blocks use the previous output.
    upsample_kernel_sizes (`list[int]`, *optional*):
        Kernel size for each upsample block. Auto-filled with `[4, ...]` when
        `upsample_out_channels` is set but this is `None`.
        Must have the same length as `upsample_out_channels`.
    upsample_kernel_size (`int`, defaults to 4):
        Default kernel size for upsample blocks when `upsample_kernel_sizes` is not set.
    use_pixel_shuffle (`bool`, *optional*):
        Whether the upsample head uses pixel-shuffle upsampling instead of transposed convolutions.
        When `None` (default), the head uses transposed convolutions.
    conv_out_channels (`list[int]`, *optional*):
        Output channel counts for the refinement conv layers that follow the upsample blocks.
    conv_kernel_sizes (`list[int]`, *optional*):
        Kernel size for each refinement conv layer. Auto-filled with `[1, ...]` when
        `conv_out_channels` is set but this is `None`.
        Must have the same length as `conv_out_channels`.
    conv_kernel_size (`int`, defaults to 1):
        Default kernel size for conv layers when `conv_kernel_sizes` is not set.
    scale_conv_out_channels (`list[int]`, *optional*):
        Output channel counts for the stride-2 conv layers used to predict the focal-length scale.
        When `None` (default), no scale branch is built.
    scale_conv_kernel_sizes (`list[int]`, *optional*):
        Kernel size for each scale conv layer. Auto-filled with `[1, ...]` when
        `scale_conv_out_channels` is set but this is `None`.
        Must have the same length as `scale_conv_out_channels`.
    scale_conv_kernel_size (`int`, defaults to 1):
        Default kernel size for scale conv layers when `scale_conv_kernel_sizes` is not set.
    scale_final_input_size (`int`, *optional*):
        Flattened feature size passed into the scale MLP.
        When `None` (default), it is automatically inferred from `image_size` and `patch_size`
        in the parent [`Sapiens2Config`].
    scale_final_hidden_sizes (`list[int]`, *optional*):
        Hidden-layer sizes for the MLP that maps flattened scale features to the scalar scale output.
        When `None` (default), no scale branch is built.
    Úsapiens2_headÚhead_configNÚupsample_out_channelsÚupsample_kernel_sizesé   Úupsample_kernel_sizeÚuse_pixel_shuffleÚconv_out_channelsÚconv_kernel_sizesé   Úconv_kernel_sizeÚscale_conv_out_channelsÚscale_conv_kernel_sizesÚscale_conv_kernel_sizeÚscale_final_input_sizeÚscale_final_hidden_sizesc                 ó¤  •— | j                   �4| j                  €(| j                  gt        | j                   «      z  | _        | j                  �4| j
                  €(| j                  gt        | j                  «      z  | _        | j                  �4| j                  €(| j                  gt        | j                  «      z  | _        t        ‰| �,  di |¤Ž y )N© )r   r   r   Úlenr   r   r   r   r   r   ÚsuperÚ__post_init__)ÚselfÚkwargsÚ	__class__s     €ú~/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/sapiens2/configuration_sapiens2.pyr   z Sapiens2HeadConfig.__post_init__T   s»   ø€ Ø×%Ñ%Ð1°d×6PÑ6PÐ6XØ*.×*CÑ*CÐ)DÄsÈ4×KeÑKeÓGfÑ)fˆDÔ&Ø×!Ñ!Ð-°$×2HÑ2HÐ2PØ&*×&;Ñ&;Ð%<¼sÀ4×CYÑCYÓ?ZÑ%ZˆDÔ"Ø×'Ñ'Ð3¸×8TÑ8TÐ8\Ø,0×,GÑ,GÐ+HÌ3Èt×OkÑOkÓKlÑ+lˆDÔ(Ü‰ÑÑ' Ó'ó    Ú
image_sizeÚ
patch_sizeÚreturnc                 ó¦  — | j                   €| j                  �| j                  €y t        |t        t
        f«      r|n||f\  }}t        |t        «      r|n|d   }t        |t        «      r|n|d   }||z  }||z  }| j                  D ],  }	|	dz
  dz  }
|d|
z  z   |	z
  dz  dz   }|d|
z  z   |	z
  dz  dz   }Œ. ||z  | j                  d   z  | _         y )Nr   r   é   éÿÿÿÿ)r   r   r   Ú
isinstanceÚlistÚtupleÚint)r    r%   r&   Úimage_heightÚimage_widthÚpatch_heightÚpatch_widthÚfeatures_heightÚfeatures_widthÚkernel_sizeÚpaddings              r#   Ú_init_scale_final_input_sizez/Sapiens2HeadConfig._init_scale_final_input_size]   s  € ð ×'Ñ'Ð3Ø×+Ñ+Ð3Ø×+Ñ+Ð3àÜ2<¸ZÌ$ÔPUÈÔ2W¡JÐ^hÐjtÐ]uÑ!ˆ�kÜ%/°
¼CÔ%@‘zÀjÐQRÁmˆÜ$.¨z¼3Ô$?‘jÀZÐPQÁ]ˆØ&¨,Ñ6ˆØ$¨Ñ3ˆØ×7Ñ7ò 	SˆKØ" Q‘¨1Ñ,ˆGØ.°°W±Ñ<¸{ÑJÈqÑPÐSTÑTˆOØ,¨q°7©{Ñ:¸[ÑHÈQÑNÐQRÑR‰Nð	Sð '6¸Ñ&FÈ×IeÑIeÐfhÑIiÑ&iˆÕ#r$   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚbase_config_keyr   r,   r.   Ú__annotations__r   r   r   Úboolr   r   r   r   r   r   r   r   r   r-   r7   Ú__classcell__©r"   s   @r#   r
   r
      s6  ø… ñ%ðN !€JØ#€Oà.2Ð˜4 ™9 tÑ+Ó2Ø.2Ð˜4 ™9 tÑ+Ó2Ø !Ð˜#Ó!Ø%)Ð�t˜d‘{Ó)Ø*.Ð�t˜C‘y 4Ñ'Ó.Ø*.Ð�t˜C‘y 4Ñ'Ó.ØÐ�cÓØ04Ð˜T #™Y¨Ñ-Ó4Ø04Ð˜T #™Y¨Ñ-Ó4Ø"#Ð˜CÓ#Ø)-Ð˜C $™JÓ-Ø15Ð˜d 3™i¨$Ñ.Ó5ô(ðjØ  S¡	™/¨E°#°s°(©OÑ;ðjØILÈtÐTWÉyÉÐ[`ÐadÐfiÐaiÑ[jÑIjðjà	÷jr$   r
   zfacebook/sapiens2-pretrain-0.4bc                   óÎ  ‡ — e Zd ZU dZdZdZeee   z  eeef   z  e	d<   dZ
ee	d<   dZe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	d<   dZee	d<   dZeee   z  eeef   z  e	d<   dZee	d<   dZee	d<   dZee	d<   dZe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	d!<   d"Zee	d#<   d$Z ed$z  e	d%<   d$Z!ed$z  e	d&<   d'Z"ed$z  e	d(<   d$Z#ee   d$z  e	d)<   d$Z$ee   d$z  e	d*<   dZ%ee	d+<   d,e&iZ'd-Z(ee	d.<   d/Z)ee	d0<   dZ*ee	d1<   dZ+ee	d2<   d$Z,ee   d$z  e	d3<   d"Z-ee	d4<   d"Z.ee	d5<   d"Z/ee	d6<   d7Z0ee	d8<   d$Z1eee      d$z  e	d9<   d$Z2e&e3z  d$z  e	d,<   ˆ fd:„Z4ˆ xZ5S );ÚSapiens2ConfiguF  
    rope_theta (`float`, *optional*, defaults to 100.0):
        The base period of the RoPE embeddings.
    query_bias (`bool`, *optional*, defaults to `True`):
        Whether to add a bias to the query projection.
    key_bias (`bool`, *optional*, defaults to `False`):
        Whether to add a bias to the key projection.
    value_bias (`bool`, *optional*, defaults to `True`):
        Whether to add a bias to the value projection.
    proj_bias (`bool`, *optional*, defaults to `True`):
        Whether to add a bias to the output projection.
    layerscale_value (`float`, *optional*, defaults to 1.0):
        Initial value to use for layer scale.
    use_gated_mlp (`bool`, *optional*, defaults to `False`):
        Whether to use the SwiGLU feedforward neural network.
    num_register_tokens (`int`, *optional*, defaults to 0):
        The number of register tokens.
    pos_embed_shift (`float`, *optional*):
        Amount to randomly shift position embedding coordinates in [-shift, shift],
        applied only in training mode if not `None`.
    pos_embed_jitter (`float`, *optional*):
        Amount to randomly jitter position embedding coordinates in log-uniform value in [1/jitter, jitter],
        applied only in training mode if not `None`.
    pos_embed_rescale (`float`, *optional*, defaults to 2.0):
        Amount to randomly rescale position embedding coordinates in log-uniform value in [1/rescale, rescale],
        applied only in training mode if not `None`.
    reshape_hidden_states (`bool`, *optional*, defaults to `True`):
        Whether to reshape the hidden states to spatial dimensions when used as backbone.
    use_mask_token (`bool`, *optional*, defaults to `False`):
        Whether to use a mask token in the embeddings (needed for masked image modeling pretraining).
    rms_norm_eps (`float`, *optional*, defaults to 1e-6):
        Epsilon for the RMS normalization layers.
    normalize_backbone_outputs (`bool`, *optional*, defaults to `True`):
        Whether to apply RMSNorm to the backbone `feature_maps` and `cls_tokens` outputs before
        returning them from the forward pass. Only applies when the model is used as a backbone.
    use_qk_norm (`bool`, *optional*, defaults to `True`):
        Whether to apply RMSNorm to queries and keys before RoPE in attention layers.
    num_key_value_heads_per_layer (`list[int]`, *optional*):
        Number of key/value heads for each transformer layer. Setting a layer's value equal to
        `num_attention_heads` gives full multi-head attention; a smaller value gives grouped-query
        attention. Defaults to `num_attention_heads` for the first `num_first_full_attention_layers`
        and last `num_last_full_attention_layers` layers and `num_key_valueattention_heads` for all other
        layers.
    num_key_value_attention_heads (`int`):
        Number of key/value heads for layers that use grouped-query attention when `num_key_value_heads_per_layer`
        is not set. Ignored when `num_key_value_heads_per_layer` is set.
    num_first_full_attention_layers (`int`, *optional*, defaults to 8):
        Number of leading transformer layers that use full multi-head attention.
        Only used when `num_key_value_heads_per_layer` is `None`.
    num_last_full_attention_layers (`int`, *optional*, defaults to 8):
        Number of trailing transformer layers that use full multi-head attention.
        Only used when `num_key_value_heads_per_layer` is `None`.
    semantic_loss_ignore_index (`int`, *optional*, defaults to 255):
        Label index ignored when computing the segmentation loss.
    flip_pairs (`list[list[int]]`, *optional*):
        Pairs of keypoint indices that are mirrored horizontally (e.g., left ear â†” right ear).
        Each pair is a two-element list `[left_index, right_index]`. Used for test-time
        horizontal flip augmentation in pose estimation: pass these pairs to the second
        forward call so the model flips heatmaps back before returning them.
    head_config (`Sapiens2HeadConfig`, *optional*):
        Configuration for the decode head. See [`Sapiens2HeadConfig`] for the available options.
    Úsapiens2é   r&   i   Úhidden_sizei   Úintermediate_sizeé   Únum_hidden_layersÚnum_attention_headsÚsiluÚ
hidden_actg        Úattention_dropoutg{®Gáz”?Úinitializer_rangeg      Y@Ú
rope_thetaéà   r%   r   Únum_channelsTÚ
query_biasÚkey_biasÚ
value_biasÚ	proj_biasÚmlp_biasg      ð?Úlayerscale_valueÚdrop_path_rateÚuse_gated_mlpé   Únum_register_tokensNÚpos_embed_shiftÚpos_embed_jitterg       @Úpos_embed_rescaleÚ_out_featuresÚ_out_indicesÚreshape_hidden_statesr   FÚuse_mask_tokeng�íµ ÷Æ°>Úrms_norm_epsÚnormalize_backbone_outputsÚuse_qk_normÚnum_key_value_heads_per_layerÚnum_key_value_attention_headsÚnum_first_full_attention_layersÚnum_last_full_attention_layerséÿ   Úsemantic_loss_ignore_indexÚ
flip_pairsc                 óÐ  •— | j                   €it        | j                  «      D �cg c]E  }|| j                  k  s|| j                  | j                  z
  k\  r| j
                  n| j                  ‘ŒG c}| _         t        | j                  t        «      rt        di | j                  ¤Ž| _        | j                  �1| j                  j                  | j                  | j                  ¬«       dgt        d| j                  dz   «      D �cg c]  }d|› �‘Œ	 c}z   | _        | j                  |j!                  dd «      |j!                  dd «      ¬«       t#        ‰| �H  di |¤Ž y c c}w c c}w )	N)r%   r&   Ústemr   ÚstageÚout_indicesÚout_features)rp   rq   r   )rf   ÚrangerI   rh   ri   rJ   rg   r+   r   Údictr
   r7   r%   r&   Ústage_namesÚ"set_output_features_output_indicesÚpopr   r   )r    r!   Úlayer_indexÚir"   s       €r#   r   zSapiens2Config.__post_init__Þ   sP  ø€ Ø×-Ñ-Ð5ô $)¨×)?Ñ)?Ó#@ö2ð  ð	   $×"FÑ"FÒFØ" d×&<Ñ&<¸t×?bÑ?bÑ&bÒbð ×(Ò(ð
 ×7Ñ7ñ8ò2ˆDÔ.ô �d×&Ñ&¬Ô-Ü1ÑE°D×4DÑ4DÑEˆDÔØ×ÑÐ'Ø×Ñ×9Ñ9ÀTÇ_Á_Ðae×apÑapÐ9ÔqØ"˜8¼EÀ!ÀT×E[ÑE[Ð^_ÑE_Ó<`Ö&a°q¨¨q¨c¢{Ò&aÑaˆÔØ×/Ñ/ØŸ
™
 =°$Ó7ÀfÇjÁjÐQ_ÐaeÓFfð 	0ô 	
ô 	‰ÑÑ' Ó'ùò#2ùò 'bs   ¥A
EÄE#)6r8   r9   r:   r;   r<   r&   r.   r,   r-   r>   rF   rG   rI   rJ   rL   ÚstrrM   ÚfloatrN   rO   r%   rQ   rR   r?   rS   rT   rU   rV   rW   rX   rY   r[   r\   r]   r^   r_   r`   ra   r
   Úsub_configsrb   rc   rd   re   rf   rg   rh   ri   rk   rl   r   rs   r   r@   rA   s   @r#   rC   rC   r   s  ø… ñ=ð~ €Jà46€J��d˜3‘i‘ %¨¨S¨¡/Ñ1Ó6à€K�ÓØ!Ð�sÓ!ØÐ�sÓØ!Ð˜Ó!Ø€J�ÓØ%(Ð�u˜s‘{Ó(Ø#Ð�uÓ#Ø€J�ÓØ47€J��d˜3‘i‘ %¨¨S¨¡/Ñ1Ó7Ø€L�#ÓØ€J�ÓØ€HˆdÓØ€J�ÓØ€IˆtÓØ€HˆdÓØ!Ð�eÓ!Ø"%€N�E˜C‘KÓ%Ø€M�4ÓØ Ð˜Ó Ø$(€O�U˜T‘\Ó(Ø%)Ð�e˜d‘lÓ)Ø&)Ð�u˜t‘|Ó)Ø&*€M�4˜‘9˜tÑ#Ó*Ø%)€L�$�s‘)˜dÑ"Ó)Ø"&Ð˜4Ó&Ø Ð"4Ð5€KØ €N�DÓ Ø€L�%ÓØ'+Ð Ó+Ø€K�ÓØ6:Ð! 4¨¡9¨tÑ#3Ó:Ø)*Ð! 3Ó*Ø+,Ð# SÓ,Ø*+Ð" CÓ+Ø&)Ð Ó)Ø)-€J��T˜#‘Y‘ $Ñ&Ó-Ø48€KÐ# dÑ*¨TÑ1Ó8÷(ð (r$   rC   N)Úhuggingface_hub.dataclassesr   Úbackbone_utilsr   Úconfiguration_utilsr   Úutilsr   r
   rC   Ú__all__r   r$   r#   ú<module>r�      s‚   ðõ& /å 1Ý 3Ý #ñ Ð7Ô8ØôSjÐ)ó Sjó ó 9ðSjñl Ð<Ô=Øô}(Ð(Ð*:ó }(ó ó >ð}(ð@ Ð1Ð
2�r$   