+
    œ°³jxq  ã                   ó¸  € R t ^ RIt^ RIt^ RIHt ^ RIt^RIHt ^RI	H
t
Ht ^RIHtHtHtHt ^RIHtHt ^RIHtHtHtHt ^RIHt ]P6                  ! ]4      t]! 4       '       d   ^ RItR	tR
t Rt!Rt"Rt#Rt$Rt%Rt&Rt' ! R R]RR7      t(R t)R t*R R lt+R R lt,R R lt-R R lt.R  R! lt/R" R# lt0R$ R% lt1]! R)R&7      ] ! R' R(]4      4       4       t2R(.t3R# )*z$
Image/Text processor class for GIT
N)ÚUnion)ÚBatchFeature)Ú
ImageInputÚmake_flat_list_of_images)ÚMultiModalDataÚProcessingKwargsÚProcessorMixinÚUnpack)ÚPreTokenizedInputÚ	TextInput)Úauto_docstringÚis_torch_availableÚloggingÚrequires_backends)Úrequiresz<box>z</box>z<point>z</point>z<0x00>z<0x01>z<0x02>z<0x03>z<0x04>c                   ó&   € ] tR t^8tRRRRR//tRtR# )ÚFuyuProcessorKwargsÚtext_kwargsÚadd_special_tokensTÚpaddingF© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú	_defaultsÚ__static_attributes__r   ó    Úi/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/fuyu/processing_fuyu.pyr   r   8   s   † àØ  $Ø�uð
ð„Ir   r   F)Útotalc                 ót   € \         P                  ! W,          4      P                  \         P                  4      # ©N©ÚnpÚroundÚastypeÚint32)Úoriginal_coordsÚscale_hs   &&r   Ú original_to_transformed_h_coordsr)   B   ó#   € Ü�8Š8�OÕ-Ó.×5Ñ5´b·h±hÓ?Ð?r   c                 ót   € \         P                  ! W,          4      P                  \         P                  4      # r!   r"   )r'   Úscale_ws   &&r   Ú original_to_transformed_w_coordsr-   G   r*   r   c          	      ó^   € V ^8„  d   QhR\         R\         R\         R\        \        ,          /# )é   ÚxÚyÚscale_factorÚreturn©ÚfloatÚlistÚint)Úformats   "r   Ú__annotate__r9   K   s/   € ÷  ñ  ¬ð  ´%ð  Äuð  ÔQUÔVYÕQZñ  r   c                 óÄ   € \        \        P                  ! V ^,          .4      V4      ^ ,          p\        \        P                  ! V^,          .4      V4      ^ ,          pW4.# ©r/   ©r-   r#   Úarrayr)   )r0   r1   r2   Úx_scaledÚy_scaleds   &&&  r   Ú scale_point_to_transformed_imager@   K   sM   € Ü/´·²¸!¸a½%¸Ó0AÀ<ÓPÐQRÕS€HÜ/´·²¸!¸a½%¸Ó0AÀ<ÓPÐQRÕS€HØÐÐr   c                óv   € V ^8„  d   QhR\         R\         R\         R\         R\         R\        \        ,          /# )r/   ÚtopÚleftÚbottomÚrightr2   r3   r4   )r8   s   "r   r9   r9   Q   sH   € ÷ Bñ BÜ	ðBÜðBÜ%*ðBÜ38ðBÜHMðBä	Œ#…YñBr   c                 ó‚  € \        \        P                  ! V ^,          .4      V4      ^ ,          p\        \        P                  ! V^,          .4      V4      ^ ,          p\        \        P                  ! V^,          .4      V4      ^ ,          p\        \        P                  ! V^,          .4      V4      ^ ,          pWVWx.# r;   r<   )	rB   rC   rD   rE   r2   Ú
top_scaledÚleft_scaledÚbottom_scaledÚright_scaleds	   &&&&&    r   Úscale_bbox_to_transformed_imagerK   Q   s“   € ô 2´"·(²(¸CÀ!½G¸9Ó2EÀ|ÓTÐUVÕW€JÜ2´2·8²8¸TÀA½X¸JÓ3GÈÓVÐWXÕY€KÜ4´R·X²X¸vÈ½z¸lÓ5KÈ\ÓZÐ[\Õ]€MÜ3´B·H²H¸eÀa½i¸[Ó4IÈ<ÓXÐYZÕ[€LØ ]ÐAÐAr   c                ó0   € V ^8„  d   QhR\         R\         /# ©r/   Úpromptr3   )Ústr)r8   s   "r   r9   r9   [   s   € ÷ ñ ´ð ¼ñ r   c                 óÖ   € V P                  \        \        4      p V P                  \        \        4      p V P                  \
        \        4      p V P                  \        \        4      p V # r!   )	ÚreplaceÚTEXT_REPR_POINT_OPENÚTOKEN_POINT_OPEN_STRINGÚTEXT_REPR_POINT_CLOSEÚTOKEN_POINT_CLOSE_STRINGÚTEXT_REPR_BBOX_OPENÚTOKEN_BBOX_OPEN_STRINGÚTEXT_REPR_BBOX_CLOSEÚTOKEN_BBOX_CLOSE_STRING)rN   s   &r   Ú$_replace_string_repr_with_token_tagsrZ   [   sO   € Ø�^‰^Ô0Ô2IÓJ€FØ�^‰^Ô1Ô3KÓL€FØ�^‰^Ô/Ô1GÓH€FØ�^‰^Ô0Ô2IÓJ€FØ€Mr   c                ó0   € V ^8„  d   QhR\         R\        /# rM   )rO   r6   )r8   s   "r   r9   r9   c   s   € ÷ ñ ¼ð Äñ r   c                ó†  € . p\         P                  ! R\         R\         R\         R\
         R2	4      pVP                  V 4      p\        V4       Fk  w  rE\        V4      ^ 8X  g   V\        \        \        \
        39   d   K2  TP                  YT^8„  ;'       d    W4^,
          ,          \        \        39   34       Km  	  V# )zQ
Given a string prompt, converts the prompt into a list of TextTokenConversions.
Ú(Ú|Ú))
ÚreÚcompilerW   rY   rS   rU   ÚsplitÚ	enumerateÚlenÚappend)rN   Úprompt_text_listÚregex_patternÚprompt_splitÚiÚelems   &     r   Ú+_segment_prompt_into_text_token_conversionsrk   c   sÆ   € ð
  ÐÜ—J’JØ
