+
    œ°³jé:  ã                   óR  € ^ RI t ^ RIt^ RIt^ RIH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 ^RIHtHtHt ^R	IHt ^R
IHt ^RIHt ^RI H!t!  ! R R]4      t" ! R R]RR7      t# ! R R]4      t$ ! R R]4      t% ! R R]RR7      t& ! R R]!4      t'. ROt(R# )é    N)Ú
functional)ÚBatchFeature)Úgroup_images_by_shapeÚreorder_images)ÚChannelDimensionÚPILImageResamplingÚSizeDictÚget_image_size)ÚImagesKwargsÚVideosKwargs)Ú
TensorType)ÚVideoMetadataÚgroup_videos_by_shapeÚreorder_videos)ÚGlm46VConfig)ÚGlm46VImageProcessor)ÚGlm46VImageProcessorPil)ÚGlm46VVideoProcessorc                   ó   € ] tR t^)tRtRtRtR# )ÚGlmgaConfigar  
image_start_token_id (`int`, *optional*, defaults to 151339):
    The image start token index to encode the start of image.
image_end_token_id (`int`, *optional*, defaults to 151340):
    The image end token index to encode the end of image.
video_start_token_id (`int`, *optional*, defaults to 151361):
    The video start token index to encode the start of video.
video_end_token_id (`int`, *optional*, defaults to 151362):
    The video end token index to encode the end of video.

```python
>>> from transformers import AutoModelForImageTextToText, GlmgaConfig

>>> # Initializing a Glmga style configuration
>>> configuration = GlmgaConfig()

>>> # Initializing a model (reusing the GLM-4.6V implementation) from that configuration
>>> model = AutoModelForImageTextToText.from_config(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```Úglmga© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú
model_typeÚ__static_attributes__r   ó    Úh/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/glmga/modular_glmga.pyr   r   )   s   † ñð. „Jr    r   c                   ó0   a € ] tR t^Dt o RtV 3R ltRtV tR# )ÚGlmgaImageProcessorKwargsa°  
patch_size (`int`, *optional*, defaults to 14):
    The spatial patch size of the vision encoder.
temporal_patch_size (`int`, *optional*, defaults to 2):
    The temporal patch size of the vision encoder.
merge_size (`int`, *optional*, defaults to 2):
    The merge size of the vision encoder to llm encoder.
patch_expand_factor (`int`, *optional*, defaults to 1):
    The patch_expand_factor of the vision encoder to llm encoder.
