+
    åûjxÉ  ã                   ó†  € ^ RI t ^ RIt^ RIHt ^ RIHt ^ RIHtHtH	t	H
t
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Ht ^ R	IHt ^ R
IHt ^ RIH t H!t! R t"R R lt#R R lt$R R lt%R R lt& ! R R]PN                  4      t( ! R R]PN                  4      t) ! R R]PN                  4      t* ! R R]PN                  4      t+ ! R R]PN                  4      t, ! R R ]PN                  4      t-R! R" lt. ! R# R$]PN                  4      t/R% R& lt0R't1R( R) lt2R* R+ lt3 ! R, R-]PN                  4      t4R# ).é    N)ÚPath)ÚSimpleNamespace)ÚAnyÚCallableÚClassVarÚDictÚListÚOptionalÚSequenceÚTuple)Únn)Úscaled_dot_product_attention)ÚKORNIA_CHECK)Úhf_urlÚload_state_dict_from_url)Ú	BaseError)Úis_exporting)Úlaf_to_three_pointsÚ	scale_lafc                ó,   € \        \        W4      V4      # )z'Clamp a value to lie within [min, max].)ÚminÚmax)ÚxÚmin_Úmax_s   &&&ÚTC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\feature\lightglue.pyÚ
math_clampr   $   s   € äŒs�1‹|˜TÓ"Ð"ó    c                óx   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  /# )é   ÚkptsÚsizeÚreturn©ÚtorchÚTensor)Úformats   "r   Ú__annotate__r(   )   s-   € ÷ :ñ :œeŸl™lð :´%·,±,ð :Ä5Ç<Á<ñ :r   c                ó¬  € \        V\        P                  4      '       d   \        P                  ! V4      R,          pV P                  P
                  pV P                  4       '       dk   V P                  \        P                  \        P                  39   d<   \        P                  ! V4      '       d    V P                  \        P                  4      p VP                  4       P                  V 4      ^,          pVP                  ^4      P                  P                  4       P                  V 4      ^,          pWR,          ,
          VR,          ,          # )z$Normalize torch.Tensor of keypoints.N)ºNNNN)r*   NN)Ú
isinstancer%   ÚSizeÚtensorÚdeviceÚtypeÚis_floating_pointÚdtypeÚfloat16Úbfloat16Úis_autocast_enabledÚtoÚfloat32Úfloatr   Úvalues)r!   r"   Údevice_typeÚshiftÚscales   &&   r   Únormalize_keypointsr<   )   sÞ   € ä�$œŸ
™
×#Ò#Ü�|Š|˜DÓ! $Õ'ˆð —+‘+×"Ñ"€Kà×Ñ× Ò Ø�J‰Jœ5Ÿ=™=¬%¯.©.Ð9Ô9Ü×%Ò% k×2Ò2à�w‰w”u—}‘}Ó%ˆØ�J‰J‹L�O‰O˜DÓ! AÕ%€EØ�H‰H�Q‹K×Ñ×$Ñ$Ó&×)Ñ)¨$Ó/°!Õ3€EØ˜•>Õ! U¨=Õ%9Õ9Ð9r   c                óš   € V ^8„  d   QhR\         P                  R\        R\        \         P                  \         P                  3,          /# )r    r   Úlengthr#   )r%   r&   Úintr   )r'   s   "r   r(   r(   >   s7   € ÷ ñ ”U—\‘\ð ¬3ð ´5¼¿¹ÄuÇ|Á|Ð9SÕ3Tñ r   c                óP  € WP                   R	,          8:  d0   V \        P                  ! V R
,          \        P                  R7      3# \        P                  ! . V P                   RR	 OWP                   R	,          ,
          NV P                   R,          N5RV P
                  RV P                  / p\        P                  ! W.R	R7      p\        P                  ! . VP                   RR O^N5R\        P                  RV P
                  / pRVRRV P                   R	,          1R3&   W43# )z#Pad torch.Tensor to desired length..)r1   Nr.   r1   ©ÚdimTr*   éþÿÿÿ).:Né   Néÿÿÿÿ)	Úshaper%   Ú	ones_likeÚboolÚonesr.   r1   ÚcatÚzeros)r   r>   Ú