Ô"Ð# 1Ô%<Ð$=¸QÔ?VÐ>WÐWXÔYqÐXrÐrsÐtó€Mð !×&Ñ& vÓ.€LÜ˜\Ö*‰ˆÜˆt‹9˜Œ>˜TÜ"Ü#Ü#Ü$ð	&
ô 
ñ Ø×ÑØ�q‘5×eÐe˜\¨a­%Õ0Ô5KÔMdÐ4eÑeÐfö	
ñ +ð Ðr   c                ó<   € V ^8„  d   QhR\         R\        R\         /# )r/   Útextr2   r3   )rO   r5   )r8   s   "r   r9   r9   |   s&   € ÷ Gñ G¤ð G´5ð G¼Sñ Gr   c                óN  € V P                  R4      p\        V4      ^8X  d   \        p\        pM\        p\
        pV Uu. uF  p\        VP                  4       4      NK  	  pp\        V4      ^8X  d   \        V^ ,          V^,          VR7      pMT\        V4      ^8X  d.   \        V^ ,          V^,          V^,          V^,          VR7      pM\        R\        V4       24      hRP                  V Uu. uF  p\        V4      NK  	  up4      pW8,           V,           # u upi u upi )z³
Given a bounding box of the fashion <box>1, 2, 3, 4</box> | <point>1, 2</point> This function is responsible for
converting 1, 2, 3, 4 into tokens of 1 2 3 4 without any commas.
Ú,)r0   r1   r2   )rB   rC   rD   rE   r2   zInvalid number of ints: Ú )rb   rd   rS   rU   rW   rY   r5   Ústripr@   rK   Ú
ValueErrorÚjoinrO   )	rm   r2   Únum_int_strsÚtoken_space_open_stringÚtoken_space_close_stringÚnumÚnum_intsÚnum_ints_translatedÚtokenss	   &&       r   Útransform_within_tagsr{   |   s
  € ð —:‘:˜c“?€LÜ
ˆ<Ó˜AÔä"9ÐÜ#;Ñ ä"8ÐÜ#:Ð ñ /;Ó;©l s”�c—i‘i“kÖ"©l€HÐ;ä
ˆ8ƒ}˜ÔÜ>ÀÈ!ÅÐPXÐYZÕP[ÐjvÔwÑÜ	ˆX‹˜!Ô	Ü=Ø˜•Ø˜!•Ø˜A•;Ø˜1•+Ø%ô
Ñô Ð3´C¸³M°?ÐCÓDÐDØ�W‰WÑ*=Ó>Ñ*= 3”c˜#–hÑ*=Ñ>Ó?€FØ"Õ+Ð.FÕFÐFùò <ùò ?s   ¿"DÃ3D"c                óv   € V ^8„  d   QhR\         \        ,          R\         R,          R\         \        ,          /# )r/   rm   Úscale_factorsútorch.Tensorr3   ©r6   rO   )r8   s   "r   r9   r9   ž   s1   € ÷ ñ ¤¤S¥	ð ¼$¸~Õ:Nð ÔSWÔX[ÕS\ñ r   c                ój  € . p\        W4       F¡  w  r4\        V4      p\        V4      p. pV F^  pV^,          '       d5   \        V^ ,          VP	                  4       4      pVP                  V4       KF  VP                  V^ ,          4       K`  	  VP                  RP                  V4      4       K£  	  V# )aÑ  
This function transforms the prompts in the following fashion:
- <box> <point> and </box> </point> to their respective token mappings
- extract the coordinates from the tag
- transform the coordinates into the transformed image space
- return the prompts with the transformed coordinates and new tags

Bounding boxes and points MUST be in the following format: <box>y1, x1, y2, x2</box> <point>x, y</point> The spaces
and punctuation added above are NOT optional.
rp   )ÚziprZ   rk   r{   Úitemre   rs   )	rm   r}   Úprocessed_textrN   r2   rf   Útransformed_promptsrj   Úprompt_within_tagss	   &&       r   Útransform_coordinatesr†   ž   s¦   € ð €NÜ # DÖ 8ÑˆÜ5°fÓ=ˆÜFÀvÓNÐØ)+ÐÛ$ˆDØ�A�wŒwä%:¸4À½7ÀL×DUÑDUÓDWÓ%XÐ"Ø#×*Ñ*Ð+=Ö>à#×*Ñ*¨4°­7Ö3ñ %ð 	×Ñ˜bŸg™gÐ&9Ó:Ö;ñ !9ð Ðr   c                óÄ   € V ^8„  d   QhR\         \        \        \        ,          ,          R3,          RRR\        \        R,          ,          R\        R\        R,          /# )r/   Únum_real_text_tokensr~   Úinput_streamÚimage_tokensÚ
batch_sizer3   )r   r6   r7   )r8   s   "r   r9   r9   ¹   s[   € ÷ ñ Ü¤¤T¬#¥Y¥°Ð ?Õ@ðà ðô ”t˜NÕ+Õ,ðô ð	ô
 
