+
    åûjÃá  ã                  óp  a € 0 t $ ^ RIHt ^ RIHt ^ RIHtHtHtH	t	 ^ RI
t
^ RIHu Ht ^ RI
Ht ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHtHt ^ RIHt ^RIHt ] ! R R4      4       tR3R R lltR4R R lltR R lt R R lt!R R lt"R R lt# ! R R]PH                  4      t% ! R R4      t& ! R R ]PH                  4      t'R5R! R" llt( ! R# R$]PH                  4      t) ! R% R&]PH                  4      t* ! R' R(]PH                  4      t+R)R6R*R7R+R7R,R8/t,R-]-R.&   R/R0.t. ! R1 R2]PH                  4      t/R# )9é    )Úannotations)Ú	dataclass)ÚAnyÚCallableÚOptionalÚTupleN)Únn)Ú_pair)Úgrayscale_to_rgb)Úload_state_dict_from_url)Ú_copied_literal)Ú_to_device_nonblockingÚis_compiling)Únms2d)Údeform_conv2dc                  ó\   € ] tR t^Ot$ RtR]R&   R]R&   R]R&   ]R R l4       tR R	 ltR
t	R# )ÚALIKEDFeaturesav  Hold the sub-pixel keypoints, descriptors and scores that ALIKED detects in one image.

``features = aliked(images)[b]`` is what :class:`ALIKED` returns for image ``b``: ``features.keypoints``
``(N, 2)``, sub-pixel ``(x, y)`` pixels, ``features.descriptors`` ``(N, D)``, L2-normalised, and
``features.keypoint_scores`` ``(N,)``, with ``N = features.n``. It is not batched, because ALIKED detects a
different number of keypoints in each image; ``features.to(device)`` moves the three tensors. For the keypoints
of a whole batch as padded LAF tensors, use :meth:`ALIKED.forward_laf` instead.

Convention:
    The keypoints, descriptors and scores that :class:`~kornia.feature.ALIKED` returns for one image; its
    Convention block gives their frame and how many there are.

Args:
    keypoints: pixel coordinates ``(N, 2)`` as ``[x, y]``.
    descriptors: L2-normalised descriptors ``(N, D)``.
    keypoint_scores: detection confidence scores ``(N,)``.

See Also:
    - :class:`ALIKED`: the detector, which returns one of these per image.
    - :class:`DISKFeatures`: the same container for :class:`DISK`, whose keypoints are integer pixels.

útorch.TensorÚ	keypointsÚdescriptorsÚkeypoint_scoresc               ó   € V ^8„  d   QhRR/# )é   ÚreturnÚint© )Úformats   "ÚXC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\feature\aliked\aliked.pyÚ__annotate__ÚALIKEDFeatures.__annotate__m   s   € ÷ 'ñ '�3ñ 'ó    c                ó<   € V P                   P                  ^ ,          # )zNumber of detected keypoints.)r   Úshape)Úselfs   &r   ÚnÚALIKEDFeatures.nl   s   € ð �~‰~×#Ñ# AÕ&Ð&r!   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úargsr   Úkwargsr   r   r   )r   s   "r   r   r    q   s!   € ÷ 
ñ 
˜ð 
 sð 
¨~ñ 
r!   c           	     ó¸   € \        V P                  P                  ! V/ VB V P                  P                  ! V/ VB V P                  P                  ! V/ VB 4      # )z)Move all tensors to a new device / dtype.)r   r   Útor   r   )r$   r(   r)   s   &*,r   r+   ÚALIKEDFeatures.toq   sX   € äØ�N‰N×Ò˜tÐ. vÑ.Ø×Ñ×Ò Ð0¨Ñ0Ø× Ñ ×#Ò# TÐ4¨VÑ4ó
ð 	
r!   r   N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Úpropertyr%   r+   Ú__static_attributes__r   r!   r   r   r   O   s7   ‡ ñð. ÓØÓØ!Ó!àô'ó ð'÷
ñ 
r!   r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Ú	in_planesr   Ú
out_planesÚstrider   ú	nn.Conv2dr   )r   s   "r   r   r      s.   € ÷ Vñ V˜ð V¨ð V°cð VÀ)ñ Vr!   c                ó6   € \         P                  ! W^VRR7      # )é   F)Úkernel_sizer8   Úbias©r	   ÚConv2d)r6   r7   r8   s   &&&r   Ú_conv1x1r@      s   € Ü�9Š9�Y¸À&ÈuÔUÐUr!   c               ó0   € V ^8„  d   QhRRRRRRRRRRRR/# )	r   r6   r   r7   r8   ÚgroupsÚdilationr   r9   r   )r   s   "r   r   r   ƒ   s8   € ÷ 
ñ 
˜ð 
¨ð 
°cð 
Àsð 
ÐZ]ð 
Ðfoñ 
r!   c                ó>   € \         P                  ! V V^VVVRVR7      # )é   F)r<   r8   ÚpaddingrB   r=   rC   r>   )r6   r7   r8   rB   rC   s   &&&&&r   Ú_conv3x3rG   ƒ   s+   € Ü�9Š9ØØØØØØØØô	ð 	r!   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Útensorr   Úrequired_cornersÚpsr   r   r   )r   s   "r   r   r   �   s)   € ÷ 'ñ '˜ð '¸ð 'È#ð 'ÐR^ñ 'r!   c                ó  € V P                   w  r4pW^,          ,
          ^,           P                  4       pVR,          P                  ^ V^,
          V,
          R7      VR&   VR,          P                  ^ V^,
          V,
          R7      VR&   \        P                  ! ^ W&P
                  VP                  R7      p\        P                  ! WwRR7      w  r‰\        P                  ! W‰34      P                  ^^^ 4      P                  ^4      p
W¦R,          ,           p
V
P                  R	^4      pV P                  ^^^ 4      \        VP                  4      RRR	1,          ,          pVP                  W"R	V4      pVP                  ^^^ ^4      # )
zFExtract ps x ps patches centred at required_corners from a CHW tensor.)ÚminÚmax©ÚdeviceÚdtypeÚij©ÚindexingN©ºNNNr   ©rV   r;   )NNéÿÿÿÿ)r#   ÚlongÚclampÚtorchÚarangerP   rQ   ÚmeshgridÚstackÚpermuteÚ	unsqueezeÚreshapeÚtupleÚT)rI   rJ   rK   ÚcÚhÚwÚcornerÚoffsetÚxÚyÚpatchesÚptsÚsampleds   &&&          r   Úget_patchesrn   �   s5  € à�l‰l�G€Aˆ!Ø a¥Õ'¨!Õ+×1Ñ1Ó3€FØ˜$•<×%Ñ%¨!°°Qµ¸µÐ%Ó<€Fˆ4�LØ˜$•<×%Ñ%¨!°°Qµ¸µÐ%Ó<€Fˆ4�Lä�\Š\˜!˜R¯©¸V¿\¹\ÔJ€FÜ�>Š>˜&°4Ô8�D€AÜ�kŠk˜1˜&Ó!×)Ñ)¨!¨Q°Ó2×<Ñ<¸QÓ?€GØ˜zÕ*Õ*€GØ
�/‰/˜"˜aÓ
 €CØ�n‰n˜Q  1Ó%¤e¨C¯E©E£l±4°R°4Õ&8Õ9€GØ�o‰o˜b b¨!Ó,€GØ�?‰?˜1˜a  AÓ&Ð&r!   c               ó    € V ^8„  d   QhRRRR/# )r   Úimager   r   Úboolr   )r   s   "r   r   r   ¡   s   € ÷ oñ o ð o°ñ or!   c                óÌ   € V P                   P                  R8H  ;'       dE    V P                  \        P                  \        P
                  39   ;'       d    \        4       '       * # )a¾  Whether :meth:`ALIKED.forward` asks for the ``channels_last`` feature map; see ``extract_dense_map``.

It does for a float32 or float64 CPU image in eager only. Under ``torch.compile`` or ``torch.export`` capture the
default layout is faster: inductor lowers the descriptor head's ``grid_sample`` to a loop that gathers one channel
at a time across the sample points, and on the channels_last map each of those reads lands on another cache line.
Úcpu)rP   ÚtyperQ   r[   Úfloat32Úfloat64r   )rp   s   &r   Ú_reads_channels_lastrw   ¡   sF   € ð �<‰<×Ñ Ñ%×nÐn¨%¯+©+¼%¿-¹-ÌÏÉÐ9WÑ*W×nÐnÔ`lÓ`nÔ\nÐnr!   c               ó    € V ^8„  d   QhRRRR/# )r   Úcovr   r   r   )r   s   "r   r   r   °   s   € ÷ >ñ >˜,ð >¨<ñ >r!   c                óŒ  € V P                   pV P                   \        P                  \        P                  39   d   V P	                  4       p \        P
                  P                  V 4      w  r#VR,          VR,          ,          VR,          VR	,          ,          ,
          pRRV^ 8  P                  VP                   4      ,          ,
          pV\        P                  ! V\        P                  ! V4      .R
R7      R,          ,          pVP                  RR7      P                  4       pW6R,          ,          P                  V4      # )aD  Build a 2x2 affine matrix from a batch of 2x2 covariance matrices.

The affine is ``U @ diag(sqrt(eigenvalues))``, where ``U`` contains the
orthonormal eigenvectors of ``cov`` as *columns*, in ascending order of
eigenvalue.  This gives an ellipse whose axes align with the principal
directions of the covariance (``A @ A.T == cov``).  The sign of the first
eigenvector is chosen so that ``det(U) = +1``: the affine is a rotation
times a scaling, never mirrored.

Args:
    cov: symmetric positive-semi-definite matrices ``(N, 2, 2)``.

Returns:
    Affine matrices ``(N, 2, 2)``.
