
     `i                         d Z ddl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dS )z
Processor class for Blip.
    )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dS )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     |/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/transformers/models/blip/processing_blip.pyr   r      sF         #').*/&+%*"

 

  IIIr   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f                  d
ee         def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                 r    d|_         t                                          ||           | j        | _        d S )NF)r   super__init__r$   current_processor)selfr$   r%   kwargs	__class__s       r    r,   zBlipProcessor.__init__=   s6    */	')444!%!5r   Nimagestextr/   returnc                     ||t          d          d} | j        t          fd| j        j        i|}| | j        |fi |d         }|- | j        |fi |d         }||                    |           |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.   r1   r2   audiovideosr/   text_encodingoutput_kwargsencoding_image_processors	            r    __call__zBlipProcessor.__call__B   s    8 >dlIJJJ +*
 
"&."<
 
 

 *DN4PP=3OPPM';t';F'e'emTcFd'e'e$((//>>>++r   c                 T    | j         j        }| j        j        }d |D             }||z   S )Nc                     g | ]
}|d k    |S )token_type_idsr   ).0names     r    
<listcomp>z3BlipProcessor.model_input_names.<locals>.<listcomp>y   s#     d d d$4ScKcKcKcKcKcr   )r%   model_input_namesr$   )r.   tokenizer_input_namesimage_processor_input_namess      r    rF   zBlipProcessor.model_input_namesu   s:     $ @&*&:&L# d d2G d d d$'BBBr   )NNNN)r   r   r   __doc__
attributesimage_processor_classtokenizer_classr,   r   r   r   strlistr   r   r	   r   r
   r?   propertyrF   __classcell__)r0   s   @r    r#   r#   +   s          $[1JL<O6 6 6 6 6 (,NR1 1$1 uS$s)Y8IIJK1 ,-1 
1 1 1 1f C C XC C C C Cr   r#   N)rI   typingr   r   image_utilsr   processing_utilsr   r   r	   tokenization_utils_baser
   r   r   r   r#   __all__r   r   r    <module>rV      s     # " " " " " " " % % % % % % H H H H H H H H H H R R R R R R R R R R    *%    "OC OC OC OC OCN OC OC OCd 
r   