+
    œ°³jc&  ã                   óê   € R 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 ^RIHtHtHtHtHt ^RIHtHt ^RIHtHt R	 R
 ltRR R llt ! R R]RR7      t] ! R R]4      4       tR.tR# )z"Image processor class for Pixtral.N)Ú
functional)ÚTorchvisionBackend)ÚBatchFeatureÚget_size_dict)Úgroup_images_by_shapeÚreorder_images)ÚChannelDimensionÚ
ImageInputÚPILImageResamplingÚSizeDictÚget_image_size)ÚImagesKwargsÚUnpack)Ú
TensorTypeÚauto_docstringc                ó€   € V ^8„  d   QhR\         \        \        3,          R\         \        \        3,          R\        /# )é   Ú
image_sizeÚ
patch_sizeÚreturn)ÚtupleÚint)Úformats   "Úu/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/pixtral/image_processing_pixtral.pyÚ__annotate__r      s2   € ÷ /ñ /¤%¬¬S¨¥/ð /¼uÄSÌ#ÀX½ð /ÔSVñ /ó    c                ó²   € V w  r#\        V\        \        34      '       d   TMW3w  rEV^,
          V,          ^,           pV^,
          V,          ^,           pWv3# )a,  
Calculate the number of image tokens given the image size and patch size.

Args:
    image_size (`tuple[int, int]`):
        The size of the image as `(height, width)`.
    patch_size (`tuple[int, int]`):
        The patch size as `(height, width)`.

Returns:
    `int`: The number of image tokens.
)Ú
isinstancer   Úlist)r   r   ÚheightÚwidthÚpatch_heightÚpatch_widthÚnum_width_tokensÚnum_height_tokenss   &&      r   Ú_num_image_tokensr%      sZ   € ð �M€FÜ.8¸ÄeÌTÀ]×.SÒ.S¡
ÐZdÐYqÑ€LØ �	 kÕ1°AÕ5ÐØ !�¨Õ4°qÕ8ÐØÐ.Ð.r   c          
      ó˜  € V ^8„  d   QhR\         R\        \        \        \        3,          ,          \        \        ,          ,          \        \        ,          ,          R\        \        \        \        3,          ,          \        \        ,          ,          \        \        ,          ,          R\        \
        ,          R,          R\        /# )r   Úinput_imageÚsizer   Úinput_data_formatNr   )r	   r   r   r   Ústrr   )r   s   "r   r   r   1   sŠ   € ÷ %Lñ %LÜð%Lä
””cœ3�h•Õ
¤$¤s¥)Õ
+¬e´C­jÕ
8ð%Lô ”eœC¤˜H•oÕ%¬¬S­	Õ1´E¼#µJÕ>ð%Lô Ô-Õ-°Õ4ð	%Lô
 ñ%Lr   c                óº  € \        V\        \        34      '       d   TMW3w  rE\        V\        \        34      '       d   TMW"3w  rg\        W4      w  r‰\	        W„,          W•,          4      p
V
^8”  dK   \        \        P                  ! WŠ,          4      4      p\        \        P                  ! Wš,          4      4      p	\        W‰3Wg34      w  r¼W¶,          WÇ,          3# )a  
Find the target (height, width) dimension of the output image after resizing given the input image and the desired
size.

Args:
    input_image (`ImageInput`):
        The image to resize.
    size (`int` or `tuple[int, int]`):
        Max image size an input image can be. Must be a dictionary with the key "longest_edge".
    patch_size (`int` or `tuple[int, int]`):
        The patch_size as `(height, width)` to use for resizing the image. If patch_size is an integer, `(patch_size, patch_size)`
        will be used
    input_data_format (`ChannelDimension`, *optional*):
        The channel dimension format of the input image. If unset, will use the inferred format from the input.