g      ð?ç       @©Údimg:Œ0âŽyE>)rM   )rV   r   r   )rV   r;   r;   )rV   r   r;   )rV   r;   r   rX   ©rV   NrV   )rQ   r[   Úfloat16Úbfloat16ÚfloatÚlinalgÚeighr+   r^   Ú	ones_likerZ   Úsqrt)ry   Ú
orig_dtypeÚeigenvaluesÚeigenvectorsÚdet_uÚsignÚscaless   &      r   Ú_affine_from_covrŒ   °   sõ   € ð& —‘€JØ
‡y�y”U—]‘]¤E§N¡NÐ3Ô3Ø�i‰i‹kˆÜ %§¡× 1Ñ 1°#Ó 6Ñ€Kð ˜Õ! L°Õ$9Õ9¸LÈÕ<QÐT`ÐahÕTiÕ<iÕi€EØ�˜ ™	—~‘~ l×&8Ñ&8Ó9Õ9Õ9€DØ¤%§+¢+¨t´U·_²_ÀTÓ5JÐ.KÐQSÔ"TÐU_Õ"`Õ`€LØ×Ñ 4ÐÓ(×-Ñ-Ó/€Fà *Õ-Õ-×1Ñ1°*Ó=Ð=r!   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úkeypoints_pxr   Úaffiner   r   )r   s   "r   r   r   Ñ   s&   € ÷ 0ñ 0Øð0àð0ð ñ0r!   c                óV   € V P                  R4      p\        P                  ! W.RR7      # )a9  Assemble a ``(N, 2, 3)`` LAF from pixel keypoints and 2x2 affine matrices.

Args:
    keypoints_px: ``(N, 2)`` pixel coordinates ``[x, y]``.
    affine: ``(N, 2, 2)`` affine (rotation+scale) part of the LAF.

Returns:
    LAF tensor ``(N, 2, 3)`` following the kornia convention
    ``[[a, b, cx], [c, d, cy]]``.
r|   rX   )r`   r[   Úcat)rŽ   r�   Úcenterss   && r   Ú_laf_from_kpts_and_affiner“   Ñ   s(   € ð ×$Ñ$ RÓ(€GÜ�9Š9�fÐ&¨BÔ/Ð/r!   c                  óX   a € ] tR t^ètRtR	R V 3R llltR V 3R lltR
R R lltRtV ;t	# )ÚDKDa  Differentiable keypoint detection from a score map.

Args:
    radius: soft detection radius; NMS kernel size is ``2 * radius + 1``. The NMS keeps strict local maxima
        only, unlike the reference's ``simple_nms``; the note of :class:`ALIKED` explains the difference.
    top_k: if ``> 0`` return at most ``top_k`` keypoints per image: its ``top_k`` highest-scoring local maxima,
        or all of them when it has fewer; otherwise threshold mode is used.
    scores_th: score threshold when ``top_k <= 0``.
        If ``> 0`` keep keypoints with ``score > scores_th``, and in an image with none above it, the keypoints
        above that image's mean score; otherwise keep keypoints above the per-image mean score.
    n_limit: maximum number of keypoints returned in threshold mode.
c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   Úradiusr   Útop_kÚ	scores_thr�   Ún_limitr   ÚNoner   )r   s   "r   r   ÚDKD.__annotate__ö   sC   € ÷ Cñ CàðCð ðCð ð	Cð
 ðCð 
ñCr!   c                	óD  <€ \         SV `  4        Wn        W n        W0n        W@n        ^V P                  ,          ^,           V n        RV n        \        P                  ! V P                  V P                  R7      V n
        \        P                  ! V P                  ) V P                  V P                  4      p\        P                  ! \        P                  ! WU.RR7      4      P                  ^R
4      P!                  4       R^^ .3,          pV P#                  RVRR7       R	# )r   gš™™™™™¹?)r<   rF   rR   rS   rV   Úhw_gridF)Ú
persistentNrX   )ÚsuperÚ__init__r—   r˜   r™   rš   r<   Útemperaturer	   ÚUnfoldÚunfoldr[   Úlinspacer^   r]   ÚviewÚtÚregister_buffer)r$   r—   r˜   r™   rš   ri   rž   Ú	__class__s   &&&&&  €r   r¡   ÚDKD.__init__ö   s×   ø€ ô 	‰ÑÔØŒØŒ
Ø"ŒØŒØ˜tŸ{™{�?¨QÕ.ˆÔØˆÔÜ—i’i¨D×,<Ñ,<ÀdÇkÁkÔRˆŒÜ�NŠN˜DŸK™K˜<¨¯©°d×6FÑ6FÓGˆÜ—+’+œeŸnšn¨a¨V¸dÔCÓD×IÑIÈ!ÈRÓP×RÑRÓTÐUVÐYZÐ\]ÐX^ÐU^Õ_ˆà×Ñ˜Y¨¸EÐÖBr!   c               ó8   € V ^8„  d   QhRRRRRRRRR	R
RR
RR
RR/# )r   Ú
state_dictzdict[str, torch.Tensor]ÚprefixÚstrÚlocal_metadatazdict[str, Any]Ústrictrq   Úmissing_keysz	list[str]Úunexpected_keysÚ
error_msgsr   r›   r   )r   s   "r   r   rœ   
  sZ   € ÷ 
ñ 
à+ð
ð ð
ð 'ð	
ð
 ð
ð  ð
ð #ð
ð ð
ð 
ñ
r!   c           	     	ó^   <€ VP                  VR ,           R4       \        SV `	  WW4WVV4       R# )rž   N)Úpopr    Ú_load_from_state_dict)	r$   r¬   r­   r¯   r°   r±   r²   r³   r©   s	   &&&&&&&&€r   r¶   ÚDKD._load_from_state_dict
  s/   ø€ ð 	�‰�v 	Õ)¨4Ô0Ü‰Ñ%Ø ¸ÐWaö	
r!   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   Ú
scores_mapr   Ú	sub_pixelrq   Ú
image_sizeúOptional[torch.Tensor]Úreturn_affiner   ztuple[list[torch.Tensor], ...]r   )r   s   "r   r   rœ     sC   € ÷ Z6ñ Z6à ðZ6ð ðZ6ð +ð	Z6ð
 ðZ6ð 
(ñZ6r!   c           
     ó„  € VP                   w  rVrxVP                  4       p	\        W�P                  V P                  3RR7      p
RV
RRRV P                  1R3&   RV
RRRRV P                  13&   VEe*   \        W1P                  \        P                  4      V P                  ,
          pVP                  R4      w  rÍ\        P                  ! V^ 8  WÈ,           V4      p\        P                  ! V^ 8  W×,           V4      p\        P                  ! WqP                  R7      P                  ^^V^4      p\        P                  ! W�P                  R7      P                  ^^^V4      pW®VP                  V^^^4      8  WüP                  V^^^4      8  ,          ,          p
M,RV
RRV P                  ) R1R3&   RV
RRRV P                  ) R13&   V P                  ^ 8”  d¯   V	P                  V
( \        R4      4      P!                  ^R7      p\        P"                  ! V\%        V P                  Wx,          4      4      p\'        V4       Uu. uF:  pVP(                  V,          VP*                  V,          \        R4      8„  ,          NK<  	  ppEMeV	P!                  ^R7      P-                  ^R	7      P/                  V^^^4      pW©V8„  ,          pV P0                  ^ 8”  d`   W©V P0                  8„  ,          p\        P                  ! VP!                  ^R7      P3                  ^R	7      P/                  V^^^4      VV4      pVP!                  ^R7      p. pV	P!                  ^R7      p\5        VV4       F€  w  ppVP7                  4       R,          p\9        V4      V P:                  8”  d9   VV,          pVP=                  RR
7      ^,          pVVRV P:                   ,          pVP?                  V4       K‚  	  \        P@                  ! VPB                  \        PD                  4      p\G        V^,
          V^,
          .V	P                  VR7      p. p. p . p!. p"V'       Edº   V PI                  V4      p#\'        V4       EF–  p$V#V$,          PK                  4       p%VV$,          p&V%V&,          p'\        PL                  ! V&V,          \        PN                  ! V&VRR7      .^R	7      p(V'PQ                  ^R	7      P*                  P                  4       R,          p)V'V),
          V PR                  ,          PU                  4       p*V*PW                  ^RR7      p+V*V PX                  ,          V+,          p,\        PZ                  ! V PX                  R,          V,R,          ,
          V P                  ,          RR	7      ^,          p-V*V-,          PW                  ^R	7      V*PW                  ^R	7      ,          p.V(P]                  V4      V,,           p/V/V,          ^,          ^,
          p/\^        P`                  ! VV$,          Pc                  ^ 4      V/P                  ^^R^4      P]                  VPB                  4      RRR7      R,          p0VP?                  V/4       V P?                  V.4       V!P?                  V04       V'       g   EK9  V*V+,          p1V PX                  R,          V,R,          ,
          p2\        Pd                  ! RV1V2V24      p3V"P?                  \g        V34      4       EK™  	  EMž\'        V4       EFŽ  p$VV$,          p&\        PL                  ! V&V,          \        PN                  ! V&VRR7      .^R	7      p(V(P]                  V4      V,          ^,          ^,
          p/\^        P`                  ! VV$,          Pc                  ^ 4      V/P                  ^^R^4      P]                  VPB                  4      RRR7      R,          p0VP?                  V/4       V P?                  \        Ph                  ! V04      4       V!P?                  V04       V'       g   EK  V/P                   ^ ,          p4V"P?                  \        Pj                  ! ^VP                  VPB                  R7      Pc                  ^ 4      Pm                  V4RR4      4       EK‘  	  V'       d   VV!V V"3# VV!V 3# u upi )u  Detect keypoints from a score map.

Args:
    scores_map: ``(B, 1, H, W)`` detection score map.
    sub_pixel: whether to apply soft-argmax sub-pixel refinement.
    image_size: optional ``(B, 2)`` tensor of valid image sizes ``(W, H)``
        for border masking.
    return_affine: if ``True``, also return per-keypoint 2x2 local affine
        matrices estimated from the soft-argmax weight covariance.

Returns:
    A 3-tuple ``(keypoints, keypoint_scores, score_dispersities)`` â€” or a
    4-tuple ``(..., local_affines)`` when ``return_affine=True``.
    Each ``keypoints[i]`` is ``(N_i, 2)`` normalised to ``[-1, 1]``.
    Each ``local_affines[i]`` is ``(N_i, 2, 2)`` (only when ``sub_pixel=True``
    and ``return_affine=True``; otherwise identity matrices are returned).
