Ë
    S^(h%  ã                   ó†   — d Z ddlmZmZmZ ddlmZ ddlmZm	Z	m
Z
 ddlmZmZmZ  G d„ ded	¬
«      Z G d„ de	«      ZdgZy)z
Processor class for Blip.
é    )ÚListÚOptionalÚUnioné   )Ú
ImageInput)ÚProcessingKwargsÚProcessorMixinÚUnpack)ÚBatchEncodingÚPreTokenizedInputÚ	TextInputc            
       ó*   — e Zd Zddddddddddœ	i dœZy)ÚBlipProcessorKwargsTFr   )	Úadd_special_tokensÚpaddingÚstrideÚreturn_overflowing_tokensÚreturn_special_tokens_maskÚreturn_offsets_mappingÚreturn_token_type_idsÚreturn_lengthÚverbose)Útext_kwargsÚimages_kwargsN)Ú__name__Ú
__module__Ú__qualname__Ú	_defaults© ó    úf/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/blip/processing_blip.pyr   r      s0   „ ð #'ØØØ).Ø*/Ø&+Ø%*Ø"Øñ

ð ñ�Ir    r   F)Útotalc            
       ó”   ‡ — e Zd ZdZddgZg ZdZdZˆ fd„Z	 	 	 	 dde	d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 )ÚBlipProcessora]  
    Constructs a BLIP processor which wraps a BERT tokenizer and BLIP image processor into a single processor.

    [`BlipProcessor`] offers all the functionalities of [`BlipImageProcessor`] and [`BertTokenizerFast`]. See the
    docstring of [`~BlipProcessor.__call__`] and [`~BlipProcessor.decode`] for more information.

    Args:
        image_processor (`BlipImageProcessor`):
            An instance of [`BlipImageProcessor`]. The image processor is a required input.
        tokenizer (`BertTokenizerFast`):
            An instance of ['BertTokenizerFast`]. The tokenizer is a required input.
    Úimage_processorÚ	tokenizer)ÚBlipImageProcessorÚBlipImageProcessorFast)ÚBertTokenizerÚBertTokenizerFastc                 óV   •— d|_         t        ‰| �	  ||«       | j                  | _        y )NF)r   ÚsuperÚ__init__r%   Úcurrent_processor)Úselfr%   r&   ÚkwargsÚ	__class__s       €r!   r-   zBlipProcessor.__init__>   s(   ø€ Ø*/ˆ	Ô'Ü‰Ñ˜¨)Ô4Ø!%×!5Ñ!5ˆÕr    ÚimagesÚtextr0   Úreturnc                 ó  — |€|€t        d«      ‚d} | j                  t        fd| j                  j                  i|¤Ž}|� | j                  |fi |d   ¤Ž}|�+ | j
                  |fi |d   ¤Ž}|�|j                  |«       |S |S )ae  
        This method uses [`BlipImageProcessor.__call__`] method to prepare image(s) for the model, and
        [`BertTokenizerFast.__call__`] to prepare text for the model.

        Please refer to the docstring of the above two methods for more information.
        Args:
            images (`ImageInput`):
                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]`):
                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.
        Nz*You have to specify either images or text.Útokenizer_init_kwargsr   r   )Ú
ValueErrorÚ_merge_kwargsr   r&   Úinit_kwargsr%   Úupdate)	r/   r2   r3   ÚaudioÚvideosr0   Útext_encodingÚoutput_kwargsÚencoding_image_processors	            r!   Ú__call__zBlipProcessor.__call__C   s·   € ð8 ˆ>˜d˜lÜÐIÓJÐJàˆð +˜×*Ñ*Üñ
à"&§.¡.×"<Ñ"<ð
ð ñ
ˆð
 ÐØ*˜DŸN™N¨4ÑP°=ÀÑ3OÑPˆMØÐØ'; t×';Ñ';¸FÑ'eÀmÐTcÑFdÑ'eÐ$àÐ(Ø(×/Ñ/°Ô>Ø+Ð+àÐr    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/   Úargsr0   s      r!   rB   zBlipProcessor.batch_decodev   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&   ÚdecoderC   s      r!   rF   zBlipProcessor.decode}   s    € ð
 %ˆt�~‰~×$Ñ$ dÐ5¨fÑ5Ð5r    c                 óœ   — | j                   j                  }| j                  j                  }t        t        j                  ||z   «      «      S )N)r&   Úmodel_input_namesr%   ÚlistÚdictÚfromkeys)r/   Útokenizer_input_namesÚimage_processor_input_namess      r!   rH   zBlipProcessor.model_input_names„   s?   € à $§¡× @Ñ @ÐØ&*×&:Ñ&:×&LÑ&LÐ#Ü”D—M‘MÐ"7Ð:UÑ"UÓVÓWÐWr    )NNNN)r   r   r   Ú__doc__Ú
attributesÚvalid_kwargsÚimage_processor_classÚtokenizer_classr-   r   r   r   Ústrr   r   r   r
   r   r   r@   rB   rF   ÚpropertyrH   Ú__classcell__)r1   s   @r!   r$   r$   +   s¡   ø„ ñð $ [Ð1€JØ€LØLÐØ<€Oô6ð "ØNRØØñ1àð1ð �u˜S $ s¡)¨YÐ8IÐIÑJÑKð1ð Ð,Ñ-ð1ð 
ó1òf<ò6ð ñXó ôXr    r$   N)rN   Útypingr   r   r   Úimage_utilsr   Úprocessing_utilsr   r	   r
   Útokenization_utils_baser   r   r   r   r$   Ú__all__r   r    r!   ú<module>r[      sK   ðñ÷ )Ñ (å %ß HÑ Hß RÑ RôÐ*°%õ ô"]X�Nô ]Xð@ Ð
�r    