+
    œ°³jë  ã                   óÖ   € R t ^ RIt^ RIHt ^RIHt ^RIHt ^RI	H
t
HtHt ^RIHtHt ^RIHtHt  ! R R	]R
R7      tRR R lltR R ltRR R llt] ! R R]4      4       tR.tR# )z"Image processor class for SigLIP2.N)Ú
functional)ÚTorchvisionBackend)ÚBatchFeature)Ú
ImageInputÚPILImageResamplingÚSizeDict)ÚImagesKwargsÚUnpack)Ú
TensorTypeÚauto_docstringc                   ó0   a € ] tR t^t o RtV 3R ltRtV tR# )ÚSiglip2ImageProcessorKwargsaZ  
patch_size (`int`, *optional*, defaults to `self.patch_size`):
    The size (resolution) of each patch the image will be split to.
max_num_patches (`int`, *optional*, defaults to `self.max_num_patches`):
    The image will be resized to have at most this number of patches,
    and then padded in "patch" dimension to match this number exactly.
c                ó2   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   # )é   Ú
patch_sizeÚmax_num_patches©Úint)ÚformatÚ__classdict__s   "€Úu/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/siglip2/image_processing_siglip2.pyÚ__annotate__Ú(Siglip2ImageProcessorKwargs.__annotate__   s   ø‡ ‚ ñ �Oñ ñ Ñò ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r      s   ø‡ € ñ÷ ƒ r   r   F)Útotalc                ó‚   € V ^8„  d   QhR\         R\         R\         R\         R\        R\        \         \         3,          /# )r   Úimage_heightÚimage_widthr   r   ÚepsÚreturn)r   ÚfloatÚtuple)r   s   "r   r   r   *   sD   € ÷ -'ñ -'Üð-'Ü$'ð-'Ü58ð-'ÜKNð-'ÜUZð-'ä
Œ3”ˆ8…_ñ-'r   c                ó  a€ ^ RI oR V3R llpV^
,          RrvWv,
          V8¼  dE   Wg,           ^,          pV! W€V4      p	V! W�V4      p
W’,          W¢,          ,          pW³8:  d   TpKM  TpKQ  TpV! W€V4      p	V! W�V4      p
Wš3# )aæ  
Determine image size based on max number of patches, ensure dimensions are divisible by patch size and image is at least 1 patch.

Args:
    image_height (`int`):
        Original image height.
    image_width (`int`):
        Original image width.
    patch_size (`int`):
        Patch size for processing.
    max_num_patches (`int`):
        Maximum number of patches.
    eps (`float`):
        Small threshold for binary search.

Returns:
    Tuple: (target_height, target_width)
Nc                óH   € V ^8„  d   QhR\         R\        R\        R\        /# )r   ÚscaleÚsizer   r(   )r)   r   )r   s   "r   r   Ú8get_image_size_for_max_num_patches.<locals>.__annotate__A   s(   € ÷  ñ  ¤Uð  ´#ð  Ä3ð  Ì3ñ  r   c                 ó|   <€ W,          pSP                  W2,          4      V,          p\        W#4      p\        V4      # ©N)ÚceilÚmaxr   )r-   r.   r   Úscaled_sizeÚmaths   &&& €r   Úget_scaled_image_sizeÚAget_image_size_for_max_num_patches.<locals>.get_scaled_image_sizeA   s5   ø€ Ø•lˆØ—i‘i Õ 8Ó9¸JÕFˆÜ˜*Ó2ˆÜ�;ÓÐr   g      Y@)r5   )r%   r&   r   r   r'   r6   Ú	scale_minÚ	scale_maxr-   Útarget_heightÚtarget_widthÚnum_patchesr5   s   &&&&&       @r   Ú"get_image_size_for_max_num_patchesr=   *   s•   ø€ ó* ÷ ð  ð  �8 UˆyØÕ  SÔ
(ØÕ&¨!Õ+ˆÙ-¨eÀ:ÓNˆÙ,¨UÀÓLˆØ$Õ1°lÕ6OÕPˆàÔ)ØŠIàŠIà€EÙ)¨%¸zÓJ€MÙ(¨¸ZÓH€LØÐ&Ð&r   c                ó,   € V ^8„  d   QhRRR\         RR/# )r   Úimageútorch.Tensorr   r(   r   )r   s   "r   r   r   Z   s!   € ÷ ñ  Nð Äð Èñ r   c                óÄ   € V P                   w  r#pW1,          pWA,          pV P                  W%WV4      pVP                  ^^^^^ 4      pVP                  WV,          R4      pV# )zÁ
Convert 3D tensor image of shape (num_channels, image_height, image_width) into 2D tensor of patches of shape
(num_patches_height * num_patches_width, patch_size * patch_size * num_channels).
éÿÿÿÿ)ÚshapeÚreshapeÚpermute)r?   r   Únum_channelsr%   r&   Únum_patches_heightÚnum_patches_widthÚpatched_images   &&      r   Úconvert_image_to_patchesrJ   Z   sl   € ð
 /4¯k©kÑ+€L Ø%Õ3ÐØ#Õ1ÐØ—M‘M ,ÀJÐcmÓn€MØ!×)Ñ)¨!¨Q°°1°aÓ8€MØ!×)Ñ)Ð*<Õ*PÐRTÓU€MØÐr   c          	      óN   € V ^8„  d   QhRRR\         R\         R\        R,          /# )r   Útensorr@   Útarget_lengthÚ	pad_valuer(   )r@   r@   )r   r*   )r   s   "r   r   r   h   s2   € ÷ ñ ØðÜ+.ðÜ;>ðä