T)Ú	mask_onlyFrV   N)rP   z-inf)Ú	start_dimr|   )Ú
descendingrO   Útrunc)Úrounding_mode)r}   ÚkeepdimÚbilinear©ÚmodeÚalign_cornerszni,nij,nik->njkrX   rU   )rV   N)NrV   rV   r~   )r   r   r   rV   )7r#   Údetachr   r<   r—   r   rP   r[   rY   ÚunbindÚwherer\   r¦   r˜   Úmasked_fillr�   ÚflattenÚtopkrM   ÚrangeÚindicesÚvaluesÚmeanra   r™   ÚanyÚzipÚnonzeroÚlenrš   ÚsortÚappendÚpromote_typesrQ   ru   r   r¤   r§   r^   ÚdivrN   r¢   ÚexpÚsumrž   Únormr+   ÚFÚgrid_sampler`   ÚeinsumrŒ   Ú
zeros_likeÚeyeÚexpand)5r$   r¹   rº   r»   r½   ÚbÚ_cre   rf   Úscores_nogradÚis_maxÚendsÚw_endÚh_endÚrowsÚcolsÚcandidate_scoresrÎ   ÚiÚindices_keypointsrÒ   ÚmasksÚaboveÚscores_viewÚmaskÚscoresrÐ   Úkpts_scÚsort_idxÚcoord_dtypeÚwhr   ÚscoredispersitysÚ	kptscoresÚlocal_affinesrk   Úb_idxÚpatchÚindices_kptÚpatch_scoresÚkeypoints_xy_nmsÚmax_vÚx_expÚx_sumÚxy_residualÚhw_grid_dist2ÚscoredispersityÚkeypoints_xyÚkptscoreÚWÚdeltary   ÚN_is5   &&&&&                                                r   ÚforwardÚDKD.forward  s{  € ð0 !×&Ñ&‰ˆˆqØ"×)Ñ)Ó+ˆä�}×'7Ñ'7¸×9IÑ9IÐ&JÐVZÔ[ˆð */ˆˆq�!�]�t—{‘{�] AÐ%Ñ&Ø).ˆˆq�!�Q˜˜$Ÿ+™+˜Ð%Ñ&ØÓ!ä)¨*×6GÑ6GÌÏÉÓTÐW[×WbÑWbÕbˆDØŸ;™; r›?‰LˆEä—K’K ¨¡	¨5­9°eÓ<ˆEÜ—K’K ¨¡	¨5­9°eÓ<ˆEÜ—<’< ×*;Ñ*;Ô<×AÑAÀ!ÀQÈÈ1ÓMˆDÜ—<’< ×*;Ñ*;Ô<×AÑAÀ!ÀQÈÈ1ÓMˆDØ˜eŸj™j¨¨A¨q°!Ó4Ñ4¸Ç
Á
È1ÈaÐQRÐTUÓ@VÑ9VÕWÕW‰Fà.3ˆF�1�a˜$Ÿ+™+˜™¨Ð*Ñ+Ø.3ˆF�1�a˜˜TŸ[™[˜L™NÐ*Ñ+à�:‰:˜Œ>à,×8Ñ8¸&¸Ä%ÈÃ-ÓP×XÑXÐcdÐXÓeÐÜ—:’:Ð.´°D·J±JÀÅÓ0FÓGˆDÜZ_Ð`aÔZbÓ cÑZbÐUV §¡¨a¥°·±¸QµÄ%ÈÃ-Ñ1O×!PÐ!PÑZbÐÐ cÑð !×(Ñ(°1Ð(Ó5×:Ñ:¸qÐ:ÓA×IÑIÈ!ÈQÐPQÐSTÓUˆDØ¨dÑ2Õ3ˆEØ�~‰~ Ô!Ø°$·.±.Ñ"@ÕA�ÜŸš E§M¡M¸A MÓ$>×$BÑ$BÀqÐ$BÓ$I×$QÑ$QÐRSÐUVÐXYÐ[\Ó$]Ð_dÐfkÓl�Ø—M‘M¨A�MÓ.ˆEà "ÐØ'×/Ñ/¸!Ð/Ó<ˆKÜ # E¨;Ö 7‘��fØŸ,™,›.¨Õ.�Ü�w“< $§,¡,Ô.Ø$ W�o�GØ&Ÿ|™|°t˜|Ó<¸QÕ?�HØ% h¨~°·±Ð&>Õ?�GØ!×(Ñ(¨Ö1ñ !8ô ×)Ò)¨*×*:Ñ*:¼E¿M¹MÓJˆÜ˜a !�e Q¨¥U˜^°M×4HÑ4HÐP[Ô\ˆàˆ	ØÐØˆ	Ø,.ˆßˆ9Ø—k‘k *Ó-ˆGÜ˜qŸ�Ø �×(Ñ(Ó*�Ø/°Õ6�Ø$ [Õ1�Ü#(§;¢;Ø  1•_¤e§i¢i°¸QÈgÔ&VÐWØô$Ð ð
 %×(Ñ(¨QÐ(Ó/×6Ñ6×=Ñ=Ó?ÀÕH�Ø&¨Õ.°$×2BÑ2BÕB×GÑGÓI�ØŸ	™	 a°˜	Ó6�à# d§l¡lÕ2°UÕ:�ô —J’JØŸ™ jÕ1°KÀ
Õ4KÕKÈtÏ{É{ÕZØôð õ	ð ð $)¨=Õ#8×"=Ñ"=À!Ð"=Ó"DÀuÇyÁyÐUVÀyÓGWÕ"W�à/×2Ñ2°;Ó?À+ÕM�Ø+¨bÕ0°1Õ4°qÕ8�äŸ=š=Ø˜uÕ%×/Ñ/°Ó2Ø ×%Ñ% a¨¨B°Ó2×5Ñ5°j×6FÑ6FÓGØ#Ø"&ô	ð
 õ�ð × Ñ  Ô.Ø ×'Ñ'¨Ô8Ø× Ñ  Ô*ç ’=ð  ��AØ ŸL™L¨Õ.°¸WÕ1EÕE�EÜŸ,š,Ð'8¸!¸UÀEÓJ�CØ!×(Ñ(Ô)9¸#Ó)>×?ó[ "ô^ ˜qŸ�Ø/°Õ6�Ü#(§;¢;Ø  1•_¤e§i¢i°¸QÈgÔ&VÐWØô$Ð ð  0×2Ñ2°;Ó?À"ÕDÀqÕHÈ1ÕL�ÜŸ=š=Ø˜uÕ%×/Ñ/°Ó2Ø ×%Ñ% a¨¨B°Ó2×5Ñ5°j×6FÑ6FÓGØ#Ø"&ô	ð
 õ�ð × Ñ  Ô.Ø ×'Ñ'¬×(8Ò(8¸Ó(BÔCØ× Ñ  Ô*ß ’=à&×,Ñ,¨QÕ/�CØ!×(Ñ(ÜŸ	š	 !¨J×,=Ñ,=ÀZ×EUÑEUÔV×`Ñ`ÐabÓc×jÑjÐknÐprÐtvÓw÷ñ' "÷. Ø˜iÐ)9¸=ÐHÐHØ˜)Ð%5Ð5Ð5ùòQ !ds   ÉA b=)r<   rš   r—   r™   r¢   r˜   r¤   )r   r   çš™™™™™É?é N  )TNF)
r-   r.   r/   r0   r1   r¡   r¶   r  r4   Ú__classcell__©r©   s   @r   r•   r•   è   s*   ø† ñ÷Cò C÷(
ð 
÷"Z6õ Z6r!   r•   c                  óB   € ] tR tRtRtRR R lltR R ltR R ltR	tR
# )ÚInputPadderi½  zKPad an image so that both spatial dimensions are divisible by ``divis_by``.c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   re   r   rf   Údivis_byr   r›   r   )r   s   "r   r   ÚInputPadder.__annotate__À  s.   € ÷ [ñ [˜#ð [ #ð [°ð [¸Tñ [r!   c                	ó  € Wn         W n        W,           ^,
          V,          V,          V,
          pW#,           ^,
          V,          V,          V,
          pV^,          WU^,          ,
          V^,          WD^,          ,
          .V n        R# )r;   N)ÚhtÚwdÚ_pad)r$   re   rf   r  Úpad_htÚpad_wds   &&&&  r   r¡   ÚInputPadder.__init__À  sk   € ØŒØŒð •, Õ" xÕ/°(Õ:¸QÕ>ˆØ•, Õ" xÕ/°(Õ:¸QÕ>ˆØ˜q•[ &°Q­;Õ"6¸À!½ÀVÐXYÍkÕEYÐZˆŽ	r!   c               ó    € V ^8„  d   QhRRRR/# ©r   ri   r   r   r   )r   s   "r   r   r  É  s   € ÷ 5ñ 5�\ð 5 lñ 5r!   c                óF   € \         P                  ! WP                  RR7      # )zTReplicate-pad ``x`` ``(B, C, H, W)`` around its centre to multiples of ``divis_by``.Ú	replicate)rÇ   )rÞ   Úpadr  ©r$   ri   s   &&r   r"  ÚInputPadder.padÉ  s   € ä�uŠu�QŸ	™	¨Ô4Ð4r!   c               ó    € V ^8„  d   QhRRRR/# r  r   )r   s   "r   r   r  Í  s   € ÷ 0ñ 0�|ð 0¨ñ 0r!   c                óP  € VP                   R,          VP                   R,          r2V P                  ^,          W P                  ^,          ,
          V P                  ^ ,          W0P                  ^,          ,
          .pVRV^ ,          V^,          1V^,          V^,          13,          # )z(Remove the padding added by :meth:`pad`..éþÿÿÿrX   )r#   r  )r$   ri   r  r  rd   s   &&   r   ÚunpadÚInputPadder.unpadÍ  sw   € à—‘˜•˜aŸg™g b�kˆBØ�Y‰Y�q�\˜2§	¡	¨!¥Õ,¨d¯i©i¸­l¸BÇÁÈ1ÅÕ<MÐNˆØ��a˜•d˜Q˜q�T�k 1 Q¥4¨!¨A­$ ;Ð.Õ/Ð/r!   )r  r  r  N)é   )	r-   r.   r/   r0   r1   r¡   r"  r(  r4   r   r!   r   r  r  ½  s   † ÙU÷[õ5÷0ñ 0r!   r  c                  óB   a € ] tR tRtRtRR V 3R llltR R ltRtV ;t# )	ÚDeformableConv2diÙ  a  Deformable conv2d (DCNv1 or DCNv2) without torchvision dependency.

Uses the pure-PyTorch :func:`~kornia.feature.aliked.deform_conv2d.deform_conv2d`
implementation that matches ``torchvision.ops.deform_conv2d``.

Args:
    in_channels: number of input channels.
    out_channels: number of output channels.
    kernel_size: spatial kernel size.
    stride: convolution stride.
    padding: zero-padding size.
    bias: whether to add a learnable bias.
    mask: if ``True`` use DCNv2 modulation mask (3 * k*k offsets instead of 2).
c               ó<   € V ^8„  d   QhRRRRRRRRRRRRRR	R
R	RR/	# )r   Úin_channelsr   Úout_channelsr<   r8   rF   rC   r=   rq   ró   r   r›   r   )r   s   "r   r   ÚDeformableConv2d.__annotate__é  sd   € ÷ "
ñ "
àð"
ð ð"
ð ð	"
ð
 ð"
ð ð"
ð ð"
ð ð"
ð ð"
ð 
ñ"
r!   c	           
     	ór  <€ \         S	V `  4        W@n        WPn        W`n        W€n        V'       d   ^V,          V,          M^V,          V,          V n        \        P                  ! VV P                  VVV P                  VRR7      V n	        \        P                  ! VVVVV P                  VVR7      V n
        R# )rE   T)r<   r8   rF   rC   r=   )r.  r/  r<   r8   rF   rC   r=   N)r    r¡   r8   rF   rC   ró   Úchannel_numr	   r?   Úoffset_convÚregular_conv)
r$   r.  r/  r<   r8   rF   rC   r=   ró   r©   s
   &&&&&&&&&€r   r¡   ÚDeformableConv2d.__init__é  sŸ   ø€ ô 	‰ÑÔØŒØŒØ ŒØŒ	ß<@˜1˜{�?¨[Ö8ÀaÈ+ÅoÐXcÕFcˆÔÜŸ9š9ØØ×ÑØ#ØØ—L‘LØØô
ˆÔô ŸIšIØ#Ø%Ø#ØØ—L‘LØØô
ˆÖr!   c               ó    € V ^8„  d   QhRRRR/# r  r   )r   s   "r   r   r0    s   € ÷ 
ñ 
˜ð 
¨,ñ 
r!   c                ó"  € VP                   R,          w  r#\        W#4      R,          pV P                  V4      pV P                  '       dW   VP                   ^,          ^,          pVRR^V,          13,          \        P
                  ! VR^V,          R13,          4      r‡MTpRpVP                  V) V4      p\        VVV P                  P                  V P                  P                  V P                  V P                  V P                  VR7      # )z¬Run the module forward pass.

Args:
    x: Input feature map with shape ``(B, C_in, H, W)``.

Returns:
    Deformable convolution output with shape ``(B, C_out, H', W')``.
:r   NNç      @rV   N)Úinputrh   Úweightr=   r8   rF   rC   ró   )r#   rN   r3  ró   r[   ÚsigmoidrZ   r   r4  r:  r=   r8   rF   rC   )	r$   ri   re   rf   Ú
max_offsetÚoutr%   rh   Úmask_ws	   &&       r   r  ÚDeformableConv2d.forward  sÞ   € ð �w‰w�r�{‰ˆÜ˜“Y •_ˆ
Ø×Ñ˜qÓ!ˆØ�9�9ˆ9à—	‘	˜!• Õ!ˆAØ   G a¨!¥e G �_¬e¯mªm¸CÀÀ1ÀqÅ5Á7À
½OÓ.L‘FàˆFØˆFØ—‘˜z˜k¨:Ó6ˆÜØØØ×$Ñ$×+Ñ+Ø×"Ñ"×'Ñ'Ø—;‘;Ø—L‘LØ—]‘]Øô	
ð 		
r!   )r2  rC   ró   r3  rF   r4  r8   )rE   r;   r;   r;   FF©	r-   r.   r/   r0   r1   r¡   r  r4   r  r  s   @r   r,  r,  Ù  s   ø† ñ÷"
ò "
÷H
ó 
r!   r,  c               ó<   € V ^8„  d   QhRRRRRRRRRRRRR	R
RRRR/	# )r   Úinplanesr   Úplanesr<   r8   rF   r=   rq   Ú	conv_typer®   ró   r   z	nn.Moduler   )r   s   "r   r   r   -  sm   € ÷ Tñ TØðTàðTð ðTð ð	Tð
 ðTð ðTð ðTð ðTð ñTr!   c           
     ó´   € VR8X  d   \         P                  ! WW#WER7      # VR8X  d#   \        V VVV\        V4      ^ ,          VVR7      # \	        RV: R24      h)z-Return a standard or deformable conv2d layer.Úconv©r<   r8   rF   r=   Údcn)r<   r8   rF   r=   ró   zUnknown conv_type: z. Expected 'conv' or 'dcn'.)r	   r?   r,  r
   Ú	TypeError)rB  rC  r<   r8   rF   r=   rD  ró   s   &&&&&&&&r   Úget_convrJ  -  sk   € ð �FÔÜ�yŠy˜°{Ð[bÔnÐnØ�EÔÜØØØ#ØÜ˜'“N 1Õ%ØØô
ð 	
ô Ð)¨)©Ð6QÐRÓ
SÐSr!   c                  óB   a € ] tR tRtRtRR V 3R llltR R ltRtV ;t# )	Ú	ConvBlockiG  z4Two-layer conv block with BN and an activation gate.c               ó4   € V ^8„  d   QhRRRRRRRRRRR	R
RR/# )r   r.  r   r/  Úgateú"Optional[Callable[..., nn.Module]]Ú
norm_layerrD  r®   ró   rq   r   r›   r   )r   s   "r   r   ÚConvBlock.__annotate__J  sP   € ÷ ,ñ ,àð,ð ð,ð 1ð	,ð
 7ð,ð ð,ð ð,ð 
ñ,r!   c                	ó  <€ \         SV `  4        Vf   \        P                  ! RR7      MTV n        Vf   \        P
                  p\        W^WVR7      V n        V! V4      V n        \        W"^WVR7      V n	        V! V4      V n
        R # )NT©Úinplace©r<   rD  ró   )r    r¡   r	   ÚReLUrN  ÚBatchNorm2drJ  Úconv1Úbn1Úconv2Úbn2)r$   r.  r/  rN  rP  rD  ró   r©   s   &&&&&&&€r   r¡   ÚConvBlock.__init__J  so   ø€ ô 	‰ÑÔØ-1ª\”B—G’G DÕ)¸tˆŒ	ØÒÜŸ™ˆJÜ˜kÀQÐR[ÔgˆŒ
Ù˜lÓ+ˆŒÜ˜lÀaÐS\ÔhˆŒ
Ù˜lÓ+ˆŽr!   c               ó    € V ^8„  d   QhRRRR/# r  r   )r   s   "r   r   rQ  \  s   € ÷ 
2ñ 
2˜ð 
2¨,ñ 
2r!   c                ó¾   € V P                  V P                  V P                  V4      4      4      pV P                  V P                  V P	                  V4      4      4      # )z·Run the module forward pass.

Args:
    x: Input feature map with shape ``(B, C_in, H, W)``.

Returns:
    Feature map with shape ``(B, C_out, H, W)`` after two gated conv-BN layers.
)rN  rY  rX  r[  rZ  r#  s   &&r   r  ÚConvBlock.forward\  sC   € ð �I‰I�d—h‘h˜tŸz™z¨!›}Ó-Ó.ˆØ�y‰y˜Ÿ™ $§*¡*¨Q£-Ó0Ó1Ð1r!   )rY  r[  rX  rZ  rN  )NNrF  Fr@  r  s   @r   rL  rL  G  s   ø† Ù>÷,ò ,÷$
2ó 
2r!   rL  c                  óR   a € ] tR tRt$ Rt^tR]R&   R
R V 3R llltR R ltR	t	V ;t
# )ÚResBlockii  zGResidual block (BasicBlock variant) supporting deformable convolutions.r   Ú	expansionc               óH   € V ^8„  d   Qh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   rB  r   rC  r8   Ú
downsampleúOptional[nn.Module]rB   Ú
base_widthrC   rN  rO  rP  rD  r®   ró   rq   r   r›   r   )r   s   "r   r   ÚResBlock.__annotate__n  s‚   € ÷ ñ àðð ðð ð	ð
 (ðð ðð ðð ðð 1ðð 7ðð ðð ðð 
ñr!   c                	óˆ  <€ \         SV `  4        Vf   \        P                  ! RR7      V n        MW€n        V	f   \        P
                  p	V^8w  g   V^@8w  d   \        R4      hV^8”  d   \        R4      h\        W^W«R7      V n	        V	! V4      V n
        \        W"^W«R7      V n        V	! V4      V n        W@n        W0n        R # )NTrS  z1ResBlock only supports groups=1 and base_width=64z&Dilation > 1 not supported in ResBlockrU  )r    r¡   r	   rV  rN  rW  Ú
ValueErrorÚNotImplementedErrorrJ  rX  rY  rZ  r[  rd  r8   )r$   rB  rC  r8   rd  rB   rf  rC   rN  rP  rD  ró   r©   s   &&&&&&&&&&&&€r   r¡   ÚResBlock.__init__n  s¨   ø€ ô 	‰ÑÔØŠ<ÜŸš¨Ô-ˆD�IàŒIØÒÜŸ™ˆJØ�QŒ;˜*¨Ô*ÜÐPÓQÐQØ�aŒ<Ü%Ð&NÓOÐOÜ˜h¸AÈÔ^ˆŒ
Ù˜fÓ%ˆŒÜ˜f¸!ÀyÔ\ˆŒ
Ù˜fÓ%ˆŒØ$ŒØŽr!   c               ó    € V ^8„  d   QhRRRR/# r  r   )r   s   "r   r   rg  Ž  s   € ÷ )ñ )˜ð )¨,ñ )r!   c                ó  € TpV P                  V P                  V P                  V4      4      4      pV P                  V P	                  V4      4      pV P
                  e   V P                  V4      pV P                  W2,           4      # )züRun the module forward pass.

Args:
    x: Input feature map with shape ``(B, C_in, H, W)``.

Returns:
    Feature map with shape ``(B, C_out, H', W')`` after the residual block,
    where ``H'`` and ``W'`` may differ from the input if ``stride > 1``.
)rN  rY  rX  r[  rZ  rd  )r$   ri   Úidentityr=  s   &&  r   r  ÚResBlock.forwardŽ  sg   € ð ˆØ�i‰i˜Ÿ™ §¡¨A£Ó/Ó0ˆØ�h‰h�t—z‘z #“Ó'ˆØ�?‰?Ò&Ø—‘ qÓ)ˆHØ�y‰y˜�Ó(Ð(r!   )rY  r[  rX  rZ  rd  rN  r8   )	r;   Nr;   é@   r;   NNrF  F)r-   r.   r/   r0   r1   rb  r2   r¡   r  r4   r  r  s   @r   ra  ra  i  s%   ø‡ ÙQà€IˆsÓ÷ò ÷@)ó )r!   ra  c                  óB   a € ] tR tRtRtRR V 3R llltR R ltRtV ;t# )	ÚSDDHi¥  aâ  Sparse descriptor head using deformable sampling positions.

Args:
    dims: input feature dimension.
    kernel_size: patch size used to estimate sampling offsets.
    n_pos: number of deformable sampling positions per keypoint.
    gate: activation function for the offset network.
    conv2d: if ``True`` use a 1x1 conv to aggregate features; otherwise
        use a learnable weighted sum (``agg_weights``).
    mask: if ``True`` use DCNv2-style attention weighting on samples.
c               ó4   € V ^8„  d   QhRRRRRRRRRRR	RR
R/# )r   Údimsr   r<   Ún_posrN  re  Úconv2drq   ró   r   r›   r   )r   s   "r   r   ÚSDDH.__annotate__²  sY   € ÷ gñ gàðgð ðgð ð	gð
 "ðgð ðgð ðgð 
ñgr!   c                	óÒ  <€ \         SV `  4        Vf   \        P                  ! 4       pW n        W0n        WPn        W`n        \        V n	        V'       d
   ^V,          M^V,          V n
        \        P                  ! \        P                  ! WP                  V^^ RR7      V\        P                  ! V P                  V P                  ^^^ RR7      4      V n        \        P                  ! W^^^ RR7      V n        V'       g@   \        P                  ! \         P"                  ! W1V4      4      pV P%                  RV4       R # \        P                  ! W,          V^^^ RR7      V n        R # )NTrG  FÚagg_weights)r    r¡   r	   rV  r<   ru  rv  ró   rn   Úget_patches_funcr2  Ú
Sequentialr?   r3  Úsf_convÚ	Parameterr[   ÚrandÚregister_parameterÚconvM)	r$   rt  r<   ru  rN  rv  ró   ry  r©   s	   &&&&&&& €r   r¡   ÚSDDH.__init__²  s  ø€ ô 	‰ÑÔØŠ<Ü—7’7“9ˆDØ&ÔØŒ
ØŒØŒ	Ü +ˆÔç(,˜1˜už9°!°eµ)ˆÔÜŸ=š=Ü�IŠI�d×,Ñ,¸+ÈaÐYZÐaeÔfØÜ�IŠI�d×&Ñ&¨×(8Ñ(8ÀaÐPQÐ[\ÐcgÔhó
ˆÔô
 —y’y ¸À1ÈaÐV[Ô\ˆŒçÜŸ,š,¤u§z¢z°%¸tÓ'DÓEˆKØ×#Ñ# M°;Ö?äŸš 4¥<°À1ÈQÐXYÐ`eÔfˆDŽJr!   c               ó$   € V ^8„  d   QhRRRRRR/# )r   ri   r   r   zlist[torch.Tensor]r   z-tuple[list[torch.Tensor], list[torch.Tensor]]r   )r   s   "r   r   rw  Ò  s-   € ÷ K)ñ K)àðK)ð &ðK)ð 
7ñ	K)r!   c                óœ	  € VP                   w  r4rV\        V^,
          V^,
          ..VP                  \        P                  ! VP
                  \        P                  4      R7      p\        WV4      R,          pV P                  w  ršpV	P                  P                  ^4      pVP                  P                  ^4      pV P                  P                  P                  ^4      p. p. p\        V4       EFÔ  pVV,          VV,          ppV^,          R,           V,          p\        V4      pV P                  ^8”  d-   V P                  VVP!                  4       V P                  4      pMLVP!                  4       pVRVR,          VR,          3,          P#                  ^^ 4      P%                  VV^^4      pV
