+
    œ°³jº  ã                   óö   € R t ^ RIH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 ^RIHtHt ]'       d   ^R	IHt ^ R
IHt  ! R R]RR7      tR R ltR R lt] ! R R]4      4       tR.tR# )z%Image processor class for SuperPoint.)ÚTYPE_CHECKINGN)ÚTorchvisionBackend)ÚBatchFeature)Úgroup_images_by_shapeÚreorder_images)ÚPILImageResamplingÚSizeDict)ÚImagesKwargsÚUnpack)Ú
TensorTypeÚauto_docstring)Ú#SuperPointKeypointDescriptionOutput)Ú
functionalc                   ó0   a € ] tR t^"t o RtV 3R ltRtV tR# )ÚSuperPointImageProcessorKwargsz´
do_grayscale (`bool`, *optional*, defaults to `self.do_grayscale`):
    Whether to convert the image to grayscale. Can be overridden by `do_grayscale` in the `preprocess` method.
c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # )é   Údo_grayscale©Úbool)ÚformatÚ__classdict__s   "€Ú{/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/superpoint/image_processing_superpoint.pyÚ__annotate__Ú+SuperPointImageProcessorKwargs.__annotate__"   s   ø‡ ‚ ñ Ñò ó    © 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   Úimageútorch.TensorÚreturnr   )r   s   "r   r   r   +   s   € ÷ ñ ˜ð ¬4ñ r   c                ó*  € V P                   ^8  g,   V P                  V P                   ^8X  d   ^ M^,          ^8X  d   R# \        P                  ! V R,          V R,          8H  4      ;'       d(    \        P                  ! V R,          V R,          8H  4      # )zAChecks if an image is grayscale (all RGB channels are identical).T).é    ºNNNr-   ).é   r-   r-   ).r   r-   r-   )ÚndimÚshapeÚtorchÚall©r(   s   &r   Úis_grayscaler4   +   st   € à‡z�z�A„~˜Ÿ™¨%¯*©*¸¬/¡Q¸qÕAÀQÔFÙÜ�9Š9�U˜<Õ(¨E°,Õ,?Ñ?Ó@÷ ð ÄUÇYÂYØˆlÕ˜u \Õ2Ñ2óFð r   c                ó    € V ^8„  d   QhRRRR/# r'   r   )r   s   "r   r   r   4   s   € ÷ >ñ > ð >°>ñ >r   c                óX   € \        V 4      '       d   V # \        P                  ! V ^R7      # )a‘  
Converts an image to grayscale format using the NTSC formula. Only support torch.Tensor.

This function is supposed to return a 1-channel image, but it returns a 3-channel image with the same value in each
channel, because of an issue that is discussed in :
https://github.com/huggingface/transformers/pull/25786#issuecomment-1730176446

Args:
    image (torch.Tensor):
        The image to convert.
)Únum_output_channels)r4   ÚtvFÚrgb_to_grayscaler3   s   &r   Úconvert_to_grayscaler:   4   s'   € ô �E×ÒØˆÜ×Ò ¸1Ô=Ð=r   c                   ó¦   a a€ ] tR t^Et o]t]P                  tRRRR/t	Rt
RtRtRtRtRtV3R lV 3R	 lltRV3R
 lR lltV3R lR ltRtVtV ;t# )ÚSuperPointImageProcessorÚheightià  Úwidthi€  FTNc                ó0   <€ V ^8„  d   QhRS[ S[,          /# )r   Úkwargs)r
   r   )r   r   s   "€r   r   Ú%SuperPointImageProcessor.__annotate__Q   s   ø€ ÷ #ñ #¡Ñ(FÕ!Gñ #r   c                ó(   <€ \         SV `  ! R/ VB  R # )Nr   )ÚsuperÚ__init__)Úselfr@   Ú	__class__s   &,€r   rD   Ú!SuperPointImageProcessor.__init__Q   s   ø€ Ü‰ÒÑ"˜6Ô"r   c                óŽ   <€ V ^8„  d   QhRS[ R,          RS[RS[RRRS[RS[R	S[R
