+
    œ°³jË>  ã                   óV  € ^ RI t ^ RIt^ RIt^ RIHu Hu Ht ^RI	H
t
 ^RIHt ^RIHtHtHtHt ^RIHtHtHtHtHt ^RIHtHtHtHt ^RIHt ^RIH t  ^R	I!H"t" ]! 4       '       d   ^ R
I#H$t% R t&R t'R t(] ! R R] 4      4       t)]]! RR7       ! R R]"4      4       4       t*RR.t+R# )é    N)ÚTorchvisionBackend)ÚBatchFeature)Úgroup_images_by_shapeÚpadÚreorder_imagesÚto_channel_dimension_format)ÚOPENAI_CLIP_MEANÚOPENAI_CLIP_STDÚChannelDimensionÚPILImageResamplingÚSizeDict)Ú
TensorTypeÚauto_docstringÚis_scipy_availableÚrequires_backends)Úrequires)ÚOwlViTImageProcessor)ÚOwlViTImageProcessorPil)Úndimagec                ó|  € \        V4      p\        V4      pV P                  pW P                  8”  d:   VRW P                  ,
          ,          ,          p\        P
                  ! W4      p W3# W P                  ^,
          8X  d   WP                  R,          3,           pW3# W P                  8  d   \        R4      hW3# )aÚ  Validate resize output shape according to input image.

Args:
    image (`np.ndarray`):
     Image to be resized.
    output_shape (`iterable`):
        Size of the generated output image `(rows, cols[, ...][, dim])`. If `dim` is not provided, the number of
        channels is preserved.

Returns
    image (`np.ndarray`):
        The input image, but with additional singleton dimensions appended in the case where `len(output_shape) >
        input.ndim`.
    output_shape (`Tuple`):
        The output shape converted to tuple.

Raises: ValueError:
    If output_shape length is smaller than the image number of dimensions.

Notes: The input image is reshaped if its number of dimensions is not equal to output_shape_length.

zIoutput_shape length cannot be smaller than the image number of dimensions)é   éÿÿÿÿ)ÚtupleÚlenÚshapeÚndimÚnpÚreshapeÚ
ValueError)ÚimageÚoutput_shapeÚoutput_ndimÚinput_shapes   &&  Úh/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/owlv2/modular_owlv2.pyÚ_preprocess_resize_output_shaper%   3   s©   € ô. ˜Ó&€LÜ�lÓ#€KØ—+‘+€KØ—Z‘ZÔà�t˜{¯Z©ZÕ7Õ8Õ8ˆÜ—
’
˜5Ó.ˆð ÐÐð 
Ÿ
™
 Q�Ô	&à#§{¡{°2¥Ð&8Õ8ˆð ÐÐð 
—z‘zÔ	!ÜÐdÓeÐeàÐÐó    c                ó:  € \         P                  ! V 4      p\         P                  ! V4      '       d*   \         P                  p\         P                  pV! V 4      pM \         P                  p\         P
                  pV! V 4      p\         P                  ! WV4      pV# )a‹  Clip output image to range of values of input image.

Note that this function modifies the values of *output_image* in-place.

Taken from:
https://github.com/scikit-image/scikit-image/blob/b4b521d6f0a105aabeaa31699949f78453ca3511/skimage/transform/_warps.py#L640.