pad_tensorÚyÚmasks   &&   r   Úpad_to_lengthrO   >   sæ   € à—‘˜•ÔØ”%—/’/ ! G¥*´E·J±JÔ?Ð?Ð?Ü—’Ðm˜QŸW™W S b˜\Ðm¨6·G±G¸BµKÕ+?ÐmÀÇÁÈÅÒmÐUV×U]ÑU]ÐmÐef×elÑelÑm€JÜ�	Š	�1�/ rÔ*€AÜ�;Š;ÐK˜Ÿ™  ˜ÐK aÒK¬u¯z©zÐKÀ!Ç(Á(ÑK€DØ"&€Dˆˆm�—‘˜•ˆm˜QÐ	ÑØˆ7€Nr   c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# ©r    r   r#   r$   )r'   s   "r   r(   r(   I   s&   € ÷ @ñ @”5—<‘<ð @¤E§L¡Lñ @r   c                ó¤   € V P                  RR4      p V P                  RR7      w  r\        P                  ! V) V3RR7      P	                  RR7      # )zApply half rotation.rA   ©Ú	start_dimrE   )rE   r    rC   )Ú	unflattenÚunbindr%   ÚstackÚflatten)r   Úx1Úx2s   &  r   Úrotate_halfr[   I   sI   € à	�‰�B˜Ó €AØ�X‰X˜"ˆXÓ�F€BÜ�;Š;˜˜˜R�y bÔ)×1Ñ1¸BÐ1Ó?Ð?r   c                óx   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  /# )r    ÚfreqsÚtr#   r$   )r'   s   "r   r(   r(   P   s-   € ÷ 8ñ 8¤5§<¡<ð 8´E·L±Lð 8ÄUÇ\Á\ñ 8r   c                ó\   € W^ ,          ,          \        V4      V ^,          ,          ,           # )zApply rotary embedding.)r[   )r]   r^   s   &&r   Úapply_cached_rotary_embr`   P   s    € à�a•�Lœ[¨›^¨e°A­hÕ6Õ7Ð7r   c                   óX   a a€ ] tR t^Ut oRtRV3R lV 3R llltV3R lR ltRtVtV ;t	# )Ú"LearnableFourierPositionalEncodinga¢  Implement learnable Fourier features for positional encoding.

This module encodes spatial coordinates into high-dimensional embeddings
using a learnable projection and periodic functions.

Args:
    M: The number of frequencies to use.
    dim: The dimension of the output embedding.
    F_dim: The dimension of the Fourier features. Default: None.
    gamma: The scaling factor for the initialization. Default: 1.0.
c          
      óF   <€ V ^8„  d   QhRS[ RS[ RS[S[ ,          RS[RR/# )r    ÚMrB   ÚF_dimÚgammar#   N)r?   r
   r7   )r'   Ú__classdict__s   "€r   r(   Ú/LearnableFourierPositionalEncoding.__annotate__b   s<   ø€ ÷ Iñ I™#ð I¡Cð I±¹µð IÉUð IÐ]añ Ir   c                ó*  <€ \         SV `  4        Ve   TMTpW@n        \        P                  ! W^,          RR7      V n        \        P                  P                  V P
                  P                  P                  ^ V P                  R,          R7       R # )NF©Úbias)ÚmeanÚstdrC   )
ÚsuperÚ__init__rf   r   ÚLinearÚWrÚinitÚnormal_ÚweightÚdata)Úselfrd   rB   re   rf   Ú	__class__s   &&&&&€r   ro   Ú+LearnableFourierPositionalEncoding.__init__b   sa   ø€ Ü‰ÑÔØÒ*‘°ˆØŒ
Ü—)’)˜A¨�z°Ô6ˆŒÜ
�‰�‰˜Ÿ™Ÿ™×+Ñ+°!¸¿¹ÀR½ˆÖHr   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# rQ   r$   )r'   rg   s   "€r   r(   rh   i   s#   ø€ ÷ 0ñ 0™Ÿ™ð 0©%¯,©,ñ 0r   c                óî   € V P                  V4      p\        P                  ! V4      \        P                  ! V4      rC\        P                  ! W4.^ 4      P                  R4      pVP                  ^RR7      # )zEncode position vector.rA   éýÿÿÿrE   )rq   r%   ÚcosÚsinrW   Ú	unsqueezeÚrepeat_interleave)rv   r   Ú	projectedÚcosinesÚsinesÚembs   &&    r   ÚforwardÚ*LearnableFourierPositionalEncoding.forwardi   s\   € à—G‘G˜A“Jˆ	ÜŸš 9Ó-¬u¯yªy¸Ó/C�Ü�kŠk˜7Ð*¨AÓ.×8Ñ8¸Ó<ˆØ×$Ñ$ Q¨BÐ$Ó/Ð/r   )rq   rf   )Nç      ð?©
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ro   r„   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©rw   rg   s   @@r   rb   rb   U   s%   ù‡ € ñ
÷Iõ I÷0÷ 0ð 0r   rb   c                   óT   a a€ ] tR t^qt oRtV3R lV 3R lltV3R lR ltRtVtV ;t	# )ÚTokenConfidencezxPredict the confidence score for each token in the sequence.

Args:
    dim: The dimension of the input feature tokens.
c                ó$   <€ V ^8„  d   QhRS[ RR/# ©r    rB   r#   N©r?   )r'   rg   s   "€r   r(   ÚTokenConfidence.__annotate__x   s   ø€ ÷ Dñ D™Cð D Dñ Dr   c                ó¬   <€ \         SV `  4        \        P                  ! \        P                  ! V^4      \        P
                  ! 4       4      V n        R# )rD   N)rn   ro   r   Ú
Sequentialrp   ÚSigmoidÚtoken©rv   rB   rw   s   &&€r   ro   ÚTokenConfidence.__init__x   s1   ø€ Ü‰ÑÔÜ—]’]¤2§9¢9¨S°!Ó#4´b·j²j³lÓCˆŽ
r   c                ó’   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[S[ P                  S[ P                  3,          /# ©r    Údesc0Údesc1r#   ©r%   r&   r   )r'   rg   s   "€r   r(   r–   |   s?   ø€ ÷ 
ñ 
™UŸ\™\ð 
±%·,±,ð 
Á5ÉÏÉÑW\×WcÑWcÐIcÕCdñ 
r   c                ó˜  € V P                   ^ ,          P                  P                  pVP                  pV P                  VP                  4       P	                  V4      4      P                  R4      P	                  V4      V P                  VP                  4       P	                  V4      4      P                  R4      P	                  V4      3# )zGet confidence tokens.rE   )rš   rt   r1   Údetachr5   Úsqueeze)rv   rŸ   r    r1   Ú
orig_dtypes   &&&  r   r„   ÚTokenConfidence.forward|   s”   € à—
‘
˜1•×$Ñ$×*Ñ*ˆØ—[‘[ˆ
à�J‰J�u—|‘|“~×(Ñ(¨Ó/Ó0×8Ñ8¸Ó<×?Ñ?À
ÓKØ�J‰J�u—|‘|“~×(Ñ(¨Ó/Ó0×8Ñ8¸Ó<×?Ñ?À
ÓKð
ð 	
r   )rš   r‡   r�   s   @@r   r’   r’   q   s%   ù‡ € ñ÷Dó D÷
÷ 
ð 
r   r’   c                   óX   a a€ ] tR t^†t oRtV3R lV 3R lltRV3R lR lltRtVtV ;t	# )Ú	AttentionaŒ  Implement the optimized multi-head attention mechanism for LightGlue.

Args:
    allow_flash: Whether to run the attention of CUDA tensors in float16, where PyTorch can select its
        FlashAttention kernel. Which ``scaled_dot_product_attention`` backends PyTorch may use stays a
        process-wide setting of the caller (``torch.nn.attention.sdpa_kernel``); this module does not change it.
c                ó$   <€ V ^8„  d   QhRS[ RR/# )r    Úallow_flashr#   N)rH   )r'   rg   s   "€r   r(   ÚAttention.__annotate__�   s   ø€ ÷ 'ñ '¡Dð '¨Tñ 'r   c                ó0   <€ \         SV `  4        Wn        R # ©N)rn   ro   rª   )rv   rª   rw   s   &&€r   ro   ÚAttention.__init__�   s   ø€ Ü‰ÑÔØ&Ör   c          
      ó¬   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  RS[S[ P                  ,          RS[ P                  /# )r    ÚqÚkÚvrN   r#   ©r%   r&   r
   )r'   rg   s   "€r   r(   r«   “   sQ   ø€ ÷ 5ñ 5Ù—‘ð5Ù"'§,¡,ð5Ù38·<±<ð5ÙGOÑPU×P\ÑP\ÕG]ð5á	�‰ñ5r   c                óÂ  € V P                   '       d„   VP                  P                  R8X  di   WV3 Uu. uF   qUP                  4       P	                  4       NK"  	  pp\        VRV/ P                  VP                  4      pVf   V# VP                  4       # WV3 Uu. uF  qUP	                  4       NK  	  pp\        VRV/ pVf   V# VP                  4       # u upi u upi )a  Apply multi-head attention to query, key, and value tensors.

Args:
    q: Query tensor with shape ``(B, H, N_q, D_h)``, where ``B`` is batch size,
        ``H`` is the number of attention heads, ``N_q`` is the number of query tokens,
        and ``D_h`` is the per-head descriptor dimension.
    k: Key tensor with shape ``(B, H, N_k, D_h)``, where ``N_k`` is the number
        of key tokens.
    v: Value tensor with shape ``(B, H, N_k, D_h)``.
    mask: Optional boolean attention mask. ``True`` entries mark token pairs that
        are allowed to attend to each other.

Returns:
    Attention output with shape ``(B, H, N_q, D_h)``.
ÚcudaÚ	attn_mask)	rª   r.   r/   ÚhalfÚ
contiguousr   r5   r1   Ú
nan_to_num)rv   r°   r±   r²   rN   r   Úargss   &&&&&  r   r„   ÚAttention.forward“   sÁ   € ð$ ××Ð §¡§¡°Ô 7à45¸!±9Ó=±9¨a—F‘F“H×'Ñ'Ö)±9ˆDÐ=Ü,¨dÐC¸dÑC×FÑFÀqÇwÁwÓOˆAØš�1Ð8¨!¯,©,«.Ð8Ø)*¨q©	Ó2©	 1—‘–©	ˆÐ2Ü(¨$Ð?¸$Ñ?ˆØ’LˆqÐ4 a§l¡l£nÐ4ùò >ùò 3s   ´&CÂC)rª   r­   r‡   r�   s   @@r   r¨   r¨   †   s#   ù‡ € ñ÷'ó '÷5÷ 5ò 5r   r¨   c                   ó\   a a€ ] tR t^¯t oRtRV3R lV 3R llltRV3R lR lltRtVtV ;t	# )	Ú	SelfBlocka©  Implement a self-attention block to process features within a single image.

Args:
    embed_dim: The dimension of the feature embeddings.
    num_heads: The number of attention heads.
    flash: Whether to run the attention of CUDA tensors in float16, where PyTorch can select its FlashAttention
        kernel (see :class:`Attention`). Default: False.
    bias: Whether to include bias in the linear layers. Default: True.
c          
      ó6   <€ V ^8„  d   QhRS[ RS[ RS[RS[RR/# ©r    Ú	embed_dimÚ	num_headsÚflashrk   r#   N©r?   rH   )r'   rg   s   "€r   r(   ÚSelfBlock.__annotate__º   s2   ø€ ÷ 
ñ 
¡#ð 
±#ð 
¹dð 
ÑRVð 
Ðbfñ 
r   c           	     ój  <€ \         SV `  4        Wn        W n        \	        V P                  V,          ^ 8H  R4       V P                  V,          V n        \        P                  ! V^V,          VR7      V n        \        V4      V n
        \        P                  ! WVR7      V n        \        P                  ! \        P                  ! ^V,          ^V,          4      \        P                  ! ^V,          RR7      \        P                  ! 4       \        P                  ! ^V,          V4      4      V n        R# )r   z0Embed dimension should be dividable by num_headsrj   T©Úelementwise_affineN)rn   ro   rÀ   rÁ   r   Úhead_dimr   rp   ÚWqkvr¨   Ú
inner_attnÚout_projr˜   Ú	LayerNormÚGELUÚffn)rv   rÀ   rÁ   rÂ   rk   rw   s   &&&&&€r   ro   ÚSelfBlock.__init__º   sÊ   ø€ Ü‰ÑÔØ"ŒØ"ŒÜ�T—^‘^ iÕ/°1Ñ4Ð6hÔiØŸ™¨)Õ3ˆŒÜ—I’I˜i¨¨Y­¸TÔBˆŒ	Ü# EÓ*ˆŒÜŸ	š	 )¸TÔBˆŒÜ—=’=Ü�IŠI�a˜)•m Q¨¥]Ó3Ü�LŠL˜˜Y�¸4Ô@Ü�GŠG‹IÜ�IŠI�a˜)•m YÓ/ó	
ˆŽr   c                ó’   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[S[ P                  ,          RS[ P                  /# )r    r   ÚencodingrN   r#   r³   )r'   rg   s   "€r   r(   rÄ   Ê   sH   ø€ ÷ 9ñ 9á�<‰<ð9ñ —,‘,ð9ñ ‘u—|‘|Õ$ð	9ñ
 
�‰ñ9r   c                óÄ  € V P                  V4      pVP                  RV P                  R^34      P                  ^^4      pVR,          VR,          VR,          rvp\	        W%4      p\	        W&4      pV P                  WVWsR7      pV P                  VP                  ^^4      P                  RR7      4      p	WP                  \        P                  ! W.R4      4      ,           # )a÷  Update descriptors from one image using self-attention.

Args:
    x: Descriptor tensor with shape ``(B, N, D)``, where ``B`` is batch size,
        ``N`` is the number of local features, and ``D`` is descriptor dimension.
    encoding: Positional encoding tensor aligned with ``x`` and used for rotary
        position embedding inside attention.
    mask: Optional boolean mask limiting which descriptors may attend to each other.

Returns:
    Updated descriptor tensor with the same shape as ``x``.
)rN   rS   rE   ©.r   ©.rD   ).r    rC   )rÉ   rU   rÁ   Ú	transposer`   rÊ   rË   rX   rÎ   r%   rJ   )
rv   r   rÑ   rN   Úqkvr°   r±   r²   ÚcontextÚmessages
   &&&&      r   r„   ÚSelfBlock.forwardÊ   s¾   € ð$ �i‰i˜‹lˆØ�m‰m˜B §¡°°QÐ 7Ó8×BÑBÀ1ÀaÓHˆØ�f•+˜s 6�{¨C°­KˆaˆÜ# HÓ0ˆÜ# HÓ0ˆØ—/‘/ !¨�/Ó5ˆØ—-‘- × 1Ñ 1°!°QÓ 7× ?Ñ ?È"Ð ?Ó MÓNˆØ—8‘8œEŸIšI q l°BÓ7Ó8Õ8Ð8r   )rÉ   rÀ   rÎ   rÈ   rÊ   rÁ   rË   ©FTr­   r‡   r�   s   @@r   r½   r½   ¯   s#   ù‡ € ñ÷
õ 
÷ 9÷ 9ò 9r   r½   c                   ón   a a€ ] tR t^æt oRtR	V3R lV 3R llltV3R lR ltR
V3R lR lltRtVt	V ;t
# )Ú
CrossBlocka«  Implement a cross-attention block to exchange information between two images.

Args:
    embed_dim: The dimension of the feature embeddings.
    num_heads: The number of attention heads.
    flash: Whether to run the attention of CUDA tensors in float16, where PyTorch can select its FlashAttention
        kernel (see :class:`Attention`). Default: False.
    bias: Whether to include bias in the linear layers. Default: True.
c          
      ó6   <€ V ^8„  d   QhRS[ RS[ RS[RS[RR/# r¿   rÃ   )r'   rg   s   "€r   r(   ÚCrossBlock.__annotate__ñ   s2   ø€ ÷ +ñ +¡#ð +±#ð +¹dð +ÑRVð +Ðbfñ +r   c           	     ó8  <€ \         SV `  4        W n        W,          pWR,          p\        P                  ! WVR 7      V n        \        P                  ! WVR 7      V n        \        P                  ! WaVR 7      V n        \        P                  ! \        P                  ! ^V,          ^V,          4      \        P                  ! ^V,          RR7      \        P                  ! 4       \        P                  ! ^V,          V4      4      V n        \        V4      V n        R# )rj   TrÆ   N)rn   ro   Úheadsr   rp   Úto_qkÚto_vÚto_outr˜   rÌ   rÍ   rÎ   r¨   rÊ   )rv   rÀ   rÁ   rÂ   rk   Údim_headÚ	inner_dimrw   s   &&&&&  €r   ro   ÚCrossBlock.__init__ñ   sº   ø€ Ü‰ÑÔØŒ
ØÕ)ˆØÕ(ˆ	Ü—Y’Y˜y¸$Ô?ˆŒ
Ü—I’I˜i¸Ô>ˆŒ	Ü—i’i 	¸4Ô@ˆŒÜ—=’=Ü�IŠI�a˜)•m Q¨¥]Ó3Ü�LŠL˜˜Y�¸4Ô@Ü�GŠG‹IÜ�IŠI�a˜)•m YÓ/ó	
ˆŒô $ EÓ*ˆŽr   c          
      ó˜   <€ V ^8„  d   QhRS[ RS[P                  RS[P                  RS[S[P                  S[P                  3,          /# )r    ÚfuncÚx0rY   r#   )r   r%   r&   r   )r'   rg   s   "€r   r(   rÞ     sI   ø€ ÷ "ñ "™ð "¡u§|¡|ð "¹¿¹ð "É%ÑPU×P\ÑP\Ñ^c×^jÑ^jÐPjÕJkñ "r   c                ó"   € V! V4      V! V4      3# )a%  Apply the same function to descriptor tensors from both images.

Args:
    func: Callable applied independently to ``x0`` and ``x1``.
    x0: Descriptor tensor for the first image.
    x1: Descriptor tensor for the second image.

Returns:
    A tuple containing ``func(x0)`` and ``func(x1)``.
© )rv   rè   ré   rY   s   &&&&r   Úmap_ÚCrossBlock.map_  s   € ñ �B‹x™˜b›Ð!Ð!r   c          
      ó¼   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[S[ P                  ,          RS[S[ P                  S[ P                  3,          /# )r    ré   rY   rN   r#   )r%   r&   r
   r   )r'   rg   s   "€r   r(   rÞ     sP   ø€ ÷ ñ Ù—,‘,ðÙ$)§L¡LðÙ8@ÁÇÁÕ8Nðá	‰u�|‰|™UŸ\™\Ð)Õ	*ñr   c           	     ó6  a € S P                  S P                  W4      w  rES P                  S P                  W4      w  rgV 3R lWEWg3 4       w  rErgS P                  WEWs4      pS P                  YTYce   VP	                  RR4      MR4      p	S P                  R W‰4      w  r‰S P                  S P
                  W‰4      w  r‰VS P                  \        P                  ! W.R4      4      ,           pVS P                  \        P                  ! W).R4      4      ,           pW3# )a1  Exchange information between two images using cross-attention.

Args:
    x0: Descriptor tensor from the first image with shape ``(B, M, D)``,
        where ``M`` is the number of local features in image 0.
    x1: Descriptor tensor from the second image with shape ``(B, N, D)``,
        where ``N`` is the number of local features in image 1.
    mask: Optional boolean mask with shape ``(B, H, M, N)`` or a broadcastable
        equivalent, marking valid descriptor pairs.

Returns:
    A tuple ``(x0_out, x1_out)`` with updated descriptors for both images.
c              3   ó~   <"  € T F2  qP                  RSP                  R34      P                  ^^4      x € K4  	  R# 5i)rD   NrE   )rU   rà   rÕ   )Ú.0r^   rv   s   & €r   Ú	<genexpr>Ú%CrossBlock.forward.<locals>.<genexpr>   s6   øé € ÐjÑWiÐRSŸK™K¨¨T¯Z©Z¸Ð,<Ó=×GÑGÈÈ1×MÐMÓWiùs   ƒ:=Nc                 óF   € V P                  ^^4      P                  RR7      # )rD   rS   rC   )rÕ   rX   )r^   s   &r   Ú<lambda>Ú$CrossBlock.forward.<locals>.<lambda>#  s   €  Q§[¡[°°AÓ%6×%>Ñ%>ÈÐ%>Ô%Lr   rE   rC   )	rì   rá   râ   rÊ   rÕ   rã   rÎ   r%   rJ   )
rv   ré   rY   rN   Úqk0Úqk1Úv0Úv1Úm0Úm1s
   f&&&      r   r„   ÚCrossBlock.forward  sê   ø€ ð  —9‘9˜TŸZ™Z¨Ó0‰ˆØ—‘˜4Ÿ9™9 bÓ-‰ˆÜjÐX[ÐbdÑWiÓjÑˆ�"Ø�_‰_˜S rÓ0ˆØ�_‰_˜S rÒEU¨4¯>©>¸"¸bÔ+AÐ[_Ó`ˆØ—‘ÑLÈbÓU‰ˆØ—‘˜4Ÿ;™;¨Ó/‰ˆØ�$—(‘(œ5Ÿ9š9 b X¨rÓ2Ó3Õ3ˆØ�$—(‘(œ5Ÿ9š9 b X¨rÓ2Ó3Õ3ˆØˆvˆr   )rÎ   rà   rÊ   rã   rá   râ   rÚ   r­   )rˆ   r‰   rŠ   r‹   rŒ   ro   rì   r„   r�   rŽ   r�   r�   s   @@r   rÜ   rÜ   æ   s-   ù‡ € ñ÷+õ +÷ "ð "÷÷ ò r   rÜ   c                   ó^   a a€ ] tR tRt oRtV 3R ltR	V3R lR lltV3R lR ltRtVt	V ;t
# )
ÚTransformerLayeri*  z®Implement a complete Transformer layer for feature matching.

This layer typically alternates between self-attention and cross-attention
to update local feature descriptors.
c                ód   <€ \         SV `  4        \        V/ VB V n        \	        V/ VB V n        R # r­   )rn   ro   r½   Ú	self_attnrÜ   Ú
cross_attn)rv   rº   Úkwargsrw   s   &*,€r   ro   ÚTransformerLayer.__init__1  s0   ø€ Ü‰ÑÔÜ" DÐ3¨FÑ3ˆŒÜ$ dÐ5¨fÑ5ˆŽr   c                óð   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  RS[ P                  RS[S[ P                  ,          RS[S[ P                  ,          RS[ P                  /# ©r    rŸ   r    Ú	encoding0Ú	encoding1Úmask0Úmask1r#   r³   )r'   rg   s   "€r   r(   ÚTransformerLayer.__annotate__6  sw   ø€ ÷ -ñ -á�|‰|ð-ñ �|‰|ð-ñ —<‘<ð	-ñ
 —<‘<ð-ñ ™Ÿ™Õ%ð-ñ ™Ÿ™Õ%ð-ñ 
�‰ñ-r   c                óž   € Ve   Ve   V P                  WW4WV4      # V P                  W4      pV P                  W$4      pV P                  W4      # )a  Run one LightGlue transformer layer over two descriptor sets.

Args:
    desc0: Descriptor tensor from image 0 with shape ``(B, M, D)``.
    desc1: Descriptor tensor from image 1 with shape ``(B, N, D)``.
    encoding0: Positional encoding for ``desc0``.
    encoding1: Positional encoding for ``desc1``.
    mask0: Optional validity mask for descriptors in image 0.
    mask1: Optional validity mask for descriptors in image 1.

Returns:
    A tuple containing updated descriptor tensors for image 0 and image 1.
)Úmasked_forwardr  r  )rv   rŸ   r    r  r  r	  r
  s   &&&&&&&r   r„   ÚTransformerLayer.forward6  sO   € ð, Ò Ò!2Ø×&Ñ& u°YÈ5ÓXÐXØ—‘˜uÓ0ˆØ—‘˜uÓ0ˆØ�‰˜uÓ,Ð,r   c                óÐ   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  RS[ P                  RS[ P                  RS[ P                  RS[ P                  /# r  r$   )r'   rg   s   "€r   r(   r  S  sm   ø€ ÷ 3ñ 3á�|‰|ð3ñ �|‰|ð3ñ —<‘<ð	3ñ
 —<‘<ð3ñ �|‰|ð3ñ �|‰|ð3ñ 
�‰ñ3r   c                óþ   € WVP                  RR4      ,          pWUP                  RR4      ,          pWfP                  RR4      ,          pV P                  WV4      pV P                  W$V4      pV P                  WV4      # )a  Run the transformer layer with explicit descriptor validity masks.

Args:
    desc0: Descriptor tensor from image 0 with shape ``(B, M, D)``.
    desc1: Descriptor tensor from image 1 with shape ``(B, N, D)``.
    encoding0: Positional encoding for image 0 descriptors.
    encoding1: Positional encoding for image 1 descriptors.
    mask0: Boolean mask for valid image 0 descriptors.
    mask1: Boolean mask for valid image 1 descriptors.

Returns:
    A tuple with masked self-attention and cross-attention updates for both images.
rE   rC   )rÕ   r  r  )rv   rŸ   r    r  r  r	  r
  rN   s   &&&&&&& r   r  ÚTransformerLayer.masked_forwardS  sn   € ð, —‘ r¨2Ó.Õ.ˆØŸ™¨¨BÓ/Õ/ˆØŸ™¨¨BÓ/Õ/ˆØ—‘˜u°Ó7ˆØ—‘˜u°Ó7ˆØ�‰˜u¨TÓ2Ð2r   )r  r  )NN)rˆ   r‰   rŠ   r‹   rŒ   ro   r„   r  r�   rŽ   r�   r�   s   @@r   rÿ   rÿ   *  s(   ù‡ € ñõ6÷
-ò -÷:3÷ 3ð 3r   rÿ   c                ó˜   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  R\         P                  /# )r    ÚsimÚz0Úz1r#   r$   )r'   s   "r   r(   r(   q  s;   € ÷ 
ñ 
¤E§L¡Lð 
´e·l±lð 
ÌÏÉð 
ÔY^×YeÑYeñ 
r   c                óŒ  € V P                   w  r4p\        P                  ! V4      \        P                  ! V4      P                  ^^4      ,           p\        P                  ! V ^4      p\        P                  ! V P                  RR4      P                  4       ^4      P                  RR4      pV P                  W4^,           V^,           3^ 4      p	Wx,           V,           V	RRV1RV13&   \        P                  ! VP                  R4      ) 4      V	RRR1R3&   \        P                  ! VP                  R4      ) 4      V	RRRR13&   V	# )z<Create the log assignment matrix from logits and similarity.r*   NrE   rC   )rF   ÚFÚ
logsigmoidrÕ   Úlog_softmaxr¸   Únew_fullr¤   )
r  r  r  ÚbÚmÚnÚcertaintiesÚscores0Úscores1Úscoress
   &&&       r   Úsigmoid_log_double_softmaxr"  q  s
  € à�i‰i�G€Aˆ!Ü—,’,˜rÓ"¤Q§\¢\°"Ó%5×%?Ñ%?ÀÀ1Ó%EÕE€KÜ�mŠm˜C Ó#€GÜ�mŠm˜CŸM™M¨"¨bÓ1×<Ñ<Ó>ÀÓB×LÑLÈRÐQSÓT€GØ�\‰\˜1 !�e Q¨¥UÐ+¨QÓ/€FØÕ)¨KÕ7€Fˆ1ˆbˆqˆb�"�1�"ˆ9ÑÜŸš r§z¡z°"£~ oÓ6€Fˆ1ˆcˆrˆc�2ˆ:ÑÜŸš r§z¡z°"£~ oÓ6€Fˆ1ˆb�#�2�#ˆ:ÑØ€Mr   c                   óf   a a€ ] tR tRt oRtV3R lV 3R lltV3R lR ltV3R lR ltR	tVt	V ;t
# )
ÚMatchAssignmenti~  z‹Assign matches between two sets of local features using a dual-softmax approach.

Args:
    dim: The dimension of the feature descriptors.
c                ó$   <€ V ^8„  d   QhRS[ RR/# r”   r•   )r'   rg   s   "€r   r(   ÚMatchAssignment.__annotate__…  s   ø€ ÷ 9ñ 9™Cð 9 Dñ 9r   c                ó¦   <€ \         SV `  4        Wn        \        P                  ! V^RR7      V n        \        P                  ! WRR7      V n        R# )rD   Trj   N)rn   ro   rB   r   rp   ÚmatchabilityÚ
final_projr›   s   &&€r   ro   ÚMatchAssignment.__init__…  s:   ø€ Ü‰ÑÔØŒÜŸIšI c¨1°4Ô8ˆÔÜŸ)š) C°4Ô8ˆŽr   c                ó’   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[S[ P                  S[ P                  3,          /# rž   r¡   )r'   rg   s   "€r   r(   r&  ‹  s?   ø€ ÷ 	ñ 	™UŸ\™\ð 	±%·,±,ð 	Á5ÉÏÉÑW\×WcÑWcÐIcÕCdñ 	r   c                ó,  € V P                  V4      V P                  V4      rCVP                  w   rVW6R,          ,          WFR,          ,          rC\        P                  ! RW44      pV P	                  V4      pV P	                  V4      p	\        WxV	4      p
W§3# )z)Build assignment matrix from descriptors.g      Ð?zbmd,bnd->bmn)r)  rF   r%   Úeinsumr(  r"  )rv   rŸ   r    Úmdesc0Úmdesc1Ú_Údr  r  r  r!  s   &&&        r   r„   ÚMatchAssignment.forward‹  s�   € àŸ™¨Ó/°·±ÀÓ1G�Ø—,‘,‰ˆˆ1Ø T¥'Õ)¨6°tµGÕ+;�Ü�lŠl˜>¨6Ó:ˆØ×Ñ˜uÓ%ˆØ×Ñ˜uÓ%ˆÜ+¨C°RÓ8ˆØˆ{Ðr   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r    Údescr#   r$   )r'   rg   s   "€r   r(   r&  –  s'   ø€ ÷ 
Bñ 
B¡U§\¡\ð 
B±e·l±lñ 
Br   c                ój   € \         P                  ! V P                  V4      4      P                  R4      # )zòEstimate how likely each descriptor is to obtain a valid match.

Args:
    desc: Descriptor tensor with shape ``(B, N, D)``, where ``N`` is the
        number of local features.

Returns:
    Matchability probabilities with shape ``(B, N)``.
rE   )r%   Úsigmoidr(  r¤   )rv   r4  s   &&r   Úget_matchabilityÚ MatchAssignment.get_matchability–  s)   € ô �}Š}˜T×.Ñ.¨tÓ4Ó5×=Ñ=¸bÓAÐAr   )rB   r)  r(  )rˆ   r‰   rŠ   r‹   rŒ   ro   r„   r7  r�   rŽ   r�   r�   s   @@r   r$  r$  ~  s0   ù‡ € ñ÷9ó 9÷	ð 	÷
B÷ 
Bð 
Br   r$  c          
      óÖ   € V ^8„  d   QhR\         P                  R\        R\        \         P                  \         P                  \         P                  \         P                  3,          /# )r    r!  Úthr#   )r%   r&   r7   r   )r'   s   "r   r(   r(   £  sI   € ÷ &ñ &œ5Ÿ<™<ð &¬Uð &´u¼U¿\¹\Ì5Ï<É<ÔY^×YeÑYeÔgl×gsÑgsÐ=sÕ7tñ &r   c                ó^  € V RRR1RR13,          P                  ^4      V RRR1RR13,          P                  ^4      r2VP                  VP                  rT\        P                  ! VP                  ^,          VP
                  R7      R,          p\        P                  ! VP                  ^,          VP
                  R7      R,          pWeP                  ^V4      8H  pWtP                  ^V4      8H  p	VP                  P                  4       p
V
P                  R4      p\        P                  ! WŠV4      p\        P                  ! WœP                  ^V4      V4      pWŒV8„  ,          pWžP                  ^V4      ,          p\        P                  ! WäR4      p\        P                  ! WõR4      pWEWÍ3# )z;Obtain matches from a log assignment matrix [Bx M+1 x N+1].r*   N©r.   rE   rë   )r   Úindicesr%   ÚarangerF   r.   Úgatherr8   ÚexpÚ	new_zerosÚwhere)r!  r:  Úmax0Úmax1rû   rü   Úindices0Úindices1Úmutual0Úmutual1Úmax0_expÚzeroÚmscores0Úmscores1Úvalid0Úvalid1s   &&              r   Úfilter_matchesrO  £  sQ  € à˜˜3˜B˜3   ˜Õ$×(Ñ(¨Ó+¨V°A°s¸°s¸C¸R¸C°KÕ-@×-DÑ-DÀQÓ-Gˆ$Ø�\‰\˜4Ÿ<™<ˆÜ�|Š|˜BŸH™H Q�K°·	±	Ô:¸4Õ@€HÜ�|Š|˜BŸH™H Q�K°·	±	Ô:¸4Õ@€HØŸ)™) A rÓ*Ñ*€GØŸ)™) A rÓ*Ñ*€GØ�{‰{�‰Ó €HØ×Ñ˜bÓ!€DÜ�{Š{˜7¨dÓ3€HÜ�{Š{˜7§O¡O°A°rÓ$:¸DÓA€HØ 2™Õ&€FØ—}‘} Q¨Ó+Õ+€FÜ	�Š�V Ó	$€BÜ	�Š�V Ó	$€BØ�8Ð%Ð%r   a�  Keypoints must lie inside the image: normalized by the image size they have to be in [-1, 1]. The keypoints are (x, y) pixel coordinates. The image size is (width, height) for the ``image_size`` of LightGlue and OnnxLightGlue, and (height, width) for the ``hw1`` / ``hw2`` of LightGlueMatcher; the wrong order, or keypoints detected on a differently sized image, put them out of range.c                ó<   € V ^8„  d   QhR\         P                  RR/# )r    r!   r#   Nr$   )r'   s   "r   r(   r(   ¾  s   € ÷ 8ñ 8¤u§|¡|ð 8¸ñ 8r   c                 ó  € \        4       '       gj   \        P                  ! V  Uu. uF  qR8¬  V^8*  ,          P                  4       NK!  	  up4      P                  4       p\	        \        V4      \        4       R# R# u upi )zÎCheck that keypoints lie in [-1, 1]; skipped under export, where reading the data is not possible.

All the given tensors are checked with one read of the device, since each read waits for its queued work.
NrE   )r   r%   rW   Úallr   rH   Ú_KEYPOINT_RANGE_MSG)r!   r±   Úinsides   *  r   Ú_check_keypoints_normalizedrU  ¾  s\   € ô
 �>Š>Ü—’ÁDÓIÁD¸q R¡¨A°©FÕ3×8Ñ8Ö:ÁDÑIÓJ×NÑNÓPˆÜ”T˜&“\Ô#6Ö7ñ ùÚIs   ¥%A<c          
      óŒ   € V ^8„  d   QhR\         \        \        3,          R\        R\        R\         \        \        3,          /# )r    Úimager±   r  r#   )r   Ústrr   r?   )r'   s   "r   r(   r(   È  s8   € ÷ ñ œœS¤#˜X�ð ¬3ð ´3ð ¼4ÄÄSÀ½>ñ r   c           	     óø   € V P                  4        UUu/ uFX  w  r4T\        P                  ! V4      '       d5   VP                  ^ 8”  d$   VP                  ^ ,          V8X  d   WAV^,            MTbKZ  	  upp# u uppi )zeTake pair ``k`` of the ``b`` pairs from the inputs of one image, keeping entries shared by the batch.)Úitemsr%   Ú	is_tensorÚndimrF   )rW  r±   r  ÚkeyÚvalues   &&&  r   Ú_select_pairr_  È  sk   € ð  Ÿ+™+œ-ôá'‰JˆCð 	¤§¢°×!7Ò!7¸E¿J¹JÈ¼NÈuÏ{É{Ð[\Í~ÐabÔObˆU�q˜1•uÑÐhmÒmÙ'òð ùó s   ”AA6c                   ó  a a€ ] tR tRt oRt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/tRRKRRKRRRR/tRR .tR!tR"t	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R0R^@R^`R^R^RRKRRRR/R1RR2R^€RR/R3RR4R^€RRRRL/R4RR4R^€RRRRL/R5RR6R^€RRKRRKR
R//t
RMV3R7 lV 3R8 llltRNV3R9 lR: lltV3R; lR< ltV3R= lR> ltV3R? lR@ ltV3RA lRB ltV3RC lRD ltV3RE lRF ltV3RG lRH ltV3RI ltRJtVtV ;t# )OÚ	LightGlueiÐ  aô  Match the keypoints and descriptors of image pairs with the LightGlue transformer, given as dicts.

``lightglue = LightGlue("disk")`` loads the weights trained for that local feature and
``out = lightglue({"image0": feats0, "image1": feats1})`` takes, for each image, a dict of ``keypoints``
``(B, M, 2)`` as ``(x, y)`` pixels, ``descriptors`` ``(B, M, D)`` and ``image_size`` ``(B, 2)`` as ``(W, H)``,
and returns a dict whose ``matches0`` ``(B, M)`` holds the index in image1 of the match of each keypoint of
image0, ``-1`` for an unmatched one, with its score in ``matching_scores0`` ``(B, M)``; ``matches`` and
``scores`` list the matched index pairs ``(S, 2)`` and scores ``(S,)`` of each pair of images. The network is a
series of transformer layers, with early stopping and point pruning unless the configuration turns them off.
For the call of the other kornia matchers, on descriptors and LAFs, use :class:`LightGlueMatcher`; for an
exported ONNX model run by onnxruntime, use :class:`OnnxLightGlue`.

Convention:
    - Complete learned weights return the model in evaluation mode, even if derived buffers are absent from
      the checkpoint. Random or partially loaded learned weights leave it in training mode.
    - The ``keypoints`` of each image are ``(x, y)`` pixels and ``image_size`` is ``(W, H)``; an ``image``
      tensor gives the size from its last two dimensions instead. ``forward`` normalises the keypoints to
      ``(k - size / 2) / (max(size) / 2)``, as the reference implementation does, and raises for a keypoint
      outside :math:`[-1, 1]` after that. The keypoints can be wider than the model, like the float32 keypoints
      of kornia's detectors with a float16 or bfloat16 model; the positional encoding runs in the model's dtype.
    - The ``"sift"``, ``"doghardnet"`` and ``"dog_affnet_hardnet"`` configurations, which set ``add_scale_ori``,
      also read ``scales`` and ``oris`` (radians) of each image; the last two multiply ``scales`` by their
      ``scale_coef`` of 1/6 first, so they take the LAF scale. ``"keynet_affnet_hardnet"``, which sets ``add_laf``,
      reads ``lafs``. :class:`~kornia.feature.LightGlueMatcher` builds them from LAFs.
    - The matching scores, ``matching_scores0``, ``matching_scores1`` and ``scores``, are in the dtype of the
      descriptors with ``mp=False``. With ``mp=True``, autocast sets it, for every configuration and also when
      point pruning removes every point. On CPU, autocast runs in float16 for a float16 model and in bfloat16,
      CPU autocast's default, for any other: a float16 model gives float16 scores for float16 and float32
      descriptors, a float32 or bfloat16 model gives bfloat16 scores for float32 and bfloat16 descriptors, and a
      float64 model gives float64 scores for float64 descriptors. Float16 descriptors with any other model, and
      bfloat16 descriptors with a float16 model, are not supported there
      (`#5929 <https://github.com/kornia/kornia/issues/5929>`_). On MPS, float32, float16 and bfloat16
      descriptors give float32 scores; on CUDA, float32 descriptors give float32 scores, and a float64 model gives
      float64 scores for float64 descriptors, as on CPU, because autocast does not cast float64. An image without
      descriptors runs no layer, and its zero scores keep the descriptor dtype, also with ``mp=True``.
    - Each pair of a batch gives the matches and scores it gives on its own when point pruning can run, that is
      with ``width_confidence > 0``, no padding to the ``static_lengths`` of ``LightGlue.compile`` (which wraps
      the transformer layers in :func:`torch.compile`), and an image with more keypoints than
      ``pruning_min_kpts(device)`` returns: any number on CPU and MPS, more than 1536 on CUDA with the default
      ``flash=True`` and more than 1024 without. Pruning keeps a different number of points in each
      pair, so then the pairs run one at a time: ``matches0``, ``matches1``, ``matching_scores0``,
      ``matching_scores1``, ``prune0`` and ``prune1`` stack the rows of the pairs, ``matches`` and ``scores`` list
      them, ``stop`` is the largest number of layers that a pair ran, and there is no ``log_assignment``.
      Otherwise a batch runs as one, and early stopping (``depth_confidence``) ends it at a layer only when every
      pair meets its own criterion. A pair can therefore run more layers in a batch than on its own, and its
      matches can differ. Early stopping counts the real keypoints only, so padding to the ``static_lengths`` of
      ``LightGlue.compile`` does not change the layer at which a pair stops.

Args:
    features: The type of local features to match, whose configuration and pretrained weights are loaded: one of
        ``"aliked"``, ``"dedodeb"``, ``"dedodeg"``, ``"disk"``, ``"dog_affnet_hardnet"``, ``"doghardnet"``,
        ``"keynet_affnet_hardnet"``, ``"raco-aliked"``, ``"sift"``, ``"superpoint"`` and ``"xfeat"``. ``None``
        builds the model from ``default_conf`` and the keyword arguments and downloads no weights.
    **conf: keyword arguments that override entries of ``default_conf`` and of the configuration of
        ``features``, such as ``filter_threshold`` or ``depth_confidence``. The configuration of ``features`` sets
        the defaults, and an explicit keyword argument always wins, except ``weights``, which must name the
        checkpoint of ``features`` when ``features`` is given; ``weights=None``, the value in ``default_conf``,
        counts as not given. This departs on purpose from cvg/LightGlue, which applies the configuration of
        ``features`` after the keyword arguments, so that the tuning knobs a preset sets, such as ``"xfeat"``'s
        ``width_confidence``, can be changed.

See Also:
    - :class:`LightGlueMatcher`: the same network on descriptors and LAFs, returning scores and index pairs like
      the other kornia matchers.
    - :class:`OnnxLightGlue`: an exported LightGlue model run by onnxruntime, for one image pair on CPU or CUDA.
    - :class:`LoFTR`: a transformer matcher that takes the images themselves, without a detector.
ÚnameÚ	lightglueÚ	input_dimé   Údescriptor_dimÚadd_scale_oriFÚadd_lafÚ
scale_coefr†   Ún_layersrÁ   rÂ   TÚmpÚdepth_confidencegffffffî?Úwidth_confidenceg®Gáz®ï?Úfilter_thresholdçš™™™™™¹?ÚweightsNÚcpuÚmpsrµ   é   é   Úimage0Úimage1z
v0.1_arxivzFhttps://github.com/cvg/LightGlue/releases/download/{}/{}_lightglue.pthÚ
superpointÚsuperpoint_lightglueÚdedodebÚdedodeb_lightglueÚdedodegÚdedodeg_lightglueÚdiskÚdisk_lightglueÚalikedÚaliked_lightgluezraco-alikedÚraco_aliked_lightglueÚxfeatÚxfeat_lighterglueÚsiftÚsift_lightglueÚdog_affnet_hardnetÚ
doghardnetÚkeynet_affnet_hardnetÚkeynet_affnet_hardnet_lightgluec                ó4   <€ V ^8„  d   QhRS[ S[,          RR/# )r    Úfeaturesr#   N)r
   rX  )r'   rg   s   "€r   r(   ÚLightGlue.__annotate__p  s#   ø€ ÷ _#ñ _#¡©#¥ð _#È4ñ _#r   c                ó  <a€ \         SV `  4        VP                  R R4      f-   VP                  4        UUu/ uF  w  r4VR 8w  g   K  W4bK  	  pppVeƒ   \	        V\        V P                  P                  4       4      9   R4       VP                  R V P                  V,          R ,          4      V P                  V,          R ,          8w  d   \        R4      hVe   V P                  V,          M/ p\        R&/ / V P                  CVCVCB ;V n        p\	        V P                  P                  ;'       d    V P                  P                  '       * 4       VP                  VP                  8w  d4   \         P"                  ! VP                  VP                  RR7      V n        M\         P&                  ! 4       V n        VP                  VP(                  ,          p\+        ^^VP                  ,          ,           ^VP                  ,          ,           VV4      V n        VP(                  VP.                  VP                  r©p\         P0                  ! \3        V	4       Uu. uF  p\5        W¨VP6                  4      NK  	  up4      V n        \         P0                  ! \3        V	4       Uu. uF  p\;        V
4      NK  	  up4      V n        \         P0                  ! \3        V	^,
          4       Uu. uF  p\?        V
4      NK  	  up4      V n         T PC                  R\D        PF                  ! \3        V P                  P.                  4       Uu. uF  qÀPI                  V4      NK  	  up4      4       RpVeø   VPJ                   RV PL                   R	2PO                  R
R4      pVR8X  d   RpVR'9   d   Rp\Q        RR4      R.pM�VR(9   d   Rp\Q        RR4      R.pM…VR)9   d   Rp\Q        RR4      R.pMmVR8X  d   Rp\Q        RR4      R.pMU\Q        RVPO                  RR4       R24      V PR                  PU                  V PL                  VPO                  RR4      4      .p\W        WþR7      pMjVPJ                  e]   \Y        \Z        4      P\                  pVRV P                  PJ                   R	2,          p\D        P^                  ! \a        V4      RRR7      pV'       Ed|   RpVP                  4        UUu/ uF-  w  r4VPc                  V4      '       d   V\e        V4      R MTVbK/  	  ppp\3        V P                  P.                  4       F}  pRV 2RV R 23pVP                  4        UUu/ uF  w  r4VPN                  ! V!  VbK  	  pppR!V 2RV R"23pVP                  4        UUu/ uF  w  r4VPN                  ! V!  VbK  	  pppK  	  V Pg                  VR#R$7      p\i        V Pk                  4       4      o\l        ;QJ d)    V3R% lVPn                   4       F  '       g   K   RM	  R#M! V3R% lVPn                   4       4      '       g   V Pq                  4        RV n9        R# u uppi u upi u upi u upi u upi u uppi u uppi u uppi )*rp  Ú NzFeatures keys are wrongz³`weights` must name the checkpoint of `features`. To load other weights, build the model with `features=None` and their architecture keyword arguments, then call `load_state_dict`Trj   Úconfidence_thresholdsr0  z.pthÚ.Ú-r†  r‡  z#keynet_affnet_hardnet_lightglue.pthrc  zLhttps://cmp.felk.cvut.cz/~mishkdmy/models/keynet_affnet_hardnet_lightlue.pthzdedodeb_lightglue.pthz?https://cmp.felk.cvut.cz/~mishkdmy/models/dedodeb_lightglue.pthzdedodeg_lightglue.pthz?https://cmp.felk.cvut.cz/~mishkdmy/models/dedodeg_lightglue.pthr‚  zxfeat-lighterglue.ptzThttps://github.com/verlab/accelerated_features/raw/main/weights/xfeat-lighterglue.ptz_lightglue.pth)Ú	file_namezweights/rq  )Úmap_locationÚweights_onlyzmatcher.z
self_attn.ztransformers.z
.self_attnzcross_attn.z.cross_attnF)Ústrictc              3   ó,   <"  € T F	  qS9   x € K  	  R # 5ir­   rë   )rñ   rb  Ú
parameterss   & €r   rò   Ú%LightGlue.__init__.<locals>.<genexpr>Ì  s   øé € ÐPÑ6O¨d˜zÖ)Ó6Oùs   ƒrë   )rˆ  )ry  )r{  ):rn   ro   ÚgetrZ  r   Úlistr‹  Úkeysr   r   Údefault_confÚconfrg  rh  rd  rf  r   rp   Ú
input_projÚIdentityrÁ   rb   Úposencrj  Ú
ModuleListÚrangerÿ   rÂ   Útransformersr$  Úlog_assignmentr’   Útoken_confidenceÚregister_bufferr%   r&   Úconfidence_thresholdrp  ÚversionÚreplacer   Úurlr'   r   r   Ú__file__ÚparentÚloadrX  Ú
startswithÚlenÚload_state_dictÚdictÚnamed_parametersÚanyÚmissing_keysÚevalÚstatic_lengths)rv   r‹  Úconf_r±   r²   Úpresetr�  rÈ   Úhr  r1  r0  ÚiÚ
state_dictÚfnamerª  ÚpathÚprefixÚpatternÚincompatibler—  rw   s   &&,                 @€r   ro   ÚLightGlue.__init__p  s“  ù€ Ü‰ÑÔØ�9‰9�Y Ó#Ò+ð ',§k¡k¤mÔF¡m™d˜a°q¸I±~”T�Q’T¡mˆEÑFØÒÜ˜¤T¨$¯-©-×*<Ñ*<Ó*>Ó%?Ñ?ÐAZÔ[ð �y‰y˜ D§M¡M°(Õ$;¸IÕ$FÓGÈ4Ï=É=ÐYaÕKbÐclÕKmÔmÜðlóð ð -5Ò,@�—‘˜xÖ(ÀbˆÜ*ÑVÐ-U°×0AÑ0AÐ-UÀVÐ-UÈuÐ-UÑVÐVˆŒ	�DÜ˜$Ÿ)™)×1Ñ1×GÐG°d·i±i×6GÑ6GÔHÔIà�>‰>˜T×0Ñ0Ô0Ü Ÿiši¨¯©¸×8KÑ8KÐRVÔWˆD�Oä Ÿkšk›mˆDŒOà×&Ñ&¨$¯.©.Õ8ˆÜ8Ø��D×&Ñ&Õ&Õ&¨¨T¯\©\Õ)9Õ9ØØó
ˆŒð —.‘. $§-¡-°×1DÑ1DˆaˆÜŸMšMÔW\Ð]^ÔW_Ó*`ÑW_ÐRSÔ+;¸AÀ$Ç*Á*Ö+MÑW_Ñ*`ÓaˆÔÜ ŸmšmÌÈqÌÓ,RÉÀA¬_¸QÖ-?ÉÑ,RÓSˆÔÜ "§¢Ì5ÐQRÐUVÕQVÌ<Ó.XÉ<Àa¬¸qÖ/AÉ<Ñ.XÓ YˆÔØ×ÑØ#Ü�LŠLÄÀdÇiÁi×FXÑFXÔ@YÓZÑ@Y¸1×3Ñ3°AÖ6Ñ@YÑZÓ[ô	
ð ˆ
ØÒØ—|‘|�n A d§l¡l ^°4Ð8×@Ñ@ÀÀcÓJˆEØÐ/Ô/Ø'�ØÐ4Ô4Ø=�ä˜;Ð(MÓNØbð‘ð ˜[Ô(Ø/�ä˜;Ð(?Ó@ØUð‘ð ˜[Ô(Ø/�ä˜;Ð(?Ó@ØUð‘ð ˜WÔ$Ø.�ä˜;Ð(>Ó?Øjð‘ô ˜;¨8×+;Ñ+;¸CÀÓ+EÐ*FÀnÐ(UÓVØ—H‘H—O‘O D§L¡L°(×2BÑ2BÀ3ÈÓ2LÓMð�ô 2°#ÔG‰JØ�\‰\Ò%Üœ“>×(Ñ(ˆDØ˜H T§Y¡Y×%6Ñ%6Ð$7°tÐ<Õ<ˆDÜŸš¤C¨£I¸EÐPTÔUˆJßˆ:àˆFØYc×YiÑYiÔYkÔlÑYkÑQUÐQR¨a¯l©l¸6×.BÒ.B˜!œC ›K˜MÑ*ÈÈ1ÒLÑYkˆJÑlä˜4Ÿ9™9×-Ñ-Ö.�Ø& q cÐ*¨m¸A¸3¸jÐ,IÐI�ØAK×AQÑAQÔASÔTÑAS¹¸˜aŸiši¨Ñ1°1Ò4ÑAS�
ÑTØ'¨ sÐ+¨}¸Q¸C¸{Ð-KÐK�ØAK×AQÑAQÔASÔTÑAS¹¸˜aŸiši¨Ñ1°1Ò4ÑAS�
ÑT‘
ñ	 /ð
  ×/Ñ/°
À5Ð/ÓIˆLä˜d×3Ñ3Ó5Ó6ˆJß“3ÔP°l×6OÒ6OÓP—3—3’3ÔP°l×6OÒ6OÓP×PÒPØ—	‘	”à"ˆÖùós Gùò6 +aùÚ,RùÚ.Xùò [ùóX mùó UùãTs5   ¸YÁYÉY"Ê#Y'Ë'Y,ÍY1Ó-3Y6Õ#Y<Ö Zc                ó:   <€ V ^8„  d   QhRS[ RS[S[,          RR/# )r    Úmoder¶  r#   N)rX  r   r?   )r'   rg   s   "€r   r(   rŒ  Ñ  s)   ø€ ÷ -ñ -Ùð-Ù=EÁc½]ð-à	ñ-r   c                óH  € V P                   P                  R8w  d   \        P                  ! R^R7       \	        \
        R4      '       dc   \	        \
        P                  R4      '       dC   \
        P                  P                  4       '       d   \
        P                  P                  4        \        V P                   P                  4       FM  p\
        P                  ! V P                  V,          P                  VRR7      V P                  V,          n        KO  	  W n        R# )	a  Compile masked transformer layers with ``torch.compile``.

Args:
    mode: Compilation mode forwarded to ``torch.compile``.
    static_lengths: Descriptor sequence lengths prepared for compiled execution.
        These lengths represent possible numbers of local features.
z9Point pruning is partially disabled for compiled forward.)Ú
stacklevelÚ	_inductorÚcudagraph_mark_step_beginT)rÃ  Ú	fullgraphNrE   )r�  rm  ÚwarningsÚwarnÚhasattrr%   rÆ  rµ   Úis_availablerÇ  r¢  rj  Úcompiler£  r  r¶  )rv   rÃ  r¶  rº  s   &&& r   rÍ  ÚLightGlue.compileÑ  sÁ   € ð �9‰9×%Ñ%¨Ô+Ü�MŠMØKØõô ”E˜;×'Ò'ÜœŸ™Ð)D×EÒEÜ—
‘
×'Ñ'×)Ò)ä�O‰O×5Ñ5Ô7Ü�t—y‘y×)Ñ)Ö*ˆAÜ27·-²-Ø×!Ñ! !Õ$×3Ñ3¸$È$ô3ˆD×Ñ˜aÕ Ö/ñ +ð
 -Ör   c                ó&   <€ V ^8„  d   QhRS[ RS[ /# ©r    ru   r#   ©r±  )r'   rg   s   "€r   r(   rŒ  î  s   ø€ ÷  'ñ  '™Dð  '¡Tñ  'r   c                ó  € V P                    F  p\        W!9   RV R24       K  	  VR,          R,          P                  P                  pVR8X  dN   V P                  P
                  P                  P                  \        P                  8X  d   \        P                  MRp\        P                  ! V P                  P                  W4R7      ;_uu_ 4        V P                  V4      uuRRR4       #   + '       g   i     R# ; i)aa  Match keypoints and descriptors between two images.

Input (dict):
    image0: dict
        keypoints: [B x M x 2]
        descriptors: [B x M x D]
        image: [B x C x H x W] or image_size: [B x 2]
        scales, oris: [B x M], with add_scale_ori
        lafs: [B x M x 2 x 3], with add_laf
    image1: dict
        keypoints: [B x N x 2]
        descriptors: [B x N x D]
        image: [B x C x H x W] or image_size: [B x 2]
        scales, oris: [B x N], with add_scale_ori
        lafs: [B x N x 2 x 3], with add_laf
Output (dict):
    log_assignment: [B x M+1 x N+1], not for a batch that prunes points (see the Convention block)
    matches0: [B x M]
    matching_scores0: [B x M]
    matches1: [B x N]
    matching_scores1: [B x N]
    matches: List[[Si x 2]], scores: List[[Si]]
    stop, prune0, prune1: diagnostics of early stopping and point pruning
zMissing key z in dataru  Ú	keypointsrq  N)Úenabledr9   r1   )Úrequired_data_keysr   r.   r/   r   rq   rt   r1   r%   r2   Úautocastr�  rk  Ú_forward)rv   ru   r]  r9   r1   s   &&   r   r„   ÚLightGlue.forwardî  s¯   € ð2 ×*Ô*ˆCÜ˜™¨°S°E¸Ð&BÖCñ +à˜8•n [Õ1×8Ñ8×=Ñ=ˆð "-°Ô!5¸$¿+¹+¿.¹.×:OÑ:O×:UÑ:UÔY^×YfÑYfÔ:f”—’ÐlpˆÜ�^Š^ D§I¡I§L¡L¸k×WÖWØ—=‘= Ó&÷ X×W×WÓWús   ÃC0Ã0D	c                ó&   <€ V ^8„  d   QhRS[ RS[ /# rÐ  rÑ  )r'   rg   s   "€r   r(   rŒ    s   ø€ ÷ L
ñ L
™Tð L
¡dñ L
r   c                óR!  € VR ,          VR,          r2VR,          VR,          rTVP                   w  rgpVP                   w  ripVP                  p
\        Wy4      pV P                  ;'       d    V\        V P                  4      8*  pV P                  P
                  ^ 8„  ;'       d    V'       * pV^8”  d@   \        Wy4      ^ 8”  d0   V'       d(   W°P                  V
4      8”  d   V P                  W#V4      # VP                  R4      VP                  R4      rþVe   TMVR,          P                   RR RRR1,          pVe   TMVR,          P                   RR RRR1,          p\        WN4      P                  4       p\        W_4      P                  4       p\        WE4       V P                  P                  '       Ed   \        P                  ! V.R Uu. uF  pVV,          P!                  R4      NK  	  up,           R4      pV P                  P"                  R8w  d(   VR,          V P                  P"                  ,          VR&   \        P                  ! V.R Uu. uF  pVV,          P!                  R4      NK  	  up,           R4      pV P                  P"                  R8w  d(   VR,          V P                  P"                  ,          VR&   EM•V P                  P$                  '       Edy   \'        VR,          V P                  P"                  4      p\'        VR,          V P                  P"                  4      p\)        V4      p\)        V4      p\        P                  ! V\        VR ,          V4      P                  4       P+                  VP,                  4      \        VR!,          V4      P                  4       P+                  VP,                  4      .R4      p\        P                  ! V\        VR ,          V4      P                  4       P+                  VP,                  4      \        VR!,          V4      P                  4       P+                  VP,                  4      .R4      pVR	,          P/                  4       P1                  4       pVR	,          P/                  4       P1                  4       pVP                   ^,          ^ 8X  g   VP                   ^,          ^ 8X  Ed�   VP,                  p\        P2                  ! Wg3RV
\        P4                  R
7      p\        P2                  ! Wi3RV
\        P4                  R
7      p\        P6                  ! Wg3V
VR
7      p\        P6                  ! Wi3V
VR
7      pR\        P8                  ! V^^3V
VR
7      RTRTRTRTR^ R\;        V4       Uu. uF*  p\        P8                  ! R"V
\        P4                  R
7      NK,  	  upR\;        V4       Uu. uF  p\        P8                  ! R#V
VR
7      NK  	  upR\        P<                  ! V4      V P                  P>                  ,          R\        P<                  ! V4      V P                  P>                  ,          /
# \A        VP                   R,          V P                  PB                  8H  R4       \A        VP                   R,          V P                  PB                  8H  R4       VP                  PD                  pVR8w  d\   \        PF                  ! V4      '       d@   VP,                  \        PH                  8w  d!   VPK                  4       pVPK                  4       pRRppV'       di   \        V P                   Uu. uF  pVV8¼  g   K  VNK  	  up4      p\M        VV4      w  pp\M        VV4      w  pp\M        VV4      w  rH\M        VV4      w  rXV PO                  V4      pV PO                  V4      pV PP                  PR                  PT                  P,                  pV PQ                  VP+                  V4      4      pV PQ                  VP+                  V4      4      p V P                  PV                  ^ 8„  p!V P                  V
4      p"V'       d‹   \        PX                  ! ^ WzR7      R,          P[                  VR4      p#\        PX                  ! ^ WšR7      R,          P[                  VR4      p$\        P<                  ! V#4      p%\        P<                  ! V$4      p&RRp(p'\;        V P                  P>                  4       EF,  p)V P\                  V),          ! VVVV VVR7      w  ppV)V P                  P>                  ^,
          8X  d   KJ  V!'       dW   V P^                  V),          ! VV4      w  p'p(V Pa                  V'RRV13,          V(RRV	13,          V)Wy,           4      '       d    EM‰V'       d¸   VP                   R,          V"8”  d    V Pb                  V),          Pe                  V4      p*V Pg                  V'V*V)4      p+\        Ph                  ! V+4      ^,          p,X#Pk                  ^V,4      p#VPk                  ^V,4      pVPk                  RV,4      pX%RV#3;;,          ^,          uu&   V'       g   EKr  VP                   R,          V"8”  g   EK�  V Pb                  V),          Pe                  V4      p-V Pg                  V(V-V)4      p.\        Ph                  ! V.4      ^,          p/X$Pk                  ^V/4      p$VPk                  ^V/4      pV Pk                  RV/4      p X&RV$3;;,          ^,          uu&   EK/  	  VRRV1R3,          VRRV	1R3,          ppVP                   R,          ^ 8X  g   VP                   R,          ^ 8X  EdÛ   V Pb                  X),          ! VR$,          VR$,          4      w  p0pV0Pm                  R%4      Po                  4       P,                  p\;        V4       Uu. uF*  p\        P6                  ! R"\        P4                  V
R7      NK,  	  p1p\;        V4       Uu. uF  p\        P6                  ! ^ V
VR
7      NK  	  p2p\        P2                  ! Wg3RV
\        P4                  R
7      p3\        P2                  ! Wi3RV
\        P4                  R
7      p4\        P6                  ! Wg3V
VR
7      p5\        P6                  ! Wi3V
VR
7      p6RT1RT2RT5RT6RT3RT4RV)^,           RV'       d   X%M1\        P<                  ! \        PX                  ! WzR7      R,          4      RV'       d   X&/	# \        P<                  ! \        PX                  ! WšR7      R,          4      /	# V Pb                  X),          ! VV4      w  p7p\q        V7V P                  Pr                  4      w  p8p9p:p;. . p2p1\;        V4       F§  p\        Pt                  ! V8V,          R8„  4      Pw                  R4      p<V8V,          V<,          p=V2Py                  V:V,          V<,          4       V'       d   X#VV<3,          p<X$VV=3,          p=V1Py                  \        Pz                  ! V<V=.R4      4       K©  	  V'       Ed…   \        P2                  ! Wg3RV8P                  V8P,                  R
7      p3\        P2                  ! Wi3RV9P                  V9P,                  R
7      p4V3P}                  ^X#\        Ph                  ! V8R8H  RX$P                  ^V8P�                  ^ R7      4      4      4       V4P}                  ^V$\        Ph                  ! V9R8H  RV#P                  ^V9P�                  ^ R7      4      4      4       \        P6                  ! Wg3V:P                  V:P,                  R
7      p5\        P6                  ! Wi3V;P                  V;P,                  R
7      p6V5P}                  ^V#V:4       V6P}                  ^V$V;4       V3V4V5V63w  p8p9p:p;Mb\        P<                  ! V:4      V P                  P>                  ,          p%\        P<                  ! V;4      V P                  P>                  ,          p&RV7RV8RV9RV:RV;RV)^,           RV1RV2RX%RX&/
# u upi u upi u upi u upi u upi u upi u upi )&ru  rv  rÓ  Ú
image_sizeNrW  r†   .ÚlafsÚdescriptors)r.   r1   r¤  Úmatches0Úmatches1Úmatching_scores0Úmatching_scores1ÚstopÚmatchesr!  Úprune0Úprune1z7Descriptor dimension does not match input dim in configrq  r<  )r	  r
  r*   )r1   r.   )r   rC   rE   )ÚscalesÚoris).rC   rÓ   rÔ   )r   r    )r   )r*   :Nr   Nrë   )ArF   r.   r   r¶  r�  rm  r   Úpruning_min_kptsÚ_forward_pairsr™  r<   ÚclonerU  rg  r%   rJ   r~   ri  rh  r   r   r5   r1   r£   r¸   ÚfullÚlongrK   Úemptyr¢  rG   rj  r   rd  r/   r4   Úfloat64r·   rO   rž  r   rq   rt   rl  r>  Úexpandr£  r¥  Úcheck_if_stopr¤  r7  Úget_pruning_maskrB  Úindex_selectrA  r@  rO  rn  Únonzeror¤   ÚappendrW   Úscatter_r?  Úclamp)>rv   ru   Údata0Údata1Úkpts0Úkpts1r  r  r0  r  r.   ÚcÚ