,          RS[S[,          R
,          RS[RS[/
# )r   Úimagesr)   Ú	do_resizeÚsizeÚresamplez7PILImageResampling | tvF.InterpolationMode | int | NoneÚ
do_rescaleÚrescale_factorÚdisable_groupingNÚreturn_tensorsr   r*   )Úlistr   r   ÚfloatÚstrr   r   )r   r   s   "€r   r   rA   T   s�   ø€ ÷ añ aá�^Õ$ðañ ðañ ð	að
 Lðañ ðañ ðañ  �+ðañ ™jÕ(¨4Õ/ðañ ðañ 
ñar   c
                ó  € \        WR 7      w  r¼/ pVP                  4        FP  w  rïV	'       d   \        V4      pV'       d   V P                  WóVR7      pV'       d   V P	                  Wö4      pWýV&   KR  	  \        WÜ4      p\        RV/VR7      # ))rO   )rK   rL   Úpixel_values)ÚdataÚtensor_type)r   Úitemsr:   ÚresizeÚrescaler   r   )rE   rI   rJ   rK   rL   rM   rN   rO   rP   r   r@   Úgrouped_imagesÚgrouped_images_indexÚprocessed_images_groupedr0   Ústacked_imagesÚprocessed_imagess   &&&&&&&&&&,      r   Ú_preprocessÚ$SuperPointImageProcessor._preprocessT   sŒ   € ô 0EÀVÔ/oÑ,ˆØ#%Ð Ø%3×%9Ñ%9Ö%;Ñ!ˆEçÜ!5°nÓ!E�çØ!%§¡¨^ÐQY Ó!Z�çØ!%§¡¨nÓ!M�Ø.< UÓ+ñ &<ô *Ð*BÓYÐÜ .Ð2BÐ!CÐQ_Ô`Ð`r   c          	      ón   <€ V ^8„  d   QhRRRS[ S[S[,          ,          RS[S[S[R3,          ,          /# )r   Úoutputsr   Útarget_sizesr*   r)   )r   rQ   ÚtupleÚdictrS   )r   r   s   "€r   r   rA   r   s@   ø€ ÷ /ñ /Ø<ð/ÙLVÑY]Ñ^cÕYdÕLdð/á	‰d‘3˜Ð&Õ'Õ	(ñ/r   c           	     óè  € \        VP                  4      \        V4      8w  d   \        R4      h\        V\        4      '       d-   \
        P                  ! W!P                  P                  R7      pM%VP                  ^,          ^8w  d   \        R4      hTp\
        P                  ! V^.4      pVP                  VR,          ,          pVP                  \
        P                  4      p. p\        VP                  WAP                  VP                  4       FZ  w  rgr‰\
        P                   ! V4      P#                  ^4      p
Wz,          pWŠ,          pWš,          p	VP%                  RVRVRV	/4       K\  	  V# )aS  
Converts the raw output of [`SuperPointForKeypointDetection`] into lists of keypoints, scores and descriptors
with coordinates absolute to the original image sizes.

Args:
    outputs ([`SuperPointKeypointDescriptionOutput`]):
        Raw outputs of the model containing keypoints in a relative (x, y) format, with scores and descriptors.
    target_sizes (`torch.Tensor` or `list[tuple[int, int]]`):
        Tensor of shape `(batch_size, 2)` or list of tuples (`tuple[int, int]`) containing the target size
        `(height, width)` of each image in the batch. This must be the original
        image size (before any processing).
Returns:
    `list[Dict]`: A list of dictionaries, each dictionary containing the keypoints in absolute format according
    to target_sizes, scores and descriptors for an image in the batch as predicted by the model.
zRMake sure that you pass in as many target sizes as the batch dimension of the mask)ÚdevicezTEach element of target_sizes must contain the size (h, w) of each image of the batchÚ	keypointsÚscoresÚdescriptors)r-   N)ÚlenÚmaskÚ
ValueErrorÚ
isinstancerQ   r1   Útensorrh   r0   Úflipri   ÚtoÚint32Úziprj   rk   ÚnonzeroÚsqueezeÚappend)rE   rc   rd   Úimage_sizesÚmasked_keypointsÚresultsÚ
image_maskri   rj   rk   Úindicess   &&&        r   Úpost_process_keypoint_detectionÚ8SuperPointImageProcessor.post_process_keypoint_detectionr   s8  € ô$ ˆw�|‰|Ó¤ LÓ 1Ô1ÜÐqÓrÐrä�l¤D×)Ò)ÜŸ,š, |¿L¹L×<OÑ<OÔP‰Kà×!Ñ! !Õ$¨Ô)Ü Øjóð ð 'ˆKô —j’j ¨q¨cÓ2ˆØ"×,Ñ,¨{¸7Õ/CÕCÐð ,×.Ñ.¬u¯{©{Ó;ÐàˆÜ:=Ø�L‰LÐ*¯N©N¸G×<OÑ<Oö;
Ñ6ˆJ 6ô —m’m JÓ/×7Ñ7¸Ó:ˆGØ!Õ*ˆIØ•_ˆFØ%Õ.ˆKØ�N‰N˜K¨°H¸fÀmÐU`ÐaÖbñ;
ð ˆr   r   gp?)F)r   r   r   r    r   Úvalid_kwargsr   ÚBILINEARrL   rK   Údefault_to_squarerJ   rM   rN   Údo_normalizer   rD   r`   r}   r#   r$   Ú__classcell__)rF   r   s   @@r   r<   r<   E   sg   ù‡ € à1€LØ!×*Ñ*€HØ�c˜7 CÐ(€DØÐØ€IØ€JØ€NØ€LØ€L÷#ó #÷aò a÷</÷ /ð /r   r<   )r!   Útypingr   r1   Úimage_processing_backendsr   Úimage_processing_utilsr   Úimage_transformsr   r   Úimage_utilsr   r   Úprocessing_utilsr	   r
   Úutilsr   r   Úmodeling_superpointr   Útorchvision.transforms.v2r   r8   r   r4   r:   r<   Ú__all__r   r   r   Ú<module>rŽ      so   ðñ ,å  ã å ;Ý 2ß Eß 7ß 4ß /÷ ÝHå 7ô \¸õ õõ>ð" ô[Ð1ó [ó ð[ð| &Ð
&‚r   