Ë
    ÜÓ^j  ã                   ó  — d 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«      «       «       Z ed¬«      e G d„ de«      «       «       Z	 ed¬«      e G d„ de«      «       «       Z
g d¢Zy)zSAM model configurationé    )Ústricté   )ÚPreTrainedConfig)Úauto_docstringzfacebook/sam-vit-huge)Ú
checkpointc                   óÂ   ‡ — e Zd ZU dZdZ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d<   dZeed<   ˆ fd„Zˆ xZS )ÚSamPromptEncoderConfigzø
    mask_input_channels (`int`, *optional*, defaults to 16):
        The number of channels to be fed to the `MaskDecoder` module.
    num_point_embeddings (`int`, *optional*, defaults to 4):
        The number of point embeddings to be used.
    Úprompt_encoder_configé   Úhidden_sizeé   Ú
image_sizeé   Ú
patch_sizeÚmask_input_channelsé   Únum_point_embeddingsÚgeluÚ
hidden_actç�íµ ÷Æ°>Úlayer_norm_epsc                 ó`   •— | j                   | j                  z  | _        t        ‰| �  di |¤Ž y ©N© )r   r   Úimage_embedding_sizeÚsuperÚ__post_init__©ÚselfÚkwargsÚ	__class__s     €út/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/sam/configuration_sam.pyr   z$SamPromptEncoderConfig.__post_init__*   s(   ø€ Ø$(§O¡O°t·±Ñ$FˆÔ!Ü‰ÑÑ' Ó'ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úbase_config_keyr   ÚintÚ__annotations__r   ÚlistÚtupler   r   r   r   Ústrr   Úfloatr   Ú__classcell__©r!   s   @r"   r	   r	      s‹   ø… ñð .€Oà€K�ÓØ48€J��d˜3‘i‘ %¨¨S¨¡/Ñ1Ó8Ø46€J��d˜3‘i‘ %¨¨S¨¡/Ñ1Ó6Ø!Ð˜Ó!Ø !Ð˜#Ó!Ø€J�ÓØ €N�EÓ ÷(ð (r#   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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<   y)ÚSamMaskDecoderConfigaµ  
    mlp_dim (`int`, *optional*, defaults to 2048):
        Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
    attention_downsample_rate (`int`, *optional*, defaults to 2):
        The downsampling rate of the attention layer.
    num_multimask_outputs (`int`, *optional*, defaults to 3):
        The number of outputs from the `SamMaskDecoder` module. In the Segment Anything paper, this is set to 3.
    iou_head_depth (`int`, *optional*, defaults to 3):
        The number of layers in the IoU head module.
    iou_head_hidden_dim (`int`, *optional*, defaults to 256):
        The dimensionality of the hidden states in the IoU head module.
    Úmask_decoder_configr   r   Úrelur   i   Úmlp_dimé   Únum_hidden_layersé   Únum_attention_headsÚattention_downsample_rater   Únum_multimask_outputsÚiou_head_depthÚiou_head_hidden_dimr   r   N)r$   r%   r&   r'   r(   r   r)   r*   r   r-   r5   r7   r9   r:   r;   r<   r=   r   r.   r   r#   r"   r2   r2   /   sw   … ñð ,€Oà€K�ÓØ€J�ÓØ€GˆSÓØÐ�sÓØ Ð˜Ó Ø%&Ð˜sÓ&Ø!"Ð˜3Ó"Ø€N�CÓØ"Ð˜Ó"Ø €N�EÔ r#   r2   c                   ó�  ‡ — 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<   dZe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d%<   d&Zed&z  ed'<   ˆ fd(„Z ˆ xZ!S ))ÚSamVisionConfigaé  
    output_channels (`int`, *optional*, defaults to 256):
        Dimensionality of the output channels in the Patch Encoder.
    use_rel_pos (`bool`, *optional*, defaults to `True`):
        Whether to use relative position embedding.
    window_size (`int`, *optional*, defaults to 14):
        Window size for relative position.
    global_attn_indexes (`list[int]`, *optional*, defaults to `[2, 5, 8, 11]`):
        The indexes of the global attention layers.
    num_pos_feats (`int`, *optional*, defaults to 128):
        The dimensionality of the position embedding.
    mlp_dim (`int`, *optional*):
        The dimensionality of the MLP layer in the Transformer encoder. If `None`, defaults to `mlp_ratio *
        hidden_size`.

    Example:

    ```python
    >>> from transformers import (
    ...     SamVisionConfig,
    ...     SamVisionModel,
    ... )

    >>> # Initializing a SamVisionConfig with `"facebook/sam-vit-huge"` style configuration
    >>> configuration = SamVisionConfig()

    >>> # Initializing a SamVisionModel (with random weights) from the `"facebook/sam-vit-huge"` style configuration
    >>> model = SamVisionModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úvision_configÚsam_vision_modeli   r   r   Úoutput_channelsé   r7   r9   r   Únum_channelsr   r   r   r   r   r   r   r   g        Úattention_dropoutg»½×Ùß|Û=Úinitializer_rangeTÚqkv_biasg      @Ú	mlp_ratioÚuse_abs_posÚuse_rel_posé   Úwindow_size)r6   é   r8   é   .Úglobal_attn_indexesé€   Únum_pos_featsNr5   c                 óÊ   •— | j                   €"t        | j                  | j                  z  «      n| j                   | _         | j                  dz  | _        t        ‰| �  di |¤Ž y )Nr6   r   )r5   r)   r   rH   Úscaler   r   r   s     €r"   r   zSamVisionConfig.__post_init__ˆ   sR   ø€ ØAEÇÁÐAU”s˜4×+Ñ+¨d¯n©nÑ<Ô=Ð[_×[gÑ[gˆŒØ×%Ñ%¨Ñ*ˆŒ
Ü‰ÑÑ' Ó'r#   )"r$   r%   r&   r'   r(   Ú
model_typer   r)   r*   rB   r7   r9   rD   r   r+   r,   r   r   r-   r   r.   rE   rF   rG   ÚboolrH   rI   rJ   rL   rO   rQ   r5   r   r/   r0   s   @r"   r?   r?   M   s%  ø… ñðB &€OØ#€Jà€K�ÓØ€O�SÓØÐ�sÓØ!Ð˜Ó!Ø€L�#ÓØ48€J��d˜3‘i‘ %¨¨S¨¡/Ñ1Ó8Ø46€J��d˜3‘i‘ %¨¨S¨¡/Ñ1Ó6Ø€J�ÓØ!€N�EÓ!Ø%(Ð�u˜s‘{Ó(Ø$Ð�uÓ$Ø€HˆdÓØ€IˆuÓØ€K�ÓØ€K�ÓØ€K�ÓØ7DÐ˜˜c™ U¨3°¨8¡_Ñ4ÓDØ€M�3ÓØ€GˆS�4‰ZÓ÷(ð (r#   r?   c                   óž   ‡ — e Zd ZU dZdZ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d	<   d
Zeed<   ˆ fd„Zˆ xZS )Ú	SamConfiga;  
    prompt_encoder_config (Union[`dict`, `SamPromptEncoderConfig`], *optional*):
        Dictionary of configuration options used to initialize [`SamPromptEncoderConfig`].
    mask_decoder_config (Union[`dict`, `SamMaskDecoderConfig`], *optional*):
        Dictionary of configuration options used to initialize [`SamMaskDecoderConfig`].

    Example:

    ```python
    >>> from transformers import (
    ...     SamVisionConfig,
    ...     SamPromptEncoderConfig,
    ...     SamMaskDecoderConfig,
    ...     SamModel,
    ... )

    >>> # Initializing a SamConfig with `"facebook/sam-vit-huge"` style configuration
    >>> configuration = SamConfig()

    >>> # Initializing a SamModel (with random weights) from the `"facebook/sam-vit-huge"` style configuration
    >>> model = SamModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config

    >>> # We can also initialize a SamConfig from a SamVisionConfig, SamPromptEncoderConfig, and SamMaskDecoderConfig

    >>> # Initializing SAM vision, SAM Q-Former and language model configurations
    >>> vision_config = SamVisionConfig()
    >>> prompt_encoder_config = SamPromptEncoderConfig()
    >>> mask_decoder_config = SamMaskDecoderConfig()

    >>> config = SamConfig(vision_config, prompt_encoder_config, mask_decoder_config)
    ```Úsam)r
   r3   r@   Nr@   r
   r3   g{®Gáz”?rF   TÚtie_word_embeddingsc                 ó  •— t        | j                  t        «      rt        di | j                  ¤Ž| _        n| j                  €t        «       | _        t        | j                  t        «      rt        di | j                  ¤Ž| _        n| j                  €t        «       | _        t        | j                  t        «      rt        di | j                  ¤Ž| _        n| j                  €t        «       | _        t        ‰| �$  di |¤Ž y r   )
