Ë
    T^(hN8  ã                   óô   — d Z ddlmZ ddlmZmZmZmZmZ er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  ej$                  e«      Z G d
„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zg d¢Zy)zOWL-ViT model configurationé    ©ÚOrderedDict)ÚTYPE_CHECKINGÚAnyÚDictÚMappingÚOptionalé   )ÚProcessorMixin)Ú
TensorType)ÚPretrainedConfig)Ú
OnnxConfig)Úloggingc                   óH   ‡ — e Zd ZdZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Zˆ xZS )ÚOwlViTTextConfiga‡  
    This is the configuration class to store the configuration of an [`OwlViTTextModel`]. It is used to instantiate an
    OwlViT text encoder according to the specified arguments, defining the model architecture. Instantiating a
    configuration with the defaults will yield a similar configuration to that of the OwlViT
    [google/owlvit-base-patch32](https://huggingface.co/google/owlvit-base-patch32) 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 OWL-ViT text model. Defines the number of different tokens that can be represented
            by the `inputs_ids` passed when calling [`OwlViTTextModel`].
        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 16):
            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 0):
            The id of the padding token in the input sequences.
        bos_token_id (`int`, *optional*, defaults to 49406):
            The id of the beginning-of-sequence token in the input sequences.
        eos_token_id (`int`, *optional*, defaults to 49407):
            The id of the end-of-sequence token in the input sequences.

    Example:

    ```python
    >>> from transformers import OwlViTTextConfig, OwlViTTextModel

    >>> # Initializing a OwlViTTextModel with google/owlvit-base-patch32 style configuration
    >>> configuration = OwlViTTextConfig()

    >>> # Initializing a OwlViTTextConfig from the google/owlvit-base-patch32 style configuration
    >>> model = OwlViTTextModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úowlvit_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Ú
hidden_actÚlayer_norm_epsÚattention_dropoutÚinitializer_rangeÚinitializer_factor)Úselfr   r   r   r   r   r    r!   r"   r#   r$   r%   r   r   r   ÚkwargsÚ	__class__s                   €úm/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/owlvit/configuration_owlvit.pyr   zOwlViTTextConfig.__init__`   sv   ø€ ô$ 	‰ÑÐs lÀÐ\hÑsÐlrÒsà$ˆŒØ&ˆÔØ!2ˆÔØ!2ˆÔØ#6ˆÔ Ø'>ˆÔ$Ø$ˆŒØ,ˆÔØ!2ˆÔØ!2ˆÔØ"4ˆÕó    )i Á  é   i   é   é   é   Ú
quick_geluçñhãˆµøä>ç        ç{®Gáz”?ç      ð?r   iþÀ  iÿÀ  ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚbase_config_keyr   Ú__classcell__©r(   s   @r)   r   r   !   sK   ø„ ñ9ðv %€JØ#€Oð ØØØØØ "ØØØØØØØØ÷5ñ 5r*   r   c                   óD   ‡ — e Zd ZdZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Zˆ xZS )ÚOwlViTVisionConfigah  
    This is the configuration class to store the configuration of an [`OwlViTVisionModel`]. It is used to instantiate
    an OWL-ViT image encoder according to the specified arguments, defining the model architecture. Instantiating a
    configuration with the defaults will yield a similar configuration to that of the OWL-ViT
    [google/owlvit-base-patch32](https://huggingface.co/google/owlvit-base-patch32) 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):
            Number of channels in the input images.
        image_size (`int`, *optional*, defaults to 768):
            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 OwlViTVisionConfig, OwlViTVisionModel

    >>> # Initializing a OwlViTVisionModel with google/owlvit-base-patch32 style configuration
    >>> configuration = OwlViTVisionConfig()

    >>> # Initializing a OwlViTVisionModel model from the google/owlvit-base-patch32 style configuration
    >>> model = OwlViTVisionModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úowlvit_vision_modelÚvision_configc                 óÌ   •— t        ‰| �  di |¤Ž || _        || _        || _        || _        || _        || _        || _        || _	        |	| _
        |
| _        || _        || _        y )Nr   )r   r   r   r   r   r   Únum_channelsÚ
image_sizeÚ
patch_sizer!   r"   r#   r$   r%   )r&   r   r   r   r   rB   rC   rD   r!   r"   r#   r$   r%   r'   r(   s                 €r)   r   zOwlViTVisionConfig.__init__¹   sr   ø€ ô  	‰ÑÑ"˜6Ò"à&ˆÔØ!2ˆÔØ!2ˆÔØ#6ˆÔ Ø(ˆÔØ$ˆŒØ$ˆŒØ$ˆŒØ,ˆÔØ!2ˆÔØ!2ˆÔØ"4ˆÕr*   )é   i   r,   r,   r
   rE   é    r/   r0   r1   r2   r3   r4   r<   s   @r)   r>   r>   �   sE   ø„ ñ2ðh '€JØ%€Oð ØØØØØØØØØØØ÷5ñ 5r*   r>   c                   óV   ‡ — e Zd ZdZdZeedœZ	 	 	 	 	 dˆ fd„	Ze	de
