Ë
    S^(h™K  ã                   óŽ   — d Z ddlmZ ddlmZ  ej
                  e«      Z G d„ de«      Z G d„ de«      Z	 G d„ d	e«      Z
g d
¢Zy)zCLIPSeg model configurationé   )ÚPretrainedConfig)Úloggingc                   óH   ‡ — e Zd ZdZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Zˆ xZS )ÚCLIPSegTextConfiga  
    This is the configuration class to store the configuration of a [`CLIPSegModel`]. It is used to instantiate an
    CLIPSeg model according to the specified arguments, defining the model architecture. Instantiating a configuration
    with the defaults will yield a similar configuration to that of the CLIPSeg
    [CIDAS/clipseg-rd64](https://huggingface.co/CIDAS/clipseg-rd64) architecture.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.

    Args:
        vocab_size (`int`, *optional*, defaults to 49408):
            Vocabulary size of the CLIPSeg text model. Defines the number of different tokens that can be represented
            by the `inputs_ids` passed when calling [`CLIPSegModel`].
        hidden_size (`int`, *optional*, defaults to 512):
            Dimensionality of the encoder layers and the pooler layer.
        intermediate_size (`int`, *optional*, defaults to 2048):
            Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
        num_hidden_layers (`int`, *optional*, defaults to 12):
            Number of hidden layers in the Transformer encoder.
        num_attention_heads (`int`, *optional*, defaults to 8):
            Number of attention heads for each attention layer in the Transformer encoder.
        max_position_embeddings (`int`, *optional*, defaults to 77):
            The maximum sequence length that this model might ever be used with. Typically set this to something large
            just in case (e.g., 512 or 1024 or 2048).
        hidden_act (`str` or `function`, *optional*, defaults to `"quick_gelu"`):
            The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
            `"relu"`, `"selu"` and `"gelu_new"` `"quick_gelu"` are supported.
        layer_norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the layer normalization layers.
        attention_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the attention probabilities.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        initializer_factor (`float`, *optional*, defaults to 1.0):
            A factor for initializing all weight matrices (should be kept to 1, used internally for initialization
            testing).
        pad_token_id (`int`, *optional*, defaults to 1):
            Padding token id.
        bos_token_id (`int`, *optional*, defaults to 49406):
            Beginning of stream token id.
        eos_token_id (`int`, *optional*, defaults to 49407):
            End of stream token id.

    Example:

    ```python
    >>> from transformers import CLIPSegTextConfig, CLIPSegTextModel

    >>> # Initializing a CLIPSegTextConfig with CIDAS/clipseg-rd64 style configuration
    >>> configuration = CLIPSegTextConfig()

    >>> # Initializing a CLIPSegTextModel (with random weights) from the CIDAS/clipseg-rd64 style configuration
    >>> model = CLIPSegTextModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úclipseg_text_modelÚtext_configc                 óÆ   •— t        ‰| �  d|||dœ|¤Ž || _        || _        || _        || _        || _        || _        || _        || _	        |
| _
        || _        |	| _        y )N)Úpad_token_idÚbos_token_idÚeos_token_id© )ÚsuperÚ__init__Ú
vocab_sizeÚhidden_sizeÚintermediate_sizeÚnum_hidden_layersÚnum_attention_headsÚmax_position_embeddingsÚlayer_norm_epsÚ
hidden_actÚinitializer_rangeÚinitializer_factorÚattention_dropout)Úselfr   r   r   r   r   r   r   r   r   r   r   r
   r   r   ÚkwargsÚ	__class__s                   €úo/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/clipseg/configuration_clipseg.pyr   zCLIPSegTextConfig.__init__V   sv   ø€ ô$ 	‰ÑÐs lÀÐ\hÑsÐlrÒsà$ˆŒØ&ˆÔØ!2ˆÔØ!2ˆÔØ#6ˆÔ Ø'>ˆÔ$Ø,ˆÔØ$ˆŒØ!2ˆÔØ"4ˆÔØ!2ˆÕó    )i Á  é   é   é   é   éM   Ú
quick_geluçñhãˆµøä>ç        ç{®Gáz”?ç      ð?é   iþÀ  iÿÀ  ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚbase_config_keyr   Ú__classcell__©r   s   @r   r   r      sK   ø„ ñ8ðt &€JØ#€Oð ØØØØØ "ØØØØØØØØ÷3ñ 3r   r   c                   óD   ‡ — e Zd ZdZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Zˆ xZS )ÚCLIPSegVisionConfigaG  
    This is the configuration class to store the configuration of a [`CLIPSegModel`]. It is used to instantiate an
    CLIPSeg model according to the specified arguments, defining the model architecture. Instantiating a configuration
    with the defaults will yield a similar configuration to that of the CLIPSeg
    [CIDAS/clipseg-rd64](https://huggingface.co/CIDAS/clipseg-rd64) architecture.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.

    Args:
        hidden_size (`int`, *optional*, defaults to 768):
            Dimensionality of the encoder layers and the pooler layer.
        intermediate_size (`int`, *optional*, defaults to 3072):
            Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
        num_hidden_layers (`int`, *optional*, defaults to 12):
            Number of hidden layers in the Transformer encoder.
        num_attention_heads (`int`, *optional*, defaults to 12):
            Number of attention heads for each attention layer in the Transformer encoder.
        num_channels (`int`, *optional*, defaults to 3):
            The number of input channels.
        image_size (`int`, *optional*, defaults to 224):
            The size (resolution) of each image.
        patch_size (`int`, *optional*, defaults to 32):
            The size (resolution) of each patch.
        hidden_act (`str` or `function`, *optional*, defaults to `"quick_gelu"`):
            The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
            `"relu"`, `"selu"` and `"gelu_new"` `"quick_gelu"` are supported.
        layer_norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the layer normalization layers.
        attention_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the attention probabilities.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        initializer_factor (`float`, *optional*, defaults to 1.0):
            A factor for initializing all weight matrices (should be kept to 1, used internally for initialization
            testing).

    Example:

    ```python
    >>> from transformers import CLIPSegVisionConfig, CLIPSegVisionModel

    >>> # Initializing a CLIPSegVisionConfig with CIDAS/clipseg-rd64 style configuration
    >>> configuration = CLIPSegVisionConfig()

    >>> # Initializing a CLIPSegVisionModel (with random weights) from the CIDAS/clipseg-rd64 style configuration
    >>> model = CLIPSegVisionModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úclipseg_vision_modelÚvision_configc                 óÌ   •— t        ‰| �  di |¤Ž || _        || _        || _        || _        || _        || _        || _        || _	        || _
        |
| _        |	| _        || _        y )Nr   )r   r   r   r   r   r   Únum_channelsÚ
patch_sizeÚ
image_sizer   r   r   r   r   )r   r   r   r   r   r9   r;   r:   r   r   r   r   r   r   r   s                 €r   r   zCLIPSegVisionConfig.__init__¯   sr   ø€ ô  	‰ÑÑ"˜6Ò"à&ˆÔØ!2ˆÔØ!2ˆÔØ#6ˆÔ Ø(ˆÔØ$ˆŒØ$ˆŒØ!2ˆÔØ"4ˆÔØ!2ˆÔØ,ˆÔØ$ˆ�r   )i   i   r"   r"   r   éà   é    r%   r&   r'   r(   r)   r+   r3   s   @r   r5   r5   w   sE   ø„ ñ2ðh (€JØ%€Oð ØØØØØØØØØØØ÷%ñ %r   r5   c                   óh   ‡ — e Zd ZdZdZeedœZddddg d¢dd	d
ddddfˆ fd„	Ze	dedefd„«       Z
ˆ xZS )ÚCLIPSegConfiga  
    [`CLIPSegConfig`] is the configuration class to store the configuration of a [`CLIPSegModel`]. It is used to
    instantiate a CLIPSeg model according to the specified arguments, defining the text model and vision model configs.
    Instantiating a configuration with the defaults will yield a similar configuration to that of the CLIPSeg
    [CIDAS/clipseg-rd64](https://huggingface.co/CIDAS/clipseg-rd64) architecture.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.

    Args:
        text_config (`dict`, *optional*):
            Dictionary of configuration options used to initialize [`CLIPSegTextConfig`].
        vision_config (`dict`, *optional*):
            Dictionary of configuration options used to initialize [`CLIPSegVisionConfig`].
        projection_dim (`int`, *optional*, defaults to 512):
            Dimensionality of text and vision projection layers.
        logit_scale_init_value (`float`, *optional*, defaults to 2.6592):
            The initial value of the *logit_scale* parameter. Default is used as per the original CLIPSeg implementation.
        extract_layers (`List[int]`, *optional*, defaults to `[3, 6, 9]`):
            Layers to extract when forwarding the query image through the frozen visual backbone of CLIP.
        reduce_dim (`int`, *optional*, defaults to 64):
            Dimensionality to reduce the CLIP vision embedding.
        decoder_num_attention_heads (`int`, *optional*, defaults to 4):
            Number of attention heads in the decoder of CLIPSeg.
        decoder_attention_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the attention probabilities.
        decoder_hidden_act (`str` or `function`, *optional*, defaults to `"quick_gelu"`):
            The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
            `"relu"`, `"selu"` and `"gelu_new"` `"quick_gelu"` are supported.
        decoder_intermediate_size (`int`, *optional*, defaults to 2048):
            Dimensionality of the "intermediate" (i.e., feed-forward) layers in the Transformer decoder.
        conditional_layer (`int`, *optional*, defaults to 0):
            The layer to use of the Transformer encoder whose activations will be combined with the condition
            embeddings using FiLM (Feature-wise Linear Modulation). If 0, the last layer is used.
        use_complex_transposed_convolution (`bool`, *optional*, defaults to `False`):
            Whether to use a more complex transposed convolution in the decoder, enabling more fine-grained
            segmentation.
        kwargs (*optional*):
            Dictionary of keyword arguments.

    Example:

    ```python
    >>> from transformers import CLIPSegConfig, CLIPSegModel

    >>> # Initializing a CLIPSegConfig with CIDAS/clipseg-rd64 style configuration
    >>> configuration = CLIPSegConfig()

    >>> # Initializing a CLIPSegModel (with random weights) from the CIDAS/clipseg-rd64 style configuration
    >>> model = CLIPSegModel(configuration)

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

    >>> # We can also initialize a CLIPSegConfig from a CLIPSegTextConfig and a CLIPSegVisionConfig

    >>> # Initializing a CLIPSegText and CLIPSegVision configuration
    >>> config_text = CLIPSegTextConfig()
    >>> config_vision = CLIPSegVisionConfig()

    >>> config = CLIPSegConfig.from_text_vision_configs(config_text, config_vision)
    ```Úclipseg©r   r7   Nr    gƒ/L¦
F@)r   é   é	   é@   é   r'   r%   r!   é    Fc                 ó4  •— |j                  dd «      }|j                  dd «      }t        ‰| �  di |¤Ž |�‚|€i }t        di |¤Žj	                  «       }|j                  «       D ]A  \  }}||v sŒ|||   k7  sŒ|dvsŒ||v r
d|› d|› d�}nd|› d�}t        j                  |«       ŒC |j                  |«       |�¹|€i }t        di |¤Žj	                  «       }d	|v r3|d	   j                  «       D ��ci c]  \  }}t        |«      |“Œ c}}|d	<   |j                  «       D ]A  \  }}||v sŒ|||   k7  sŒ|dvsŒ||v r
d|› d
|› d�}nd|› d�}t        j                  |«       ŒC |j                  |«       |€i }t        j                  d«       |€i }t        j                  d«       t        di |¤Ž| _        t        di |¤Ž| _        || _        || _        || _        || _        || _        || _        |	| _        |
| _        || _        d| _        || _        y c c}}w )NÚtext_config_dictÚvision_config_dict)Útransformers_versionú`zp` is found in both `text_config_dict` and `text_config` but with different values. The value `text_config_dict["z"]` will be used instead.zm`text_config_dict` is provided which will be used to initialize `CLIPSegTextConfig`. The value `text_config["z"]` will be overridden.Úid2labelzv` is found in both `vision_config_dict` and `vision_config` but with different values. The value `vision_config_dict["zs`vision_config_dict` is provided which will be used to initialize `CLIPSegVisionConfig`. The value `vision_config["zR`text_config` is `None`. Initializing the `CLIPSegTextConfig` with default values.zV`vision_config` is `None`. initializing the `CLIPSegVisionConfig` with default values.r)   r   )Úpopr   r   r   Úto_dictÚitemsÚloggerÚinfoÚupdater5   Ústrr   r7   Úprojection_dimÚlogit_scale_init_valueÚextract_layersÚ
reduce_dimÚdecoder_num_attention_headsÚdecoder_attention_dropoutÚdecoder_hidden_actÚdecoder_intermediate_sizeÚconditional_layerr   Ú"use_complex_transposed_convolution)r   r   r7   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r   rH   rI   Ú_text_config_dictÚkeyÚvalueÚmessageÚ_vision_config_dictr   s                        €r   r   zCLIPSegConfig.__init__  s¯  ø€ ð& "Ÿ:™:Ð&8¸$Ó?ÐØ#ŸZ™ZÐ(<¸dÓCÐä‰ÑÑ"˜6Ò"ð
 Ð'ØÐ"Ø �ô !2Ñ EÐ4DÑ E× MÑ MÓ OÐð 0×5Ñ5Ó7ò )‘