! \&        P(                  ! VP                  ^4      WÉP*                  4      R,          4      P                  ^4      p\&        P(                  ! VWÛP*                  4      P-                  V) V4      pV P.                  '       d[   VP1                  V^V P2                  4      P#                  ^ ^^4      p\        P4                  ! VR,          4      pVRRRR13,          pM0VP1                  V^V P2                  4      P#                  ^ ^^4      pRpVP7                  V4       VP9                  ^4      V,           pRV,          VR,          ,          ^,
          pVP%                  ^VV P2                  ,          ^^4      p\&        P:                  ! VP9                  ^ 4      VP=                  VP
                  4      RRR	7      pVP%                  VVV P2                  4      P#                  ^^^ 4      pVe   VVR,          ,          p\        P>                  ! \&        P(                  ! VWàP                  P*                  4      4      pV P@                  '       g4   VP                  ^4      V PB                  P                  ^ ^4      ,          pM[VPE                  ^^4      P                  ^4      p\&        P(                  ! VV PF                  P                  P                  ^4      4      p\&        PH                  ! VR^R
7      pVP7                  V4       EK×  	  VV3# )a  Compute descriptors at keypoint locations.

Args:
    x: dense feature map ``(B, C, H, W)``.
    keypoints: list of ``(N_i, 2)`` normalised keypoint coordinates ``[-1, 1]``.

Returns:
    A pair ``(descriptors, offsets)`` where each element is a list of length B.
rO   r8  g      à?rV   Nr{   rÅ   TrÆ   ©Úpr}   rW   rU   )rV   rV   NNrX   )rV   rV   rX   )rV   rV   N)%r#   r   rP   r[   rÙ   rQ   ru   rN   r3  r:  rÍ   r|  rÏ   rÖ   r<   rz  rY   r_   ra   rÞ   Úlinearr=   rZ   ró   r¦   ru  r;  rØ   r`   rß   r+   Úselu_rv  ry  Ú	transposer€  Ú	normalize)r$   ri   r   rä   rd   re   rf   rø   r<  Úconv_offsetrN  Úconv_offset_1x1Úw_offsetÚw_offset_1x1Úw_sfÚoffsets_listr   ÚibÚxiÚkptsiÚkptsi_whÚN_kptsrý   Úkptsi_wh_longrh   r>  ÚposÚfeaturesÚdescss   &&&                          r   r  ÚSDDH.forwardÒ  sÏ  € ð —W‘W‰
ˆˆaä˜q 1�u a¨!¥e˜nÐ-°a·h±hÄe×FYÒFYÐZ[×ZaÑZaÔch×cpÑcpÓFqÔrˆÜ˜“Y •_ˆ
ð
 .2×-=Ñ-=Ñ*ˆ˜?Ø×%Ñ%×-Ñ-¨aÓ0ˆØ&×-Ñ-×5Ñ5°aÓ8ˆØ�|‰|×"Ñ"×*Ñ*¨1Ó-ˆàˆØˆä˜—(ˆBØ˜"�˜y¨�}�ˆBØ �	 C�¨2Õ-ˆHÜ˜“ZˆFà×Ñ !Ô#Ø×-Ñ-¨b°(·-±-³/À4×CSÑCSÓT‘à (§¡£�Ø˜1˜m¨DÕ1°=ÀÕ3FÐFÕG×OÑOÐPQÐSTÓU×]Ñ]Ð^dÐfgÐijÐlmÓn�ñ œ!Ÿ(š( 5§=¡=°Ó#3°X×?OÑ?OÓPÐQaÕbÓc×kÑkÐlmÓnˆFÜ—X’X˜f l×4HÑ4HÓI×OÑOÐQ[ÐP[Ð]gÓhˆFà�y�yˆyØŸ™ V¨Q°·
±
Ó;×CÑCÀAÀqÈ!ÓL�ÜŸš v¨hÕ'7Ó8�Ø  1 c r c 	Õ*‘àŸ™ V¨Q°·
±
Ó;×CÑCÀAÀqÈ!ÓL�Ø�Ø×Ñ Ô'à×$Ñ$ QÓ'¨&Õ0ˆCØ˜•)˜b �hÕ&¨Õ*ˆCØ—+‘+˜a ¨$¯*©*Õ!4°a¸Ó;ˆCä—}’} R§\¡\°!£_°c·f±f¸R¿X¹XÓ6FÈZÐgkÔlˆHØ×'Ñ'¨¨6°4·:±:Ó>×FÑFÀqÈ!ÈQÓOˆHàÒ!Ø# f¨ZÕ&8Õ8�ä—{’{¤1§8¢8¨H°d¿L¹L×<MÑ<MÓ#NÓOˆHà—;—;�;Ø ×(Ñ(¨Ó+¨d×.>Ñ.>×.FÑ.FÀqÈ!Ó.LÕL‘à#×-Ñ-¨a°Ó3×;Ñ;¸AÓ>�ÜŸš ¨4¯:©:×+<Ñ+<×+DÑ+DÀQÓ+GÓH�ä—K’K ¨°!Ô4ˆEØ×Ñ˜u×%ñW ðZ ˜LÐ(Ð(r!   )	r2  rv  r€  rz  r<   ró   ru  r3  r|  )rE   r*  NFFr@  r  s   @r   rr  rr  ¥  s!   ø† ñ
÷gò g÷@K)ó K)r!   rr  z
aliked-t16ú
aliked-n16zaliked-n16rotz
aliked-n32z3dict[str, tuple[int, int, int, int, int, int, int]]Ú_ALIKED_CFGSz8https://huggingface.co/kornia/aliked/resolve/main/{}.pthz:https://github.com/Shiaoming/ALIKED/raw/main/models/{}.pthc                  ó    a € ] tR tRt$ RtRtR]R&   RR V 3R llltR R	 ltR
R/R R llt	RR R llt
RR R llt]RR R ll4       tRtV ;t# )ÚALIKEDi2  a˜  Detect sub-pixel keypoints in images of any size, described by deformable sampling (ALIKED).