Ð)Õ*ñr   c                óF  € V P                   ^ ,          pW,
          p\        P                  ! V3\        P                  R7      pV^ 8”  dW   ^ ^ .V P                  ^,
          ,          ^ V.,           p\        P
                  P                  P                  WRVR7      p ^ WT) R% W3# )z+
Pad the tensor along the first dimension.
)ÚdtypeÚconstant)ÚmodeÚvalueN)rC   ÚtorchÚonesÚint32ÚndimÚnnr   Úpad)rL   rM   rN   Úcurrent_lengthÚpadding_lengthÚmaskÚpaddings   &&&    r   Úpad_along_first_dimr^   h   s�   € ð —\‘\ !•_€NØ"Õ3€NÜ�:Š:�}Ð&¬e¯k©kÔ:€DØ˜ÔØ�a�&˜FŸK™K¨!�OÕ,°°>Ð/BÕBˆÜ—‘×$Ñ$×(Ñ(¨¸zÐQZÐ(Ó[ˆØ!"ˆˆ_ÐÐØˆ<Ðr   c                   óÒ   a a€ ] tR t^xt o]t]P                  t. ROt	. ROt
RtRtRt^tRt. ROtV3R lV 3R llt]V3R lV 3R ll4       tV3R lV 3R lltV3R	 lR
 ltRtVtV ;t# )ÚSiglip2ImageProcessorTé   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# )r   Úkwargs)r	   r   )r   r   s   "€r   r   Ú"Siglip2ImageProcessor.__annotate__…   s   ø€ ÷ #ñ #¡Ñ(CÕ!Dñ #r   c                ó(   <€ \         SV `  ! R/ VB  R # )Nr   )ÚsuperÚ__init__©Úselfrc   Ú	__class__s   &,€r   rg   ÚSiglip2ImageProcessor.__init__…   s   ø€ Ü‰ÒÑ"˜6Ô"r   c                ó<   <€ V ^8„  d   QhRS[ RS[S[,          RS[/# )r   Úimagesrc   r(   )r   r	   r   r   )r   r   s   "€r   r   rd   ‰   s)   ø€ ÷ 4ñ 4¡ð 4±vÑ>YÕ7Zð 4Ñ_kñ 4r   c                ó&   <€ \         SV `  ! V3/ VB # r1   )rf   Ú