do_compileÚdo_point_pruningÚsize0Úsize1r±   Úlaf0Úlaf1rŸ   r    r1   Úempty_m0Úempty_m1Úempty_s0Úempty_s1r9   r	  r
  ÚknÚpe_dtyper  r  Údo_early_stopÚ
pruning_thÚind0Úind1rä  rå  Útoken0Útoken1rº  r  Ú
prunemask0Úkeep0r   Ú
prunemask1Úkeep1r¤  rã  ÚmscoresÚm0_Úm1_Ú	mscores0_Ú	mscores1_r!  rû   rü   rK  rL  Úm_indices_0Úm_indices_1s>   &&                                                            r   r×  ÚLightGlue._forward  s4  € Ø˜H•~ t¨H¥~ˆuØ˜[Õ)¨5°Õ+=ˆuØ—+‘+‰ˆˆaØ—+‘+‰ˆˆaØ—‘ˆÜ�‹IˆØ×(Ñ(×JÐJ¨Q´#°d×6IÑ6IÓ2JÑ-Jˆ
ØŸ9™9×5Ñ5¸Ñ9×LÐLÀ*¼nÐØˆqŒ5”S˜“Y ”]×'7¸A×@UÑ@UÐV\Ó@]Ô<]à×&Ñ& u°QÓ7Ð7Ø—y‘y Ó.°·	±	¸,Ó0GˆuØÒ*‘°°gµ×0DÑ0DÀRÀSÐ0IÉ$ÈBÈ$Õ0OˆØÒ*‘°°gµ×0DÑ0DÀRÀSÐ0IÉ$ÈBÈ$Õ0Oˆä# EÓ1×7Ñ7Ó9ˆÜ# EÓ1×7Ñ7Ó9ˆÜ# EÔ1Ø�9‰9×"×"Ñ"Ü—I’I˜u˜gÑI[Ó(\ÑI[ÀA¨¨q­×);Ñ);¸BÖ)?ÑI[Ñ(\Õ\Ð^`ÓaˆEØ�y‰y×#Ñ# sÔ*Ø!& w¥°$·)±)×2FÑ2FÕ!F��g‘Ü—I’I˜u˜gÑI[Ó(\ÑI[ÀA¨¨q­×);Ñ);¸BÖ)?ÑI[Ñ(\Õ\Ð^`ÓaˆEØ�y‰y×#Ñ# sÔ*Ø!& w¥°$·)±)×2FÑ2FÕ!F��g‘ùØ�Y‰Y××ÑÜ˜U 6�]¨D¯I©I×,@Ñ,@ÓAˆDÜ˜U 6�]¨D¯I©I×,@Ñ,@ÓAˆDÜ& tÓ,ˆDÜ& tÓ,ˆDÜ—I’IàÜ'¨¨V­°eÓ<×BÑBÓD×GÑGÈÏÉÓTÜ'¨¨V­°eÓ<×BÑBÓD×GÑGÈÏÉÓTðð
 óˆEô —I’IàÜ'¨¨V­°eÓ<×BÑBÓD×GÑGÈÏÉÓTÜ'¨¨V­°eÓ<×BÑBÓD×GÑGÈÏÉÓTðð
 óˆEð �mÕ$×+Ñ+Ó-×8Ñ8Ó:ˆØ�mÕ$×+Ñ+Ó-×8Ñ8Ó:ˆð �;‰;�q�>˜QÔ %§+¡+¨a¥.°AÕ"5à—K‘KˆEÜ—z’z 1 &¨"°VÄ5Ç:Á:ÔNˆHÜ—z’z 1 &¨"°VÄ5Ç:Á:ÔNˆHÜ—{’{ A 6°&ÀÔFˆHÜ—{’{ A 6°&ÀÔFˆHð !¤%§+¢+¨q°!°Q¨iÀÈeÔ"TØ˜HØ˜HØ" HØ" HØ˜ØÔZ_Ð`aÔZbÓcÑZbÐUVœEŸKšK¨°vÄUÇZÁZ×PÑZbÑcØÔRWÐXYÔRZÓ[ÑRZÈQœ5Ÿ;š; t°FÀ%×HÑRZÑ[Øœ%Ÿ/š/¨(Ó3°d·i±i×6HÑ6HÕHØœ%Ÿ/š/¨(Ó3°d·i±i×6HÑ6HÕHðð ô 	�U—[‘[ •_¨¯	©	×(;Ñ(;Ñ;Ð=vÔwÜ�U—[‘[ •_¨¯	©	×(;Ñ(;Ñ;Ð=vÔwà—l‘l×'Ñ'ˆà˜%Ô¤E×$=Ò$=¸k×$JÒ$JÈuÏ{É{Ô^c×^kÑ^kÔOkØ—J‘J“LˆEØ—J‘J“LˆEà˜TˆuˆßÜ ×!4Ò!4Ó?Ñ!4˜A¸¸Q¹—a�aÑ!4Ñ?Ó@ˆBÜ(¨°Ó3‰LˆE�5Ü(¨°Ó3‰LˆE�5Ü$ U¨BÓ/‰HˆEÜ$ U¨BÓ/‰HˆEØ—‘ Ó&ˆØ—‘ Ó&ˆð —;‘;—>‘>×(Ñ(×.Ñ.ˆØ—K‘K §¡¨Ó 2Ó3ˆ	Ø—K‘K §¡¨Ó 2Ó3ˆ	ð Ÿ	™	×2Ñ2°QÑ6ˆØ×*Ñ*¨6Ó2ˆ
ßÜ—<’<  1Ô4°TÕ:×AÑAÀ!ÀRÓHˆDÜ—<’<  1Ô4°TÕ:×AÑAÀ!ÀRÓHˆDä—_’_ TÓ*ˆFÜ—_’_ TÓ*ˆFØ˜t�ˆÜ�t—y‘y×)Ñ)×*ˆAØ×,Ñ,¨QÖ/°°u¸iÈÐZ_ÐglÔm‰LˆE�5Ø�D—I‘I×&Ñ&¨Õ*Ô*ÙçØ!%×!6Ñ!6°qÖ!9¸%ÀÓ!G‘�˜Ø×%Ñ% f¨S°"°1°"¨W¥o°v¸cÀ2ÀAÀ2¸gµÈÈ1Í5×QÒQÚç E§K¡K°¥O°jÔ$@Ø×-Ñ-¨aÕ0×AÑAÀ%ÓH�Ø!×2Ñ2°6¸7ÀAÓF�
ÜŸš JÓ/°Õ2�Ø×(Ñ(¨¨EÓ2�Ø×*Ñ*¨1¨eÓ4�Ø%×2Ñ2°2°uÓ=�	Ø�q˜$�w— 1Õ$“ßÒ E§K¡K°¥O°j×$@Ø×-Ñ-¨aÕ0×AÑAÀ%ÓH�Ø!×2Ñ2°6¸7ÀAÓF�
ÜŸš JÓ/°Õ2�Ø×(Ñ(¨¨EÓ2�Ø×*Ñ*¨1¨eÓ4�Ø%×2Ñ2°2°uÓ=�	Ø�q˜$�w— 1Õ$–ñ3 +ð6 ˜S " 1 " a˜ZÕ(¨%°°R°a°R¸°
Õ*;ˆuˆð �;‰;�r�?˜aÔ 5§;¡;¨r¥?°aÕ#7ð
 !%× 3Ñ 3°AÖ 6°u¸Uµ|ÀUÈ5Å\Ó RÑˆN˜AØ"×,Ñ,¨RÓ0×4Ñ4Ó6×<Ñ<ˆEÜUZÐ[\ÔU]Ó^ÑU]ÐPQ”u—{’{ 6´·±ÀF×KÑU]ˆGÐ^ÜKPÐQRÌ8ÓTÉ8Àa”u—{’{ 1¨V¸5×AÉ8ˆGÐTÜ—*’*˜a˜V R°¼e¿j¹jÔIˆCÜ—*’*˜a˜V R°¼e¿j¹jÔIˆCÜŸš Q F°6ÀÔGˆIÜŸš Q F°6ÀÔGˆIà˜7Ø˜'Ø" IØ" IØ˜CØ˜CØ˜˜A�Ø×$4™&¼%¿/º/Ì%Ï,Ê,ÐWXÔJhÐimÕJnÓ:oØ×$4˜&ð
ð 
ô ;@¿/º/Ì%Ï,Ê,ÐWXÔJhÐimÕJnÓ:oð
ð 
ð ×'Ñ'¨Ö*¨5°%Ó8‰	ˆ�Ü%3°F¸D¿I¹I×<VÑ<VÓ%WÑ"ˆˆB�˜(à˜r�ˆÜ�q–ˆAô  Ÿ-š-¨¨1­°©
Ó3×;Ñ;¸BÓ?ˆKØ˜Q�% Õ,ˆKØ�N‰N˜8 A�; {Õ3Ô4ßØ" 1 k >Õ2�Ø" 1 k >Õ2�Ø�N‰Nœ5Ÿ;š;¨°[Ð'AÀ2ÓFÖGñ ÷ ÐÜ—*’*˜a˜V R°·	±	ÀÇÁÔJˆCÜ—*’*˜a˜V R°·	±	ÀÇÁÔJˆCØ�L‰L˜˜D¤%§+¢+¨b°B©h¸¸D¿K¹KÈÈ2Ï8É8ÐXYÈ8Ë?Ó<[Ó"\Ô]Ø�L‰L˜˜D¤%§+¢+¨b°B©h¸¸D¿K¹KÈÈ2Ï8É8ÐXYÈ8Ë?Ó<[Ó"\Ô]ÜŸš Q F°8·?±?È(Ï.É.ÔYˆIÜŸš Q F°8·?±?È(Ï.É.ÔYˆIØ×Ñ˜q $¨Ô1Ø×Ñ˜q $¨Ô1Ø),¨c°9¸iÐ)GÑ&ˆB��H™hä—_’_ XÓ.°·±×1CÑ1CÕCˆFÜ—_’_ XÓ.°·±×1CÑ1CÕCˆFð ˜fØ˜Ø˜Ø Ø Ø�A˜•EØ�wØ�gØ�fØ�fð
ð 	
ùò[ )]ùò )]ùòX dùÚ[ùò  @ùòz _ùÚTs8   Ç!AB
É!AB
Ö0AB×"AB"Ý&	ABÝ4ABð0ABñ"AB$c                ó2   <€ V ^8„  d   QhRS[ RS[ RS[RS[ /# )r    r÷  rø  r  r#   )r±  r?   )r'   rg   s   "€r   r(   rŒ  Þ  s)   ø€ ÷ ñ ¡Dð ±ð ¹#ð Á$ñ r   c                óê  € \        V4       Uu. uF+  q@P                  R\        WV4      R\        W$V4      /4      NK-  	  ppRpV UUu/ uF/  qw\        P                  ! V Uu. uF  qˆV,          NK  	  up4      bK1  	  p	ppV Uu. uF  qˆR,          ^ ,          NK  	  upV	R&   V Uu. uF  qˆR,          ^ ,          NK  	  upV	R&   \        R V 4       4      V	R&   V	# u upi u upi u uppi u upi u upi )zÛMatch the ``b`` pairs of a batch one at a time and stack their outputs.

The pairs have no common ``log_assignment``, since each covers the points its pair kept, and ``stop`` is the
largest number of layers a pair ran.
ru  rv  rã  r!  c              3   ó2   "  € T F  qR ,          x € K  	  R# 5i)râ  Nrë   )rñ   Úos   & r   rò   Ú+LightGlue._forward_pairs.<locals>.<genexpr>ë  s   é € Ð2©T¨˜FŸ)š)«Tùs   ‚râ  )rÞ  rß  rà  rá  rä  rå  )r¢  r×  r_  r%   rJ   r   )
rv   r÷  rø  r  r±   ÚoutsÚstackedr]  r  Úouts
   &&&&      r   ré  ÚLightGlue._forward_pairsÞ  sô   € ô puÐuvÔowó
ÙowÐjk�M‰M˜8¤\°%¸AÓ%>ÀÌ,ÐW\ÐabÓJcÐdÖeÑowð 	ð 
ð gˆÙQXÔYÑQXÈ#¤E§I¢I¹tÓ.D¹t¸!°¯v¨v¹tÑ.DÓ$EÒEÑQXˆÑYÙ37Ó8±4¨a˜I�, qŸ/˜/±4Ñ8ˆˆI‰Ù15Ó6±¨A˜8� QŸ˜±Ñ6ˆˆH‰ÜÑ2©TÓ2Ó2ˆˆF‰Øˆ
ùò
ùò /EùÓYùÚ8ùÚ6s)   Ž1CÁC%Á!C Á2C%ÂC+Â&C0Ã C%c                ó&   <€ V ^8„  d   QhRS[ RS[/# )r    Úlayer_indexr#   )r?   r7   )r'   rg   s   "€r   r(   rŒ  î  s   ø€ ÷ )ñ )±ð )¹ñ )r   c                óº   € RR\         P                  ! RV,          V P                  P                  ,          4      ,          ,           p\	        \        V^ 4      ^4      # )zScaled confidence threshold.gš™™™™™é?ro  g      À)Úmathr@  r�  rj  r   r   )rv   r$  Ú	thresholds   && r   r§  ÚLightGlue.confidence_thresholdî  sB   € à˜#¤§¢¨°Õ);¸d¿i¹i×>PÑ>PÕ)PÓ QÕQÕQˆ	Ü”3�y !Ó$ aÓ(Ð(r   c                ón   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[RS[ P                  /# )r    Úconfidencesr!  r$  r#   ©r%   r&   r?   )r'   rg   s   "€r   r(   rŒ  ó  s9   ø€ ÷ ñ ©E¯L©Lð Á%Ç,Á,ð Ñ]`ð Ñej×eqÑeqñ r   c                ó†   € V^V P                   P                  ,
          8„  pVe   WAV P                  V,          8*  ,          pV# )z$Mask points which should be removed.)r�  rm  r�  )rv   r*  r!  r$  Úkeeps   &&&& r   rñ  ÚLightGlue.get_pruning_maskó  s>   € à˜˜TŸY™Y×7Ñ7Õ7Ñ8ˆØÒ"Ø 4×#=Ñ#=¸kÕ#JÑJÕJˆDØˆr   c          
      ót   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[RS[RS[ P                  /# )r    Úconfidences0Úconfidences1r$  Ú
num_pointsr#   r+  )r'   rg   s   "€r   r(   rŒ  ú  sP   ø€ ÷ Dñ Dá—l‘lðDñ —l‘lðDñ ð	Dñ
 ðDñ 
�‰ñDr   c                ó  € \         P                  ! W.R4      pV P                  V,          pRWV8  P                  4       P	                  R4      V,          ,
          pWpP
                  P                  8„  P                  4       # )a  Evaluate the early-stopping condition of every pair in a batch.

Args:
    confidences0: Token confidences of image 0, shape ``(B, M)``.
    confidences1: Token confidences of image 1, shape ``(B, N)``.
    layer_index: Index of the layer that computed the confidences.
    num_points: Number of keypoints of one pair that the unconfident points are counted against.

Returns:
    Whether every pair has a ratio of confident points above ``depth_confidence``: each pair counts its own
    points below the confidence threshold of the layer.
r†   rE   )r%   rJ   r�  r7   Úsumr�  rl  rR  )rv   r0  r1  r$  r2  r*  r'  Úratio_confidents   &&&&&   r   rð  ÚLightGlue.check_if_stopú  si   € ô& —i’i Ð <¸bÓAˆØ×.Ñ.¨{Õ;ˆ	Ø Ñ!8× ?Ñ ?Ó A× EÑ EÀbÓ IÈJÕ VÕVˆØ§)¡)×"<Ñ"<Ñ<×AÑAÓCÐCr   c                ó:   <€ V ^8„  d   QhRS[ P                  RS[/# )r    r.   r#   )r%   r.   r?   )r'   rg   s   "€r   r(   rŒ    s   ø€ ÷ =ñ =¡u§|¡|ð =¹ñ =r   c                ó¼   € V P                   P                  '       d%   VP                  R8X  d   V P                  R,          # V P                  VP                  ,          # )a  Return the minimum keypoint count needed before pruning is enabled.

Args:
    device: Torch device on which descriptors are processed.

Returns:
    With point pruning enabled, it runs on an image while the image has more keypoints than this number,
    so ``-1`` means always.
rµ   rÂ   )r�  rÂ   r/   Úpruning_keypoint_thresholds)rv   r.   s   &&r   rè  ÚLightGlue.pruning_min_kpts  sB   € ð �9‰9�?�?ˆ?˜vŸ{™{¨fÔ4Ø×3Ñ3°GÕ<Ð<Ø×/Ñ/°·±Õ<Ð<r   c                ó  <€ V ^8„  d   Qh/ S[ S[S[S[3,          ,          ;R&   S[ S[S[S[3,          ,          ;R&   S[ S[S[,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[S[S[3,          ,          ;R&   # )r    rœ  r9  rÕ  r¨  rª  r‹  )r   r   rX  r   r	   )r'   rg   s   "€r   r(   rŒ  Ð  s�   ø‡ ‚ ñJ ™4¡¡S �>Õ*ñ ñK ñp "*©$©s±C¨x­.Õ!9ñ ñq ñ| !¡¡c¥Õ+ÑBñ} ñ@ ‘c�]Ñ)ñA ñB 
‘#�ÑañC ñF ‘t™C¡˜H•~Õ&ñ ;òG r   )r�  rž  r¤  r   r¶  r¥  r£  rE   gUUUUUUÅ?)rw  )zreduce-overhead)re  i   i   rs  i   rt  )rˆ   r‰   rŠ   r‹   rŒ   rœ  r9  rÕ  r¨  rª  r‹  ro   rÍ  r„   r×  ré  r§  rñ  rð  rè  Ú__annotate_func__r�   rŽ   r�   r�   s   @@r   ra  ra  Ð  s/  ù‡ € ñBðJ 	�Ø�SØ˜#Ø˜Ø�5Ø�cØ�AØ�QØ�ØˆeØ˜DØ˜DØ˜CØ�4ð.€Lð( 	ˆrØˆrØ�Ø�ð	=Ðð 08¸Ð.BÐà)€GØa€Cð 	ØÐ-Ø˜ð
ð 	ØÐ*Ø˜ð
ð 	ØÐ*Ø˜ð
ð 	ØÐ'Ø˜ð
ð 	ØÐ)Ø˜ð
ð 	ØÐ.Ø˜ð
ð 	ØÐ*Ø˜Ø˜bØ˜Ø˜Ø Ø Ø ð	
ð 	ØÐ'Ø˜Ø˜Tð
ð
 	Ø�|Ø˜Ø˜TØ˜)ð	
ð 	Ø�|Ø˜Ø˜TØ˜)ð	
ð 	 ØÐ8Ø˜Ø Ø Ø�tð"
ði;*€H÷z_#õ _#÷B-ò -÷: 'ð  '÷DL
ð L
÷\ð ÷ )ð )÷
ð ÷Dð D÷0=ð =÷E … r   ra  )5r&  rÉ  Úpathlibr   Útypesr   Útypingr   r   r   r   r	   r
   r   r   r%   Útorch.nn.functionalr   Ú
functionalr  Úkornia.core._compatr   Úkornia.core.checkr   Úkornia.core.downloadr   r   Úkornia.core.exceptionsr   Úkornia.core.utilsr   Úkornia.feature.lafr   r   r   r<   rO   r[   r`   ÚModulerb   r’   r¨   r½   rÜ   rÿ   r"  r$  rO  rS  rU  r_  ra  rë   r   r   Ú<module>rI     s   ðó$ Û Ý Ý !ß Q× QÓ Qã ß Ð Ý å <Ý *ß AÝ ,Ý *ß =ò#õ
:õ*õ@õ8ô
0¨¯©ô 0ô8
�b—i‘iô 
ô*&5�—	‘	ô &5ôR49�—	‘	ô 49ônA�—‘ô AôHD3�r—y‘yô D3õN
ô"B�b—i‘iô "BõJ&ð(Dð õ8õôN	=�—	‘	ö N	=r   