``aliked = ALIKED.from_pretrained("aliked-n16")`` loads the trained weights in evaluation mode, and
``features = aliked(images)`` takes RGB images ``(B, 3, H, W)`` in :math:`[0, 1]`, or grayscale ``(B, 1, H, W)``,
of any height and width, and returns a list of ``B`` :class:`ALIKEDFeatures`, one per image. Each holds sub-pixel
keypoints ``(N, 2)`` as ``(x, y)`` pixels, their scores ``(N,)`` and L2-normalised descriptors ``(N, D)``, with
``D`` 128, or 64 for ``"aliked-t16"``, and ``N`` set by the image's score map. With
``lafs, responses, descs = aliked.forward_laf(images)``, the same keypoints, scores and descriptors come as
tensors ``(B, N, 2, 3)``, ``(B, N, 1)`` and ``(B, N, D)``, padded to the largest ``N`` of the batch. To match two
images, pass the 128-D descriptors with ``laf_from_center_scale_ori(keypoints[None])`` to
:class:`LightGlueMatcher` in ``"aliked"`` mode; for the same number of keypoints in every image, use
:class:`DeDoDe` instead.

ALIKED (Adaptive Local Image KEypoint Detection) combines a multi-scale ResNet backbone with deformable
descriptor sampling (SDDH) and a differentiable keypoint detector (DKD); see :cite:`zhao2023aliked` for details.

