Ë
    ÜÓ^jy*  ã                   óØ  — d 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
mZ  ed	¬
«      e G d„ de«      «       «       Z ed	¬
«      e G d„ de«      «       «       Z ed	¬
«      e G d„ de«      «       «       Z ed	¬
«      e G d„ de«      «       «       Z ed	¬
«      e G d„ de«      «       «       Z ed	¬
«      e G d„ de«      «       «       Z ed	¬
«      e G d„ de«      «       «       Zg d¢Zy)zSAM3 model configurationé    )Ústrict)ÚCLIPTextConfigé   )ÚPreTrainedConfig)Úauto_docstringé   )ÚCONFIG_MAPPINGÚ
AutoConfigzfacebook/sam3)Ú
checkpointc                   óŒ  ‡ — e Zd ZU dZdZdZ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e   z  eeef   z  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z  ed<   dZeed<   dZeed<   dZee   dz  ed<   dZedz  ed<   dZeee   z  eeef   z  ed <   dZeez  ed!<   d"Zeed#<   ˆ fd$„Zˆ xZS )%ÚSam3ViTConfiga8  
    rope_theta (`float`, *optional*, defaults to 10000.0):
        Base frequency for RoPE.
    window_size (`int`, *optional*, defaults to 24):
        Window size for windowed attention.
    global_attn_indexes (`list[int]`, *optional*, defaults to `[7, 15, 23, 31]`):
        Indexes of layers with global attention.
    pretrain_image_size (`int`, *optional*, defaults to 336):
        Pretrained model image size for position embedding initialization.
    hidden_dropout (`float`, *optional*, defaults to 0.0):
        Dropout probability for hidden states.
    Úbackbone_configÚsam3_vit_modelé   Úhidden_sizei€  Úintermediate_sizeé    Únum_hidden_layersé   Únum_attention_headsr   Únum_channelsið  Ú
image_sizeé   Ú
patch_sizeÚgeluÚ
hidden_actç�íµ ÷Æ°>Úlayer_norm_epsç        Úattention_dropoutg     ˆÃ@Ú
rope_thetaé   Úwindow_sizeNÚglobal_attn_indexesÚlayer_scale_init_valueiP  Úpretrain_image_sizeÚhidden_dropoutç{®Gáz”?Úinitializer_rangec                 óP   •— t        ‰| �  di |¤Ž | j                  €
g d¢| _        y y )N)é   é   é   é   © )ÚsuperÚ__post_init__r$   ©ÚselfÚkwargsÚ	__class__s     €úv/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/sam3/configuration_sam3.pyr1   zSam3ViTConfig.__post_init__>   s,   ø€ Ü‰ÑÑ' Ò'Ø×#Ñ#Ð+Ú'6ˆDÕ$ð ,ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úbase_config_keyÚ
model_typer   ÚintÚ__annotations__r   r   r   r   r   ÚlistÚtupler   r   Ústrr   Úfloatr    r!   r#   r$   r%   r&   r'   r)   r1   Ú__classcell__©r5   s   @r6   r   r      s$  ø… ñð (€OØ!€Jà€K�ÓØ!Ð�sÓ!ØÐ�sÓØ!Ð˜Ó!Ø€L�#ÓØ48€J��d˜3‘i‘ %¨¨S¨¡/Ñ1Ó8Ø46€J��d˜3‘i‘ %¨¨S¨¡/Ñ1Ó6Ø€J�ÓØ €N�EÓ Ø%(Ð�u˜s‘{Ó(Ø€J�ÓØ€K�ÓØ,0Ð˜˜c™ TÑ)Ó0Ø+/Ð˜E D™LÓ/Ø=@Ð˜˜t C™y™¨5°°c°©?Ñ:Ó@Ø"%€N�E˜C‘KÓ%Ø#Ð�uÓ#÷7ð 7r7   r   c                   óè   ‡ — e Zd ZU dZdZdZdeiZdZe	e
z  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<   dZeed<   dZeed<   ˆ fd„Zed„ «       Zej2                  d„ «       Zˆ xZS )ÚSam3VisionConfigaî  
    fpn_hidden_size (`int`, *optional*, defaults to 256):
        The hidden dimension of the FPN.
    backbone_feature_sizes (`List[List[int]]`, *optional*, defaults to `[[288, 288], [144, 144], [72, 72]]`):
        The spatial sizes (height, width) of the feature maps from the backbone at different scales.
    scale_factors (`list[float]`, *optional*, defaults to `[4.0, 2.0, 1.0, 0.5]`):
        Scale factors for FPN multi-scale features. List of scaling factors for each FPN level.
    Úvision_configÚsam3_vision_modelr   Né   Úfpn_hidden_sizeÚbackbone_feature_sizesÚscale_factorsr   r   r   r   r(   r)   c                 ó¶  •— | j                   €g d¢n| j                   | _         | j                  €ddgddgddgg| _        t        | j                  t        «      rT| j                  j                  dd«      | j                  d<   t        | j                  d      di | j                  ¤Ž| _        n| j                  €t        d   «       | _        t        ‰| �   di |¤Ž y )N)g      @g       @g      ð?g      à?i   é�   éH   r=   r   r/   )	rM   rL   Ú