de
fd„«       Zˆ xZS )	ÚOwlViTConfiga½  
    [`OwlViTConfig`] is the configuration class to store the configuration of an [`OwlViTModel`]. It is used to
    instantiate an OWL-ViT 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 OWL-ViT
    [google/owlvit-base-patch32](https://huggingface.co/google/owlvit-base-patch32) 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 [`OwlViTTextConfig`].
        vision_config (`dict`, *optional*):
            Dictionary of configuration options used to initialize [`OwlViTVisionConfig`].
        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 OWL-ViT
            implementation.
        return_dict (`bool`, *optional*, defaults to `True`):
            Whether or not the model should return a dictionary. If `False`, returns a tuple.
        kwargs (*optional*):
            Dictionary of keyword arguments.
    Úowlvit)r   r@   c                 ó   •— t        ‰| �  di |¤Ž |€i }t        j                  d«       |€i }t        j                  d«       t	        di |¤Ž| _        t        di |¤Ž| _        || _        || _	        || _
        d| _        y )NzKtext_config is None. Initializing the OwlViTTextConfig with default values.zOvision_config is None. initializing the OwlViTVisionConfig with default values.r3   r   )r   r   ÚloggerÚinfor   r   r>   r@   Úprojection_dimÚlogit_scale_init_valueÚreturn_dictr%   )r&   r   r@   rM   rN   rO   r'   r(   s          €r)   r   zOwlViTConfig.__init__ö   s…   ø€ ô 	‰ÑÑ"˜6Ò"àÐØˆKÜ�K‰KÐeÔfàÐ ØˆMÜ�K‰KÐiÔjä+Ñ:¨kÑ:ˆÔÜ/Ñ@°-Ñ@ˆÔà,ˆÔØ&<ˆÔ#Ø&ˆÔØ"%ˆÕr*   r   r@   c                 ó@   — i }||d<   ||d<    | j                   |fi |¤ŽS )zï
        Instantiate a [`OwlViTConfig`] (or a derived class) from owlvit text model configuration and owlvit vision
        model configuration.

        Returns:
            [`OwlViTConfig`]: An instance of a configuration object
        r   r@   )Ú	from_dict)Úclsr   r@   r'   Úconfig_dicts        r)   Úfrom_text_vision_configsz%OwlViTConfig.from_text_vision_configs  s3   € ð ˆØ%0ˆ�MÑ"Ø'4ˆ�OÑ$àˆs�}‰}˜[Ñ3¨FÑ3Ð3r*   )NNr+   gƒ/L¦