Ú
isinstancer@   Údictr?   r
   r	   r3   r2   r   r   r   s     €r"   r   zSamConfig.__post_init__Á   sÊ   ø€ Ü�d×(Ñ(¬$Ô/Ü!0Ñ!F°4×3EÑ3EÑ!FˆDÕØ×ÑÐ'Ü!0Ó!2ˆDÔä�d×0Ñ0´$Ô7Ü)?Ñ)]À$×B\ÑB\Ñ)]ˆDÕ&Ø×'Ñ'Ð/Ü)?Ó)AˆDÔ&ä�d×.Ñ.´Ô5Ü';Ñ'W¸d×>VÑ>VÑ'WˆDÕ$Ø×%Ñ%Ð-Ü';Ó'=ˆDÔ$ä‰ÑÑ' Ó'r#   )r$   r%   r&   r'   rT   r	   r2   r?   Úsub_configsr@   r\   r   r*   r
   r3   rF   r.   rY   rU   r   r/   r0   s   @r"   rW   rW   Ž   sƒ   ø… ñ!ðF €Jà!7Ø3Ø(ñ€Kð 59€M�4Ð*Ñ*¨TÑ1Ó8Ø<@Ð˜4Ð"2Ñ2°TÑ9Ó@Ø:>Ð˜Ð 0Ñ0°4Ñ7Ó>Ø#Ð�uÓ#Ø $Ð˜Ó$÷(ð (r#   rW   )rW   r2   r	   r?   N)r'   Úhuggingface_hub.dataclassesr   Úconfiguration_utilsr   Úutilsr   r	   r2   r?   rW   Ú__all__r   r#   r"   ú<module>rb      sÈ   ðñ å .å 3Ý #ñ Ð2Ô3Øô(Ð-ó (ó ó 4ð(ñ. Ð2Ô3Øô!Ð+ó !ó ó 4ð!ñ8 Ð2Ô3Øô<(Ð&ó <(ó ó 4ð<(ñ~ Ð2Ô3ØôA(Ð ó A(ó ó 4ðA(òH ]�r#   