
    <h	                     |    S r SSKJrJr  SSKJr  SSKJrJrJ	r	  SSK
JrJrJr   " S S\S	S
9r " S S\5      rS/rg)z
Processor class for Blip.
    )OptionalUnion   )
ImageInput)ProcessingKwargsProcessorMixinUnpack)BatchEncodingPreTokenizedInput	TextInputc            
       2    \ rS rSrSSSSSSSSSS.	0 S.rSrg)	BlipProcessorKwargs   TFr   )	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_kwargs N)__name__
__module____qualname____firstlineno__	_defaults__static_attributes__r       `/var/www/html/shao/venv/lib/python3.13/site-packages/transformers/models/blip/processing_blip.pyr   r      s0     #').*/&+%*"

 Ir"   r   F)totalc            
          ^  \ rS rSrSrSS/rSrSrU 4S jr    SS\	S	\
\\\\   \\4      S
\\   S\4S jjrS rS r\S 5       rSrU =r$ )BlipProcessor+   a9  
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                 T   > SUl         [        TU ]	  X5        U R                  U l        g )NF)r   super__init__r(   current_processor)selfr(   r)   kwargs	__class__s       r#   r0   BlipProcessor.__init__=   s&    */	'4!%!5!5r"   imagestextr3   returnc                    Uc  Uc  [        S5      eSnU R                  " [        4SU R                  R                  0UD6nUb  U R                  " U40 US   D6nUb,  U R
                  " U40 US   D6nUb  UR                  U5        U$ U$ )a  
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)	r2   r6   r7   audiovideosr3   text_encodingoutput_kwargsencoding_image_processors	            r#   __call__BlipProcessor.__call__B   s    8 >dlIJJ **
"&.."<"<
 

  NN4P=3OPM'+';';F'emTcFd'e$((//>++r"   c                 :    U R                   R                  " U0 UD6$ )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r2   argsr3   s      r#   rG   BlipProcessor.batch_decodeu   s    
 ~~**D;F;;r"   c                 :    U R                   R                  " U0 UD6$ )z
This method forwards all its arguments to BertTokenizerFast's [`~PreTrainedTokenizer.decode`]. Please refer to
the docstring of this method for more information.
)r)   decoderH   s      r#   rL   BlipProcessor.decode|   s    
 ~~$$d5f55r"   c                     U R                   R                  nU R                  R                  n[        [        R                  X-   5      5      $ )N)r)   model_input_namesr(   listdictfromkeys)r2   tokenizer_input_namesimage_processor_input_namess      r#   rO   BlipProcessor.model_input_names   s<     $ @ @&*&:&:&L&L#DMM"7"UVWWr"   )r1   )NNNN)r   r   r   r   __doc__
attributesimage_processor_classtokenizer_classr0   r   r   r   strrP   r   r   r	   r   r
   rD   rG   rL   propertyrO   r!   __classcell__)r4   s   @r#   r&   r&   +   s     $[1JL<O6 "NR11 uS$s)Y8IIJK1 ,-1 
1f<6 X Xr"   r&   N)rV   typingr   r   image_utilsr   processing_utilsr   r   r	   tokenization_utils_baser
   r   r   r   r&   __all__r   r"   r#   <module>rb      sH    # % H H R R*% "\XN \X~ 
r"   