F@T)r5   r6   r7   r8   r9   r   r>   Úsub_configsr   Úclassmethodr   rT   r;   r<   s   @r)   rH   rH   Ù   sR   ø„ ñð2 €JØ"2ÐEWÑX€Kð ØØØ%Øõ&ð6 ð4°4ð 4Èò 4ó ô4r*   rH   c                   óÌ   ‡ — e Zd Zedeeeeef   f   fd„«       Zedeeeeef   f   fd„«       Zede	fd„«       Z
	 	 	 ddddeded	ed
   deeef   f
ˆ fd„Zedefd„«       Zˆ xZS )ÚOwlViTOnnxConfigÚreturnc           	      ó@   — t        ddddœfdddddd	œfd
dddœfg«      S )NÚ	input_idsÚbatchÚsequence)r   é   Úpixel_valuesrB   ÚheightÚwidth)r   r^   é   r
   Úattention_maskr   ©r&   s    r)   ÚinputszOwlViTOnnxConfig.inputs"  s@   € äà '¨jÑ9Ð:Ø W°ÀHÐQXÑ!YÐZØ! w°:Ñ#>Ð?ðó
ð 	
r*   c                 ó@   — t        dddifdddifdddifdddifg«      S )NÚlogits_per_imager   r\   Úlogits_per_textÚtext_embedsÚimage_embedsr   rd   s    r)   ÚoutputszOwlViTOnnxConfig.outputs,  sD   € äà# a¨ \Ð2Ø" Q¨ LÐ1Ø  G Ð-Ø ! W Ð.ð	ó
ð 	
r*   c                  ó   — y)Ng-Cëâ6?r   rd   s    r)   Úatol_for_validationz$OwlViTOnnxConfig.atol_for_validation7  s   € àr*   Ú	processorr   Ú
batch_sizeÚ
seq_lengthÚ	frameworkr   c                 ó‚   •— t         ‰| �  |j                  |||¬«      }t         ‰| �  |j                  ||¬«      }i |¥|¥S )N)ro   rp   rq   )ro   rq   )r   Úgenerate_dummy_inputsÚ	tokenizerÚimage_processor)r&   rn   ro   rp   rq   Útext_input_dictÚimage_input_dictr(   s          €r)   rs   z&OwlViTOnnxConfig.generate_dummy_inputs;  s`   ø€ ô  ™'Ñ7Ø×Ñ¨JÀ:ÐYbð 8ó 
ˆô !™7Ñ8Ø×%Ñ%°*È	ð 9ó 
Ðð 7�/Ð6Ð%5Ð6Ð6r*   c                  ó   — y)Né   r   rd   s    r)   Údefault_onnx_opsetz#OwlViTOnnxConfig.default_onnx_opsetJ  s   € àr*   )éÿÿÿÿr{   N)r5   r6   r7   Úpropertyr   ÚstrÚintre   rk   Úfloatrm   r	   r   rs   rz   r;   r<   s   @r)   rX   rX   !  sá   ø„ Øð
˜  W¨S°#¨XÑ%6Ð 6Ñ7ò 
ó ð
ð ð
˜  g¨c°3¨hÑ&7Ð!7Ñ8ò 
ó ð
ð ð Uò ó ðð ØØ,0ñ7à#ð7ð ð7ð ð	7ð
 ˜LÑ)ð7ð 
��c�Ñ	õ7ð ð Cò ó ôr*   rX   )rH   rX   r   r>   N)r8   Úcollectionsr   Útypingr   r   r   r   r	   Úprocessing_utilsr   Úutilsr   Úconfiguration_utilsr   Úonnxr   r   Ú
get_loggerr5   rK   r   r>   rH   rX   Ú__all__r   r*   r)   ú<module>rˆ      s€   ðñ "å #ß >Õ >ñ Ý2Ý#å 3Ý Ý ð 
ˆ×	Ñ	˜HÓ	%€ô]5Ð'ô ]5ô@U5Ð)ô U5ôpE4Ð#ô E4ôP+�zô +ò\ Y�r*   