preprocess)ri   rm   rc   rj   s   &&,€r   ro   Ú Siglip2ImageProcessor.preprocessˆ   s   ø€ ä‰wÒ! &Ñ3¨FÑ3Ð3r   c                ó    <€ V ^8„  d   QhRS[ /# )r   r(   )r*   )r   r   s   "€r   r   rd   Œ   s   ø€ ÷ =ñ =±uñ =r   c                óH   <€ VP                  R R4       \        SV `  ! R/ VB # )Ú	do_resizeNr   )Úpoprf   Ú_validate_preprocess_kwargsrh   s   &,€r   ru   Ú1Siglip2ImageProcessor._validate_preprocess_kwargsŒ   s$   ø€ à�
‰
�; Ô%Ü‰wÒ2Ñ<°VÑ<Ð<r   c                óè   <€ V ^8„  d   QhRS[ R,          RS[RS[RS[RRRS[R	S[R
S[RS[S[ S[,          ,          R,          RS[S[ S[,          ,          R,          RS[S[,          R,          RS[/# )r   rm   r@   rs   r   r   Úresamplez7PILImageResampling | tvF.InterpolationMode | int | NoneÚ
do_rescaleÚrescale_factorÚdo_normalizeÚ
image_meanNÚ	image_stdÚreturn_tensorsr(   )ÚlistÚboolr   r)   Ústrr
   r   )r   r   s   "€r   r   rd   ‘   s¯   ø€ ÷ 3ñ 3á�^Õ$ð3ñ ð3ñ ð	3ñ
 ð3ð Lð3ñ ð3ñ ð3ñ ð3ñ ™D¡�KÕ'¨$Õ.ð3ñ ™4¡�;Õ&¨Õ-ð3ñ ™jÕ(¨4Õ/ð3ñ 
ñ3r   c           	     ó4  € . p. p. pV Fø  pV'       dV   \        VP                  R,          VP                  R	,          VVR7      w  pp\        VVR7      pV P                  VVVR7      pV P	                  VWgW‰V
4      p\        VV4      p\        VV4      w  ppVP                  R,          V,          pVP                  R	,          V,          pVP                  VV34       VP                  V4       VP                  V4       Kú  	  \        RVRVRV/VR7      pV# )
r   )r%   r&   r   r   )ÚheightÚwidth)r?   r.   rx   Úpixel_valuesÚpixel_attention_maskÚspatial_shapes)ÚdataÚtensor_typeéþÿÿÿrB   )	r=   rC   r   ÚresizeÚrescale_and_normalizerJ   r^   Úappendr   )ri   rm   rs   r   r   rx   ry   rz   r{   r|   r}   r~   rc   Úpixel_masksr…   r‡   r?   rƒ   r„   Ú	size_dictÚpatchesr\   rG   rH   Úbatch_features   &&&&&&&&&&&&,            r   Ú_preprocessÚ!Siglip2ImageProcessor._preprocess‘   s&  € ð ˆØˆØˆãˆEßÜ BØ!&§¡¨R¥Ø %§¡¨B¥Ø)Ø$3ô	!‘�˜ô %¨F¸%Ô@�	ØŸ™¨%°iÈ(˜ÓS�à×.Ñ.¨u°jÐR^ÐluÓvˆEô /¨u°jÓAˆGÜ/°¸ÓI‰MˆG�Tà!&§¡¨R¥°JÕ!>ÐØ %§¡¨B¥°:Õ =Ðà×!Ñ!Ð#5Ð7HÐ"IÔJØ×Ñ Ô(Ø×Ñ˜tÖ$ñ- ô0 %à Ø&¨Ø  .ðð
 'ô
ˆð Ðr   r   )ç      à?r”   r”   )r…   r†   r‡   )r   r   r   r   r   Úvalid_kwargsr   ÚBILINEARrx   r|   r}   rs   ry   r{   r   r   Úmodel_input_namesrg   r   ro   ru   r’   r!   r"   Ú__classcell__)rj   r   s   @@r   r`   r`   x   sz   ù‡ € à.€LØ!×*Ñ*€HÚ €JÚ€IØ€IØ€JØ€LØ€JØ€OÚRÐ÷#ó #ð ÷4ò 4ó ð4÷=ó =÷
3÷ 3ð 3r   r`   )gñhãˆµøä>)é    )r   rT   Útorchvision.transforms.v2r   ÚtvFÚimage_processing_backendsr   Úimage_processing_utilsr   Úimage_utilsr   r   r   Úprocessing_utilsr   r	   Úutilsr
   r   r   r=   rJ   r^   r`   Ú__all__r   r   r   Ú<module>r¢      sl   ðñ )ã Ý 7å ;Ý 2ß CÑ Cß 4÷ô
 ,°eõ 
÷-'õ`÷ð  ôKÐ.ó Kó ðKð\ #Ð
#‚r   