isinstancer   ÚdictÚgetr	   r0   r1   r2   s     €r6   r1   zSam3VisionConfig.__post_init__^   sÏ   ø€ Ø59×5GÑ5GÐ5OÓ1ÐUY×UgÑUgˆÔØ×&Ñ&Ð.Ø,/°¨:¸¸S°zÀBÈÀ8Ð*LˆDÔ'ä�d×*Ñ*¬DÔ1Ø15×1EÑ1E×1IÑ1IÈ,ÐXhÓ1iˆD× Ñ  Ñ.Ü#1°$×2FÑ2FÀ|Ñ2TÑ#UÑ#mÐX\×XlÑXlÑ#mˆDÕ Ø×!Ñ!Ð)Ü#1Ð2BÑ#CÓ#EˆDÔ ä‰ÑÑ' Ó'r7   c                 ó.   — | j                   j                  S )z"Image size for the vision encoder.©r   r   ©r3   s    r6   r   zSam3VisionConfig.image_sizek   s   € ð ×#Ñ#×.Ñ.Ð.r7   c                 ó&   — || j                   _        y)z-Set the image size and propagate to backbone.NrU   ©r3   Úvalues     r6   r   zSam3VisionConfig.image_sizep   s   € ð +0ˆ×ÑÕ'r7   )r8   r9   r:   r;   r<   r=   r
   Úsub_configsr   rR   r   r?   rK   r>   rL   r@   rM   rC   r   rB   r   r)   r1   Úpropertyr   ÚsetterrD   rE   s   @r6   rG   rG   D   sµ   ø… ñð &€OØ$€Jà˜:ð€Kð 7;€O�TÐ,Ñ,¨tÑ3Ó:Ø€O�SÓØ*.Ð˜D 4™KÓ.Ø(,€M�4˜‘; Ñ%Ó,Ø€J�ÓØ €N�EÓ Ø#Ð�uÓ#ô(ð ñ/ó ð/ð ×Ññ0ó ô0r7   rG   c                   ó®   — e Zd ZU dZdZ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z  ed<   dZeed<   dZeed<   dZeed<   y)ÚSam3GeometryEncoderConfigzc
    roi_size (`int`, *optional*, defaults to 7):
        ROI size for box pooling operations.
    Úsam3_geometry_encoderrJ   r   r   Ú
num_layersé   r   é   r   çš™™™™™¹?ÚdropoutÚrelur   r   r'   r   r   r+   Úroi_sizer(   r)   N)r8   r9   r:   r;   r=   r   r>   r?   r`   r   r   rd   rC   r   rB   r'   r   rf   r)   r/   r7   r6   r^   r^   v   s}   … ñð
 )€Jà€K�ÓØ€J�ÓØ Ð˜Ó Ø!Ð�sÓ!Ø€GˆU�S‰[ÓØ€J�ÓØ"%€N�E˜C‘KÓ%Ø €N�EÓ Ø€HˆcÓØ#Ð�uÔ#r7   r^   c                   ó    — e Zd ZU dZdZ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z  ed<   dZeed<   dZeed<   y)ÚSam3DETREncoderConfigzo
    hidden_dropout (`float`, *optional*, defaults to 0.0):
        Dropout probability for hidden states.
    Úsam3_detr_encoderrJ   r   é   r`   ra   r   rb   r   rc   rd   re   r   r   r'   r   r   r(   r)   N)r8   r9   r:   r;   r=   r   r>   r?   r`   r   r   rd   rC   r   rB   r'   r   r)   r/   r7   r6   rh   rh   Œ   ss   … ñð
 %€Jà€K�ÓØ€J�ÓØ Ð˜Ó Ø!Ð�sÓ!Ø€GˆU�S‰[ÓØ€J�ÓØ"%€N�E˜C‘KÓ%Ø €N�EÓ Ø#Ð�uÔ#r7   rh   c                   ó®   — e Zd ZU dZdZ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z  ed<   dZeed<   dZeed<   y)ÚSam3DETRDecoderConfigz]
    num_queries (`int`, *optional*, defaults to 200):
        Number of object queries.
    Úsam3_detr_decoderrJ   r   rj   r`   éÈ   Únum_queriesra   r   rb   r   rc   rd   re   r   r   r'   r   r   r(   r)   N)r8   r9   r:   r;   r=   r   r>   r?   r`   ro   r   r   rd   rC   r   rB   r'   r   r)   r/   r7   r6   rl   rl   ¡   s}   … ñð
 %€Jà€K�ÓØ€J�ÓØ€K�ÓØ Ð˜Ó Ø!Ð�sÓ!Ø€GˆU�S‰[ÓØ€J�ÓØ"%€N�E˜C‘KÓ%Ø €N�EÓ Ø#Ð�uÔ#r7   rl   c                   óp   — e Zd ZU dZdZ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<   y)ÚSam3MaskDecoderConfigzƒ
    num_upsampling_stages (`int`, *optional*, defaults to 3):
        Number of upsampling stages in the pixel decoder (FPN).
    Úsam3_mask_decoderrJ   r   r   Únum_upsampling_stagesr   r   r   rd   ra   r   r(   r)   N)r8   r9   r:   r;   r=   r   r>   r?   rs   r   rC   rd   r   r)   r/   r7   r6   rq   rq   ·   sQ   … ñð
 %€Jà€K�ÓØ!"Ð˜3Ó"Ø €N�EÓ Ø€GˆU�S‰[ÓØ Ð˜Ó Ø#Ð�uÔ#r7   rq   c                   ó  ‡ — e Zd ZU dZdZdZeeee	e
edœZdZeez  dz  ed<   dZeez  dz  ed<   dZeez  dz  ed<   dZeez  dz  ed	<   dZeez  dz  ed
<   dZeez  dz  ed<   dZeed<   ˆ fd„Zed„ «       Zej6                  d„ «       Zˆ xZS )Ú
Sam3ConfigaD  
    geometry_encoder_config (`dict` or `Sam3GeometryEncoderConfig`, *optional*):
        Configuration for the geometry encoder.
    detr_encoder_config (`dict` or `Sam3DETREncoderConfig`, *optional*):
        Configuration for the DETR encoder.
    detr_decoder_config (`dict` or `Sam3DETRDecoderConfig`, *optional*):
        Configuration for the DETR decoder.
    mask_decoder_config (`dict` or `Sam3MaskDecoderConfig`, *optional*):
        Configuration for the mask decoder.

    Example:
    ```python
    >>> from transformers import Sam3Config, Sam3Model

    >>> # Initializing a SAM3 configuration
    >>> configuration = Sam3Config()

    >>> # Initializing a model from the configuration
    >>> model = Sam3Model(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```
    Úsam3T)rH   Útext_configÚgeometry_encoder_configÚdetr_encoder_configÚdetr_decoder_configÚmask_decoder_configNrH   rw   rx   ry   rz   r{   r(   r)   c                 óì  •— | j                   €t        «       | _         t        | j                   t        «      rt        d
i | j                   ¤Ž| _         | j                  €t        d
i ddddddddd	œ¤Ž| _        t        | j                  t        «      rt        d
i | j                  ¤Ž| _        | j                  €t        «       | _        t        | j                  t        «      rt        d
i | j                  ¤Ž| _        | j                  €t        «       | _        t        | j                  t        «      rt        d
i | j                  ¤Ž| _        | j                  €t        «       | _
        t        | j                  t        «      rt        d
i | j                  ¤Ž| _
        | j                  €t        «       | _        t        | j                  t        «      rt        d
i | j                  ¤Ž| _        t        ‰| �<  d
i |¤Ž y )Ni Á  r   i   i   r"   r   r   r   )Ú
vocab_sizer   r   Úprojection_dimr   r   Úmax_position_embeddingsr   r/   )rH   rG   rQ   rR   rw   r   rx   r^   ry   rh   rz   rl   r{   rq   r0   r1   r2   s     €r6   r1   zSam3Config.__post_init__ø   s§  ø€ Ø×ÑÐ%Ü!1Ó!3ˆDÔÜ�d×(Ñ(¬$Ô/Ü!1Ñ!G°D×4FÑ4FÑ!GˆDÔà×ÑÐ#Ü-ñ  à"'Ø#'Ø)-Ø&)Ø)+Ø+-Ø/1Ø"(ñ	ñ ˆDÔô �d×&Ñ&¬Ô-Ü-ÑA°×0@Ñ0@ÑAˆDÔà×'Ñ'Ð/Ü+DÓ+FˆDÔ(Ü�d×2Ñ2´DÔ9Ü+DÑ+dÀt×GcÑGcÑ+dˆDÔ(à×#Ñ#Ð+Ü'<Ó'>ˆDÔ$Ü�d×.Ñ.´Ô5Ü'<Ñ'X¸t×?WÑ?WÑ'XˆDÔ$à×#Ñ#Ð+Ü'<Ó'>ˆDÔ$Ü�d×.Ñ.´Ô5Ü'<Ñ'X¸t×?WÑ?WÑ'XˆDÔ$à×#Ñ#Ð+Ü'<Ó'>ˆDÔ$Ü�d×.Ñ.´Ô5Ü'<Ñ'X¸t×?WÑ?WÑ'XˆDÔ$ä‰ÑÑ' Ó'r7   c                 ó.   — | j                   j                  S )zImage size for the SAM3 model.©rH   r   rV   s    r6   r   zSam3Config.image_size$  s   € ð ×!Ñ!×,Ñ,Ð,r7   c                 ó&   — || j                   _        y)z2Set the image size and propagate to vision config.Nr�   rX   s     r6   r   zSam3Config.image_size)  s   € ð ).ˆ×ÑÕ%r7   )r8   r9   r:   r;   r=   Úis_compositionrG   r   r^   rh   rl   rq   rZ   rH   rR   r   r?   rw   rx   ry   rz   r{   r)   rC   r1   r[   r   r\   rD   rE   s   @r6   ru   ru   É   sð   ø… ñð2 €JØ€Nà)Ø%Ø#<Ø4Ø4Ø4ñ€Kð 59€M�4Ð*Ñ*¨TÑ1Ó8Ø26€K�Ð(Ñ(¨4Ñ/Ó6Ø>BÐ˜TÐ$4Ñ4°tÑ;ÓBØ:>Ð˜Ð 0Ñ0°4Ñ7Ó>Ø:>Ð˜Ð 0Ñ0°4Ñ7Ó>Ø:>Ð˜Ð 0Ñ0°4Ñ7Ó>Ø#Ð�uÓ#ô*(ðX ñ-ó ð-ð ×Ññ.ó ô.r7   ru   )ru   r   rG   r^   rh   rl   rq   N)r;   Úhuggingface_hub.dataclassesr   Útransformersr   Úconfiguration_utilsr   Úutilsr   Úautor	   r
   r   rG   r^   rh   rl   rq   ru   Ú__all__r/   r7   r6   ú<module>rŠ      sE  ðñ å .å 'å 3Ý #ß -ñ ˜?Ô+Øô&7Ð$ó &7ó ó ,ð&7ñR ˜?Ô+Øô-0Ð'ó -0ó ó ,ð-0ñ` ˜?Ô+Øô$Ð 0ó $ó ó ,ð$ñ( ˜?Ô+Øô$Ð,ó $ó ó ,ð$ñ& ˜?Ô+Øô$Ð,ó $ó ó ,ð$ñ( ˜?Ô+Øô$Ð,ó $ó ó ,ð$ñ  ˜?Ô+Øôa.Ð!ó a.ó ó ,ða.òH�r7   