Speed against the authors' Python code (640 px, 2,048 keypoints): on CUDA, compile the model for repeated
inference. Eager, it runs at 0.8x the authors' speed on an RTX 4090, because its PyTorch deformable convolution
launches many small kernels; ``torch.compile(model)`` runs at 1.6x (1.2x with ``dynamic=True``). On CPUs keep it
eager: it runs at 1.7-2.0x the authors' speed, and compiling it made it slower on an x86 CPU. See the `image
matching guide <https://kornia.readthedocs.io/en/latest/applications/image_matching.html#feature-speed-by-device>`_.

.. image:: _static/img/ALIKED.png

Convention:
    - ``ALIKED()`` builds random weights in training mode, where BatchNorm normalises with the batch, updates its
      running statistics on every call, and a single small image raises; call ``.eval()`` for inference.
      :meth:`from_pretrained` returns the trained model in evaluation mode.
    - The network applies no normalisation, so pass images in :math:`[0, 1]`, the range of the pretrained
      weights; a ``(B, 1, H, W)`` image is repeated to three channels, and other channel counts raise. Any ``H``
      and ``W`` work: the image is replicate-padded around its centre to multiples of 32 and the maps are cropped
      back, so the padding does not move the keypoints. The image must have the model's dtype: a float16,
      bfloat16 or float64 image raises on a float32 model, so cast the model first, ``aliked.to(images.dtype)``.
    - The keypoints of :meth:`forward` are sub-pixel ``(x, y)`` in the pixel convention of
      :func:`~kornia.feature.laf_from_center_scale_ori`
      (see :ref:`Local features <local-features-conventions>`): a strict maximum of the score map in its
      ``2 * nms_radius + 1`` window (see the note), at least ``nms_radius`` pixels from the border, moved by a
      soft-argmax over that window. Its score is the score map read bilinearly there, and the descriptors are
      L2-normalised. The keypoints, and the LAFs of :meth:`forward_laf`, are float32 for a float16 or bfloat16
      model and otherwise in the image's dtype; scores and descriptors keep the model's dtype.
    - With ``detection_threshold > 0`` (threshold mode), the maxima strictly above it are kept, at most
      ``max_num_keypoints`` of them, and at most 20000 for a non-positive ``max_num_keypoints``. An image with no
      maximum above the threshold keeps the maxima above its own mean score instead, whatever the rest of the
      batch. With ``detection_threshold <= 0`` and ``max_num_keypoints > 0`` (top-k mode), the
      ``max_num_keypoints`` strongest maxima are kept, or all of them when there are fewer; with both ``<= 0``,
      the maxima above the image's mean score.
    - ``image_size`` holds the valid ``(W, H)`` of each image of a batch padded at the bottom and right to a
      common size: maxima closer than ``nms_radius`` pixels to that image's last valid row or column are dropped.
    - :meth:`forward_laf` returns padded tensors like :class:`~kornia.feature.LocalFeature`, but ``N`` is the
      largest keypoint count in the batch and the responses are ``(B, N, 1)``. Padded slots hold zero LAFs,
      responses and descriptors; ``laf_is_filled(lafs)`` is true for detections, so index every output with it to
      discard the padding. Its ``mask`` multiplies the score map, and it takes no ``image_size``.
    - Known defects: on CPU, float16 and bfloat16 score and feature maps go to torch's ``grid_sample`` without
      an upcast: the half-precision kernel can return wrong values, NaN or overflow, and where torch has none the
      call raises (`#5810 <https://github.com/kornia/kornia/issues/5810>`_).

Args:
    model_name: backbone configuration, one of
        ``'aliked-t16'``, ``'aliked-n16'``, ``'aliked-n16rot'``, ``'aliked-n32'``.
    max_num_keypoints: the keypoint budget, a cap on the number of maxima kept in threshold mode and in top-k
        mode; see the Convention block.
    detection_threshold: a positive value selects threshold mode and is the score a maximum must exceed; zero or
        a negative value selects top-k mode when ``max_num_keypoints`` is positive. See the Convention block.
    nms_radius: NMS radius (kernel size ``= 2 * nms_radius + 1``). The suppression keeps strict local maxima
        only; see the note below.

Note:
    Keypoints are the strict local maxima of the score map: :func:`~kornia.geometry.subpix.nms2d` keeps a
    position only if its score is greater than every other score in its ``2 * nms_radius + 1`` window. This
    departs on purpose from the reference implementations (Shiaoming/ALIKED and LightGlue's port). Their
    ``simple_nms`` also keeps tied maxima, and in two further rounds it adds the positions that become the
    maximum of their window once the windows around the maxima already kept are zeroed. Those positions lie on
    the flank of a stronger peak and are not local maxima of the score map. In threshold mode, when neither the
    keypoint budget nor the fallback below decides the count, kornia therefore returns a subset of the reference
    keypoints: with the pretrained ``aliked-n16`` and the default threshold it returns up to 10 % fewer keypoints
    than the reference on the Oxford img1 images, and each one left out has a higher score in its window.
    Otherwise the two keypoint sets need not be nested, because the reference ranks those extra positions with
    the maxima: in top-k mode, where it also fills ``top_k`` slots with positions that are not maxima when the
    score map has fewer maxima, and when the budget cuts the count in threshold mode. The reference falls back to
    the mean score only when no image of the batch has a maximum above the threshold; kornia returns maxima only
    and decides the fallback for each image, so an image's keypoints do not depend on the rest of the batch.

See Also:
    - :class:`ALIKEDFeatures`: the per-image result of :meth:`forward`.
    - :class:`DISK`: learned integer-pixel keypoints with 128-D descriptors, for RGB images whose sides are
      multiples of 16.
    - :class:`XFeat`: learned keypoints with 64-D descriptors, and its own mutual-nearest-neighbour and refined
      matching of image pairs.
    - :class:`DeDoDe`: separate learned detector and descriptor networks, with ``n`` keypoints in every image.
    - :class:`LocalFeature`: a classical detector and LAF descriptor in one call; :meth:`forward_laf` returns
      padded LAF tensors like it, with ``(B, N, 1)`` responses.
    - :class:`LightGlueMatcher`: matches ALIKED's descriptors and keypoints with the ``"aliked"`` weights.

Example:
    >>> aliked = ALIKED.from_pretrained('aliked-n16')  # doctest: +SKIP
    >>> images = torch.rand(1, 3, 256, 256)  # doctest: +SKIP
    >>> features = aliked(images)  # doctest: +SKIP
r  r   Ún_limit_maxc          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   Ú
model_namer®   Úmax_num_keypointsr   Údetection_thresholdr�   Ú
nms_radiusr   r›   r   )r   s   "r   r   ÚALIKED.__annotate__˜  s<   € ÷ 9
ñ 9
àð9
ð ð9
ð #ð	9
ð
 ð9
