+
    œ°³jc%  ã                   ó–   € ^ RI t^RIHtHtHt ^RIHtHt ]P                  ! ]
4      t ! R R]RR7      t] ! R R	]4      4       tR	.tR# )
é    N)ÚMultiModalDataÚProcessingKwargsÚProcessorMixin)Úauto_docstringÚloggingc                   ó2   € ] tR t^tRRRRRRR/RRR//tR	tR
# )ÚGlm46VProcessorKwargsÚtext_kwargsÚpaddingFÚreturn_token_type_idsÚreturn_mm_token_type_idsTÚvideos_kwargsÚreturn_metadata© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú	_defaultsÚ__static_attributes__r   ó    Úm/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/glm46v/processing_glm46v.pyr	   r	      s-   † àØ�uØ# UØ&¨ð
ð
 	Ð+¨TÐ2ð„Ir   r	   F)Útotalc                   ó°   a a€ ] tR t^)t o]tRV 3R lltV3R lR ltV3R lR ltRR lt	RR lt
]V 3R l4       tV3R	 lR
 ltRV3R lR lltRtVtV ;t# )ÚGlm46VProcessorc                ó  <€ \        VR 4      '       g   RMVP                  V n        \        VR4      '       g   RMVP                  V n        \        VRR4      '       d   VP                  MVP                  V P                  4      V n        \        VRR4      '       d   VP                  MVP                  V P                  4      V n        \        SV `!  WW4R7       VP                  R4      V n	        VP                  R	4      V n
        R# )
Úimage_tokenz	<|image|>Úvideo_tokenz	<|video|>Úimage_token_idNÚvideo_token_id)Úchat_templatez<|begin_of_video|>z<|end_of_video|>)Úhasattrr   r   Úgetattrr   Úconvert_tokens_to_idsr    ÚsuperÚ__init__Úvideo_start_idÚvideo_end_id)ÚselfÚimage_processorÚ	tokenizerÚvideo_processorr!   ÚkwargsÚ	__class__s   &&&&&,€r   r&   ÚGlm46VProcessor.__init__-   së   ø€ Ü.5°iÀ×.OÒ.O™;ÐU^×UjÑUjˆÔÜ.5°iÀ×.OÒ.O™;ÐU^×UjÑUjˆÔô �yÐ"2°D×9Ò9ð ×$Ò$à×0Ñ0°×1AÑ1AÓBð 	Ôô �yÐ"2°D×9Ò9ð ×$Ò$à×0Ñ0°×1AÑ1AÓBð 	Ôô
 	‰Ñ˜°_ÐÔbØ'×=Ñ=Ð>RÓSˆÔØ%×;Ñ;Ð<NÓOˆÖr   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )é   Úimage_inputsÚ	image_idxÚreturn©ÚdictÚintÚstr)ÚformatÚ__classdict__s   "€r   Ú__annotate__ÚGlm46VProcessor.__annotate__>   s#   ø€ ÷ 3ñ 3±ð 3Áð 3ÑSVñ 3r   c                ó¬   € V P                   P                  ^,          pVR,          V,          P                  4       V,          pV P                  V,          # )r1   Úimage_grid_thw)r*   Ú
merge_sizeÚprodr   )r)   r2   r3   r-   Úmerge_lengthÚnum_image_tokenss   &&&,  r   Úreplace_image_tokenÚ#Glm46VProcessor.replace_image_token>   sI   € Ø×+Ñ+×6Ñ6¸Õ9ˆØ'Ð(8Õ9¸)ÕD×IÑIÓKÈ|Õ[ÐØ×ÑÐ"2Õ2Ð2r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )r1   Úvideo_inputsÚ	video_idxr4   r5   )r9   r:   s   "€r   r;   r<   C   s#   ø€ ÷ ñ ±ð Áð ÑSVñ r   c                óÜ  € V P                   P                  ^,          pVR,          V,          ^ ,          pVR,          V,          P                  4       V,          V,          pVR,          V,          pRpVP                  f   \        P                  R4       VP                  f   ^MVP                  Vn        VP                  R,          p	. p
\        ^ \        V	4      4       F  pV
P                  W›,          4       K  	  V
RV p\        V4      V8  d%   TP                  V'       d
   VR,          M^ 4       K4  \        V4       F%  pWÍ,          pV P                  WæR7      pW�,          pK'  	  V# )	r1   Úvideo_grid_thwÚvideo_metadataÚ Na  GLM46V requires frame timestamps to construct prompts, but the `fps` of the input video could not be inferred. Probably `video_metadata` was missing from inputs and you passed pre-sampled frames. Defaulting to `fps=24`. Please provide `video_metadata` for more accurate results.:NNr1   )rB   éÿÿÿÿ)r,   r?   r@   ÚfpsÚloggerÚwarning_onceÚ