Args:
    input_image : ndarray
        Input image.
    output_image : ndarray
        Output image, which is modified in-place.
)r   ÚminÚisnanÚnanminÚnanmaxÚmaxÚclip)Úinput_imageÚoutput_imageÚmin_valÚmin_funcÚmax_funcÚmax_vals   &&    r$   Ú_clip_warp_outputr4   Z   so   € ô �fŠf�[Ó!€GÜ	‡x‚x�×Òä—9‘9ˆÜ—9‘9ˆÙ˜;Ó'‰ä—6‘6ˆÜ—6‘6ˆÙ�{Ó#€Gä—7’7˜<°'Ó:€LàÐr&   c                óF  € \        V\        \        34      '       dZ   \        P                  ! V Uu. uF  q"^ ,          NK  	  up4      p\        P                  ! V Uu. uF  q"^,          NK  	  up4      pM?\        V\        P
                  4      '       d   VP                  ^4      w  r4M\        R4      h\        P                  ! W44      p\        P                  ! WUWU.^R7      pVP                  ^4      P                  V P                  4      pW,          p V # u upi u upi )aó  
Scale batch of bounding boxes to the target sizes.

Args:
    boxes (`torch.Tensor` of shape `(batch_size, num_boxes, 4)`):
        Bounding boxes to scale. Each box is expected to be in (x1, y1, x2, y2) format.
    target_sizes (`list[tuple[int, int]]` or `torch.Tensor` of shape `(batch_size, 2)`):
        Target sizes to scale the boxes to. Each target size is expected to be in (height, width) format.

Returns:
    `torch.Tensor` of shape `(batch_size, num_boxes, 4)`: Scaled bounding boxes.
z4`target_sizes` must be a list, tuple or torch.Tensor)Údim)Ú
isinstanceÚlistr   ÚtorchÚtensorÚTensorÚunbindÚ	TypeErrorr,   ÚstackÚ	unsqueezeÚtoÚdevice)ÚboxesÚtarget_sizesÚiÚimage_heightÚimage_widthÚmax_sizeÚscale_factors   &&     r$   Ú_scale_boxesrI   x   sã   € ô �,¤¤u ×.Ò.Ü—|’|±<Ó$@±<¨a q§T T±<Ñ$@ÓAˆÜ—l’l±,Ó#?±,¨Q a§D D±,Ñ#?Ó@‰Ü	�L¤%§,¡,×	/Ò	/Ø$0×$7Ñ$7¸Ó$:Ñ!ˆ�käÐNÓOÐOô �yŠy˜Ó3€Hä—;’; °HÐGÈQÔO€LØ×)Ñ)¨!Ó,×/Ñ/°·±Ó=€LØÕ €EØ€Lùò %AùÚ#?s   ±DÁDc                   ó¼   a € ] tR t^—t o ]P
                  t]t]	t
RRRR/tRtRtRtRtRtRtRtRV 3R lR lltRV 3R lR	 lltRV 3R
 lR lltV 3R lR ltRtV tR# )ÚOwlv2ImageProcessorÚheightéÀ  ÚwidthTNc                ó(   <€ V ^8„  d   QhRRRS[ RR/# )é   Úimagesútorch.TensorÚconstant_valueÚreturn)Úfloat)ÚformatÚ__classdict__s   "€r$   Ú__annotate__Ú Owlv2ImageProcessor.__annotate__¥   s#   ø€ ÷ ñ  .ð Á%ð ÐR`ñ r&   c                ó˜   € VP                   RR w  r4\        W44      pWS,
          pWT,
          p^ ^ Wv3p\        P                  ! WVR7      p	V	# )ú,
Pad an image with zeros to the given size.
N)Úfilléþÿÿÿ)r   r,   ÚtvFr   )
ÚselfrQ   rS   rL   rN   ÚsizeÚ
pad_bottomÚ	pad_rightÚpaddingÚpadded_images
   &&&       r$   Ú_pad_imagesÚOwlv2ImageProcessor._pad_images¥   sP   € ð Ÿ™ R SÐ)‰ˆÜ�6Ó!ˆØ•]ˆ
