o
    ¾e¦i^0  ã                   @   sb   d Z ddlmZ ddlmZ e e¡ZG dd„ deƒZG dd„ deƒZ	G dd	„ d	eƒZ
g d
¢ZdS )zOWL-ViT model configurationé   )ÚPreTrainedConfig)Úloggingc                       sF   e Zd ZdZdZdZ								
							d‡ fdd„	Z‡  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_configé Á  é   é   é   é   é   Ú
quick_geluçñhãˆµøä>ç        ç{®Gáz”?ç      ð?é    éþÀ  éÿÀ  c                    sj   t ƒ jdi |¤Ž || _|| _|| _|| _|| _|| _|| _|| _	|| _
|| _|| _|	| _|
| _|| _d S ©N© )ÚsuperÚ__init__Úpad_token_idÚbos_token_idÚeos_token_idÚ
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__r   úm/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/transformers/models/owlvit/configuration_owlvit.pyr   V   s   
zOwlViTTextConfig.__init__)r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚbase_config_keyr   Ú__classcell__r   r   r)   r+   r      s&    ;ñr   c                       sB   e Zd ZdZdZdZ										
			d‡ fdd„	Z‡  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_configé   é   r
   r   é    r   r   r   r   r   c                    s^   t ƒ jdi |¤Ž || _|| _|| _|| _|| _|| _|| _|| _	|	| _
|
| _|| _|| _d S r   )r   r   r   r   r   r    Únum_channelsÚ
image_sizeÚ
patch_sizer"   r#   r$   r%   r&   )r'   r   r   r   r    r:   r;   r<   r"   r#   r$   r%   r&   r(   r)   r   r+   r   ²   s   
zOwlViTVisionConfig.__init__)r7   r8   r
   r
   r   r7   r9   r   r   r   r   r   r,   r   r   r)   r+   r4   z   s"    4ór4   c                       s:   e Zd ZdZdZeedœZ					d
‡ fdd	„	Z‡  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   r6   Nr   çƒ/L¦
F@Tc                    sž   |d u rt ƒ }t d¡ nt|tƒrt di |¤Ž}|d u r&tƒ }t d¡ nt|tƒr2tdi |¤Ž}|| _|| _|| _|| _	|| _
d| _tƒ jdi |¤Ž d S )NzQ`text_config` is `None`. initializing the `OwlViTTextConfig` with default values.zU`vision_config` is `None`. initializing the `OwlViTVisionConfig` with default values.r   r   )r   ÚloggerÚinfoÚ
isinstanceÚdictr4   r   r6   Úprojection_dimÚlogit_scale_init_valueÚreturn_dictr&   r   r   )r'   r   r6   rD   rE   rF   r(   r)   r   r+   r   ï   s"   	

zOwlViTConfig.__init__)NNr   r?   T)
r-   r.   r/   r0   r1   r   r4   Úsub_configsr   r3   r   r   r)   r+   r=   Ò   s    
úr=   )r=   r   r4   N)r0   Úconfiguration_utilsr   Úutilsr   Ú
get_loggerr-   r@   r   r4   r=   Ú__all__r   r   r   r+   Ú<module>   s   
cX<