c                óJ   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   # )é   Ú
patch_sizeÚtemporal_patch_sizeÚ
merge_sizeÚpatch_expand_factor)Úint)ÚformatÚ__classdict__s   "€r!   Ú__annotate__Ú&GlmgaImageProcessorKwargs.__annotate__D   s7   ø‡ ‚ ñ �Oñ ñ Ññ ñ �Oñ ñ Ñò r    r   N©r   r   r   r   r   Ú__annotate_func__r   Ú__classdictcell__©r,   s   @r!   r#   r#   D   s   ø‡ € ñ	÷ ƒ r    r#   F)Útotalc                   ó6   a € ] tR t^Vt o ^tV 3R lR ltRtV tR# )ÚGlmgaImageProcessorc                 ó  <€ V ^8„  d   QhRS[ R,          RS[RS[RRRS[RS[R	S[R
S[S[ S[,          ,          R,          RS[S[ S[,          ,          R,          RS[RS[RS[RS[RS[R,          RS[S[,          R,          RS[/# )r%   Úimagesztorch.TensorÚ	do_resizeÚsizeÚresampleú7PILImageResampling | tvF.InterpolationMode | int | NoneÚ
do_rescaleÚrescale_factorÚdo_normalizeÚ
image_meanNÚ	image_stdr&   r'   r(   r)   Údisable_groupingÚreturn_tensorsÚreturn)ÚlistÚboolr	   Úfloatr*   Ústrr   r   )r+   r,   s   "€r!   r-   Ú GlmgaImageProcessor.__annotate__Y   sÛ   ø€ ÷ ?
ñ ?
á�^Õ$ð?
ñ ð?
ñ ð	?
ð
 Lð?
ñ ð?
ñ ð?
ñ ð?
ñ ™D¡�KÕ'¨$Õ.ð?
ñ ™4¡�;Õ&¨Õ-ð?
ñ ð?
ñ !ð?
ñ ð?
ñ !ð?
ñ  �+ð?
ñ  ™jÕ(¨4Õ/ð!?
ñ$ 
ñ%?
r    c           	     ó¢  € \        WR7      w  pp/ pVP                  4        F6  w  ppV'       d$   V P                  VVVW¬,          V,          VR7      pVVV&   K8  	  \        VV4      p\        VVR7      w  pp/ p/ pVP                  4        FQ  w  ppV P	                  VWVWxV	4      pV P                  VV
VVR7      w  pppVVV&   ^VV..\        V4      ,          VV&   KS  	  \        VV4      p\        VV4      p\        V4      ^8X  d
   V^ ,          M\        P                  ! V^ R7      p\        P                  ! V4      p\        RVRV/VR7      # )z)
Preprocess an image or batch of images.
)rA   )r7   r9   r:   ÚfactorÚtemporal_factor©r&   r(   r'   ©ÚdimÚpixel_valuesÚimage_grid_thw©ÚdataÚtensor_type)r   ÚitemsÚresizer   Úrescale_and_normalizeÚpatchifyÚlenÚtorchÚcatÚtensorr   )Úselfr7   r8   r9   r:   r<   r=   r>   r?   r@   r&   r'   r(   r)   rA   rB   ÚkwargsÚgrouped_imagesÚgrouped_images_indexÚresized_images_groupedÚshapeÚstacked_imagesÚresized_imagesÚprocessed_images_groupedÚprocessed_gridsÚpatchesÚgrid_hÚgrid_wÚprocessed_imagesrO   rP   s   &&&&&&&&&&&&&&&&,              r!   Ú_preprocessÚGlmgaImageProcessor._preprocessY   s‘  € ô. 0EÀVÔ/oÑ,ˆÐ,Ø!#ÐØ%3×%9Ñ%9Ö%;Ñ!ˆE�>ßØ!%§¡Ø)ØØ%Ø%Õ2Ð5HÕHØ$7ð "-ó "�ð -;Ð" 5Ó)ñ &<ô (Ð(>Ð@TÓUˆä/DÀ^ÐfvÔ/wÑ,ˆÐ,Ø#%Ð Øˆà%3×%9Ñ%9Ö%;Ñ!ˆE�>Ø!×7Ñ7Ø 
¸LÐV_óˆNð '+§m¡mØØ%Ø%Ø$7ð	 '4ó 'Ñ#ˆG�V˜Vð /6Ð$ UÑ+Ø'(¨&°&Ð&9Ð%:¼SÀÓ=PÕ%PˆO˜EÓ"ñ &<ô *Ð*BÐDXÓYÐÜ(¨Ð:NÓOˆä.1Ð2BÓ.CÀqÔ.HÐ'¨Ö*ÌeÏiÊiÐXhÐnoÔNpˆÜŸš oÓ6ˆäØ  ,Ð0@À.ÐQÐ_mô
ð 	
r    r   N©r   r   r   r   r)   rj   r   r1   r2   s   @r!   r5   r5   V   s   ø‡ € ØÐ÷?
ö ?
r    r5   c                   ó6   a € ] tR t^›t o ^tV 3R lR ltRtV tR# )ÚGlmgaImageProcessorPilc                ó  <€ V ^8„  d   QhRS[ S[P                  ,          RS[RS[RRRS[RS[RS[R	S[S[ S[,          ,          R
,          RS[S[ S[,          ,          R
,          RS[RS[RS[RS[RS[S[,          R
,          RS[	/# )r%   r7   r8   r9   r:   zPILImageResampling | int | Noner<   r=   r>   r?   Nr@   r)   r&   r'   r(   rB   rC   )
rD   ÚnpÚndarrayrE   r	   rF   r*   rG   r   r   )r+   r,   s   "€r!   r-   Ú#GlmgaImageProcessorPil.__annotate__ž   sÐ   ø€ ÷ 9
ñ 9
á‘R—Z‘ZÕ ð9
ñ ð9
ñ ð	9
ð
 4ð9
ñ ð9
ñ ð9
ñ ð9
ñ ™D¡�KÕ'¨$Õ.ð9
ñ ™4¡�;Õ&¨Õ-ð9
ñ !ð9
ñ ð9
ñ !ð9
ñ ð9
ñ ™jÕ(¨4Õ/ð9
ñ" 
ñ#9
r    c           	     óÆ  € . p. pV F™  pV'       d   V P                  VVVW½,          VR7      pV'       d   V P                  VV4      pV'       d   V P                  VW‰4      pV P                  VVVVR7      w  pppVP	                  V4       VP	                  ^VV.4       K›  	  \
        P                  ! V^ R7      p\
        P                  ! V4      p\        RVRV/VR7      # )z/
Preprocess images one by one for PIL backend.
)r9   r:   rJ   rK   rL   )ÚaxisrO   rP   rQ   )	rU   ÚrescaleÚ	normalizerW   Úappendrp   ÚconcatenateÚarrayr   )r\   r7   r8   r9   r:   r<   r=   r>   r?   r@   r)   r&   r'   r(   rB   r]   ri   re   Úimagerf   rg   rh   rO   rP   s   &&&&&&&&&&&&&&&,        r!   rj   Ú"GlmgaImageProcessorPil._preprocessž   sò   € ð* ÐØˆãˆEßØŸ™ØØØ%Ø%Õ2Ø$7ð $ó �÷ ØŸ™ U¨NÓ;�ßØŸ™ u¨jÓD�à&*§m¡mØØ%Ø%Ø$7ð	 '4ó 'Ñ#ˆG�V˜Vð ×#Ñ# GÔ,Ø×"Ñ" A v¨vÐ#6Ö7ñ3 ô8 —~’~Ð&6¸QÔ?ˆÜŸš /Ó2ˆäØ  ,Ð0@À.ÐQÐ_mô
ð 	
r    r   Nrl   r2   s   @r!   rn   rn   ›   s   ø‡ € ØÐ÷9
ö 9
r    rn   c                   ó0   a € ] tR t^Út o RtV 3R ltRtV tR# )ÚGlmgaVideoProcessorInitKwargsaœ  
patch_size (`int`, *optional*, defaults to 14):
    The spatial patch size of the vision encoder.
temporal_patch_size (`int`, *optional*, defaults to 2):
    The temporal patch size of the vision encoder.
merge_size (`int`, *optional*, defaults to 2):
    The merge size of the vision encoder to llm encoder.
max_frames (`int`, *optional*, defaults to 640):
    The maximum number of frames that can be sampled.
max_image_size (`dict`, *optional*, defaults to `28 * 28 * 2 * 55790`):
    The maximum pixels a video can be resized to.
patch_expand_factor (`int`, *optional*, defaults to 1):
    The factor that will be multiplied to `patch_size` when resizing videos.
c                óx   <€ V ^8„  d   Qh/ S[ S[S[3,          ;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[;R&   # )r%   Úmax_image_sizer&   r'   r(   r)   Ú
max_frames)ÚdictrG   r*   )r+   r,   s   "€r!   r-   Ú*GlmgaVideoProcessorInitKwargs.__annotate__Ú   sX   ø‡ ‚ ñ  ™™c˜•NÑ"ñ! ñ" �Oñ# ñ$ Ññ% ñ& �Oñ' ñ( Ññ) ñ* �Oò+ r    r   Nr/   r2   s   @r!   r}   r}   Ú   s   ø‡ € ñ÷ ƒ r    r}   c                   óœ   a € ] tR t^òt o RRRR/tRR/t^t^tRtRV 3R lR llt	RRR]
P                  RRRRRRRRRR3V 3R lR	 lltR
tV tR# )ÚGlmgaVideoProcessorÚshortest_edgeÚlongest_edgei€  Nc                óD   <€ V ^8„  d   QhRS[ RS[S[,          R,          /# )r%   ÚmetadataÚfpsN)r   r*   rF   )r+   r,   s   "€r!   r-   Ú GlmgaVideoProcessor.__annotate__ù   s,   ø€ ÷ A)ñ A)áðA)ñ ‘5�[˜4ÕñA)r    c                óx  € Ve   \        VRR4      f   \        R4      hVP                  pV^,
          pVP                  ;'       g#    \	        WQP
                  ,          4      ^,           pVe   TMV P
                  p\        Wg,          4      p\        W€P                  4      p^VP
                  ,          p	\        V4       U
u. uF  qªV	,          NK  	  pp
WH8  d=   \        V4       Uu. uF&  p\        P                  ! WÄ,          V,          4      NK(  	  ppMW. p^ p^V,          p\        V4       F;  pVV,          V8¼  g   K  Wï,          pVP                  V4       WæV,
          8¼  g   K;   M	  \        V4      V8  df   \        V4      ^ 8X  d   ^ \        V^,
          ^ 4      ppMV^ ,          VR,          pp\        P                   ! VVV\        R7      P#                  4       pMC\        V4      V8”  d4   \        P                   ! ^ V^,
          V\        R7      P#                  4       p\%        4       . ppV F.  pVV9  g   K  VP'                  V4       VP                  V4       K0  	  \        V4      ^,          '       d   VP                  VR,          4       \        P(                  ! V\        R7      # u up
i u upi )a?  
Args:
    metadata (`VideoMetadata`):
        Metadata of the video containing information about total duration, fps and total number of frames.
    fps (`int` or `float`, *optional*):
        Target frames to sample per second. Defaults to `self.fps`.
Returns:
    np.ndarray:
        Indices to sample video frames.
Nr‰   z´Asked to sample frames per second but no video metadata was provided which is required when sampling in Glmga. Please pass in `VideoMetadata` object or set `do_sample_frames=False`)Údtypeéÿÿÿÿ)ÚgetattrÚ
ValueErrorÚtotal_num_framesÚdurationÚroundr‰   r*   Úminr€   ÚrangeÚmathÚfloorrw   rX   Úmaxrp   ÚlinspaceÚtolistÚsetÚaddry   )r\   rˆ   r‰   r]   Útotal_framesÚmax_frame_idxr‘   Ú
target_fpsÚ	extract_tÚduration_per_frameÚiÚ
timestampsÚ_iÚframe_indicesÚcurrent_secondÚinv_fpsÚframe_indexÚstartÚendÚseenÚuniqÚidxs   &&&,                  r!   Úsample_framesÚ!GlmgaVideoProcessor.sample_framesù   sK  € ð  Òœw x°¸Ó=ÒEÜðXóð ð
  ×0Ñ0ˆØ$ qÕ(ˆØ×$Ñ$×OÐO¬¨m¿l¹lÕ.JÓ(KÈaÕ(OˆàšO‘S°·±ˆ
ä˜Õ-Ó.ˆ	Ü˜	§?¡?Ó3ˆ	à §¡Õ-ÐÜ6;¸LÔ6IÓJÑ6I°Ð,×,Ð,Ñ6Iˆ
ÐJàÔ#ÜQVÐW`ÔQaÓbÑQaÈ2œTŸZšZ¨Õ(9¸IÕ(EÖFÑQaˆMÐbˆMàˆMØˆNØ˜*•nˆGÜ$ \Ö2�Ø˜kÕ*¨nÖ<Ø"Õ-�NØ!×(Ñ(¨Ô5Ø%°GÕ);Ö;Ùñ  3ô ˆ}Ó 	Ô)Ü�=Ó! QÔ&Ø¤ L°1Õ$4°aÓ 8�s��sà*¨1Õ-¨}¸RÕ/@�s�ÜŸKšK¨¨s°IÄSÔI×PÑPÓR‰MÜ�Ó )Ô+ÜŸKšK¨¨<¸!Õ+;¸YÌcÔR×YÑYÓ[ˆMä“U˜BˆdˆÛ ˆCØ˜$ŽØ—‘˜”Ø—‘˜CÖ ñ !ô
 ˆt‹9�q�=Œ=Ø�K‰K˜˜R�Ô!ä�xŠx˜¤CÔ(Ð(ùòC Kùò cs   ÃJ2Ã(,J7Tc                óV  <€ V ^8„  d   QhRS[ S[P                  ,          RS[RS[RS[R,          RRRS[R	S[R
S[RS[S[ S[,          ,          R,          RS[S[ S[,          ,          R,          RS[R,          RS[R,          RS[R,          RS[R,          RS[S[,          R,          /# )r%   ÚvideosÚdo_convert_rgbr8   r9   Nr:   r;   r<   r=   r>   r?   r@   r)   r&   r'   r(   rB   )	rD   rY   ÚTensorrE   r	   rF   r*   rG   r   )r+   r,   s   "€r!   r-   rŠ   <  s  ø€ ÷ CCñ CCá‘U—\‘\Õ"ðCCñ ðCCñ ð	CCñ
 ˜�oðCCð LðCCñ ðCCñ ðCCñ ðCCñ ™D¡�KÕ'¨$Õ.ðCCñ ™4¡�;Õ&¨Õ-ðCCñ ! 4�ZðCCñ ˜$•JðCCñ ! 4�ZðCCñ ˜$•JðCCñ  ™jÕ(¨4Õ/ñ!CCr    c           	     óì  € \        V4      w  pp/ pVP                  4        FO  w  ppV'       d   V P                  V4      pV'       d$   V P                  VVVWÎ,          V,          VR 7      pVVV&   KQ  	  \	        VV4      p\        V4      w  pp/ p/ pVP                  4        Fw  w  pp\        V^ ,          \        P                  R7      w  ppV P                  VWgW‰V
4      pV P                  VVVVR7      w  ppppVVV&   VVV..\        V4      ,          VV&   Ky  	  \	        VV4      p\	        VV4      p\        P                  ! V^ R7      p \        P                  ! V4      p!RV RV!/p"\        V"VR7      # ))r°   r9   r:   rJ   rK   )Úchannel_dimrL   rM   Úpixel_values_videosÚvideo_grid_thwrQ   )r   rT   Úconvert_to_rgbrU   r   r
   r   ÚFIRSTrV   rW   rX   rY   rZ   r[   r   )#r\   r°   r±   r8   r9   r:   r<   r=   r>   r?   r@   r)   r&   r'   r(   rB   r]   Úgrouped_videosÚgrouped_videos_indexÚresized_videos_groupedra   Ústacked_videosÚresized_videosÚprocessed_videos_groupedre   Úresized_heightÚresized_widthrf   Úgrid_trg   rh   Úprocessed_videosrµ   r¶   rR   s#   &&&&&&&&&&&&&&&&,                  r!   rj   ÚGlmgaVideoProcessor._preprocess<  s´  € ô& 0EÀVÓ/LÑ,ˆÐ,Ø!#Ðà%3×%9Ñ%9Ö%;Ñ!ˆE�>ßØ!%×!4Ñ!4°^Ó!D�ßØ!%§¡Ø)ØØ%Ø%Õ2Ð5HÕHØ$7ð "-ó "�ð -;Ð" 5Ó)ñ &<ô (Ð(>Ð@TÓUˆô 0EÀ^Ó/TÑ,ˆÐ,Ø#%Ð ØˆØ%3×%9Ñ%9Ö%;Ñ!ˆE�>Ü,:¸>È!Õ;LÔZj×ZpÑZpÔ,qÑ)ˆN˜Mð "×7Ñ7Ø 
¸LÐV_óˆNð /3¯m©mØØ%Ø%Ø$7ð	 /<ó /Ñ+ˆG�V˜V Vð /6Ð$ UÑ+Ø'-¨v°vÐ&>Ð%?Ä#ÀnÓBUÕ%UˆO˜EÓ"ñ &<ô" *Ð*BÐDXÓYÐÜ(¨Ð:NÓOˆÜ#ŸišiÐ(8¸aÔ@ÐÜŸš oÓ6ˆà!Ð#6Ø˜nð
ˆô
  °>ÔBÐBr    r   i 1  iÀÑ6)Ngp?)r   r   r   r   r9   r   r‰   r)   r€   r­   r   ÚBICUBICrj   r   r1   r2   s   @r!   r„   r„   ò   sƒ   ø‡ € Ø˜Y¨Ð8KÐL€DØ$Ð&9Ð:€NØ
€CØÐØ€J÷A)ò A)ðL  $ØØ $ØN`×NhÑNhØØ )Ø!Ø15Ø04Ø*.Ø!%Ø*.Ø!%Ø26÷!CC÷ CCð CCr    r„   )r   r5   rn   r„   ))r•   Únumpyrp   rY   Útorchvision.transforms.v2r   ÚtvFÚimage_processing_utilsr   Úimage_transformsr   r   Úimage_utilsr   r   r	   r
   Úprocessing_utilsr   r   Úutilsr   Úvideo_utilsr   r   r   Úglm46v.configuration_glm46vr   Úglm46v.image_processing_glm46vr   Ú"glm46v.image_processing_pil_glm46vr   Úglm46v.video_processing_glm46vr   r   r#   r5   rn   r}   r„   Ú__all__r   r    r!   Ú<module>rÓ      sœ   ðó ã Û Ý 7å 2ß E÷ó ÷ ;Ý ß OÑ OÝ 6Ý AÝ HÝ Aô�,ô ô6 °Eõ ô$B
Ð.ô B
ôJ<
Ð4ô <
ô~ L¸õ ô0MCÐ.ô MCò`‚r    