ð 
ñ9
r!   c                	óÜ  <€ \         SV `  4        V\        9  d!   \        R V: R\	        \        4       R24      hWn        W n        W0n        W@n        \        V,          w  rVrxršp. ROpRpRp\        P                  ! ^^R7      V n        \        P                  ! ^^R7      V n        \        P                  V n        \        P                  ! RR7      V n        \#        ^WPP                   V P                  V^ ,          R7      V n        V P'                  WVV^,          V4      V n        V P'                  WgV^,          V4      V n        V P'                  WxV^,          V4      V n        \/        WY^,          4      V n        \/        Wi^,          4      V n        \/        Wy^,          4      V n        \/        W™^,          4      V n        \        P8                  ! ^RRR	7      V n        \        P8                  ! ^RRR	7      V n        \        P8                  ! ^RRR	7      V n        \        P8                  ! ^ RRR	7      V n         \        PB                  ! \/        V	^4      V P                   \E        ^^4      V P                   \E        ^^4      V P                   \E        ^^4      4      V n#        \I        WšW°P                   WÞR
7      V n%        \M        TV^ 8”  d   RMTTV^ 8”  d   TMV PN                  R7      V n(        R# )zUnknown model_name z. Choose from Ú.F)r<   r8   TrS  )rD  rÅ   )Úscale_factorrÇ   rÈ   )rN  rv  ró   )r—   r˜   r™   rš   N)rF  rF  rH  rH  rX   ))r    r¡   r›  ri  Úlistr   r¡  r¢  r£  r	   Ú	AvgPool2dÚpool2Úpool4rW  rÝ   ÚSELUrN  rL  Úblock1Ú_make_resblockÚblock2Úblock3Úblock4r@   rX  rZ  Úconv3Úconv4ÚUpsampleÚ	upsample2Ú	upsample4Ú	upsample8Ú
upsample32r{  rG   Ú
score_headrr  Ú	desc_headr•   rž  Údkd)r$   r   r¡  r¢  r£  Úc1Úc2Úc3Úc4r}   ÚKÚMÚ
conv_typesrv  ró   r©   s   &&&&&          €r   r¡   ÚALIKED.__init__˜  sE  ø€ ô 	‰ÑÔàœ\Ô)ÜÐ2°:±.ÀÌtÔT`ÓOaÐNbÐbcÐdÓeÐeà$ŒØ!2ÔØ#6Ô Ø$Œä$0°Õ$<Ñ!ˆ�˜ Ú3ˆ
ØˆØˆä—\’\¨a¸Ô:ˆŒ
Ü—\’\¨a¸Ô:ˆŒ
Ü—N‘NˆŒ	Ü—G’G DÔ)ˆŒ	ä  2§y¡y°$·)±)ÀzÐRSÅ}ÔUˆŒØ×)Ñ)¨"°*¸Qµ-ÀÓFˆŒØ×)Ñ)¨"°*¸Qµ-ÀÓFˆŒØ×)Ñ)¨"°*¸Qµ-ÀÓFˆŒä˜b¨¥(Ó+ˆŒ
Ü˜b¨¥(Ó+ˆŒ
Ü˜b¨¥(Ó+ˆŒ
Ü˜c¨!¥8Ó,ˆŒ
äŸš°!¸*ÐTXÔYˆŒÜŸš°!¸*ÐTXÔYˆŒÜŸš°!¸*ÐTXÔYˆŒÜŸ+š+°2¸JÐVZÔ[ˆŒäŸ-š-Ü�S˜!ÓØ�I‰IÜ�Q˜‹NØ�I‰IÜ�Q˜‹NØ�I‰IÜ�Q˜‹Nó
ˆŒô ˜c a¯i©iÀÔRˆŒÜØØ+¨aÔ/‘"Ð5FØ)Ø):¸QÔ)>Ñ%ÀD×DTÑDTô	
ˆŽr!   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   Úc_inr   Úc_outrD  r®   ró   rq   r   ra  r   )r   s   "r   r   r¤  Ó  s0   € ÷ 

ñ 

 3ð 

¨sð 

¸sð 

È$ð 

ÐS[ñ 

r!   c                	óz   € \        VV^\        P                  ! W^4      V P                  V P                  VVR7      # )r;   )r8   rd  rN  rP  rD  ró   )ra  r	   r?   rN  rÝ   )r$   rÅ  rÆ  rD  ró   s   &&&&&r   r®  ÚALIKED._make_resblockÓ  s:   € ÜØØØÜ—y’y ¨aÓ0Ø—‘Ø—y‘yØØô	
ð 		
r!   Úchannels_lastFc               ó$   € V ^8„  d   QhRRRRRR/# )r   rp   r   rÉ  rq   r   z!tuple[torch.Tensor, torch.Tensor]r   )r   s   "r   r   r¤  ß  s$   € ÷ >&ñ >&Ø!ð>&Ø59ð>&à	*ñ>&r!   c               óp  € ^ p\        VP                  R,          VP                  R,          V4      pVP                  V4      pV P                  V4      pV P	                  V P                  V4      4      pV P                  V P                  V4      4      pV P                  V P                  V4      4      pV P                  V P                  V4      4      pV P                  V P                  V4      4      pV P                  V P                  V4      4      pV P                  V P                  V4      4      pV P                  V4      p	V P                  V4      p
V P!                  V4      p\"        P$                  ! WYW«.^R7      p\"        P&                  ! V P)                  V4      4      pV'       dM   \*        P,                  ! VP/                  ^ ^^^4      P1                  4       ^RR7      P/                  ^ ^^^4      pM\*        P,                  ! V^^R7      pVP3                  V4      pVP3                  V4      pWí3# )ae  Run the backbone and return ``(feature_map, score_map)``.

Args:
    image: ``(B, 3, H, W)`` float image. Inputs are internally padded to
        a multiple of 32 and the padding is removed before returning.
    channels_last: if ``True``, ``feature_map`` has the strides of the ``torch.channels_last`` memory
        format (it is a crop of such a tensor when the image was padded): the ``dim`` channels of each pixel
        lie next to each other. Its values equal those of the default
        layout up to the rounding of the normalisation, and ``score_map`` is the same either way. On CPU,
        normalising the map and the sampling of the descriptor head are then several times faster, so
        :meth:`forward` and :meth:`forward_laf` use it for a float32 or float64 CPU image in eager. They keep
        the default elsewhere: on MPS, ``grid_sample`` is about 4x slower with this layout; on CUDA the forward
        is 0.80-0.94x as fast with it (RTX 4090, float32, float16 and bfloat16); and on CPU torch's float16
        and bfloat16 ``grid_sample`` is unreliable in either layout: it returned NaN for this one on an Apple
        M1, and on x86 it crashes the process for a 640 x 480 image in both
        (`#5810 <https://github.com/kornia/kornia/issues/5810>`_). By default each channel is a plane of the
        map, as before. Under ``torch.compile`` they keep the default too. On an x86 CPU (torch 2.14),
        inductor lowers the descriptor head's ``grid_sample`` to a loop that gathers one channel at a time
        across the sample points, and on this layout each of those reads lands on another cache line. The
        compiled forward of a 416 x 640 image took 254 ms with this map and 199 ms without (4 threads).

Returns:
    ``feature_map``: ``(B, dim, H, W)`` L2-normalised dense features.
    ``score_map``: ``(B, 1, H, W)`` detection score map in ``(0, 1)``.
r|   r„  r'  rX   )r  r#   r"  r­  r¯  rª  r°  r«  r±  rN  rX  rZ  r²  r³  rµ  r·  r¸  r[   r‘   r;  r¹  rÞ   r‰  r_   Ú
contiguousr(  )r$   rp   rÉ  Údiv_byÚpadderÚx1Úx2Úx3Úx4Úx2_upÚx3_upÚx4_upÚx1234Ú	score_mapÚfeature_maps   &&$            r   Úextract_dense_mapÚALIKED.extract_dense_mapß  s°  € ð8 ˆÜ˜UŸ[™[¨�_¨e¯k©k¸"­o¸vÓFˆØ—
‘
˜5Ó!ˆà�[‰[˜ÓˆØ�[‰[˜Ÿ™ B›Ó(ˆØ�[‰[˜Ÿ™ B›Ó(ˆØ�[‰[˜Ÿ™ B›Ó(ˆà�Y‰Y�t—z‘z "“~Ó&ˆØ�Y‰Y�t—z‘z "“~Ó&ˆØ�Y‰Y�t—z‘z "“~Ó&ˆØ�Y‰Y�t—z‘z "“~Ó&ˆà—‘˜rÓ"ˆØ—‘˜rÓ"ˆØ—‘ Ó#ˆÜ—	’	˜2 eÐ3¸Ô;ˆä—M’M $§/¡/°%Ó"8Ó9ˆ	ßô Ÿ+š+ e§m¡m°A°q¸!¸QÓ&?×&JÑ&JÓ&LÐPQÐWYÔZ×bÑbÐcdÐfgÐijÐlmÓn‰KäŸ+š+ e¨q°aÔ8ˆKà—l‘l ;Ó/ˆØ—L‘L Ó+ˆ	àÐ%Ð%r!   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úimagesr   r»   r¼   r   zlist[ALIKEDFeatures]r   )r   s   "r   r   r¤    s(   € ÷ #ñ #àð#ð +ð#ð 
ñ	#r!   c           	     ó~  € VP                   ^,          ^8X  d   \        V4      pV P                  V\        V4      R7      w  r4V P	                  WBR7      w  rVpV P                  W54      w  r‰VP                   ^ ,          p
VP                   w   r¼p\        V^,
          V^,
          .VP                  \        P                  ! VP                  \        P                  4      R7      p. p\        V
4       FJ  pWåV,          ^,           ,          R,          pVP                  \        VVV,          VV,          4      4       KL  	  V# )uË  Detect and describe local features in a batch of images.

Args:
    images: ``(B, 3, H, W)`` float images (can be grayscale ``(B, 1, H, W)``
        â€” will be broadcast to 3 channels automatically).
    image_size: optional ``(B, 2)`` tensor of valid ``(W, H)`` for
        border masking when images are padded to a common size.

Returns:
    A list of :class:`ALIKEDFeatures` of length B, one per image.
    Keypoints are in pixel coordinates ``[x, y]``.
©rÉ  )r»   rO   r{   )r#   r   rÙ  rw   r»  rº  r   rP   r[   rÙ   rQ   ru   rÏ   rØ   r   )r$   rÜ  r»   rØ  r×  r   rú   Ú_scoredispersitysr   Ú_offsetsÚBÚ_re   rf   rø   Úresultsrî   Úkps_pxs   &&&               r   r  ÚALIKED.forward  s  € ð" �<‰<˜�?˜aÔÜ% fÓ-ˆFà!%×!7Ñ!7¸ÔNbÐciÓNjÐ!7Ó!kÑˆØ26·(±(¸9°(Ó2\Ñ/ˆ	Ð/Ø $§¡¨{Ó FÑˆà�L‰L˜�OˆØ—\‘\‰
ˆˆ1�ÜØ��U�A˜•EˆN 6§=¡=¼×8KÒ8KÈFÏLÉLÔZ_×ZgÑZgÓ8hô
ˆð ˆÜ�q–ˆAà Q�<¨!Õ+Õ,¨sÕ2ˆFØ�N‰Nœ>¨&°+¸aµ.À)ÈAÅ,ÓOÖPñ ð ˆr!   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   Úimgr   ró   r¼   Úcompute_affinerq   r   z/Tuple[torch.Tensor, torch.Tensor, torch.Tensor]r   )r   s   "r   r   r¤  D  s8   € ÷ g&ñ g&àðg&ð %ðg&ð ð	g&ð
 
9ñg&r!   c           	     óð  € VP                   ^,          ^8X  d   \        V4      pV P                  V\        V4      R7      w  rEVeI   \        P
                  ! VP                  VP                  4      VP                   RR RRR7      pWV,          pV P                  WSR7      pV'       d   Vw  r‰r«MVw  r‰p
RpV P                  WH4      w  rÍVP                   w  rïpp\        P                  ! V^,
          V^,
          .VP                  \        P                  ! VP                  \        P                  4      R7      pV^ 8X  d¹   \        P                  ! WUP!                  ^ ^^ ^4      RRR7      pVP#                  4       R	,          P                  VP                  4      P%                  ^ ^ ^^4      VP%                  ^ ^ ^4      VP#                  4       R	,          P%                  ^ ^ VP                   ^,          4      3# . p\'        V4       F¬  pVVV,          ^,           ,          R
,          pVe   VV,          pM`VP                   ^ ,          p\        P(                  ! ^VP                  VP                  R7      P+                  ^ 4      P-                  VRR4      p\/        VV4      pVP1                  V4       K®  	  \3        R V 4       4      pRR R llp\        P4                  ! V Uu. uF  pV! VV4      NK  	  up4      p\        P4                  ! V	 Uu. uF  pV! VV4      P+                  R4      NK  	  up4      p\        P4                  ! V Uu. uF  pV! VV4      NK  	  up4      p VVV 3# u upi u upi u upi )a\  Detect and describe local features, returning results in kornia LAF format.

With ``compute_affine=True`` the 2x2 block ``A`` of each LAF comes from
the covariance of the soft-argmax weights in the keypoint's
``2 * nms_radius + 1`` detection window, computed by the keypoint detection
step (``DKD``) without any additional network parameters: ``A @ A.T`` is that
covariance, so the axes of the frame are its principal axes, and
``det A > 0`` (the frame is never mirrored). The frame describes how
sharply the score map peaks, not an image structure. Its scale
(:func:`~kornia.feature.get_laf_scale`) is about a pixel or less with
the pretrained ``aliked-n16``. That is much smaller than the region the descriptor
samples, so rescale the frames, for example with
:func:`~kornia.feature.scale_laf`, before using them as a region size.

All per-image tensors are zero-padded along the keypoint dimension to
the largest keypoint count in the batch, so that the outputs are proper
batched tensors.

Args:
    img: image to extract features with shape ``(B, 3, H, W)``, or ``(B, 1, H, W)``, repeated to three
        channels.
    mask: optional spatial mask ``(B, 1, H, W)`` with values in
        ``[0, 1]``; the score map is multiplied by this mask before
        keypoint detection so that features are suppressed in masked
        regions.
    compute_affine: if ``True`` (default), estimate the 2x2 affine shape
        of each LAF using ``torch.linalg.eigh`` on the soft-argmax
        covariance.  Set to ``False`` to skip the eigendecomposition and
        return identity affines, which avoids the linalg call entirely
        (useful when only keypoint positions are needed).

Returns:
    - Detected local affine frames with shape ``(B, N, 2, 3)``.
    - Response function values for corresponding LAFs with shape ``(B, N, 1)``.
    - Local descriptors of shape ``(B, N, D)``.

rÞ  NrÅ   T)ÚsizerÇ   rÈ   )r½   rO   rÆ   :Nr   Nr{   c              3  óF   "  € T F  qP                   ^ ,          x € K  	  R# 5i)r   N)r#   )Ú.0Úlafs   & r   Ú	<genexpr>Ú%ALIKED.forward_laf.<locals>.<genexpr>ž  s   é € Ð6©I S—I‘I˜a—L’L«Iùs   ‚!c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r§   r   r%   r   Úfillr�   r   r   )r   s   "r   r   Ú(ALIKED.forward_laf.<locals>.__annotate__   s.   € ÷ 	Fñ 	F�Lð 	F Sð 	F°ð 	FÀñ 	Fr!   c                óÌ   € WP                   ^ ,          ,
          pV^ 8X  d   V # V3V P                   R,          ,           p\        P                  ! W P                  WB4      .^ R7      # )r   :r;   NNr|   )r#   r[   r‘   Únew_full)r§   r%   rñ  Úpad_nÚ	pad_shapes   &&&  r   r  Ú ALIKED.forward_laf.<locals>._pad   sN   € ØŸ™ �
•NˆEØ˜ŒzØ�Ø˜ 1§7¡7¨2¥;Õ.ˆIÜ—9’9˜a§¡¨IÓ!<Ð=À1ÔEÐEr!   r'  rX   )g        )r#   r   rÙ  rw   rÞ   Úinterpolater+   rQ   r»  rº  r[   rI   rP   rÙ   ru   rß   Ú	new_zerosrÍ   r¦   rÏ   râ   r`   rã   r“   rØ   rN   r^   )!r$   rç  ró   rè  rØ  r×  Úmask_rsÚdkd_outr   rú   rß  rû   r   rà  rá  râ  ÚHr	  rø   Ú	responsesÚ	lafs_listrî   rä  Úaffine_ir%   Úlaf_iÚn_maxr  rí  ÚlafsÚsÚdr˜  s!   &&&&                             r   Úforward_lafÚALIKED.forward_lafD  sõ  € ðV �9‰9�Q�<˜1ÔÜ" 3Ó'ˆCà!%×!7Ñ!7¸ÔK_Ð`cÓKdÐ!7Ó!eÑˆàÒä—m’mØ—‘˜	Ÿ™Ó(¨y¯©¸r¸sÐ/CÈ*ÐdhôˆGð "Õ+ˆIà—(‘(˜9�(ÓCˆßØELÑBˆIÐ"3°]à6=Ñ3ˆIÐ"3Ø ˆMØ $§¡¨{Ó FÑˆà—Y‘Y‰
ˆˆa�Ü�\Š\˜1˜q�5 ! a¥%˜.°·±Ä5×CVÒCVÐWZ×W`ÑW`Ôbg×boÑboÓCpÔqˆà�Œ6ô Ÿš i×1DÑ1DÀQÈÈ1ÈaÓ1PÐWaÐquÔvˆIà×!Ñ!Ó# BÕ'×*Ñ*¨2¯8©8Ó4×9Ñ9¸!¸QÀÀ1ÓEØ—‘˜q ! QÓ'Ø×#Ñ#Ó% bÕ)×.Ñ.¨q°!°[×5FÑ5FÀqÕ5IÓJðð ð )+ˆ	Ü�q–ˆAØ˜9 Q�<¨!Õ+Õ,¨sÕ2ˆFØÒ(Ø(¨Õ+‘ð —L‘L •O�Ü Ÿ9š9 Q¨s¯z©zÀÇÁÔK×UÑUÐVWÓX×_Ñ_Ð`aÐceÐgiÓj�Ü-¨f°hÓ?ˆEØ×Ñ˜UÖ#ñ ô Ñ6©IÓ6Ó6ˆ÷	Fô �{Š{¹	ÓB¹	°™D  eÖ,¹	ÑBÓCˆÜ—K’KÁyÓ QÁyÀ!¡ a¨£×!9Ñ!9¸"Ö!=ÁyÑ QÓRˆ	Ü—’±[ÓA±[°™T ! Už^±[ÑAÓBˆà�Y Ð%Ð%ùò	 CùÚ QùÚAs   Ë"M)Ì!M.ÍM3c               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )r   r   r®   r¡  r   r¢  r�   r£  rP   zOptional[torch.device]r   r�  r   )r   s   "r   r   r¤  ®  sF   € ÷ !ñ !àð!ð ð!ð #ð	!ð
 ð!ð 'ð!ð 
ñ!r!   c                ó  € Vf   \         P                  ! R4      pV ! VVVVR7      P                  V4      p\         Uu. uF  qwP	                  V4      NK  	  pp\        W…R7      p	VP                  V	4       VP                  4        V# u upi )aé  Build an ALIKED model and load the pretrained checkpoint of ``model_name``, in evaluation mode.

Args:
    model_name: one of ``'aliked-t16'``, ``'aliked-n16'``,
        ``'aliked-n16rot'``, ``'aliked-n32'``.
    max_num_keypoints: passed to :class:`ALIKED` constructor.
    detection_threshold: passed to :class:`ALIKED` constructor.
    nms_radius: passed to :class:`ALIKED` constructor.
    device: target device; defaults to CPU.

Returns:
    Pretrained :class:`ALIKED` in eval mode.
rs   )r   r¡  r¢  r£  )Úmap_location)r[   rP   r+   Ú_CHECKPOINT_URLSr   r   Úload_state_dictÚeval)
Úclsr   r¡  r¢  r£  rP   Úmodelr§   Úurlsr¬   s
   &&&&&&    r   Úfrom_pretrainedÚALIKED.from_pretrained­  s†   € ð, Š>Ü—\’\ %Ó(ˆFÙØ!Ø/Ø 3Ø!ô	
÷
 ‰"ˆV‹*ð 	õ /?Ó?Ñ.>¨—‘˜Ö$Ñ.>ˆÐ?Ü-¨dÔHˆ
Ø×Ñ˜jÔ)Ø�
‰
ŒØˆùò	 @s   ¾B)r­  r¯  r°  r±  rX  rZ  r²  r³  rº  r¢  r»  rN  r¡  r   r£  rÝ   rª  r«  r¹  rµ  r¸  r¶  r·  )rš  rX   r  r   )N)NT)rš  rX   r  r   N)r-   r.   r/   r0   r1   rž  r2   r¡   r®  rÙ  r  r  Úclassmethodr  r4   r  r  s   @r   r�  r�  2  sU   ø‡ ñaðF €K�Ó÷9
ò 9
õv

ð>&Ø<A÷>&÷@#÷Jg&ðR ö!ó ö!r!   r�  )r;   )r;   r;   r;   )rE   r;   r;   FrF  F)r*  é   é    rp  rp  rE   r  )r  r  rp  é€   r  rE   r  )r  r  rp  r  r  rE   r  )0Ú__conditional_annotations__Ú
__future__r   Údataclassesr   Útypingr   r   r   r   r[   Útorch.nn.functionalr	   Ú
functionalrÞ   Útorch.nn.modules.utilsr
   Úkornia.colorr   Úkornia.core.downloadr   Úkornia.core.opsr   Úkornia.core.utilsr   r   Úkornia.geometry.subpixr   r   r   r@   rG   rn   rw   rŒ   r“   ÚModuler•   r  r,  rJ  rL  ra  rr  r›  r2   r
  r�  )r  s   @r   Ú<module>r#     s+  øð÷p #Ð "å !ß 1Ó 1ã ß Ð Ý Ý (å )Ý 9Ý +ß BÝ (å (ð ÷'
ð '
ó ð'
÷^V÷
õ'õ"oõ>õB0ô.M6ˆ"�)‰)ô M6÷j0ñ 0ô8Q
�r—y‘yô Q
÷hTô42�—	‘	ô 2ôD4)ˆr�y‰yô 4)ôxx)ˆ2�9‰9ô x)ðB Ð,ØÐ/ØÐ2ØÐ/ðE€ÐAó ð ?Ø@ðÐ ô]ˆR�Y‰Yö ]r!   