
    Z j)                         S r SSKJr  SSKJr  SSKJrJrJrJ	r	J
r
  SSKJrJrJr  SSKJr  \R"                  " \5      r\ " S S\5      5       rS/rg	)
zq
Processor class for InstructBLIP. Largely copy of Blip2Processor with addition of a tokenizer for the Q-Former.
   )BatchFeature)ProcessorMixin)
AddedTokenPaddingStrategyPreTokenizedInput	TextInputTruncationStrategy)
TensorTypeauto_docstringlogging)
VideoInputc            $         ^  \ rS rSrSU 4S jjr\                SS\S-  S\\-  \	\   -  \	\   -  S\
S\
\-  \-  S\
\-  \-  S	\S-  S
\S\S-  S\
S-  S\
S\
S\
S\
S\
S\
S\\-  S-  S\4"S jj5       r\S 5       rSrU =r$ )InstructBlipVideoProcessor"   Nc                    > [        US5      (       d,  [        SSSS9U l        UR                  U R                  /SS9  OUR                  U l        X@l        [
        TU ]  XU5        g)z
qformer_tokenizer (`AutoTokenizer`):
    An instance of ['PreTrainedTokenizer`]. The Q-Former tokenizer is a required input.
num_query_tokens (`int`, *optional*):
    Number of tokens used by the Qformer as queries, should be same as in model's config.
video_tokenz<video>FT)
normalizedspecial)special_tokensN)hasattrr   r   
add_tokensnum_query_tokenssuper__init__)selfvideo_processor	tokenizerqformer_tokenizerr   kwargs	__class__s         ړ/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/transformers/models/instructblipvideo/processing_instructblipvideo.pyr   #InstructBlipVideoProcessor.__init__$   sc     y-00))tTD  $"2"2!3D I(44D 05FG    imagestextadd_special_tokenspadding
truncation
max_lengthstridepad_to_multiple_ofreturn_attention_maskreturn_overflowing_tokensreturn_special_tokens_maskreturn_offsets_mappingreturn_token_type_idsreturn_lengthverbosereturn_tensorsreturnc                 (   Uc  Uc  [        S5      e0 nUGbG  [        U[        5      (       a  U/nO8[        U[        5      (       d#  [        US   [        5      (       d  [        S5      eU R                  " SUUUUUUUU	U
UUUUUUS.UD6nUR                  S5      US'   UR                  S5      US'   Ub  X`R                  -  nU R                  " SUUUUUUUU	U
UUUUUS S.UD6nUbe  U R                  R                  U R                  -  S	-  nU R                  US
U	U
UUUUS S9	nU H"  nUU    Vs/ s H  nUU   U-   PM     snUU'   M$     UR                  U5        Ub!  U R                  UUS9nUR                  U5        [        UUS9nU$ s  snf )Nz3You have to specify at least one of images or text.    zAInvalid input text. Please provide a string, or a list of strings)r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   	input_idsqformer_input_idsattention_maskqformer_attention_mask   F)r&   r,   r-   r.   r/   r0   r1   r3   )r3   )tensor_type )
ValueError
isinstancestrlistr   popr   r   r   contentupdater   r   )r   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r   encodingqformer_text_encodingtext_encodingvideo_tokensvideo_text_encodingksampleimage_encodings                             r!   __call__#InstructBlipVideoProcessor.__call__3   s   * >dlRSS$$$vd++JtAw4L4L !dee$($:$: %#5%%#5&;*C+E'=&;+-%  !%!$ -B,E,Ek,RH()1F1J1JK[1\H-. %333
 NN #5%%#5&;*C+E'=&;+#  !M& !#//77$:O:OORSS&*nn ',*?.G/I+A*?"/#' '5 
'# 'AVcdeVf'gVfF(;A(>(GVf'gM!$ 'OOM*!11&1XNOON+nE (hs   2Fc                 p    U R                   R                  nU R                  R                  nSS/nX-   U-   $ )Nr8   r:   )r   model_input_namesr   )r   tokenizer_input_namesvideo_processor_input_namesqformer_input_namess       r!   rP   ,InstructBlipVideoProcessor.model_input_names   s?     $ @ @&*&:&:&L&L#24LM$BEXXXr#   )r   r   )N)NNTFNNr6   NNFFFFFTN)__name__
__module____qualname____firstlineno__r   r   r   r   r   rA   boolr@   r   r	   intr
   r   rM   propertyrP   __static_attributes____classcell__)r    s   @r!   r   r   "   si   H  %)Z^#'056:!%)--1*/+0',&+#26#`T!` ++d9o=EV@WW` !	`
 o-` 3J!33` $J` `  $J`  $d{` $(` %)` !%`  $` `  !`" j(4/#`& 
'` `D Y Yr#   r   N)__doc__image_processing_utilsr   processing_utilsr   tokenization_utils_baser   r   r   r   r	   utilsr
   r   r   video_utilsr   
get_loggerrU   loggerr   __all__r=   r#   r!   <module>rg      se    3 .  9 8 % 
		H	% xY xY xYv (
(r#   