Returns:
    `tuple`: The target (height, width) dimension of the output image after resizing.
)	r   r   r   r   Úmaxr   ÚmathÚfloorr%   )r'   r(   r   r)   Ú
max_heightÚ	max_widthr!   r"   r   r    Úratior$   r#   s   &&&&         r   Úget_resize_output_image_sizer2   1   s¶   € ô0 %/¨t´e¼T°]×$CÒ$C™DÈ$ÈÑ€JÜ.8¸ÄeÌTÀ]×.SÒ.S¡
ÐZdÐYqÑ€LÜ" ;ÓB�M€Fä�Õ# UÕ%6Ó7€Eàˆq„yô ”T—Z’Z ¥Ó/Ó0ˆÜ”D—J’J˜u�}Ó-Ó.ˆä*;¸V¸OÈlÐMhÓ*iÑ'ÐØÕ+Ð-=Õ-KÐKÐKr   c                   ó0   a € ] tR t^Yt o RtV 3R ltRtV tR# )ÚPixtralImageProcessorKwargsz±
patch_size (`Union[dict[str, int], int]` *optional*, defaults to `{"height": 16, "width": 16}`):
    Size of the patches in the model, used to calculate the output image size.
c                óL   <€ V ^8„  d   Qh/ S[ S[S[3,          S[,          ;R&   # )r   r   )Údictr*   r   )r   Ú__classdict__s   "€r   r   Ú(PixtralImageProcessorKwargs.__annotate__Y   s   ø‡ ‚ ñ ‘S™#�X•¡Õ$Ñ$ò r   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r7   s   @r   r4   r4   Y   s   ø‡ € ñ÷ ƒ r   r4   F)Útotalc                   ó   a a€ ] tR t^bt o]P
                  t. ROt. ROtR^R^/t	RR/t
RtRtRtRtRt]tRR.tV3R lV 3R	 llt]V3R
 lV 3R ll4       tRV3R lV 3R llltV3R lR ltRV3R lR lltRtVtV ;t# )ÚPixtralImageProcessorr   r    Úlongest_edgei   TÚpixel_valuesÚimage_sizesc                ó0   <€ V ^8„  d   QhRS[ S[,          /# )r   Úkwargs)r   r4   )r   r7   s   "€r   r   Ú"PixtralImageProcessor.__annotate__r   s   ø€ ÷ #ñ #¡Ñ(CÕ!Dñ #r   c                ó(   <€ \         SV `  ! R/ VB  R # )Nr9   )ÚsuperÚ__init__)ÚselfrI   Ú	__class__s   &,€r   rM   ÚPixtralImageProcessor.__init__r   s   ø€ Ü‰ÒÑ"˜6Ô"r   c                ó<   <€ V ^8„  d   QhRS[ RS[S[,          RS[/# )r   ÚimagesrI   r   )r	   r   r4   r   )r   r7   s   "€r   r   rJ   v   s)   ø€ ÷ 4ñ 4¡ð 4±vÑ>YÕ7Zð 4Ñ_kñ 4r   c                ó&   <€ \         SV `  ! V3/ VB # ©N)rL   Ú
preprocess)rN   rR   rI   rO   s   &&,€r   rU   Ú PixtralImageProcessor.preprocessu   s   ø€ ä‰wÒ! &Ñ3¨FÑ3Ð3r   c          
      ó2   <€ V ^8„  d   QhRRRS[ RS[ RRRR/# )r   Úimageútorch.Tensorr(   r   Úresampleú7PILImageResampling | tvF.InterpolationMode | int | Noner   )r   )r   r7   s   "€r   r   rJ   y   s>   ø€ ÷ %
ñ %
àð%
ñ ð%
ñ ð	%
ð
 Lð%
ð 
ñ%
r   c           	     óð  <€ VP                   '       d   VP                   VP                   3pMHVP                  '       d,   VP                  '       d   VP                  VP                  3pM\        R4      hVP                  '       d,   VP                  '       d   VP                  VP                  3pM\        R4      h\	        WVR7      p\
        S	V `  ! V3R\        V^ ,          V^,          R7      RV/VB # )a%  
Resize an image. The longest edge of the image is resized to size["longest_edge"], with the aspect ratio
preserved. Output dimensions are aligned to patch_size.

Args:
    image (`torch.Tensor`):
        Image to resize.
    size (`SizeDict`):
        Dict containing the longest possible edge of the image.
    patch_size (`SizeDict`):
        Patch size used to calculate the size of the output image.
    resample (`PILImageResampling | tvF.InterpolationMode | int | None`, *optional*):
        Resampling filter to use when resizing the image.
z@size must contain either 'longest_edge' or 'height' and 'width'.z-patch_size must contain 'height' and 'width'.)r(   r   r(   )r   r    rZ   )rE   r   r    Ú
ValueErrorr2   rL   Úresizer   )
rN   rX   r(   r   rZ   rI   Ú
size_tupleÚpatch_size_tupleÚoutput_sizerO   s
   &&&&&,   €r   r^   ÚPixtralImageProcessor.resizey   sØ   ø€ ð, ××ÐØ×+Ñ+¨T×->Ñ->Ð?‰JØ�[�[ˆ[˜TŸZŸZ˜ZØŸ+™+ t§z¡zÐ2‰JäÐ_Ó`Ð`à××Ð ×!1×!1Ð!1Ø *× 1Ñ 1°:×3CÑ3CÐDÑäÐLÓMÐMä2°5ÐVfÔgˆÜ‰wŠ~Øñ
Ü ¨°A­¸kÈ!½nÔMð
ØX`ð
Ødjñ
ð 	
r   c                ó^   <€ V ^8„  d   QhRS[ R,          RS[ S[S[S[3,          ,          RR/# )r   rF   rY   rG   r   )r   r   r   )r   r7   s   "€r   r   rJ       s;   ø€ ÷ #ñ #á˜>Õ*ð#ñ ™%¡¡S �/Õ*ð#ð 
ñ	#r   c                ól  € \        R V 4       4      \        R V 4       4      3p\        W4       UUu. uF^  w  rE\        P                  P                  P                  V^ V^,          V^,          ,
          ^ V^ ,          V^ ,          ,
          3R7      NK`  	  ppp\        P                  ! V4      # u uppi )a;  
Pads images to form a batch of same shape.

Args:
    pixel_values (`list[torch.Tensor]`):
        A list of pixel values, each of shape (channels, height, width).
    image_sizes (`list[tuple[int, int]]`):
        A list of (height, width) for each image.

Returns:
    `torch.Tensor`: Stacked and padded images.
c              3   ó2   "  € T F  q^ ,          x € K  	  R# 5i)é    Nr9   ©Ú.0Úss   & r   Ú	<genexpr>Ú:PixtralImageProcessor._pad_for_batching.<locals>.<genexpr>±   s   é € Ð3¡{ !˜1Ÿš£{ùó   ‚c              3   ó2   "  € T F  q^,          x € K  	  R# 5i)é   Nr9   rg   s   & r   rj   rk   ±   s   é € Ð8SÁ{À!¸1¿ºÃ{ùrl   )Úpad)r,   ÚzipÚtorchÚnnr   ro   Ústack)rN   rF   rG   Ú	max_shapeÚimgr(   Úpaddeds   &&&    r   Ú_pad_for_batchingÚ'PixtralImageProcessor._pad_for_batching    s¤   € ô" Ñ3¡{Ó3Ó3´SÑ8SÁ{Ó8SÓ5SÐTˆ	ô ! Ô;ô
á;‘	�ô �H‰H×Ñ×#Ñ# C¨a°¸1µÀÀQÅÕ1GÈÈIÐVWÍLÐ[_Ð`aÕ[bÕLbÐ-cÐ#ÖdÙ;ð 	ñ 
ô �{Š{˜6Ó"Ð"ùó	
s   ³A$B0c                ó<  <€ V ^8„  d   QhRS[ R,          RS[RS[RRRS[RS[R	S[R
S[RS[RS[S[ S[,          ,          R,          RS[S[ S[,          ,          R,          RS[R,          RS[S[,          R,          RS[S[S[3,          S[,          R,          RS[/# )r   rR   rY   Ú	do_resizer(   rZ   r[   Údo_center_cropÚ	crop_sizeÚ
do_rescaleÚrescale_factorÚdo_normalizeÚ
image_meanNÚ	image_stdÚdisable_groupingÚreturn_tensorsr   r   )	r   Úboolr   Úfloatr*   r   r6   r   r   )r   r7   s   "€r   r   rJ   ¸   sã   ø€ ÷ 3
ñ 3
á�^Õ$ð3
ñ ð3
ñ ð	3
ð
 Lð3
ñ ð3
ñ ð3
ñ ð3
ñ ð3
ñ ð3
ñ ™D¡�KÕ'¨$Õ.ð3
ñ ™4¡�;Õ&¨Õ-ð3
ñ  �+ð3
ñ ™jÕ(¨4Õ/ð3
ñ ™™c˜•N¡XÕ-°Õ4ð3
ñ" 
ñ#3
r   c           	     óp  € \        T;'       g    V P                  R R7      p\        R	/ VB p\        WR7      w  pp/ pVP	                  4        F(  w  ppV'       d   V P                  VVVVR7      pVVV&   K*  	  \        VV4      p\        VVR7      w  ppV Uu. uF  pVP                  R
R NK  	  pp/ pVP	                  4        F9  w  ppV'       d   V P                  VV4      pV P                  VWxWšV4      pVVV&   K;  	  \        VV4      pV P                  VVR7      p\        RVRV/VR7      # u upi )T)Údefault_to_square)r‚   )rX   r(   r   rZ   N)rF   rG   rF   rG   )ÚdataÚtensor_typer9   éþÿÿÿ)r   r   r   r   Úitemsr^   r   ÚshapeÚcenter_cropÚrescale_and_normalizerw   r   )rN   rR   rz   r(   rZ   r{   r|   r}   r~   r   r€   r�   r‚   rƒ   r   rI   Úpatch_size_sdÚgrouped_imagesÚgrouped_images_indexÚresized_images_groupedÚkeyÚstacked_imagesÚresized_imagesrX   Úbatch_image_sizesÚprocessed_images_groupedÚprocessed_imagesÚpadded_imagess   &&&&&&&&&&&&&&&,            r   Ú_preprocessÚ!PixtralImageProcessor._preprocess¸   ss  € ô$ # :×#@Ð#@°·±ÐTXÔYˆ
Ü Ñ. :Ñ.ˆä/DÀVÔ/oÑ,ˆÐ,Ø!#ÐØ#1×#7Ñ#7Ö#9ÑˆC�ßØ!%§¡Ø(¨tÀÐX`ð "-ó "�ð +9Ð" 3Ó'ñ $:ô (Ð(>Ð@TÓUˆä/DÀ^ÐfvÔ/wÑ,ˆÐ,Ù;IÓJ¹>°%˜UŸ[™[¨¨Ó-¹>ÐÐJà#%Ð Ø#1×#7Ñ#7Ö#9ÑˆC�ßØ!%×!1Ñ!1°.À)Ó!L�Ø!×7Ñ7Ø 
¸LÐV_óˆNð -;Ð$ SÓ)ñ $:ô *Ð*BÐDXÓYÐØ×.Ñ.Ø)Ø)ð /ó 
ˆô
 Ø  -°Ð@QÐRÐ`nô
ð 	
ùò# Ks   ÂD3r9   )g3<Í4'ÐÞ?gwgí¶MÝ?gy{Îå Ú?)g�‡Bô91Ñ?g•wÝt.¹Ð?g�Ý	U¦Ñ?rT   )r:   r;   r<   r=   r
   ÚBICUBICrZ   r€   r�   r   r(   r‡   rz   r}   r   Údo_convert_rgbr4   Úvalid_kwargsÚmodel_input_namesrM   r   rU   r^   rw   rš   r@   rA   Ú__classcell__)rO   r7   s   @@r   rD   rD   b   s£   ù‡ € à!×)Ñ)€HÚ4€JÚ4€IØ˜B ¨Ð,€JØ˜DÐ!€DØÐØ€IØ€JØ€LØ€NØ.€Là'¨Ð7Ð÷#ó #ð ÷4ò 4ó ð4÷%
õ %
÷N#ð #÷03
÷ 3
ò 3
r   rD   rT   )r>   r-   rq   Útorchvision.transforms.v2r   ÚtvFÚimage_processing_backendsr   Úimage_processing_utilsr   r   Úimage_transformsr   r   Úimage_utilsr   r	   r
   r   r   Úprocessing_utilsr   r   Úutilsr   r   r%   r2   r4   rD   Ú__all__r9   r   r   Ú<module>rª      sl   ðñ )ã ã Ý 7å ;ß Aß Eß eÕ eß 4ß /õ/÷(%LôP% ,°eõ %ð ôH
Ð.ó H
ó ðH
ðV #Ð
#‚r   