Ø•Lˆ	à�a˜Ð/ˆÜ—w’w˜v°^ÔDˆØÐr&   c          	      ó\   <€ V ^8„  d   QhRS[ R,          RS[R,          RS[RS[ R,          /# )rP   rQ   rR   Údisable_groupingNrS   rT   )r8   ÚboolrU   )rV   rW   s   "€r$   rX   rY   ²   sA   ø€ ÷  ñ  á�^Õ$ð ñ  �+ð ñ ð	 ñ 
ˆnÕ	ñ r&   c                óœ   € \        WR7      w  rV/ pVP                  4        F  w  r‰V P                  V	VR7      p	W—V&   K  	  \        Wv4      p
V
# )zx
Unlike the Base class `self.pad` where all images are padded to the maximum image size,
Owlv2 pads an image to square.
©rh   )rS   )r   Úitemsre   r   )r_   rQ   rh   rS   ÚkwargsÚgrouped_imagesÚgrouped_images_indexÚprocessed_images_groupedr   Ústacked_imagesÚprocessed_imagess   &&&&,      r$   r   ÚOwlv2ImageProcessor.pad²   sg   € ô 0EÀVÔ/oÑ,ˆØ#%Ð Ø%3×%9Ñ%9Ö%;Ñ!ˆEØ!×-Ñ-ØØ-ð .ó ˆNð /= UÓ+ñ &<ô *Ð*BÓYÐàÐr&   c                ó.   <€ V ^8„  d   QhRRRS[ RS[RR/# )rP   r    rR   r`   Úanti_aliasingrT   )r   ri   )rV   rW   s   "€r$   rX   rY   Ê   s9   ø€ ÷ 4Oñ 4Oàð4Oñ ð4Oñ ð	4Oð 
ñ4Or&   c                ó  € VP                   VP                  3pVP                  p\        P                  ! VR,          4      P                  VP                  4      \        P                  ! V4      P                  VP                  4      ,          pV'       EdR   Vf"   V^,
          ^,          P                  ^ R7      pMš\        P                  ! V4      \        P                  ! V4      ,          p\        P                  ! V^ 8  4      '       d   \        R4      h\        P                  ! V^ 8„  V^8*  ,          4      '       d   \        P                  ! R4       \        P                  ! V^ 8H  4      '       d   Tp	Mr^\        P                  ! ^V,          4      P                  4       ,          ^,           p
\         P"                  ! W^ ,          V
^,          3VP%                  4       R7      p	MTp	\&        P(                  ! W’RR7      # )a  
Resize an image as per the original implementation.

Args:
    image (`Tensor`):
        Image to resize.
    size (`dict[str, int]`):
        Dictionary containing the height and width to resize the image to.
    anti_aliasing (`bool`, *optional*, defaults to `True`):
        Whether to apply anti-aliasing when downsampling the image.
    anti_aliasing_sigma (`float`, *optional*, defaults to `None`):
        Standard deviation for Gaussian kernel when downsampling the image. If `None`, it will be calculated
        automatically.
:rP   NN)r(   úFAnti-aliasing standard deviation must be greater than or equal to zeroúWAnti-aliasing standard deviation greater than zero but not down-sampling along all axes)ÚsigmaF)r`   Ú	antialias)rL   rN   r   r9   r:   r@   rA   ÚclampÚ
atleast_1dÚ	ones_likeÚanyr   ÚwarningsÚwarnÚceilÚintr^   Úgaussian_blurÚtolistr   Úresize)r_   r    r`   ru   Úanti_aliasing_sigmarm   r!   r#   ÚfactorsÚfilteredÚkernel_sizess   &&&&&,     r$   r…   ÚOwlv2ImageProcessor.resizeÊ   sƒ  € ð, Ÿ™ T§Z¡ZÐ0ˆà—k‘kˆô —,’,˜{¨2�Ó/×2Ñ2°5·<±<Ó@Ä5Ç<Â<ÐP\ÓC]×C`ÑC`Ðaf×amÑamÓCnÕnˆçˆ=Ø"Ò*Ø(/°!­°qÕ'8×&?Ñ&?ÀAÐ&?Ó&FÑ#ä&+×&6Ò&6Ð7JÓ&KÌeÏoÊoÐ^eÓNfÕ&fÐ#Ü—9’9Ð0°1Ñ4×5Ò5Ü$Ð%mÓnÐnÜ—Y’YÐ 3°aÑ 7¸GÀq¹LÕI×JÒJÜ—M’MØqôô �yŠyÐ,°Ñ1×2Ò2Ø ‘à ¤5§:¢:¨aÐ2EÕ.EÓ#F×#JÑ#JÓ#LÕLÈqÕP�ä×,Ò,Ø¨�O¨\¸!­_Ð=ÐEX×E_ÑE_ÓEaô‘ð
 ˆHä!×(Ò(¨ÈÔNÐNr&   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[S[ S[,          ,          R,          RS[S[ S[,          ,          R,          RS[R,          RS[S[,          R,          RS[/# )rP   rQ   rR   Ú	do_resizer`   ÚresampleúPILImageResampling | NoneÚdo_padÚ
do_rescaleÚrescale_factorÚdo_normalizeÚ
image_meanNÚ	image_stdrh   Úreturn_tensorsrT   )r8   ri   r   rU   Ústrr   r   )rV   rW   s   "€r$   rX   rY      sË   ø€ ÷ 7añ 7aá�^Õ$ð7añ ð7añ ð	7að
 .ð7añ ð7añ ð7añ ð7añ ð7añ ™D¡�KÕ'¨$Õ.ð7añ ™4¡�;Õ&¨Õ-ð7añ  �+ð7añ ™jÕ(¨4Õ/ð7añ 
ñ7ar&   c           	     óH  € \        WR 7      w  rï/ pVP                  4        F  w  ppV P                  VWgRWš4      pVVV&   K!  	  \        VV4      pV'       d   V P	                  VRVR7      p\        VVR 7      w  rï/ pVP                  4        F(  w  ppV'       g   K  V P                  VW4R7      pVVV&   K*  	  \        VV4      p\        VVR 7      w  rï/ pVP                  4        F  w  ppV P                  VRWxWš4      pVVV&   K!  	  \        VV4      p\        RV/VR7      # )rk   Fç        )rS   rh   )r    r`   r�   Úpixel_values©ÚdataÚtensor_type)r   rl   Úrescale_and_normalizer   r   r…   r   )r_   rQ   rŒ   r`   r�   r�   r�   r‘   r’   r“   r”   rh   r•   rm   rn   ro   rp   r   rq   rr   Úresized_images_groupedÚresized_stackÚresized_imagess   &&&&&&&&&&&&&,         r$   Ú_preprocessÚOwlv2ImageProcessor._preprocess   sb  € ô" 0EÀVÔ/oÑ,ˆØ#%Ð à%3×%9Ñ%9Ö%;Ñ!ˆE�>à!×7Ñ7Ø 
¸EÀ:óˆNð /=Ð$ UÓ+ñ &<ô *Ð*BÐDXÓYÐçØ#Ÿx™xÐ(8ÈÐ_o˜xÓpÐä/DØÐ/?ô0
Ñ,ˆð "$ÐØ%3×%9Ñ%9Ö%;Ñ!ˆE�>ß‰yØ $§¡°.Àt Ó _�Ø0=Ð& uÓ-ñ &<ô (Ð(>Ð@TÓUˆô 0EÀ^ÐfvÔ/wÑ,ˆØ#%Ð Ø%3×%9Ñ%9Ö%;Ñ!ˆE�>à!×7Ñ7Ø  ~ÀZóˆNð /=Ð$ UÓ+ñ &<ô *Ð*BÐDXÓYÐä .Ð2BÐ!CÐQ_Ô`Ð`r&   © çp?©r˜   ©TN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   ÚBILINEARr�   r	   r“   r
   r”   r`   r‘   rŒ   r�   r’   r�   Ú	crop_sizeÚdo_center_cropre   r   r…   r¡   Ú__static_attributes__Ú__classdictcell__©rW   s   @r$   rK   rK   —   sx   ø‡ € à!×*Ñ*€HØ!€JØ€IØ�c˜7 CÐ(€DØ€NØ€IØ€JØ€LØ€FØ€IØ€N÷ò ÷ ò  ÷04Oò 4O÷l7aö 7ar&   rK   )Úbackendsc                   ó¦   a € ] tR tRt o ]P
                  t]t]	t
RRRR/tRtRtRtRtRtRtRtRV 3R lR lltRV 3R	 lR
 lltV 3R lR ltRtV tR# )ÚOwlv2ImageProcessorPili:  rL   rM   rN   TNc                óT   <€ V ^8„  d   QhRS[ P                  RS[RS[ P                  /# )rP   r    rS   rT   )r   ÚndarrayrU   )rV   rW   s   "€r$   rX   Ú#Owlv2ImageProcessorPil.__annotate__I  s*   ø€ ÷ ñ ™Ÿ™ð ±Uð ÁRÇZÁZñ r&   c                ó†   € VP                   RR w  r4\        W44      pWS,
          pWT,
          p\        V^ V3^ V33VR7      pV# )r[   N)r    rc   Úconstant_valuesr]   )r   r,   r   )r_   r    rS   rL   rN   r`   ra   rb   s   &&&     r$   r   ÚOwlv2ImageProcessorPil.padI  sU   € ð Ÿ™ B CÐ(‰ˆÜ�6Ó!ˆØ•]ˆ
Ø•Lˆ	ÜØØ˜�_ q¨) nÐ5Ø*ô
ˆð
 ˆr&   c                óp   <€ V ^8„  d   QhRS[ P                  RS[S[S[3,          RS[RS[ P                  /# )rP   r    r`   ru   rT   )r   rµ   Údictr–   r‚   ri   )rV   rW   s   "€r$   rX   r¶   X  sC   ø€ ÷ 7ñ 7á�z‰zð7ñ ‘3™�8�nð7ñ ð	7ñ 
�‰ñ7r&   c           	     óf  € \        V R4       VR,          VR,          3p\        V\        P                  4      p\	        W4      w  rVP
                  p\        P                  ! Wv4      pRp	^ p
^pV'       dÞ   Vf'   \        P                  ! ^ V^,
          ^,          4      pMš\        P                  ! V4      \        P                  ! V4      ,          p\        P                  ! V^ 8  4      '       d   \        R4      h\        P                  ! V^ 8„  V^8*  ,          4      '       d   \        P                  ! R4       \        P                   ! WW©R7      pMTpV Uu. uF  p^V,          NK  	  pp\        P"                  ! WÎW¹V
RR	7      p\%        W4      p\        V\        P&                  4      pV# u upi )
a  
Resize an image as per the original implementation.

Args:
    image (`np.ndarray`):
        Image to resize.
    size (`dict[str, int]`):
        Dictionary containing the height and width to resize the image to.
    anti_aliasing (`bool`, *optional*, defaults to `True`):
        Whether to apply anti-aliasing when downsampling the image.
    anti_aliasing_sigma (`float`, *optional*, defaults to `None`):
        Standard deviation for Gaussian kernel when downsampling the image. If `None`, it will be calculated
        automatically.
ÚscipyrL   rN   Úmirrorrw   rx   )ÚcvalÚmodeT)ÚorderrÀ   r¿   Ú	grid_mode)r   r   r   ÚLASTr%   r   r   ÚdivideÚmaximumr|   r}   r~   r   r   r€   ÚndiÚgaussian_filterÚzoomr4   ÚFIRST)r_   r    r`   ru   r†   rm   r!   r#   r‡   Úndi_moder¿   rÁ   rˆ   ÚfÚzoom_factorsÚouts   &&&&&,          r$   r…   ÚOwlv2ImageProcessorPil.resizeX  sh  € ô, 	˜$ Ô(à˜X�¨¨W­Ð6ˆÜ+¨EÔ3C×3HÑ3HÓIˆÜ=¸eÓRÑˆØ—k‘kˆÜ—)’)˜KÓ6ˆð ˆØˆØˆßØ"Ò*Ü&(§j¢j°°W¸qµ[ÀAÕ4EÓ&FÑ#ä&(§m¢mÐ4GÓ&HÌ2Ï<Ê<ÐX_ÓK`Õ&`Ð#Ü—6’6Ð-°Ñ1×2Ò2Ü$Ð%mÓnÐnÜ—V’VÐ0°1Ñ4¸ÀA¹ÕF×GÒGÜ—M’MØqôô ×*Ò*¨5ÈDÔ`‰HàˆHá'.Ó/¡w !˜˜AŸ˜¡wˆÐ/Ü�hŠh�x°UÐPTÐ`dÔeˆä! %Ó-ˆä+¨EÔ3C×3IÑ3IÓJˆØˆùò 0s   ÅF.c                óþ   <€ V ^8„  d   QhRS[ S[P                  ,          RS[RS[RRRS[RS[RS[R	S[R
S[S[ S[,          ,          R,          RS[S[ S[,          ,          R,          RS[S[,          R,          RS[/# )rP   rQ   rŒ   r`   r�   rŽ   r�   r�   r‘   r’   r“   Nr”   r•   rT   )	r8   r   rµ   ri   r   rU   r–   r   r   )rV   rW   s   "€r$   rX   r¶   ‘  sÀ   ø€ ÷ añ aá‘R—Z‘ZÕ ðañ ðañ ð	að
 .ðañ ðañ ðañ ðañ ðañ ™D¡�KÕ'¨$Õ.ðañ ™4¡�;Õ&¨Õ-ðañ ™jÕ(¨4Õ/ðañ 
ñar&   c                ó$  € . pV Fz  pV'       d   V P                  Wç4      pV'       d   V P                  V4      pV'       d   V P                  WãV4      pV'       d   V P                  WéV
4      pVP	                  V4       K|  	  \        R V/VR7      # )r™   rš   )Úrescaler   r…   Ú	normalizeÚappendr   )r_   rQ   rŒ   r`   r�   r�   r�   r‘   r’   r“   r”   r•   rm   rr   r    s   &&&&&&&&&&&&,  r$   r¡   Ú"Owlv2ImageProcessorPil._preprocess‘  s   € ð ÐÛˆEßØŸ™ UÓ;�ßØŸ™ ›�ßØŸ™ E°Ó:�ßØŸ™ u¸)ÓD�Ø×#Ñ# EÖ*ñ ô  .Ð2BÐ!CÐQ_Ô`Ð`r&   r£   r¤   r¥   r¦   )r§   r¨   r©   rª   r   r«   r�   r	   r“   r
   r”   r`   r‘   rŒ   r�   r’   r�   r¬   r­   r   r…   r¡   r®   r¯   r°   s   @r$   r³   r³   :  sn   ø‡ € ð "×*Ñ*€HØ!€JØ€IØ�c˜7 CÐ(€DØ€NØ€IØ€JØ€LØ€FØ€IØ€N÷ò ÷7ò 7÷raö ar&   r³   )r9   ),r   Únumpyr   r9   Ú$torchvision.transforms.v2.functionalÚ
transformsÚv2Ú
functionalr^   Úimage_processing_backendsr   Úimage_processing_utilsr   Úimage_transformsr   r   r   r   Úimage_utilsr	   r
   r   r   r   Úutilsr   r   r   r   Úutils.import_utilsr   Úowlvit.image_processing_owlvitr   Ú"owlvit.image_processing_pil_owlvitr   r½   r   rÆ   r%   r4   rI   rK   r³   Ú__all__r£   r&   r$   Ú<module>rã      sÃ   ðó ã Û ß 2Ó 2å ;Ý 2÷ó ÷õ ÷ó õ +Ý AÝ Hñ ×ÒÝ$ò$òNò<ð> ô_aÐ.ó _aó ð_aðD Ù	�:ÔôoaÐ4ó oaó ó ðoaðd !Ð":Ð
;‚r&   