Ë
    S^(hK  ã                   óÂ   — d Z ddlmZmZmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZ ddlmZmZ ddlmZ  G d	„ d
e
d¬«      Z ej(                  e«      Z G d„ de«      ZdgZy)z$
Image/Text processor class for GIT
é    )ÚListÚOptionalÚUnioné   )ÚBatchFeature)Ú
ImageInput)ÚProcessingKwargsÚProcessorMixinÚUnpackÚ!_validate_images_text_input_order)ÚPreTokenizedInputÚ	TextInput)Úloggingc                   ó   — e Zd Zi Zy)ÚGitProcessorKwargsN)Ú__name__Ú
__module__Ú__qualname__Ú	_defaults© ó    úd/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/git/processing_git.pyr   r      s   „ Ø�Ir   r   F)Útotalc                   óœ   ‡ — e Zd ZdZddgZdZdZˆ fd„Z	 	 	 	 ddee	   dee
eeee   ee   f      d	ee   d
efd„Zd„ Zd„ Zed„ «       Zˆ xZS )ÚGitProcessora  
    Constructs a GIT processor which wraps a CLIP image processor and a BERT tokenizer into a single processor.

    [`GitProcessor`] offers all the functionalities of [`CLIPImageProcessor`] and [`BertTokenizerFast`]. See the
    [`~GitProcessor.__call__`] and [`~GitProcessor.decode`] for more information.

    Args:
        image_processor ([`AutoImageProcessor`]):
            The image processor is a required input.
        tokenizer ([`AutoTokenizer`]):
            The tokenizer is a required input.
    Úimage_processorÚ	tokenizerÚAutoImageProcessorÚAutoTokenizerc                 óH   •— t         ‰| �  ||«       | j                  | _        y )N)ÚsuperÚ__init__r   Úcurrent_processor)Úselfr   r   Ú	__class__s      €r   r"   zGitProcessor.__init__5   s    ø€ Ü‰Ñ˜¨)Ô4Ø!%×!5Ñ!5ˆÕr   ÚimagesÚtextÚkwargsÚreturnc                 ó~  — |€|€t        d«      ‚t        ||«      \  }} | j                  t        fd| j                  j
                  i|¤Ž}i }|�' | j                  |fi |d   ¤Ž}|j                  |«       |�' | j                  |fi |d   ¤Ž}	|j                  |	«       t        ||d   j                  d«      ¬«      S )a	  
        Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
        and `kwargs` arguments to BertTokenizerFast's [`~BertTokenizerFast.__call__`] if `text` is not `None` to encode
        the text. To prepare the image(s), this method forwards the `images` and `kwrags` arguments to
        CLIPImageProcessor's [`~CLIPImageProcessor.__call__`] if `images` is not `None`. Please refer to the docstring
        of the above two methods for more information.

        Args:
            images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`):
                The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
                tensor. Both channels-first and channels-last formats are supported.
            text (`TextInput`, `PreTokenizedInput`, `List[TextInput]`, `List[PreTokenizedInput]`, *optional*):
                The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
                (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
                `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).

            return_tensors (`str` or [`~utils.TensorType`], *optional*):
                If set, will return tensors of a particular framework. Acceptable values are:

                - `'tf'`: Return TensorFlow `tf.constant` objects.
                - `'pt'`: Return PyTorch `torch.Tensor` objects.
                - `'np'`: Return NumPy `np.ndarray` objects.
                - `'jax'`: Return JAX `jnp.ndarray` objects.

        Returns:
            [`BatchFeature`]: A [`BatchFeature`] with the following fields:

            - **input_ids** -- List of token ids to be fed to a model. Returned when `text` is not `None`.
            - **attention_mask** -- List of indices specifying which tokens should be attended to by the model (when
              `return_attention_mask=True` or if *"attention_mask"* is in `self.model_input_names` and if `text` is not
              `None`).
            - **pixel_values** -- Pixel values to be fed to a model. Returned when `images` is not `None`.
        z?You have to specify either text or images. Both cannot be none.Útokenizer_init_kwargsÚtext_kwargsÚimages_kwargsÚcommon_kwargsÚreturn_tensors)ÚdataÚtensor_type)
Ú
ValueErrorr   Ú_merge_kwargsr   r   Úinit_kwargsÚupdater   r   Úget)
r$   r&   r'   ÚaudioÚvideosr(   Úoutput_kwargsr0   Útext_featuresÚimage_featuress
             r   Ú__call__zGitProcessor.__call__9   sÜ   € ðR ˆ<˜F˜NÜÐ^Ó_Ð_ô 9¸ÀÓF‰ˆ�à*˜×*Ñ*Üñ
à"&§.¡.×"<Ñ"<ð
ð ñ
ˆð ˆØÐØ*˜DŸN™N¨4ÑP°=ÀÑ3OÑPˆMØ�K‰K˜Ô&ØÐØ1˜T×1Ñ1°&Ñ[¸MÈ/Ñ<ZÑ[ˆNØ�K‰K˜Ô'ä °=ÀÑ3Q×3UÑ3UÐVfÓ3gÔhÐhr   c                 ó:   —  | j                   j                  |i |¤ŽS )zÁ
        This method forwards all its arguments to BertTokenizerFast's [`~PreTrainedTokenizer.batch_decode`]. Please
        refer to the docstring of this method for more information.
        )r   Úbatch_decode©r$   Úargsr(   s      r   r>   zGitProcessor.batch_decodex   s    € ð
 +ˆt�~‰~×*Ñ*¨DÐ;°FÑ;Ð;r   c                 ó:   —  | j                   j                  |i |¤ŽS )z»
        This method forwards all its arguments to BertTokenizerFast's [`~PreTrainedTokenizer.decode`]. Please refer to
        the docstring of this method for more information.
        )r   Údecoder?   s      r   rB   zGitProcessor.decode   s    € ð
 %ˆt�~‰~×$Ñ$ dÐ5¨fÑ5Ð5r   c                 ó
   — g d¢S )N)Ú	input_idsÚattention_maskÚpixel_valuesr   )r$   s    r   Úmodel_input_nameszGitProcessor.model_input_names†   s   € â>Ð>r   )NNNN)r   r   r   Ú__doc__Ú
attributesÚimage_processor_classÚtokenizer_classr"   r   r   r   r   r   r   r   r   r   r<   r>   rB   ÚpropertyrG   Ú__classcell__)r%   s   @r   r   r   #   sª   ø„ ñð $ [Ð1€JØ0ÐØ%€Oô6ð (,ØhlØØñ=ià˜Ñ$ð=ið �u˜YÐ(9¸4À	¹?ÈDÐQbÑLcÐcÑdÑeð=ið Ð+Ñ,ð=ið 
ó=iò~<ò6ð ñ?ó ô?r   r   N)rH   Útypingr   r   r   Úfeature_extraction_utilsr   Úimage_utilsr   Úprocessing_utilsr	   r
   r   r   Útokenization_utils_baser   r   Úutilsr   r   Ú
get_loggerr   Úloggerr   Ú__all__r   r   r   ú<module>rW      s`   ðñ÷ )Ñ (å 4Ý %ß kÓ kß CÝ ôÐ)°õ ð 
ˆ×	Ñ	˜HÓ	%€ôe?�>ô e?ðP Ð
�r   