timestampsÚrangeÚlenÚappendÚreplace_frame_token_id)r)   rF   rG   r-   rA   Ú
num_framesrB   ÚmetadataÚvideo_structurerP   Úunique_timestampsÚidxÚselected_timestampsÚ	frame_idxÚtimestamp_secÚframe_structures   &&&,            r   Úreplace_video_tokenÚ#Glm46VProcessor.replace_video_tokenC   sI  € Ø×+Ñ+×6Ñ6¸Õ9ˆØ!Ð"2Õ3°IÕ>¸qÕAˆ
Ø'Ð(8Õ9¸)ÕD×IÑIÓKÈ|Õ[Ð_iÕiÐØÐ 0Õ1°)Õ<ˆØˆà�<‰<ÒÜ×Ñðeôð
 &Ÿ\™\Ò1‘r°x·|±|ˆŒØ×(Ñ(¨Õ-ˆ
àÐÜ˜œC 
›OÖ,ˆCØ×$Ñ$ Z¥_Ö5ñ -ð 0°°Ð<ÐÜÐ%Ó&¨Ô3Ø×&Ñ&×BUÐ':¸2Ö'>Ð[\Ö]ä˜zÖ*ˆIØ/Õ:ˆMØ"×9Ñ9¸-Ð9ÓkˆOØÕ.ŠOñ +ð
 Ðr   c                óÚ  € / pVeÃ   \         P                  P                  R/ 4      pVP                  V4       VP                  RR4      ;'       g    V P                  P
                  pV Uu. uF"  pV P                  P                  ! . VOVN5!  NK$  	  ppV U	u. uF  q™V^,          ,          NK  	  p
p	VP                  RV
RV/4       Ve‚   \         P                  P                  R/ 4      pVP                  V4       V Uu. uF"  pV P                  P                  ! . VOVN5!  NK$  	  ppV U	u. uF  q™X^,          ,          NK  	  pp	WäR&   \        R/ VB # u upi u up	i u upi u up	i )	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.
    video_sizes (`list[list[int]]`, *optional*):
        The input sizes formatted as (num_frames, height, width) per each video.
Returns:
    `MultiModalData`: A `MultiModalData` object holding number of tokens per each of the provided
    input modalities, along with other useful data.
NÚimages_kwargsr?   rB   Únum_image_patchesr   Únum_video_tokensr   )
r	   r   ÚgetÚupdater*   r?   Úget_number_of_image_patchesr,   Úget_number_of_video_patchesr   )r)   Úimage_sizesÚvideo_sizesr-   Úvision_datara   r?   Ú
image_sizerb   Únum_patchesrB   r   Ú
video_sizeÚnum_video_patchesrc   s   &&&,           r   Ú_get_num_multimodal_tokensÚ*Glm46VProcessor._get_num_multimodal_tokensb   s‘  € ð ˆØÒ"Ü1×;Ñ;×?Ñ?ÀÐQSÓTˆMØ× Ñ  Ô(Ø&×*Ñ*¨<¸Ó>×aÐaÀ$×BVÑBV×BaÑBaˆJñ #.ó!á"-�Jð ×$Ñ$×@Ò@Ð\À*Ð\ÈmÖ\Ù"-ð ð !ñ SdÓdÑRcÀ;°
¸Aµ×!=Ð!=ÑRcÐÐdØ×ÑÐ 2Ð4DÐFYÐ[lÐmÔnàÒ"Ü1×;Ñ;×?Ñ?ÀÐQSÓTˆMØ× Ñ  Ô(ñ #.ó!á"-�Jð ×$Ñ$×@Ò@Ð\À*Ð\ÈmÖ\Ù"-ð ð !ñ SdÓdÑRcÀ;°
¸Aµ×!=Ð!=ÑRcÐÐdØ.>Ð*Ñ+äÑ, Ñ,Ð,ùò#!ùò  eùò!ùò  es   Á,(EÂEÄ(E#Ä0E(c                óD   € V P                   P                  ! V3RVRV/VB # )a*  
Post-process the output of the model to decode the text.

Args:
    generated_outputs (`torch.Tensor` or `np.ndarray`):
        The output of the model `generate` function. The output is expected to be a tensor of shape `(batch_size, sequence_length)`
        or `(sequence_length,)`.
    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.
    clean_up_tokenization_spaces (`bool`, *optional*, defaults to `False`):
        Whether or not to clean up the tokenization spaces. 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.
Úskip_special_tokensÚclean_up_tokenization_spaces)r+   Úbatch_decode)r)   Úgenerated_outputsrr   rs   r-   s   &&&&,r   Úpost_process_image_text_to_textÚ/Glm46VProcessor.post_process_image_text_to_textˆ   s;   € ð( �~‰~×*Ò*Øñ
à 3ð
ð *Fð
ð ñ	
ð 	
r   c                ó(   <€ \         SV `  R .,           # )Úmm_token_type_ids)r%   Úmodel_input_names)r)   r.   s   &€r   rz   Ú!Glm46VProcessor.model_input_names£   s   ø€ ä‰wÑ(Ð,?Ð+@Õ@Ð@r   c                óF   <€ V ^8„  d   QhRS[ RS[ S[ S[,          ,          /# )r1   Ú	input_idsr4   )Úlistr7   )r9   r:   s   "€r   r;   r<   §   s#   ø€ ÷ !ñ !±$ð !¹4ÁÁSÅ	½?ñ !r   c                ó¬  € . pV FË  p\         P                  ! V4      p\         P                  ! V4      p\         P                  ! W@P                  8H  ^ R7      p\         P                  ! W@P
                  8H  ^ R7      pWg8„  p^WTV P                  8H  V,          &   ^WTV P                  8H  V( ,          &   VP                  VP                  4       4       KÍ  	  V# )r   )Úaxis)	ÚnpÚarrayÚ
zeros_likeÚcumsumr'   r(   r   rS   Útolist)	r)   r}   ry   ÚinputÚ	array_idsÚmm_token_typesÚstartsÚendsÚis_video_modalitys	   &&       r   Úcreate_mm_token_type_idsÚ(Glm46VProcessor.create_mm_token_type_ids§   s¿   € ð ÐÛˆEÜŸš ›ˆIÜŸ]š]¨5Ó1ˆNô
 —Y’Y˜y×,?Ñ,?Ñ?ÀaÔHˆFÜ—9’9˜Y×*;Ñ*;Ñ;À!ÔDˆDØ &¡ÐàUVˆN¨×)<Ñ)<Ñ<Ð@QÕQÑRØXYˆN¨×)<Ñ)<Ñ<ÐBSÐASÕTÑUØ×$Ñ$ ^×%:Ñ%:Ó%<Ö=ñ ð !Ð r   c                ó    <€ V ^8„  d   QhRS[ /# )r1   rB   )r7   )r9   r:   s   "€r   r;   r<   ¼   s   ø€ ÷ uñ uÁcñ ur   c                ó8   € R V P                   V,           RVR R2# )z<|begin_of_image|>z<|end_of_image|>z.1fz seconds)r   )r)   r\   rB   s   &&&r   rT   Ú&Glm46VProcessor.replace_frame_token_id¼   s+   € Ø# D×$4Ñ$4Ð7GÕ$GÐ#HÐHXÐYfÐgjÐXkÐksÐtÐtr   )r   r   r(   r'   r   r    )NNNN)NN)TF)é   )r   r   r   r   r	   Úvalid_processor_kwargsr&   rC   r^   ro   rv   Úpropertyrz   rŒ   rT   r   Ú__classdictcell__Ú__classcell__)r.   r:   s   @@r   r   r   )   sb   ù‡ € à2Ð÷P÷"3ð 3÷
ð ô>$-ôL
ð6 ôAó ðA÷!ð !÷*u÷ uò ur   r   )Únumpyr�   Úprocessing_utilsr   r   r   Úutilsr   r   Ú
get_loggerr   rN   r	   r   Ú__all__r   r   r   Ú<module>r›      s`   ðó* ç PÑ Pß ,ð 
×	Ò	˜HÓ	%€ôÐ,°Eõ ð ôSu�nó Suó ðSuðl Ð
‚r   