ˆ.Õñr   c                ó
  € \         P                  ! V^ ,          ^ ,          VR,          .^ R7      pV^ ,          ^ ,          P                  ^ ,          V ^ ,          ^ ,          ,           p\         P                  ! VRV .^ R7      .pV# )a  Takes an input_stream tensor of shape B x S x ?. For each subsequence, adds any required
padding to account for images and then unpacks the subsequences to create a single sequence per item in the batch.
Returns a list of tensors, one for each item in the batch.©ÚdimN)é    r�   )ÚtorchÚcatÚshape)rˆ   r‰   rŠ   r‹   Úsubsequence_streamÚnum_real_tokensÚall_bi_streams   &&&&   r   Úconstruct_full_unpacked_streamr–   ¹   sw   € ô Ÿš L°¥O°AÕ$6¸ÀTÕ8JÐ#KÐQRÔSÐØ" 1•o aÕ(×.Ñ.¨qÕ1Ð4HÈÕ4KÈAÕ4NÕN€OÜ—Y’YÐ 2Ð3C°OÐ DÐEÈ1ÔMÐN€MàÐr   )Úbackendsc                   ó&  a a€ ] tR t^Êt o]t]RR l4       tV 3R lt]	V3R lR l4       t
]RV3R lR ll4       tRV3R lR lltRV3R	 lV 3R
 llltV3R lR ltV3R lR lt]	V3R lR l4       tRR ltRR ltRR lt]	R 4       tRtVtV ;t# )ÚFuyuProcessorc                ó�   € ^RI Hp VP                  ! V3/ VB pRVP                  9   d   VP                  P	                  R4       V# )zÅ