��UØ˜+Ò%¨%°;¸sÑ3CÓ*CÈÐSkÒHkàÐ.Ñ.à ˜uð %<Ø<?¸5Ð@Yð[ñ  ð3Ø36°%Ð7NðPð  ô —K‘K Õ(ð)ð" ×ÑÐ0Ô1àÐ)ØÐ$Ø "�ô #6Ñ"KÐ8JÑ"K×"SÑ"SÓ"UÐàÐ0Ñ0à6IÈ*Ñ6U×6[Ñ6[Ó6]÷3Ù(2¨¨U”C˜“H˜e‘Oó3Ð# JÑ/ð
 2×7Ñ7Ó9ò )‘
��UØ˜-Ò'¨E°]À3Ñ5GÓ,GÈCÐWoÒLoàÐ0Ñ0à ˜uð %FØFIÀUÐJcðeñ  ð9Ø9<¸Ð=TðVð  ô —K‘K Õ(ð)ð" × Ñ Ð!4Ô5àÐØˆKÜ�K‰KÐlÔmàÐ ØˆMÜ�K‰KÐpÔqä,Ñ;¨{Ñ;ˆÔÜ0ÑA°=ÑAˆÔà,ˆÔØ&<ˆÔ#Ø,ˆÔØ$ˆŒØ+FˆÔ(Ø)BˆÔ&Ø"4ˆÔØ)BˆÔ&Ø!2ˆÔØ"%ˆÔØ2TˆÕ/ùó[3s   Ã2Hr   r7   c                 óP   —  | d|j                  «       |j                  «       dœ|¤ŽS )zó
        Instantiate a [`CLIPSegConfig`] (or a derived class) from clipseg text model configuration and clipseg vision
        model configuration.

        Returns:
            [`CLIPSegConfig`]: An instance of a configuration object
        rA   r   )rN   )Úclsr   r7   r   s       r   Úfrom_text_vision_configsz&CLIPSegConfig.from_text_vision_configs  s,   € ñ Ðf˜{×2Ñ2Ó4ÀM×DYÑDYÓD[ÑfÐ_eÑfÐfr   )r,   r-   r.   r/   r0   r   r5   Úsub_configsr   Úclassmethodre   r2   r3   s   @r   r?   r?   Ï   sq   ø„ ñ=ð~ €JØ"3ÐFYÑZ€Kð ØØØ%Ú ØØ$%Ø"%Ø'Ø"&ØØ+0õkUðZ ð	gÐ3Dð 	gÐUhò 	gó ô	gr   r?   )r?   r   r5   N)r/   Úconfiguration_utilsr   Úutilsr   Ú
get_loggerr,   rP   r   r5   r?   Ú__all__r   r   r   ú<module>rl      s^   ðñ "å 3Ý ð 
ˆ×	Ñ	˜HÓ	%€ô\3Ð(ô \3ô~U%Ð*ô U%ôpzgÐ$ô zgòz H�r   