+
    œ°³jÒ  ã                   ó  € R t ^ RIt^ RIHt ^ RIHtHt ^RIHt ^RI	H
t
HtHt ^RIHtHtHt ^RIHtHt ^RIHtHt ]'       d   ^R	IHt ]P0                  ! ]4      tR
 R ltR t ! R R]RR7      t] ! R R]4      4       tR.tR# )z
Processor class for IDEFICS2.
N)Ú
accumulate)ÚTYPE_CHECKINGÚUnion)ÚBatchFeature)Ú
ImageInputÚis_valid_imageÚ
load_image)ÚProcessingKwargsÚProcessorMixinÚUnpack)Ú
AddedTokenÚ	TextInput)Úauto_docstringÚlogging)ÚPreTokenizedInputc                ó$   € V ^8„  d   QhR\         /# )é   Úreturn)Úbool)Úformats   "Úq/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/idefics2/processing_idefics2.pyÚ__annotate__r   (   s   € ÷ ;ñ ;”4ñ ;ó    c                 óT   € \        V \        4      ;'       d    V P                  R 4      # )Úhttp)Ú
isinstanceÚstrÚ
startswith)Úvals   &r   Úis_urlr   (   s    € Ü�cœ3Ó×:Ð: C§N¡N°6Ó$:Ð:r   c                 ó>   € \        V 4      ;'       g    \        V 4      # ©N)r   r   )Úelems   &r   Úis_image_or_image_urlr#   ,   s   € Ü�$‹<×/Ð/œ>¨$Ó/Ð/r   c                   ó*   € ] tR t^0tRRRRRRR//tRtR# )	ÚIdefics2ProcessorKwargsÚtext_kwargsÚadd_special_tokensTÚpaddingFÚis_split_into_words© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú	_defaultsÚ__static_attributes__r*   r   r   r%   r%   0   s    † àØ  $Ø�uØ! 5ð
ð„Ir   r%   F)Útotalc                   ól   a a€ ] tR t^:t o]tRV3R lV 3R llltR t]RV3R lR ll4       t	Rt
VtV ;t# )	ÚIdefics2Processorc                ó4   <€ V ^8„  d   QhRS[ RS[R,          /# )r   Úimage_seq_lenÚchat_templateN)Úintr   )r   Ú__classdict__s   "€r   r   ÚIdefics2Processor.__annotate__>   s'   ø€ ÷ Rñ RÙ>AðRÙWZÐ]aÕWañRr   c                ó.  <€ \        VR4      '       g‡   \        RRRR7      P                  V n        \        RRRR7      P                  V n        RV P                  V P                  ./pVP                  V4       VP                  V P                  4      V n        M3VP                  V n        VP                  V n        VP                  V n        \        RRRR7      V n	        VP                  RV P                  ./4       W0n
        \        SV `1  WVR	7       R
# )aH  
image_seq_len (`int`, *optional*, defaults to 64):
    The length of the image sequence i.e. the number of <image> tokens per image in the input.
    This parameter is used to build the string from the input prompt and image tokens and should match the
    config.perceiver_config.resampler_n_latents value for the model used.
Úimage_tokenz<fake_token_around_image>FT)Ú
normalizedÚspecialz<image>Úadditional_special_tokensz<end_of_utterance>)r6   N)Úhasattrr   ÚcontentÚfake_image_tokenr;   r'   Úconvert_tokens_to_idsÚimage_token_idÚimage_boundary_tokenÚend_of_utterance_tokenr5   ÚsuperÚ__init__)ÚselfÚimage_processorÚ	tokenizerr5   r6   ÚkwargsÚtokens_to_addÚ	__class__s   &&&&&, €r   rG   ÚIdefics2Processor.__init__>   sù   ø€ ô �y -×0Ò0Ü$.Ð/JÐW\ÐfjÔ$k×$sÑ$sˆDÔ!Ü)¨)ÀÈtÔT×\Ñ\ˆDÔØ8¸4×;PÑ;PÐRV×RbÑRbÐ:cÐdˆMØ×(Ñ(¨Ô7Ø"+×"AÑ"AÀ$×BRÑBRÓ"SˆDÕà$-×$BÑ$BˆDÔ!Ø(×4Ñ4ˆDÔØ"+×":Ñ":ˆDÔä&0Ð1EÐRWÐaeÔ&fˆÔ#Ø×$Ñ$Ð&AÀD×D_ÑD_ÐC`Ð%aÔbØ*Ôä‰Ñ˜À=ÐÖQr   c                óö   € . pV Fp  p. pV FT  p\        V4      '       d   VP                  V4       K'  \        V4      '       g   K:  VP                  \        V4      4       KV  	  VP                  V4       Kr  	  V# r!   )r   Úappendr   r   )rH   ÚpromptsÚprompt_imagesÚpromptÚimagesr"   s   &&    r   Ú_extract_images_from_promptsÚ.Idefics2Processor._extract_images_from_promptsX   si   € ØˆÛˆFØˆFÛ�Ü! $×'Ò'Ø—M‘M $Ö'Ü˜D—\”\Ø—M‘M¤*¨TÓ"2Ö3ñ	 ð
 × Ñ  Ö(ñ ð Ðr   c          	      óÌ   <€ V ^8„  d   QhRS[ S[S[ ,          ,          S[S[S[ ,          ,          ,          RS[S[RS[S[,          S[R,          3,          RS[S[,          RS[/# )r   rT   Útextr   rK   r   )r   Úlistr   r   r   r%   r   )r   r8   s   "€r   r   r9   e   sw   ø€ ÷ X@ñ X@á™T¡*Õ-Õ-±±T¹*Õ5EÕ0FÕFðX@ñ ‘IÐ2±D¹µOÁTÐJ]ÕE^Ð^Õ_ðX@ñ Ñ0Õ1ð	X@ñ
 
ñX@r   c                óü  € Vf   Vf   \        R4      hV P                  ! \        3RV P                  P                  /VB pVR,          P                  RR 4      p. p/ pVEe“   \        V\        4      '       d   V.pM>\        V\        4      '       d   \        V^ ,          \        4      '       g   \        R4      hV P                  pV P                  p	V W�P                  ,           V 2p
V P                  P                  '       d
   V
^,          p
. p\        P                  ! \        P                   ! V4       R24      pV Fq  pVP#                  VP%                  V	4      4       VP'                  Wš4      pVP'                  V V 2V 4      pVP)                  V R2V4      pVP#                  V4       Ks  	  V P                  ! V3/ VR,          B pV P+                  W¾R.R	7       VP-                  V4       VEeä   \/        V4      '       d   V..pEM?\        V\        \0        34      '       d»   \/        V^ ,          4      '       d£   Ve›   \3        V4      \5        V4      8w  d+   \        R
X	 R\3        V4       RV	 R\5        V4       R2	4      h^ .\        \7        V4      4      ,           p\9        \5        V4      4       Uu. uF  pWV,          VV^,           ,           NK  	  ppMmV.pMi\        V\        \0        34      '       gN   \        V^ ,          \        \0        34      '       g+   \/        V^ ,          ^ ,          4      '       g   \        R4      hV Uu. uF  p\5        V4      NK  	  ppVe   VV8X  g   \        RV RV R24      hV UUu. uF  qÝ Uu. uF  p\;        V4      NK  	  upNK  	  pppV P                  ! V3/ VR,          B pVP-                  V4       \=        WuR7      # u upi u upi u upi u uppi )Nz+You must provide either `text` or `images`.Útokenizer_init_kwargsr&   Úreturn_tensorszAInvalid input text. Please provide a string, or a list of stringsz
(?=[^\s<])Ú Úimage)Ú
modalitieszThe total number of zP tokens in the prompts should be the same as the number of images passed. Found z tokens and z images.zdInvalid input images. Please provide a single image or a list of images or a list of list of images.z!The number of images in the text z and images  z should be the same.Úimages_kwargs)Útensor_type)Ú
ValueErrorÚ_merge_kwargsr%   rJ   Úinit_kwargsÚpopr   r   rY   rA   r;   r5   rI   Údo_image_splittingÚreÚcompileÚescaperP   ÚcountÚreplaceÚsubÚ_check_special_mm_tokensÚupdater#   ÚtupleÚsumÚlenr   Úranger   r   )rH   rT   rX   rK   Úoutput_kwargsr\   Ún_images_in_textÚinputsrA   r;   Ú	image_strÚprompt_stringsÚclosing_fake_patternÚsampleÚtext_inputsÚcumsum_images_in_textÚiÚn_images_in_imagesÚimÚimage_inputss   &&&,                r   Ú__call__ÚIdefics2Processor.__call__d   sç  € ð Š<˜FšNÜÐJÓKÐKà×*Ò*Ü#ñ
à"&§.¡.×"<Ñ"<ð
ð ñ
ˆð
 ' }Õ5×9Ñ9Ð:JÈDÓQˆàÐØˆàÓÜ˜$¤×$Ò$Ø�v‘Ü ¤d×+Ò+´:¸dÀ1½gÄs×3KÒ3KÜ Ð!dÓeÐeð  $×4Ñ4ÐØ×*Ñ*ˆKØ+Ð,¨[×;MÑ;MÕ-MÐ,NÐO_ÐN`ÐaˆIà×#Ñ#×6×6Ð6à%¨�M�	àˆNÜ#%§:¢:´"·)²)Ð<LÓ2MÐ1NÈjÐ.YÓ#ZÐ Û�Ø ×'Ñ'¨¯©°[Ó(AÔBØŸ™¨Ó?�àŸ™Ð+;Ð*<Ð=MÐ<NÐ(OÐTdÐSeÓg�à-×1Ñ1Ð5EÐ4FÀaÐ2HÈ&ÓQ�Ø×%Ñ% fÖ-ñ ð Ÿ.š.¨ÑX¸=ÈÕ;WÑXˆKØ×)Ñ)¨.ÐSZÐR[Ð)Ô\Ø�M‰M˜+Ô&àÓÜ$ V×,Ò,Ø!˜(˜’Ü˜F¤T¬5 M×2Ò2Ô7LÈVÐTUÍY×7WÒ7WØÒ#ÜÐ+Ó,´°F³Ô;Ü(Ø2°;°-ð @&Ü&)Ð*:Ó&;Ð%<¸A¸k¸]È,ÔWZÐ[aÓWbÐVcÐckðmóð ð
 ./¨C´$´zÐBRÓ7SÓ2TÕ,TÐ)ô "'¤sÐ+;Ó'<Ô!=óá!=˜Að °QÕ7Ð:OÐPQÐTUÕPUÕ:VÓWÙ!=ð ð �Fð
 %˜X‘Fô ˜v¬¬e }×5Ò5Ü" 6¨!¥9¬t´U¨m×<Ò<Ü-¨f°Q­i¸­l×;Ò;ä Øzóð ñ =CÓ!C¹F°&¤# f¦+¹FÐÐ!CØÒÐ(:Ð>NÔ(NÜ Ø7Ð8HÐ7IÈÐWiÐVjÐj~Ðóð ñ
 GMÔMÁf¸F°Ó7±¨"”z "–~±Ô7ÁfˆFÑMØ×/Ò/°ÑY¸-ÈÕ:XÑYˆLØ�M‰M˜,Ô'ä˜FÔ?Ð?ùò7ùò  "Dùò 8ùÓMs$   Ê>"O)ÍO.ÎO8ÎO3Î(O8Ï3O8)rE   rA   r5   r;   rC   )Né@   N)NN)r+   r,   r-   r.   r%   Úvalid_processor_kwargsrG   rU   r   r€   r0   Ú__classdictcell__Ú__classcell__)rM   r8   s   @@r   r3   r3   :   sB   ù‡ € à4Ð÷Rõ Rò4
ð ÷X@ñ X@ó ÷X@ð X@r   r3   ) Ú__doc__rg   Ú	itertoolsr   Útypingr   r   Úfeature_extraction_utilsr   Úimage_utilsr   r   r   Úprocessing_utilsr	   r
   r   Útokenization_utils_baser   r   Úutilsr   r   r   Ú
get_loggerr+   Úloggerr   r#   r%   r3   Ú__all__r*   r   r   Ú<module>r‘      s�   ðñó 
Ý  ß 'å 4ß AÑ A÷ñ ÷
 =ß ,÷ Ý<ð 
×	Ò	˜HÓ	%€õ;ò0ôÐ.°eõ ð ôB@˜ó B@ó ðB@ðJ Ð
‚r   