Override for BC. Fuyu uses TokenizersBackend and requires token_type_ids to be removed from model_input_names
because Fuyu uses mm_token_type_ids instead for multimodal token identification.    `
)ÚTokenizersBackendÚtoken_type_ids)Útokenization_utils_tokenizersr›   Úfrom_pretrainedÚmodel_input_namesÚremove)ÚclsÚsub_processor_typeÚpretrained_model_name_or_pathÚ	subfolderÚkwargsr›   Ú	tokenizers   &&&&,  r   Ú_load_tokenizer_from_pretrainedÚ-FuyuProcessor._load_tokenizer_from_pretrainedÏ   sH   € õ 	Gà%×5Ò5Ð6SÑ^ÐW]Ñ^ˆ	à˜y×:Ñ:Ô:Ø×'Ñ'×.Ñ.Ð/?Ô@ØÐr   c                ó¸   <€ ^
V n         VP                  4       p^ Vn        RV n        RV n        VR,          V n        VR,          V n        \        SV `!  WR7       R# )é
   z	|SPEAKER|z	|NEWLINE|)Úimage_processorr¦   N)	Úmax_tokens_to_generateÚ	get_vocabÚpad_token_idÚimage_tokenÚimage_newline_tokenÚimage_token_idÚimage_newline_idÚsuperÚ__init__)Úselfr«   r¦   r¥   ÚvocabÚ	__class__s   &&&, €r   r´   ÚFuyuProcessor.__init__ß   s[   ø€ Ø&(ˆÔ#Ø×#Ñ#Ó%ˆØ!"ˆ	Ôà&ˆÔØ#.ˆÔ Ø# KÕ0ˆÔØ % kÕ 2ˆÔÜ‰Ñ¨ÐÖNr   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ©r/   r3   )r6   r7   )r8   Ú__classdict__s   "€r   r9   ÚFuyuProcessor.__annotate__ë   s   ø€ ÷ <ñ <¡¡c¥ñ <r   c                ó2   € V P                   V P                  .# r!   )r²   r±   ©rµ   s   &r   Úimage_token_idsÚFuyuProcessor.image_token_idsê   s   € à×%Ñ% t×':Ñ':Ð;Ð;r   c                óœ   <€ V ^8„  d   QhRS[ R,          RS[S[S[,          ,          S[,          S[,          R,          RS[S[,          RR/# )r/   ÚimagesNrm   r¥   r3   r   )r   rO   r6   r   r
   r	   r   )r8   r»   s   "€r   r9   r¼   ï   sb   ø€ ÷ orñ orá˜TÕ!ðorñ ‘D™•I�o¡	Õ)Ñ,=Õ=ÀÕDðorñ Ñ,Õ-ð	orð
 
ñorr   c                ó  € \        V R.4       V P                  ! \        3RV P                  P                  /VB pVR,          P                  RR4      '       g   \        R4      hVe   Ve   RVR,          R	&   RVR,          R
&   Ve   RVR,          R&   RVR,          R&   V P                  ! R RVRV/VB vrpV P                  ! R RVRV/VB  / p. pVe/   \        V R4      '       d   V P                  ! V3/ VR,          B w  rg/ pVR,          P                  RR4      p	VEeƒ   VR,          P                  RR4      p
VR,          P                  RR4      pVP                  R4      ;pe)   \        W,4       UUu. uF  w  rÞ\        WÞ4      NK  	  upppV'       d   V P                  VV4      w  r/V'       g   V P                  ! V3/ VR,          B pEM‡. . ppV EFZ  p\         P"                  ! RV^R7      pV P                  ! VR!,          3/ VR,          B p\%        V4      ^8X  d¿   V P                  ! V^ ,          3/ VR,          B pVP'                  \(        P*                  ! VR,          R",          VR,          .R!R7      P-                  ^ 4      4       VP'                  \(        P*                  ! VR,          R",          VR,          .R!R7      P-                  ^ 4      4       EK  VP'                  VR,          P-                  ^ 4      4       VP'                  VR,          P-                  ^ 4      4       EK]  	  V P                  P/                  RVRV/RRR7      pV'       d   V P1                  W(R.R7       V'       d   XVR&   V
'       d   V P3                  VR,          4      VR&   / VCVCpVP5                  4        UUu/ uF  w  ppVV P6                  9  g   K  VVbK  	  ppp\9        VW�P:                  R7      # u uppi u uppi )#a°  
Returns:
    [`FuyuBatchEncoding`]: A [`FuyuBatchEncoding`] with the following fields:

    - **input_ids** -- Tensor of token ids to be fed to a model. Returned when `text` is not `None`.
    - **image_patches** -- List of Tensor of image patches. Returned when `images` is not `None`.
    - **attention_mask** -- List of indices specifying which tokens should be attended to by the model when
      `return_attention_mask=True`.
r�   Útokenizer_init_kwargsr   Úreturn_attention_maskTz>`return_attention_mask=False` is not supported for this model.NFr   r   ÚptÚreturn_tensorsÚimages_kwargsrÂ   rm   r«   Úreturn_mm_token_type_idsÚreturn_text_replacement_offsetsÚimage_scale_factorsz(?<=<s>))ÚmaxsplitÚ	input_idsr�   Úattention_maskrC   )Úpadding_sideÚ
max_lengthÚimage)Ú
modalitiesÚtext_replacement_offsetsÚmm_token_type_ids)Útensor_typeÚskip_tensor_conversionr   éÿÿÿÿ).ºé   NN)r   Ú_merge_kwargsr   r¦   Úinit_kwargsÚ
setdefaultrr   Úprepare_inputs_layoutÚvalidate_inputsÚhasattrÚ_process_imagesÚgetÚpopr�   r†   Úget_text_with_replacementsr`   rb   rd   re   r�   r‘   ÚsqueezeÚpadÚ_check_special_mm_tokensÚcreate_mm_token_type_idsÚitemsÚunused_input_namesr   rÖ   )rµ   rÂ   rm   r¥   Úmerged_kwargsÚ_Úprocessed_imagesÚimages_replacementsÚtext_inputsrÇ   rÉ   rÊ   rË   ÚsampleÚscalerÓ   Úbatch_input_idsÚbatch_attention_maskÚsplit_sampleÚprompt_inputsÚplaceholder_inputsÚdataÚkÚvs   &&&,                    r   Ú__call__ÚFuyuProcessor.__call__î   s  € ô  	˜$  	Ô*à×*Ò*Üñ
à"&§.¡.×"<Ñ"<ð
ð ñ
ˆð
 ˜]Õ+×6Ñ6Ð7NÐPT×UÒUÜÐ]Ó^Ð^ð Ò Ò 2ØAFˆM˜-Õ(Ð)=Ñ>Ø6;ˆM˜-Õ(¨Ñ3àÒØ=AˆM˜-Õ(Ð)9Ñ:Ø?CˆM˜/Õ*Ð+;Ñ<ð  ×5Ò5ÑY¸VÐYÈ$ÐYÐRXÑYÐˆ�qØ×ÒÑ@ FÐ@°Ð@¸Ò@àÐØ ÐØÒ¤'¨$Ð0A×"BÒ"BØ48×4HÒ4HÈÑ4rÐS`ÐapÕSqÑ4rÑ1ÐàˆØ& }Õ5×9Ñ9Ð:JÈDÓQˆØÓØ'4°]Õ'C×'GÑ'GÐHbÐdiÓ'jÐ$Ø.;¸MÕ.J×.NÑ.NØ1°5ó/Ð+ð (8×';Ñ';Ð<QÓ'RÐRÐ#Ò_ÜTWÐX\ÔTrÔsÑTrÁ=À6Ô/°Ö>ÑTrÒs�ç"Ø15×1PÑ1PØØ'ó2Ñ.�÷ 'Ø"Ÿnšn¨TÑR°]À=Õ5QÑR’ð 9;¸BÐ!5�Ü"�FÜ#%§8¢8¨K¸È!Ô#L�LØ$(§N¢N°<ÀÕ3CÑ$dÀ}ÐUbÕGcÑ$d�Mä˜<Ó(¨AÔ-ð .2¯^ª^¸LÈ½OÑ-lÈ}Ð]jÕOkÑ-lÐ*Ø'×.Ñ.Ü!ŸIšIØ!3°KÕ!@ÀÕ!IÈ=ÐYdÕKeÐ fÐlnôç%™g a›jôð
 -×3Ñ3Ü!ŸIšIØ!3Ð4DÕ!EÀgÕ!NÐP]Ð^nÕPoÐ pØ$&ô÷ &™g a›j÷	ð (×.Ñ.¨}¸[Õ/I×/QÑ/QÐRSÓ/TÔUØ,×3Ñ3°MÐBRÕ4S×4[Ñ4[Ð\]Ó4^×_ñ+ #ð0 #Ÿn™n×0Ñ0Ø  /Ð3CÐEYÐZØ!'Ø#ð 1ó �÷ #Ø×-Ñ-¨dÈWÈIÐ-ÔVç.Ø:R�Ð6Ñ7ç'Ø37×3PÑ3PÐQ\Ð]hÕQiÓ3j�Ð/Ñ0ð 3�+Ð2Ð!1Ð2ˆØ!%§¡¤ÔR¡™˜˜A°¸$×:QÑ:QÑ1Q”��1’¡ˆÑRÜ˜D¨n×UpÑUpÔqÐqùóq tùón Ss   Å:O<Ï PÏPc                ó„   <€ V ^8„  d   QhRS[ R,          RS[S[,          S[S[,          ,          S[S[,          ,          /# )r/   rÂ   Nrm   )r   r   r
   r6   )r8   r»   s   "€r   r9   r¼   `  s>   ø€ ÷ 1ñ 1á˜TÕ!ð1ñ Ñ+Õ+©d±9­oÕ=ÁÑEVÕ@WÕWñ1r   c                ó(  € Ve¤   Ve    . p\        V\        4      '       d   V.MTp\        V\        \        34      '       g   V.MTp\	        W!4       FQ  w  rV\        V\        4      '       d   V. 8X  g   V P
                  V,           pVP                  V\        ,           4       KS  	  M<Ve   \        P                  R4       TpM Vf   Ve   \        P                  R4       R.pVe'   V P                  P                  V4      p\        V4      pVXR R 3# )NzMYou are processing a text with no associated image. Make sure it is intended.zNYou are processing an image with no associated text. Make sure it is intended.rp   )Ú
isinstancerO   r6   Útupler�   r¯   re   ÚBEGINNING_OF_ANSWER_STRINGÚloggerÚwarningr«   Úfetch_imagesr   )rµ   rÂ   rm   r¥   Úprepared_textrï   rÑ   s   &&&,   r   rÝ   Ú#FuyuProcessor.prepare_inputs_layout`  sù   € ð Ò Ò 2ØˆMÜ'¨¬c×2Ò2�D‘6¸ˆDÜ%/°¼¼u¸×%FÒ%F�f‘XÈFˆFÜ!$ TÖ!2‘�Ü" 5¬$×/Ò/°E¸R´KØ!×-Ñ-°Õ6�Fð ×$Ñ$ VÔ.HÕ%HÖIò "3ð ÒÜ�N‰NÐjÔkØ ‰MØŠ\˜fÒ0Ü�N‰NÐkÔlØ˜DˆMàÒØ×)Ñ)×6Ñ6°vÓ>ˆFÜ-¨fÓ5ˆFà�} d¨DÐ0Ð0r   c                óº   <€ V ^8„  d   QhRS[ S[S[ ,          ,          R,          RS[S[,          S[S[,          ,          S[S[,          ,          RS[S[,          /# )r/   rÂ   Nrm   r¥   )r   r6   r   r
   r	   r   )r8   r»   s   "€r   r9   r¼   €  s]   ø€ ÷ 	Lñ 	Lá™T¡*Õ-Õ-°Õ4ð	Lñ Ñ+Õ+©d±9­oÕ=ÁÑEVÕ@WÕWð	Lñ Ñ)Õ*ñ		Lr   c                óZ   <€ \         SV `  ! RR VRV/VB  Vf   Vf   \        R4      hR# R# )rÂ   rm   Nz+You must provide either `text` or `images`.r   )r³   rÞ   rr   )rµ   rÂ   rm   r¥   r·   s   &&&,€r   rÞ   ÚFuyuProcessor.validate_inputs€  s;   ø€ ô 	‰ÒÑC vÐC°DÐC¸FÒCàŠ<˜FšNÜÐJÓKÐKñ +‰<r   c                ó    <€ V ^8„  d   QhRS[ /# )r/   rÂ   )r   )r8   r»   s   "€r   r9   r¼   ‹  s   ø€ ÷ !4ñ !4¡jñ !4r   c           
     ó   € V P                   ! V3/ VB p. p. pVP                  R 4      p\        \        V4      4       EFp  pWg,          P                  RR w  r‰V P                   P
                  p
V
P                  V
P                  rË\        V\        P                  ! VR,          V,          ^ ,          V,          4      V,          4      p\        V	\        P                  ! VR,          V,          ^ ,          V,          4      V,          4      pV P                   P                  WÞV
R7      pWg,          RRV1RV13,          pV P                   P                  VV
R7      pVP                  VP                  ^ 4      4       Wì,          pV P                  ! V3RVRVR	V/VB pVP                  V4       EKs  	  \         P"                  ! V^ R
7      VR&   W53# )rÂ   NÚimage_unpadded_heightsÚimage_unpadded_widths)Úimage_heightÚimage_widthÚ
patch_size.)rÑ   r  Ú	image_idxÚnum_patchesÚ	row_widthr�   Úimage_patcheséþÿÿÿ)r«   râ   Úrangerd   r’   r  ÚheightÚwidthÚminÚmathÚceilÚget_num_patchesÚpatchify_imagere   rä   Úreplace_image_tokenr�   r‘   )rµ   rÂ   r¥   rì   Úbatch_image_patchesÚimage_replacementsÚprocessor_output_imagesr  r  r  r  Úpatch_heightÚpatch_widthÚnew_hÚnew_wr  rÑ   r  r  Úreplacement_texts   &&,                 r   rà   ÚFuyuProcessor._process_images‹  sÙ  € Ø×/Ò/°ÑA¸&ÑAÐà ÐØÐØ"2×"6Ñ"6°xÓ"@ÐÜœs 6›{×+ˆIØ(?Õ(J×(PÑ(PÐQSÐQTÐ(UÑ%ˆLØ×-Ñ-×8Ñ8ˆJØ(2×(9Ñ(9¸:×;KÑ;K˜+äØÜ—	’	Ð*Ð+CÕDÀYÕOÐPQÕRÐUaÕaÓbÐeqÕqóˆEô ØÜ—	’	Ð*Ð+BÕCÀIÕNÈqÕQÐT_Õ_Ó`ÐcnÕnóˆEð ×.Ñ.×>Ñ>Ø"À*ð ?ó ˆKð ,Õ6°s¸F¸U¸FÀFÀUÀFÐ7JÕKˆEØ ×0Ñ0×?Ñ?ÀeÐXbÐ?ÓcˆMØ×&Ñ& }×'<Ñ'<¸QÓ'?Ô@àÕ,ˆIØ#×7Ò7Ø ñ Ø,5ð ØCNð ØZcð Øgmñ Ðð ×%Ñ%Ð&6×7ñ1 ,ô4 -2¯IªIÐ6IÈqÔ,QÐ˜Ñ)ØÐ3Ð3r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )r/   Úimage_inputsr  r3   )Údictr7   rO   )r8   r»   s   "€r   r9   r¼   ®  s#   ø€ ÷ ;ñ ;±ð ;Áð ;ÑSVñ ;r   c                óî   € . p\        ^ VR,          VR,          4       F=  pVP                  V P                  VR,          ,          V P                  ,           4       K?  	  RP	                  V4      R,           # )r�   r  r  rp   z<s>)r  re   r¯   r°   rs   )rµ   r'  r  r¥   Úimage_tokens_with_newlinesrë   s   &&&,  r   r  Ú!FuyuProcessor.replace_image_token®  sg   € à%'Ð"Ü�q˜& Õ/°¸Õ1DÖEˆAØ&×-Ñ-¨d×.>Ñ.>ÀÈÕATÕ.TÐW[×WoÑWoÕ.oÖpñ Fð �w‰wÐ1Ó2°UÕ:Ð:r   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# rº   r   )r8   r»   s   "€r   r9   r¼   ¸  s   ø€ ÷ iñ i¡D©¥Iñ ir   c                ó
   € . RO# )r
  )r
  r  Úimage_sizesrË   r   r¾   s   &r   ré   Ú FuyuProcessor.unused_input_names·  s   € âhÐhr   c                ón  € / pVEe¥   VP                  R4      ;'       g    V P                  P                  pVR,          VR,          re. p^.\        V4      ,          pV EF3  p	WY^ ,          ,          p
Wi^,          ,          p\	        W«4      p\	        \        V	^ ,          V,          4      V	^ ,          4      p\	        \        V	^,          V,          4      V	^,          4      pV P                  P                  \        P                  ! ^^^WV4      \        P                  ! ^^^4      \        P                  ! V..4      \        P                  ! V..4      ^ ^ RR7      pVP                  VR,          ^ ,          ^ ,          P                  R	,          4       EK6  	  VP                  RVRV/4       \        R
/ VB # )a{  
Computes the number of placeholder tokens needed for multimodal inputs with the given sizes.

Args:
    image_sizes (`list[list[int]]`, *optional*):
        The input sizes formatted as (height, width) per each image.

Returns:
    `MultiModalData`: A `MultiModalData` object holding number of tokens per each of the provided
    input modalities, along with other useful data.
Úsizer  r  T)Úimage_inputÚimage_presentÚimage_unpadded_hÚimage_unpadded_wÚimage_placeholder_idr²   Úvariable_sizedÚimage_input_idsÚnum_image_tokensÚnum_image_patchesr×   r   )rá   r«   r1  rd   r  r7   Úpreprocess_with_tokenizer_infor�   ÚzerosÚonesÚtensorre   r’   Úupdater   )rµ   r.  r¥   Úvision_datar1  Úpadded_heightÚpadded_widthr9  r:  Ú
image_sizeÚheight_scale_factorÚwidth_scale_factorÚoptimal_scale_factorr4  r5  Úmodel_image_inputs   &&,             r   Ú_get_num_multimodal_tokensÚ(FuyuProcessor._get_num_multimodal_tokens»  s—  € ð ˆØÓ"Ø—:‘:˜fÓ%×BÐB¨×)=Ñ)=×)BÑ)BˆDØ*.¨x­.¸$¸w½-˜<à!ÐØ!" ¤c¨+Ó&6Õ 6ÐÜ)�
Ø&3ÀµmÕ&CÐ#Ø%1¸qµMÕ%AÐ"Ü'*Ð+>Ó'SÐ$ä#&¤s¨:°a­=Ð;OÕ+OÓ'PÐR\Ð]^ÕR_Ó#`Ð Ü#&¤s¨:°a­=Ð;OÕ+OÓ'PÐR\Ð]^ÕR_Ó#`Ð ð %)×$8Ñ$8×$WÑ$WÜ %§¢¨A¨q°!°]Ó QÜ"'§*¢*¨Q°°1Ó"5Ü%*§\¢\Ð4DÐ3EÐ2FÓ%GÜ%*§\¢\Ð4DÐ3EÐ2FÓ%GØ)*Ø%&Ø#'ð %Xó %Ð!ð !×'Ñ'Ð(9Ð:KÕ(LÈQÕ(OÐPQÕ(R×(XÑ(XÐY[Õ(\×]ñ' *ð( ×ÑÐ 2Ð4DÐFYÐ[lÐmÔnÜÑ, Ñ,Ð,r   c                óä  a aa	€ R	V 3R llo	V 3R loVV	V 3R lpVV	V 3R lpVfM   S P                   P                  R,          S P                   P                  R,          33\        V4      ,          pM#VP                  ^,          ^8w  d   \	        R4      h\        V4      \        V4      8w  d   \	        R4      h. p\        W4       F&  w  rgV! Wg4      pV! Wg4      pVP                  V4       K(  	  V# )
a.  
Transforms raw coordinates detected by [`FuyuForCausalLM`] to the original images' coordinate space.
Coordinates will be returned in "box" format, with the following pattern:
    `<box>top, left, bottom, right</box>`

Point coordinates are not supported yet.

Args:
    outputs ([`GenerateOutput`]):
        Raw outputs from `generate`.
    target_sizes (`torch.Tensor`, *optional*):
        Tensor of shape (batch_size, 2) where each entry is the (height, width) of the corresponding image in
        the batch. If set, found coordinates in the output sequence are rescaled to the target sizes. If left
        to None, coordinates will not be rescaled.

Returns:
    `GenerateOutput`: Same output type returned by `generate`, with output token ids replaced with
        boxed and possible rescaled coordinates.
c                 óÞ   <€ V w  r#Vf<   SP                   P                  R,          pSP                   P                  R,          pMVw  rEW58:  d	   W$8:  d   R# \        WB,          WS,          4      # )Nr  r  g      ð?)r«   r1  r  )Úoriginal_sizeÚtarget_sizer  r  Ú
max_heightÚ	max_widthrµ   s   &&    €r   Úscale_factor_to_fitÚGFuyuProcessor.post_process_box_coordinates.<locals>.scale_factor_to_fitû  se   ø€ Ø)‰MˆFØÒ"Ø!×1Ñ1×6Ñ6°xÕ@�
Ø ×0Ñ0×5Ñ5°gÕ>‘	à(3Ñ%�
ØÔ! fÔ&:ÙÜ�zÕ*¨IÕ,=Ó>Ð>r   c                 ót  <€ SP                   P                  V4      pSP                   P                  V4      pW8H  P                  R R7      ^ ,          pW8H  P                  R R7      ^ ,          p\        P                  ! V4      '       d/   \        P                  ! V4      '       d   V^ ,          V^ ,          3# R# )T©Úas_tuple©NN)r¦   Úconvert_tokens_to_idsÚnonzeror�   Úany)rz   Ústart_tokenÚ	end_tokenÚstart_idÚend_idÚstarting_positionsÚending_positionsrµ   s   &&&    €r   Úfind_delimiters_pairÚHFuyuProcessor.post_process_box_coordinates.<locals>.find_delimiters_pair  sž   ø€ Ø—~‘~×;Ñ;¸KÓHˆHØ—^‘^×9Ñ9¸)ÓDˆFà"(Ñ"4×!=Ñ!=ÀtÐ!=Ó!LÈQÕ!OÐØ &Ñ 0×9Ñ9À4Ð9ÓHÈÕKÐä�yŠyÐ+×,Ò,´·²Ð;K×1LÒ1LØ*¨1Õ-Ð/?ÀÕ/BÐCÐCØÐr   c           
      óx  <€ S! V \         \        4      ;pR8w  Ed   Vw  r4WC^,           8w  d   K-  SP                  P                  W^,           V 4      pS! V4      pV Uu. uF%  p^\	        \        V4      V,          4      ,          NK'  	  upw  r‰r«R\         V RV	 RV
 RV \         2
pSP                  P                  V4      R,          pSP                  P                  V4      p\        P                  ! V4      P                  V 4      p\        P                  ! V R V WÀV^,           R  .^ 4      p EK3  V # u upi ©NÚ z, rØ   rU  )rW   rY   r¦   Úconvert_ids_to_tokensr7   r5   rV   rX   ÚtokenizerV  r�   r>  Útor‘   )rz   rL  ÚpairÚstartÚendÚcoordsrð   ÚcrB   rC   rD   rE   Úreplacementr_  rP  rµ   s   &&           €€€r   Útokens_to_boxesÚCFuyuProcessor.post_process_box_coordinates.<locals>.tokens_to_boxes  s7  ø€ Ù/°Ô8NÔPgÓhÐh�4ð nõ ð "‘
�Ø !�)Ô#Ùð Ÿ™×=Ñ=¸fÈQÅYÐQTÐ>UÓV�ñ ,¨MÓ:�ÙOUÓ+VÉvÈ!¨A´´E¸!³H¸uÕ4DÓ0E×,EÐ,EÉvÑ+VÑ(�˜6ð !"Ô"5Ð!6°s°e¸2¸d¸VÀ2ÀfÀXÈRÐPUÈwÔWkÐVlÐm�Ø"Ÿn™n×5Ñ5°kÓBÀ2ÕF�Ø"Ÿn™n×BÑBÀ;ÓO�Ü#Ÿlšl¨;Ó7×:Ñ:¸6ÓB�äŸš F¨6¨E N°KÈÈaÍÈ	ÐARÐ#SÐUVÓW“ØˆMùò ,Ws   Á+D7c           	      ój  <€ S! V \         \        4      ;pR8w  Ed   Vw  r4WC^,           8w  d   K-  SP                  P                  W^,           V 4      pS! V4      pV Uu. uF%  p^\	        \        V4      V,          4      ,          NK'  	  upw  r‰R\         V RV	 \         2p
SP                  P                  V
4      R,          p
SP                  P                  V
4      p
\        P                  ! V
4      P                  V 4      p
\        P                  ! V R V W V^,           R  .^ 4      p EK,  V # u upi rb  )rS   rU   r¦   rd  r7   r5   rR   rT   re  rV  r�   r>  rf  r‘   )rz   rL  rg  rh  ri  rj  rð   rk  r0   r1   rl  r_  rP  rµ   s   &&         €€€r   Útokens_to_pointsÚDFuyuProcessor.post_process_box_coordinates.<locals>.tokens_to_points*  s'  ø€ Ù/°Ô8OÔQiÓjÐj�4ð põ ð "‘
�Ø !�)Ô#Ùð Ÿ™×=Ñ=¸fÈQÅYÐQTÐ>UÓV�ñ ,¨MÓ:�Ù;AÓB¹6°a˜œC¤ a£¨5Õ 0Ó1×1Ð1¹6ÑB‘�ð !"Ô"6Ð!7¸°s¸"¸Q¸CÔ@UÐ?VÐW�Ø"Ÿn™n×5Ñ5°kÓBÀ2ÕF�Ø"Ÿn™n×BÑBÀ;ÓO�Ü#Ÿlšl¨;Ó7×:Ñ:¸6ÓB�äŸš F¨6¨E N°KÈÈaÍÈ	ÐARÐ#SÐUVÓW“ØˆMùò Cs   Á+D0r  r  zTEach element of target_sizes must contain the size (h, w) of each image of the batchzCMake sure that you pass in as many target sizes as output sequencesr!   )r«   r1  rd   r’   rr   r�   re   )
rµ   ÚoutputsÚtarget_sizesrm  rp  ÚresultsÚseqr1  r_  rP  s
   f&&     @@r   Úpost_process_box_coordinatesÚ*FuyuProcessor.post_process_box_coordinatesæ  sÔ   ú€ ÷*		?õ		 ÷	÷2	ð2 ÒØ!×1Ñ1×6Ñ6°xÕ@À$×BVÑBV×B[ÑB[Ð\cÕBdÐeÐgÔjmÐnuÓjvÕv‰LØ×Ñ Õ" aÔ'ÜÐsÓtÐtäˆw‹<œ3˜|Ó,Ô,ÜÐbÓcÐcàˆÜ˜WÖ3‰IˆCÙ! #Ó,ˆCÙ" 3Ó-ˆCØ�N‰N˜3Öñ 4ð
 ˆr   c                óÜ  € V P                   P                  \        4      pV Uu. uF'  qUWT8H  P                  RR7      ^ ,          ^,           R NK)  	  pp\	        R V 4       4      p\
        P                  ! \        V4      V3V P                   P                  4      p\        V4       F*  w  r•\
        P                  ! V4      W‰R\        V4      13&   K,  	  V P                  ! V3RV/VB # u upi )aš  
Post-processes the output of `FuyuForConditionalGeneration` to only return the text output.

Args:
    generated_outputs (`torch.Tensor` or `np.ndarray`):
        The output of the model. The output is expected to be a tensor of shape `(batch_size, sequence_length)`
        containing the token ids of the generated sequences.
    skip_special_tokens (`bool`, *optional*, defaults to `True`):
        Whether or not to remove special tokens in the output. Argument passed to the tokenizer's `batch_decode` method.
    **kwargs:
        Additional arguments to be passed to the tokenizer's `batch_decode method`.

Returns:
    `list[str]`: The decoded text output.
TrS  Nc              3   ó8   "  € T F  p\        V4      x € K  	  R # 5ir!   )rd   )Ú.0ru  s   & r   Ú	<genexpr>Ú@FuyuProcessor.post_process_image_text_to_text.<locals>.<genexpr>i  s   é € ÐDÑ*C 3”c˜#—h�hÓ*Cùs   ‚Úskip_special_tokens)r¦   rV  rÿ   rW  Úmaxr�   Úfullrd   r®   rc   r>  Úbatch_decode)
rµ   Úgenerated_outputsr}  r¥   Úbeginning_of_answerru  Úunpadded_output_sequencesÚmax_lenÚpadded_output_sequencesri   s
   &&&,      r   Úpost_process_image_text_to_textÚ-FuyuProcessor.post_process_image_text_to_textS  sî   € ð  #Ÿn™n×BÑBÔC]Ó^Ðñ Zkó%
ÙYjÐRU�Ñ+×4Ñ4¸dÐ4ÓCÀAÕFÈÕJÐLÓMÑYjð 	"ð %
ô ÑDÑ*CÓDÓDˆä"'§*¢*¬cÐ2KÓ.LÈgÐ-VÐX\×XfÑXf×XsÑXsÓ"tÐÜÐ 9Ö:‰FˆAÜ5:·\²\À#Ó5FÐ# z¬¨S« z MÓ2ñ ;ð × Ò Ð!8ÑlÐNaÐlÐekÑlÐlùò%
s   ¤-C)c                óT   € V P                   P                  p\        VR .,           4      # )r  )r¦   rŸ   r6   )rµ   Útokenizer_input_namess   & r   rŸ   ÚFuyuProcessor.model_input_namesq  s&   € à $§¡× @Ñ @ÐÜÐ)¨_Ð,=Õ=Ó>Ð>r   )r²   r°   r¯   r±   r¬   )rp   rU  r!   )T)r   r   r   r   r   Úvalid_processor_kwargsÚclassmethodr§   r´   Úpropertyr¿   r   rù   rÝ   rÞ   rà   r  ré   rH  rv  r†  rŸ   r   Ú__classdictcell__Ú__classcell__)r·   r»   s   @@r   r™   r™   Ê   sÇ   ù‡ € ð 1Ðàóó ðõ	Oð ÷<ó ð<ð ÷orñ oró ðor÷b1ò 1÷@	Lõ 	L÷!4ð !4÷F;ð ;ð ÷ió ðiô)-ôVkôZmð< ñ?ó ÷?ð ?r   r™   )Úvision)4Ú__doc__r  r`   Útypingr   Únumpyr#   Úimage_processing_utilsr   Úimage_utilsr   r   Úprocessing_utilsr   r   r   r	   Útokenization_utils_baser
   r   Úutilsr   r   r   r   Úutils.import_utilsr   Ú
get_loggerr   r   r�   rV   rX   rR   rT   rW   rY   rS   rU   rÿ   r   r)   r-   r@   rK   rZ   rk   r{   r†   r–   r™   Ú__all__r   r   r   Ú<module>rœ     s  ðñó Û 	Ý ã å 2ß ?÷ó ÷ Dß SÓ SÝ *ð 
×	Ò	˜HÓ	%€ñ ×ÒÛð Ð ØÐ Ø Ð Ø"Ð à!Ð Ø"Ð Ø"Ð Ø#Ð Ø%Ð ôÐ*°%õ ò@ò
@õ õBõõõ2GõDõ6ñ" 
�;ÔØôh?�Nó h?ó ó  ðh?ðV Ð
‚r   