+
    åûja< ã                   óF  € ^ RI t ^ RIt^ RIt^ RIt^ RIHtHtHtHtH	t	H
t
Ht ^ RI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 ^R	IHt ^R
IHt ^RIHt ^RIH t H!t!H"t"H#t#H$t$H%t% ^RI&H't' ^RI(H)t)H*t* ^RI+H,t,H-t-H.t. ^RI/H0t0H1t1H2t2H3t3 ^RI4H5t5H6t6H7t7H8t8 ^RI9H:t: ^RI;H<t<H=t=H>t> ^RI?H@t@HAtAHBtB R R ltCR R ltDR R ltER R ltFR=R R lltG ! R R ]P�                  4      tI ! R! R"]P�                  4      tJ ! R# R$]P�                  4      tK ! R% R&]J4      tL ! R' R(]L4      tM ! R) R*]J4      tN ! R+ R,]J4      tO ! R- R.]J4      tPR/ R0 ltQ ! R1 R2]J4      tR ! R3 R4]J4      tS ! R5 R6]J4      tT ! R7 R8]J4      tU ! R9 R:]P�                  4      tV ! R; R<])4      tWR# )>é    N)ÚClassVarÚDictÚListÚLiteralÚOptionalÚTupleÚUnion)Únn)Úrgb_to_grayscale)ÚKORNIA_CHECKÚKORNIA_CHECK_LAF)Ú_copied_literal)ÚConvQuadInterp3d)ÚScalePyramid)ÚLAFAffNetShapeEstimator)ÚHardNet)ÚKeyNetDetector)Úextract_patches_from_pyramidÚget_laf_centerÚget_laf_orientationÚget_laf_scaleÚlaf_is_filledÚ	scale_laf)Ú	LightGlue)ÚGeometryAwareDescriptorMatcherÚ	_no_match)ÚLAFOrienterÚOriNetÚPassLAF)ÚBlobDoGÚBlobDoGSingleÚBlobHessianÚ
CornerGFTT)ÚDetector_configÚMultiResolutionDetectorÚScaleSpaceDetectorÚget_default_detector_config)ÚSIFTDescriptorFromPyramid)Ú_SIFTScalePyramidÚ_SIFTScaleSpaceDescriptorÚ_SIFTScaleSpaceDetector)ÚSIFTDescriptorÚ_check_sift_descriptor_layoutÚconvert_sift_descriptor_layoutc                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# )é   ÚdescriptorsÚlayoutÚreturn)ÚtorchÚTensorÚstr)Úformats   "ÚUC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\feature\integrated.pyÚ__annotate__r9   ;   s.   € ÷ pñ p¤§¡ð p´sð p¼u¿|¹|ñ pó    c                ó.   € VR8X  d   V # \        V RV4      # )zeReturn kornia-layout SIFT descriptors in ``layout``; the default ``"kornia"`` returns them unchanged.Úkornia)r.   )r1   r2   s   &&r8   Ú_in_sift_layoutr=   ;   s!   € à  HÔ,ˆ;ÐoÔ2PÐQ\Ð^fÐhnÓ2oÐor:   c                óš   € V ^8„  d   QhR\         P                  R\        R\        \         P                  \         P                  3,          /# )r0   ÚlafsÚfeature_namer3   )r4   r5   r6   r   )r7   s   "r8   r9   r9   @   sB   € ÷ Eñ E¬¯©ð EÄCð EÌEÔRW×R^ÑR^Ô`e×`lÑ`lÐRlÕLmñ Er:   c                óº  € \        V 4      P                  ^R4      p\        P                  ! \	        V 4      P                  ^R4      4      pVR8X  dS   V) pVR,          \        P
                  ! V\        P                  ) 8*  VR\        P                  ,          ,           V4      3# V\        P
                  ! V^ 8  VR\        P                  ,          ,           V4      3# )aÄ  Return the keypoint scales and orientations, shape ``(1, N)``, that LightGlue takes for ``lafs``.

LightGlue's ``"sift"`` weights were trained on COLMAP keypoints, whose scale is the detection sigma and whose
orientation is, for the similarity frames ``A = s R`` of the SIFT features (nearly so for
:class:`SIFTFeatureScaleSpace`'s), the image angle of the frame's x-axis in :math:`(-\pi, \pi]`, which is the
negative of the LAF orientation; for another frame the two differ, and the negated LAF orientation is passed.
The scale is taken as a sixth of the LAF scale, which is sigma for 6-sigma DoG frames such as
:class:`SIFTFeatureScaleSpace`'s. Every other feature keeps the LAF scale and the LAF orientation in
:math:`[0, 2\pi)`. The ``"sift"`` scale is converted here rather than through :class:`LightGlue`'s
``scale_coef``, which the ``"doghardnet"`` configurations use, so that ``LightGlue("sift")`` itself keeps taking
keypoints in the training convention.
Úsiftç      @ç       @éÿÿÿÿ)r   Úreshaper4   Údeg2radr   ÚwhereÚmathÚpi)r?   r@   ÚscalesÚoriss   &&  r8   Ú_lightglue_keypoint_scale_orirM   @   s©   € ô ˜4Ó ×(Ñ(¨¨BÓ/€FÜ�=Š=Ô,¨TÓ2×:Ñ:¸1¸bÓAÓB€DØ�vÔØˆuˆØ˜�|œUŸ[š[¨´$·'±'°Ñ)9¸4À#ÌÏÉÅ-Õ;OÐQUÓVÐVÐVà”5—;’;˜t a™x¨°´d·g±gµÕ)=¸tÓDÐDÐDr:   c                ó†   € V ^8„  d   QhR\         \        \        3,          R\        P                  R\        P                  /# )r0   ÚhwÚdevicer3   )r   Úintr4   rP   r5   )r7   s   "r8   r9   r9   V   s6   € ÷ Oñ OœE¤#¤s (�Oð O´U·\±\ð OÄeÇlÁlñ Or:   c                ó\   € \        V ^,          V ^ ,          ..V\        P                  R7      # )zÂReturn LightGlue's ``image_size`` ``[[W, H]]`` of an ``(H, W)`` pair, on ``device``.

The copy does not block: a blocking copy from host memory would wait for all the work queued on the device.
©rP   Údtype)r   r4   Úint64)rO   rP   s   &&r8   Ú_image_size_from_hwrV   V   s&   € ô
 ˜R �U B q¥E˜NÐ+°FÄ%Ç+Á+ÔNÐNr:   c                óx   € V ^8„  d   QhR\         P                  R\        P                  R\        P                  /# )r0   ÚmoduleÚpatchesr3   )r
   ÚModuler4   r5   )r7   s   "r8   r9   r9   ^   s-   € ÷ .ñ .œBŸI™Ið .´·±ð .ÄÇÁñ .r:   c                ó:  aaaa€ V P                  4        Uu. uF  q"P                  NK  	  ppV P                  4         \        \        P
                  ! V P                  4       V P                  4       4      4      p\        4       oSP                  \        P                  8X  dK   V P                  4        F6  w  op\        VRR4      '       g   K  SP                  V3R lR 4       4       K8  	  R VV3R llo\        ;QJ d     VV3R lV 4       F  '       g   K   RM	  RM! VV3R lV 4       4      pV'       g2   V ! S4      \!        V P                  4       V4       F  w  r'Wrn        K  	  # V UU	u/ uF(  w  r‰W‰P#                  SP$                  S! W‰4      R7      bK*  	  p
pp	\'        V \        P(                  P*                  4      '       gK   \        P,                  P/                  W
S34      \!        V P                  4       V4       F  w  r'Wrn        K  	  # \        P0                  ! 4       ;_uu_ 4        \2        P4                  ! V 4      pR	R	R	4       V
P7                  4        F:  w  r‰VP9                  R
4      Ev rÍXpV F  p\        Wï4      pK  	  \;        WíV	4       K<  	  X! S4      \!        V P                  4       V4       F  w  r'Wrn        K  	  # u upi u up	pi   + '       g   i     Lš; i  \!        T P                  4       T4       F  w  r'Yrn        K  	  i ; i)aä  Run ``module`` in eval mode on ``patches``, leaving its device, dtype and parameters as they are.

A module whose floating-point parameters and buffers already sit on the device and dtype of ``patches`` is called
directly. Otherwise they are cast for the call only, through ``torch.func.functional_call`` or, for a TorchScript
module, which that API refuses, in the slots of a copy of the module. The cast is differentiable, so gradients
reach the module's own parameters. Eager calls, ``torch.compile`` and ``torch.export`` take the same path. Every
submodule is switched to eval for the call and its ``training`` flag is restored afterwards.
Descriptor statistics marked for float32 computation retain that precision for float16 patches.
Ú_descriptor_float32_statisticsFc              3   óF   <"  € T F  pS'       d   S R V 2MTx € K  	  R# 5i)Ú.N© )Ú.0ÚnameÚprefixs   & €r8   Ú	<genexpr>Ú"_run_descriptor.<locals>.<genexpr>p   s'   øé € ð .ÙKjÀ4¯f˜6˜( ! D 6Ñ*¸$Ô>ÓKjùs   ƒ!�!c                ód   € V ^8„  d   QhR\         R\        P                  R\        P                  /# )r0   ra   Útensorr3   )r6   r4   r5   rT   )r7   s   "r8   r9   Ú%_run_descriptor.<locals>.__annotate__t   s.   € ÷ 	Qñ 	Qœsð 	Q¬E¯L©Lð 	Q¼U¿[¹[ñ 	Qr:   c                 óŽ   <€ V S9   d   \         P                  # VP                  4       '       d   SP                  # VP                  # ©N)r4   Úfloat32Úis_floating_pointrT   )ra   rf   Úfloat32_statisticsrY   s   &&€€r8   Útarget_dtypeÚ%_run_descriptor.<locals>.target_dtypet   s7   ø€ ØÐ)Ô)Ü—}‘}Ð$Ø$*×$<Ñ$<×$>Ò$>�7—=‘=ÐPÀFÇLÁLÐPr:   c              3   ó”   <"  € T F=  w  rVP                   SP                   8g  ;'       g    VP                  S! W4      8g  x € K?  	  R # 5iri   rS   )r`   ra   ÚtrY   rm   s   &  €€r8   rc   rd   y   s=   øé € ÐoÑgnÑ\cÐ\`˜Ÿ™ W§^¡^Ñ3×WÐW°q·w±wÁ,ÈtÓBWÑ7WÔWÓgnùs
   ƒ&AªATrS   Nr^   )Úrunning_meanÚrunning_var)ÚmodulesÚtrainingÚevalÚlistÚ	itertoolsÚchainÚnamed_parametersÚnamed_buffersÚsetrT   r4   Úfloat16Únamed_modulesÚgetattrÚupdateÚanyÚzipÚtorP   Ú
isinstanceÚjitÚScriptModuleÚfuncÚfunctional_callÚno_gradÚcopyÚdeepcopyÚitemsÚsplitÚsetattr)rX   rY   ÚmÚmodesÚtensorsÚchildÚ
needs_castÚmodera   rp   ÚstateÚcopiedÚpathÚattrÚownerÚpartrl   rb   rm   s   &f              @@@r8   Ú_run_descriptorrš   ^   sU  û€ ð "(§¡Ô!1Ó2Ñ!1˜A�ZŒZÑ!1€EÐ2Ø
‡K�K„Mð"Ü”y—’ v×'>Ñ'>Ó'@À&×BVÑBVÓBXÓYÓZˆÜ'*£uÐØ�=‰=œEŸM™MÔ)Ø!'×!5Ñ!5Ö!7‘�˜Ü˜5Ð"BÀE×JÔJØ&×-Ñ-ô .ÙKjó.ö ñ "8÷	Qñ 	Q÷
 “SÕoÑgnÓo—S—S’SÕoÑgnÓoÓoˆ
ßÙ˜'“?ô  ˜6Ÿ>™>Ó+¨UÖ3‰GˆAØŽJò 4ñ `gÔgÑ_fÑT[ÐTX�—t‘t 7§>¡>¹ÀdÓ9N�tÓOÒOÑ_fˆÑgÜ˜&¤%§)¡)×"8Ñ"8×9Ò9Ü—:‘:×-Ñ-¨f¸g¸ZÓHô ˜6Ÿ>™>Ó+¨UÖ3‰GˆAØŽJò 4ô �]Š]�_�_Ü—]’] 6Ó*ˆF÷ à—{‘{–}‰GˆDØŸ*™* S›/‰KˆTØˆEÛ�Ü Ó,’ñ ä�E Ö#ñ %ñ �g‹ä˜6Ÿ>™>Ó+¨UÖ3‰GˆAØŽJò 4ùòG 3ùó( h÷
 �_ûô ˜6Ÿ>™>Ó+¨UÖ3‰GˆAØŽJò 4úsa   —K¾BK/ Ã3K/ ÄK/ Ä K/ Ä;K/ Å,K/ Å1.KÆAK/ ÈK/ È3KÉ
AK/ ËK/ ËK,	Ë'K/ Ë/+Lc                ó°   € V ^8„  d   QhR\         P                  R\         P                  R\        P                  R\        R\
        R\         P                  /# )r0   Úimgr?   Úpatch_descriptorÚ
patch_sizeÚgrayscale_descriptorr3   )r4   r5   r
   rZ   rQ   Úbool)r7   s   "r8   r9   r9   �   sd   € ÷ PDñ PDÜ	�‰ðPDä
�,‰,ðPDô —i‘iðPDô ð	PDô
 ðPDô ‡\�\ñPDr:   c                ón  € \        V4       T pV'       d"   V P                  ^4      ^8X  d   \        V 4      pVP                  ^,          ^ 8X  dã   \        P
                  ! RVP                   R2^R7       \        P                  ! 4       ;_uu_ 4        \        V\        P                  ! ^VP                  ^4      W3VP                  VP                  R7      4      pRRR4       \        P                  ! VP                  ^ ,          ^ XP                  4       VP                  VP                  R7      # \        WQV4      pVP                  4       w  r‰r«p\        W'P                  W‰,          W«V4      4      pVP!                  W‰VP                  R,          P                  4       4      #   + '       g   i     LÑ; i)aÖ  Describe LAFs on an image by running a patch descriptor on one patch sampled per LAF.

``descs = get_laf_descriptors(img, lafs, patch_descriptor, patch_size)`` takes images ``(B, C, H, W)``, their
LAFs ``(B, N, 2, 3)`` in pixels and a patch descriptor module, and returns one descriptor per LAF, ``(B, N, D)``.
The descriptor determines the output dtype. The function converts a 3-channel image to grayscale when
``grayscale_descriptor`` is set, samples a ``patch_size`` x ``patch_size`` patch per LAF with
:func:`extract_patches_from_pyramid`, and runs the descriptor on the stack of the ``B * N`` patches.
The patch follows the LAF's scale and orientation, so orient the LAFs first, e.g. with :class:`LAFOrienter`,
unless upright descriptors are wanted. ``patch_size`` must be what the descriptor takes: 32 for :class:`HardNet`
and the other learned descriptors, 41 for a default :class:`SIFTDescriptor`. For the module form, use
:class:`LAFDescriptor`; for SIFT descriptors of LAFs without sampling patches, :class:`SIFTDescriptorFromPyramid`.

Convention:
    - The descriptor sees the patches of :func:`~kornia.feature.extract_patches_from_pyramid` at ``patch_size``;
      see its Convention block for how they are sampled. ``patch_size`` is this argument, 32 by default, and is
      not read from the descriptor, so it has to be a size the descriptor accepts.
    - The descriptor runs in eval mode, with its floating-point parameters and buffers cast to the device and
      dtype of ``img`` for the call (a TorchScript module is called on a cast copy). SOSNet and HyNet retain their
      final BatchNorm statistics in float32 for float16 images. The module keeps its device, dtype and
      parameters, every submodule is switched to eval for the call and gets its train/eval mode back afterwards,
      and gradients reach the module's parameters.
    - An empty LAF set gives a ``(B, 0, D)`` result, ``D`` as wide as a non-empty result, and a warning.
      That result does not require grad, so no gradient reaches ``img`` or the descriptor's parameters through
      it.

Args:
    img: image features with shape ``(B,C,H,W)``.
    lafs: local affine frames ``(B,N,2,3)`` in the pixels of ``img``, with its batch size.
    patch_descriptor: patch descriptor module, e.g. :class:`~kornia.feature.SIFTDescriptor`
        or :class:`~kornia.feature.HardNet`.
    patch_size: patch size in pixels, which descriptor expects.
    grayscale_descriptor: True if ``patch_descriptor`` expects single-channel image; a 3-channel ``img`` is
        then converted to grayscale. An image with another channel count is passed on unchanged.

Returns:
    Local descriptors of shape ``(B,N,D)`` where :math:`D` is descriptor size.

See Also:
    - :class:`LAFDescriptor`: the module form, which holds the descriptor, a pretrained :class:`HardNet` by
      default.
    - :func:`extract_patches_from_pyramid`: the patch sampler, for the patches themselves.
    - :func:`laf_from_center_scale_ori`: LAFs from keypoint centres, scales and orientations, to describe here.
    - :class:`SIFTDescriptorFromPyramid`: SIFT descriptors of LAFs, pooled from a gradient pyramid without
      sampling patches.
    - :class:`LAFOrienter`: orients LAFs from their patches, before they are described.

zLAF contains no keypoints z, returning empty torch.Tensor)Ú
stacklevel)rT   rP   N:é   NN)r   Úsizer   ÚshapeÚwarningsÚwarnr4   rˆ   rš   ÚzerosrT   rP   ÚemptyÚnumelr   ÚviewrF   )rœ   r?   r�   rž   rŸ   ÚtimgÚproberY   ÚBÚNÚCHÚHÚWr1   s   &&&&&         r8   Úget_laf_descriptorsr³   �   s>  € ôl �TÔØ€Dß §¡¨£¨qÔ 0Ü Ó$ˆà‡z�z�!…}˜ÔÜ�ŠÐ2°4·:±:°,Ð>\Ð]ÐjkÕlô �]Š]�_�_Ü#Ø Ü—’˜A˜tŸy™y¨›|¨ZÈ4Ï:É:Ð^b×^iÑ^iÔjóˆE÷ ô
 �{Š{˜4Ÿ:™: a�=¨!¨U¯[©[«]À%Ç+Á+ÐV[×VbÑVbÔcÐcä8¸ÀZÓP€Gð —\‘\“^�N€Aˆ"�ô "Ð"2·L±LÀÅÈÈqÓ4QÓR€KØ×Ñ˜q [×%6Ñ%6°rÕ%:×%@Ñ%@Ó%BÓCÐC÷ �_ús   ÂA	F$Æ$F4	c                   ój   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V3R lR ltRtVt	V ;t
# )
ÚLAFDescriptorað	  Describe LAFs with a held patch descriptor, as a module (HardNet by default).

``describer = LAFDescriptor()``, then ``descs = describer(img, lafs)`` takes images ``(B, C, H, W)`` and their
LAFs ``(B, N, 2, 3)`` in pixels and returns one descriptor per LAF, ``(B, N, D)``: ``forward`` calls
:func:`get_laf_descriptors` with the held descriptor, ``patch_size`` and ``grayscale_descriptor``, which samples a
patch per LAF with :func:`extract_patches_from_pyramid`. By default it holds a pretrained :class:`HardNet` on
32 x 32 grayscale patches, converts an RGB image to grayscale and returns ``(B, N, 128)``; with another
descriptor, pass the patch size it takes, e.g. ``LAFDescriptor(SIFTDescriptor(41), patch_size=41)``. It is the
descriptor of the HardNet local features, such as :class:`DoGHardNet`, and of the ``"patch"`` backend of
:class:`SIFTFeature` and :class:`SIFTFeatureScaleSpace`. For SIFT descriptors of LAFs without sampling patches,
use :class:`SIFTDescriptorFromPyramid` instead.

Convention:
    See the Convention block on :func:`~kornia.feature.get_laf_descriptors`, which ``forward`` calls with this
    module's ``patch_size`` and ``grayscale_descriptor``. The default descriptor is a pretrained
    :class:`~kornia.feature.HardNet` on ``32 x 32`` grayscale patches; :class:`~kornia.feature.SIFTDescriptor`
    defaults to 41-pixel patches, so pass ``patch_size=41`` with it.

Args:
    patch_descriptor_module: patch descriptor module, e.g. :class:`~kornia.feature.SIFTDescriptor`
        or :class:`~kornia.feature.HardNet`. Default: :class:`~kornia.feature.HardNet` with pretrained weights.
    patch_size: patch size in pixels, which descriptor expects.
    grayscale_descriptor: ``True`` if patch_descriptor expects single-channel image; a 3-channel image is then
        converted to grayscale.

See Also:
    - :func:`get_laf_descriptors`: the function form, which takes the descriptor in each call.
    - :class:`HardNet`: the default descriptor; :class:`SIFTDescriptor`, :class:`HardNet8`, :class:`HyNet`,
      :class:`SOSNet`, :class:`TFeat` and :class:`MKDDescriptor` fit as well.
    - :func:`extract_patches_from_pyramid`: the patch sampler, for the patches themselves.
    - :func:`laf_from_center_scale_ori`: LAFs from keypoint centres, scales and orientations, to describe here.
    - :class:`SIFTDescriptorFromPyramid`: SIFT descriptors of LAFs, pooled from a gradient pyramid without
      sampling patches.
    - :class:`LocalFeature`: runs a detector and a descriptor such as this module in one call.

c                óT   <€ V ^8„  d   QhRS[ S[P                  ,          RS[RS[RR/# )r0   Úpatch_descriptor_modulerž   rŸ   r3   N)r   r
   rZ   rQ   r    )r7   Ú__classdict__s   "€r8   r9   ÚLAFDescriptor.__annotate__  s<   ø€ ÷ 9ñ 9á!)©"¯)©)Õ!4ð9ñ ð9ñ #ð	9ð
 
ñ9r:   c                óf   <€ \         SV `  4        Vf   \        R4      pWn        W n        W0n        R # )NT)ÚsuperÚ__init__r   Ú
descriptorrž   rŸ   )Úselfr·   rž   rŸ   Ú	__class__s   &&&&€r8   r¼   ÚLAFDescriptor.__init__  s0   ø€ ô 	‰ÑÔØ"Ò*Ü&-¨d£mÐ#Ø1ŒØ$ŒØ$8Ö!r:   c                ó    <€ V ^8„  d   QhRS[ /# )r0   r3   )r6   )r7   r¸   s   "€r8   r9   r¹     s   ø€ ÷ 
ñ 
™#ñ 
r:   c                óž   € V P                   P                   R V P                  P                  4        RV P                   RV P
                   R2# )z(descriptor=z, patch_size=z, grayscale_descriptor='Ú))r¿   Ú__name__r½   Ú__repr__rž   rŸ   )r¾   s   &r8   rÅ   ÚLAFDescriptor.__repr__  sT   € à�~‰~×&Ñ&Ð'Ø˜4Ÿ?™?×3Ñ3Ó5Ð6ð 7ØŸ/™/Ð*ð +%Ø%)×%>Ñ%>Ð$?¸qðBð	
r:   c                óh   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  /# )r0   rœ   r?   r3   ©r4   r5   )r7   r¸   s   "€r8   r9   r¹     s3   ø€ ÷ kñ k™5Ÿ<™<ð k©u¯|©|ð kÁÇÁñ kr:   c                óZ   € \        WV P                  V P                  V P                  4      # )a
  Describe the given LAFs with :func:`~kornia.feature.get_laf_descriptors`.

Args:
    img: image features with shape ``(B,C,H,W)``.
    lafs: local affine frames ``(B,N,2,3)``.

Returns:
    Local descriptors of shape ``(B,N,D)`` where :math:`D` is descriptor size.

)r³   r½   rž   rŸ   )r¾   rœ   r?   s   &&&r8   ÚforwardÚLAFDescriptor.forward  s$   € ô # 3¨d¯o©o¸t¿¹ÐPT×PiÑPiÓjÐjr:   )r½   rŸ   rž   )Né    T)rÄ   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r¼   rÅ   rÊ   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r¿   r¸   s   @@r8   rµ   rµ   â   s1   ù‡ € ñ#÷J9õ 9÷
ð 
÷k÷ kð kr:   rµ   c                   ó\   a a€ ] tR tR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	# )
ÚLocalFeaturei+  a¤  Detect and describe LAFs in one call with a given detector and LAF descriptor module.

``feature = LocalFeature(detector, descriptor)``, then ``lafs, responses, descs = feature(img, mask)`` runs a
detector and descriptor as one pipeline. It takes images ``(B, C, H, W)`` and an optional mask. The detector
returns LAFs ``(B, N, 2, 3)`` in pixels and responses ``(B, N)``. The descriptor returns one descriptor per LAF,
``(B, N, D)``. ``scaling_coef`` changes the LAF shape before description. Use :class:`LAFDescriptor` to adapt a
patch descriptor such as :class:`HardNet`; :class:`SIFTDescriptorFromPyramid` already takes images and LAFs.
The detector and descriptor define accepted batch sizes, channels and intensity ranges. To match features from two
images, use :class:`LocalFeatureMatcher`. For learned features, use :class:`DISK`, :class:`ALIKED`, :class:`XFeat`
or :class:`DeDoDe`.

Convention:
    - The returned LAFs use the pixel convention of :func:`~kornia.feature.laf_from_center_scale_ori`
      (see :ref:`Local features <local-features-conventions>`). ``scaling_coef`` multiplies their shape ``A``
      (:func:`~kornia.feature.scale_laf`) before the description and leaves the centres and the responses
      unchanged.
    - Cast the module to the image dtype before calling it, for example ``feature.to(img.dtype)``. See each preset
      for its supported dtypes.
    - A detector can return zero-LAF padding when fewer than ``N`` features are found. ``laf_is_filled(lafs)`` is
      ``True`` for detections; index LAFs, responses and descriptors with it to discard padding before matching.
      :class:`LocalFeatureMatcher` does this automatically.

Args:
    detector: the detection module, called as ``detector(img, mask)`` and returning ``(lafs, responses)``, such
        as :class:`~kornia.feature.ScaleSpaceDetector`.
    descriptor: the descriptor module, called as ``descriptor(img, lafs)`` and returning ``(B, N, D)``, such as
        :class:`~kornia.feature.LAFDescriptor`.
    scaling_coef: the multiplier of the detector's LAFs before the description, see the Convention block. An
        ``int`` is converted to ``float``. Must be positive.

Raises:
    ValueError: if ``scaling_coef`` is not positive.

See Also:
    - :class:`ScaleSpaceDetector`: a scale-space detector for a batch of images.
    - :class:`MultiResolutionDetector`: a detector for one image per call.
    - :func:`laf_is_filled`: returns the detection slots to keep and discard padding.
    - :class:`LocalFeatureMatcher`: runs a local feature on two images and matches the descriptors.
    - :class:`SIFTFeatureScaleSpace`: the SIFT preset for a batch of images.

Example:
    >>> feature = LocalFeature(ScaleSpaceDetector(10), LAFDescriptor(SIFTDescriptor(32), patch_size=32))
    >>> lafs, responses, descs = feature(torch.rand(2, 1, 64, 64))
    >>> lafs.shape, responses.shape, descs.shape
    (torch.Size([2, 10, 2, 3]), torch.Size([2, 10]), torch.Size([2, 10, 128]))

c                óX   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[RR/# )r0   Údetectorr½   Úscaling_coefr3   N)r
   rZ   Úfloat)r7   r¸   s   "€r8   r9   ÚLocalFeature.__annotate__\  s3   ø€ ÷ 0ñ 0¡§¡ð 0¹¿	¹	ð 0ÑQVð 0Ðaeñ 0r:   c                ó†   <€ \         SV `  4        Wn        W n        V^ 8:  d   \	        RV 24      h\        V4      V n        R# )r   z Scaling coef should be > 0, got N)r»   r¼   rØ   r½   Ú
ValueErrorrÚ   rÙ   )r¾   rØ   r½   rÙ   r¿   s   &&&&€r8   r¼   ÚLocalFeature.__init__\  s@   ø€ Ü‰ÑÔØ ŒØ$ŒØ˜1ÔÜÐ?À¸~ÐNÓOÐOä! ,Ó/ˆÖr:   c          	      óº   <€ V ^8„  d   QhRS[ P                  RS[S[ P                  ,          RS[S[ P                  S[ P                  S[ P                  3,          /# ©r0   rœ   Úmaskr3   ©r4   r5   r   r   )r7   r¸   s   "€r8   r9   rÛ   e  sJ   ø€ ÷ (ñ (Ù—<‘<ð(Ù'/±·±Õ'=ð(á	‰u�|‰|™UŸ\™\©5¯<©<Ð7Õ	8ñ(r:   c                ó|   € V P                  W4      w  r4\        W0P                  4      pV P                  W4      pW4V3# )a�  Run forward.

Args:
    img: image to extract features with shape ``(B,C,H,W)``.
    mask: a mask saying where a detection may be, shape ``(B,1,H,W)`` with the spatial size of the
        image. It is forwarded to the detector unchanged; see the detector for its semantics.

Returns:
    - Detected local affine frames with shape ``(B,N,2,3)``.
    - Response function values for corresponding lafs with shape ``(B,N)``.
    - Local descriptors of shape ``(B,N,D)`` where :math:`D` is descriptor size.

The Convention block of :class:`LocalFeature` gives the frame, ``N`` and the slots the detector did not fill,
which have to be dropped before matching.

)rØ   r   rÙ   r½   )r¾   rœ   rá   r?   Ú	responsesÚdescss   &&&   r8   rÊ   ÚLocalFeature.forwarde  s=   € ð& Ÿ-™-¨Ó2‰ˆÜ˜×0Ñ0Ó1ˆØ—‘ Ó*ˆØ Ð'Ð'r:   )r½   rØ   rÙ   )ç      ð?ri   ©
rÄ   rÍ   rÎ   rÏ   rÐ   r¼   rÊ   rÑ   rÒ   rÓ   rÔ   s   @@r8   rÖ   rÖ   +  s$   ù‡ € ñ.÷`0õ 0÷(÷ (ò (r:   rÖ   c                   óX   a a€ ] tR tRt 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	# )	Ú_DoGSingleMagnitudei~  zmMagnitude of a single-scale DoG response, whose maxima are maxima of the DoG above zero or minima below zero.c                ó*   <€ V ^8„  d   QhRS[ RS[ RR/# )r0   Úsigma1Úsigma2r3   N)rÚ   )r7   r¸   s   "€r8   r9   Ú _DoGSingleMagnitude.__annotate__�  s"   ø€ ÷ 1ñ 1™uð 1±Eð 1ÀDñ 1r:   c                óD   <€ \         SV `  4        \        W4      V n        R # ri   )r»   r¼   r!   Údog)r¾   rì   rí   r¿   s   &&&€r8   r¼   Ú_DoGSingleMagnitude.__init__�  s   ø€ Ü‰ÑÔÜ  Ó0ˆŽr:   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r0   Úinputr3   rÈ   )r7   r¸   s   "€r8   r9   rî   …  s#   ø€ ÷ %ñ %™UŸ\™\ð %©e¯l©lñ %r:   c                ó@   € V P                  V4      P                  4       # ri   )rð   Úabs)r¾   ró   s   &&r8   rÊ   Ú_DoGSingleMagnitude.forward…  s   € Ø�x‰x˜‹×"Ñ"Ó$Ð$r:   )rð   )rç   çš™™™™™ù?rè   rÔ   s   @@r8   rê   rê   ~  s!   ù‡ € Ùw÷1õ 1÷%÷ %ð %r:   rê   c                   ób   a a€ ] tR tRt oRtRV3R lV 3R llltR	V3R lV 3R llltRtVtV ;t	# )
Ú_SIFTFeaturei‰  zJCompose a sparse SIFT detector with a patch or pyramid extraction backend.c          
      ó^   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[RS[RR/# )r0   rØ   r½   ÚuprightÚdescriptor_layoutr3   N)r
   rZ   r    r6   )r7   r¸   s   "€r8   r9   Ú_SIFTFeature.__annotate__Œ  s=   ø€ ÷ 3ñ 3ÙŸ	™	ð3Ù/1¯y©yð3ÙCGð3Ù\_ð3à	ñ3r:   c                óT   <€ \        V4       \        SV `	  W4       W0n        W@n        R # ri   )r-   r»   r¼   rû   rü   )r¾   rØ   r½   rû   rü   r¿   s   &&&&&€r8   r¼   Ú_SIFTFeature.__init__Œ  s&   ø€ ô 	&Ð&7Ô8Ü‰Ñ˜Ô.ØŒØ!2Ör:   c          	      óº   <€ V ^8„  d   QhRS[ P                  RS[S[ P                  ,          RS[S[ P                  S[ P                  S[ P                  3,          /# rà   râ   )r7   r¸   s   "€r8   r9   rý   ”  sO   ø€ ÷ Uñ UÙ—<‘<ðUÙ'/±·±Õ'=ðUá	‰u�|‰|™UŸ\™\©5¯<©<Ð7Õ	8ñUr:   c                ó„  <€ \        V P                  \        4      '       g   \        SV `  W4      w  r4pMvV P                  W4      w  r4\        W0P                  4      pVP                  ^,          ^8X  d   \        V4      MTpV P                  P                  WcV P                  R7      w  r5W4\        WPP                  4      3# )zCReturn sparse LAFs, detector responses, and one descriptor per LAF.©rû   )rƒ   r½   r(   r»   rÊ   rØ   r   rÙ   r¥   r   Úorient_and_describerû   r=   rü   )r¾   rœ   rá   r?   rä   r1   Ú
gray_imager¿   s   &&&    €r8   rÊ   Ú_SIFTFeature.forward”  sŸ   ø€ ô ˜$Ÿ/™/Ô+D×EÒEÜ+0©7©?¸3Ó+EÑ(ˆD™[à"Ÿm™m¨CÓ6‰OˆDÜ˜T×#4Ñ#4Ó5ˆDØ25·)±)¸Aµ,À!Ô2CÔ)¨#Ô.ÈˆJØ $§¡× CÑ CÀJÐ^b×^jÑ^jÐ CÓ kÑˆDØ¤°×=SÑ=SÓ TÐTÐTr:   )rü   rû   )r<   ri   rè   rÔ   s   @@r8   rù   rù   ‰  s$   ù‡ € ÙT÷3õ 3÷U÷ Uõ Ur:   rù   c                   óF   a a€ ] tR tRt oRtRV3R lV 3R llltRtVtV ;t# )ÚSIFTFeaturei¢  a-  Detect per-level DoG keypoints and describe them with SIFT, one image per call.

``sift = SIFTFeature(2048)`` loads a per-level DoG detector and SIFT descriptor. ``lafs, responses, descs =
sift(img)`` takes one grayscale image ``(1, 1, H, W)``; a batch or color image raises. It returns LAFs
``(1, N, 2, 3)``, DoG-response magnitudes ``(1, N)``, strongest first, and RootSIFT descriptors
``(1, N, 128)`` in kornia's layout. Use :func:`laf_is_filled` to keep detections and discard padding.
``descriptor_backend`` chooses patches (``"patch"``, the default) or a gradient pyramid (``"pyramid"``). For
scale-space extrema or batches, use :class:`SIFTFeatureScaleSpace` with ``descriptor_backend="pyramid"``.

For CPU throughput use OpenCV's SIFT: on an Apple M1 CPU, a matching pipeline on it ran 11x faster than one on
this module (640 px, 2,048 features). This module takes one image per call; for batches use
:class:`SIFTFeatureScaleSpace`. See the `image matching guide
<https://kornia.readthedocs.io/en/latest/applications/image_matching.html#feature-speed-by-device>`_.

Convention:
    - A :class:`~kornia.feature.LocalFeature`, whose Convention block gives the output contract. The detector is
      a :class:`~kornia.feature.MultiResolutionDetector` on the magnitude of a single-scale
      :class:`~kornia.feature.BlobDoGSingle` response. With ``descriptor_backend="patch"``, the default,
      ``LAFOrienter(19)`` orients the LAFs unless ``upright`` and :class:`~kornia.feature.SIFTDescriptor`
      describes 41 x 41 patches. ``"pyramid"`` keeps the detector and orients and describes its LAFs with
      :class:`SIFTDescriptorFromPyramid`, which integrates smoothed image gradients without extracting patches.
    - The detector applies the response independently at each image resolution. It does not apply classical
      SIFT's contrast or Hessian edge rejection. One orientation is assigned per detection unless
      ``upright=True``.
    - Extrema of both polarities are kept: dark blobs are DoG maxima and bright blobs are DoG minima. On each
      image-pyramid level, a keypoint is a strict maximum of the response magnitude in its ``config["nms_size"]``
      window (15 pixels by default), so a stronger extremum of either polarity suppresses a weaker one.
      ``responses`` holds the magnitude.
    - The frames are those of :class:`~kornia.feature.MultiResolutionDetector`: a pixel of a pyramid level, with a
      scale of ``config["s_mult"]`` (22 by default) times that level's pixel size whatever the size of the blob.
      Unlike the 6-sigma frames of :class:`SIFTFeatureScaleSpace`, their scale is not a fixed multiple of the
      detection sigma: a sixth of it, which ``LightGlueMatcher("sift")`` takes as the detection sigma, is not that
      sigma here (see :ref:`sift-pipelines`).
    - Descriptors come in kornia's SIFT layout; ``descriptor_layout="opencv"`` returns them in OpenCV's, which
      :class:`~kornia.feature.LightGlueMatcher` expects with ``"sift"``.
      :func:`~kornia.feature.convert_sift_descriptor_layout` converts between the two.
    - Known defects: ``descriptor_backend="pyramid"`` is less accurate than the patch backend on Oxford
      homographies at 2048 features, and not faster on CPU at 1024 features
      (`#5748 <https://github.com/kornia/kornia/issues/5748>`_).

Args:
    num_features: the number of slots per image; the strongest detections fill them, the rest are padding.
    upright: if ``True``, skip the orientation estimation and return upright frames.
    rootsift: if ``True``, the default, return RootSIFT descriptors, otherwise SIFT.
    device: the device of the detector and descriptor modules. Default: CPU.
    config: the pyramid and suppression settings of :class:`~kornia.feature.MultiResolutionDetector`, whose
        ``config`` argument lists them with their defaults.
    compile_model: wrap the DoG response and the non-maxima suppression with :func:`torch.compile`, see
        :class:`~kornia.feature.MultiResolutionDetector`.
    score_threshold: the response magnitude a detection has to exceed. Must be non-negative.
    descriptor_backend: ``"patch"`` or ``"pyramid"``, see the Convention block.
    descriptor_layout: ``"kornia"`` or ``"opencv"``, the order of the descriptor values.

Raises:
    ValueError: for a ``descriptor_backend`` or ``descriptor_layout`` other than those listed, or a negative
        ``score_threshold``.

See Also:
    - :class:`SIFTFeatureScaleSpace`: SIFT on a DoG scale space, with extrema across scale, sub-pixel refinement
      and 6-sigma frames, for a batch of images.
    - :class:`MultiResolutionDetector`: its detector, on the magnitude of the DoG.
    - :class:`BlobDoGSingle`: the single-scale DoG response whose magnitude it detects on.
    - :class:`SIFTDescriptor`: the descriptor of the ``"patch"`` backend, run on 41 x 41 patches through
      :class:`LAFDescriptor`.
    - :class:`SIFTDescriptorFromPyramid`: the orientation and descriptor of the ``"pyramid"`` backend.
    - :func:`convert_sift_descriptor_layout`: the reordering that ``descriptor_layout="opencv"`` applies.
    - :class:`LocalFeature`: its base class, which gives the output contract.

Example:
    >>> lafs, responses, descs = SIFTFeature(100)(torch.rand(1, 1, 64, 64))
    >>> lafs.shape, responses.shape, descs.shape
    (torch.Size([1, 100, 2, 3]), torch.Size([1, 100]), torch.Size([1, 100, 128]))

c                ó¬   <€ V ^8„  d   QhRS[ RS[RS[RS[S[S[P
                  R3,          RS[S[,          RS[RS[R	S[	R,          R
S[	R,          RR/
# )r0   Únum_featuresrû   ÚrootsiftrP   NÚconfigÚcompile_modelÚscore_thresholdÚdescriptor_backendrü   r3   ©ÚpatchÚpyramid©r<   Úopencv)
rQ   r    r	   r6   r4   rP   r   r$   rÚ   r   )r7   r¸   s   "€r8   r9   ÚSIFTFeature.__annotate__î  sœ   ø€ ÷ &Kñ &Káð&Kñ ð&Kñ ð	&Kñ
 ‘c™5Ÿ<™<¨Ð-Õ.ð&Kñ ™Õ)ð&Kñ ð&Kñ ð&Kñ $Ð$6Õ7ð&Kñ #Ð#5Õ6ð&Kð 
ñ&Kr:   c
           
     óü  <€ VR9  d   \        RV: 24      h\        V	4       ^)p
Vf   \        P                  ! R4      pVf   \	        4       p\        \        RR4      TTV'       g   VR8X  d   \        4       M
\        ^4      \        4       VVR7      P                  V4      pVR8X  d   \        VR7      P                  V4      pM'\        \        W£R	7      V
R
R7      P                  V4      p\        SV `9  W¼W)4       R# )r  r  ú!Unknown SIFT descriptor backend: NÚcpurç   r÷   )Ú
ori_moduleÚ
aff_moduler  r  ©r
  ©rž   r
  T©rž   rŸ   r  )rÝ   r-   r4   rP   r'   r%   rê   r   r   r‚   r(   rµ   r,   r»   r¼   )r¾   r	  rû   r
  rP   r  r  r  r  rü   rž   rØ   r½   r¿   s   &&&&&&&&&&   €r8   r¼   ÚSIFTFeature.__init__î  sò   ø€ ð Ð%9Ô9ÜÐ@ÐASÑ@VÐWÓXÐXÜ%Ð&7Ô8Øˆ
ØŠ>Ü—\’\ %Ó(ˆFØŠ>Ü0Ó2ˆFÜ*Ü  SÓ)ØØß$+Ð/AÀYÔ/N”w”yÔT_Ð`bÓTcÜ“yØ'Ø+ô
÷ ‰"ˆV‹*ð 	ð  Ô*Ü2¸HÔE×HÑHÈÓP‰Jä&Ü¨*ÔHØ%Ø%)ô÷ ‰b�‹jð	 ô
 	‰Ñ˜¨wÖJr:   r_   )	é@  FTNNFç        r  r<   ©	rÄ   rÍ   rÎ   rÏ   rÐ   r¼   rÑ   rÒ   rÓ   rÔ   s   @@r8   r  r  ¢  s   ù‡ € ñI÷V&K÷ &Kõ &Kr:   r  c                   ób   a a€ ] tR tRt oRtRV3R lV 3R llltR	V3R lV 3R llltRtVtV ;t	# )
ÚSIFTFeatureScaleSpacei  aY  Detect refined DoG scale-space extrema and describe them with SIFT, for a batch.

``sift = SIFTFeatureScaleSpace(2048, descriptor_backend="pyramid")`` builds a DoG scale-space SIFT pipeline.
``lafs, responses, descs = sift(img)`` takes grayscale images ``(B, 1, H, W)``. It returns six-sigma LAFs
``(B, N, 2, 3)``, absolute DoG responses ``(B, N)``, strongest first, and RootSIFT descriptors ``(B, N, 128)``.
Use :func:`laf_is_filled` to keep detections and discard padding. The ``"pyramid"`` backend reuses Gaussian
images and accepts RGB input; ``"patch"`` samples patches and requires grayscale input. Use
``descriptor_layout="opencv"`` with ``LightGlueMatcher("sift")``; use :class:`DoGHardNet` for HardNet
descriptors on the ``"patch"`` detections.

For CPU throughput use OpenCV's SIFT: on an Apple M1 CPU, a matching pipeline on it ran 8x faster than one on this
module with ``descriptor_backend="pyramid"``, and 14x faster with ``"patch"`` (640 px, 2,048 features). See the
`image matching guide
<https://kornia.readthedocs.io/en/latest/applications/image_matching.html#feature-speed-by-device>`_.

Convention:
    - A :class:`~kornia.feature.LocalFeature`, whose Convention block gives the output contract, of grayscale
      images ``(B, 1, H, W)``; the pyramid backend converts an RGB image to grayscale first.
      ``descriptor_backend="patch"``, the default, runs :class:`~kornia.feature.ScaleSpaceDetector` with
      :class:`~kornia.feature.BlobDoG` on ``ScalePyramid(3, 1.6, 32, double_image=True)``, keeping minima as well
      as maxima, then ``LAFOrienter(19)`` unless ``upright``, and :class:`~kornia.feature.SIFTDescriptor` on 41 x
      41 patches. ``"pyramid"`` runs a dedicated DoG detector and reuses its Gaussian images and the octave and
      layer of each detection for orientation and description: it refines only sparse extrema, ranks all valid
      candidates by absolute response, and computes image gradients once per used layer.
    - Each backend assigns one orientation per detection unless ``upright=True``. The backend selects a different
      detector as well as different orientation and description stages, so the backends can return different
      detections as well as different descriptors; the feature budget is the same.
    - On both backends the LAF scale is 6 times the detection sigma, and ``responses`` is the absolute DoG, the
      same for a bright blob as for a dark one. The LAF centres are in the frame of
      :func:`~kornia.feature.laf_from_center_scale_ori` (see :ref:`Local features <local-features-conventions>`) on
      every octave. For a float16 or bfloat16 image the LAFs are float32 on both backends, and the responses and
      descriptors keep the image dtype.
    - Descriptors come in kornia's SIFT layout; ``descriptor_layout="opencv"`` returns them in OpenCV's, which
      :class:`~kornia.feature.LightGlueMatcher` expects with ``"sift"``.
      :func:`~kornia.feature.convert_sift_descriptor_layout` converts between the two.

Args:
    num_features: the number of slots per image; the strongest detections fill them, the rest are padding.
    upright: if ``True``, skip the orientation estimation and return upright frames.
    rootsift: if ``True``, the default, return RootSIFT descriptors, otherwise SIFT.
    device: the device of the detector and descriptor modules. Default: CPU.
    compile_modules: the detector sub-modules to wrap with :func:`torch.compile`. With ``"patch"``, the
        ``compile_modules`` of :class:`~kornia.feature.ScaleSpaceDetector`; with ``"pyramid"``, ``"scale_pyr"``
        and ``"subpix"`` only, both for ``True``, while the orientation and description run eagerly.
    descriptor_backend: ``"patch"`` or ``"pyramid"``, see the Convention block.
    descriptor_layout: ``"kornia"`` or ``"opencv"``, the order of the descriptor values.

Raises:
    ValueError: for a ``descriptor_backend`` or ``descriptor_layout`` other than those listed, or a
        ``compile_modules`` name the selected backend does not have.

See Also:
    - :class:`SIFTFeature`: a per-level DoG approximation of SIFT, without selection across scale or sub-pixel
      refinement, one image per call.
    - :class:`ScaleSpaceDetector`: the detector of the ``"patch"`` backend, on a :class:`BlobDoG` response.
    - :class:`BlobDoG`: the scale-space DoG response of the ``"patch"`` backend.
    - :class:`SIFTDescriptor`: the descriptor of the ``"patch"`` backend, run on 41 x 41 patches through
      :class:`LAFDescriptor`.
    - :func:`convert_sift_descriptor_layout`: the reordering that ``descriptor_layout="opencv"`` applies.
    - :class:`LightGlueMatcher`: its ``"sift"`` weights match these features, in the ``"opencv"`` layout.
    - :class:`DoGHardNet`: the detections of the ``"patch"`` backend described by HardNet, at twice the frame
      scale.
    - :class:`LocalFeature`: its base class, which gives the output contract.

Example:
    >>> sift = SIFTFeatureScaleSpace(100, descriptor_backend="pyramid")
    >>> lafs, responses, descs = sift(torch.rand(2, 1, 64, 64))
    >>> lafs.shape, responses.shape, descs.shape
    (torch.Size([2, 100, 2, 3]), torch.Size([2, 100]), torch.Size([2, 100, 128]))

c                ó¶   <€ V ^8„  d   QhRS[ RS[RS[RS[S[S[P
                  R3,          RS[S[S[S[,          3,          RS[R
,          RS[R,          R	R/# )r0   r	  rû   r
  rP   NÚcompile_modulesr  rü   r3   r  r  )rQ   r    r	   r6   r4   rP   r   r   )r7   r¸   s   "€r8   r9   Ú"SIFTFeatureScaleSpace.__annotate__`  s„   ø€ ÷ 53ñ 53áð53ñ ð53ñ ð	53ñ
 ‘c™5Ÿ<™<¨Ð-Õ.ð53ñ ™t¡T©#¥Y˜Õ/ð53ñ $Ð$6Õ7ð53ñ #Ð#5Õ6ð53ð 
ñ53r:   c                ó‚  <€ VR9  d   \        RV: 24      h\        V4       Vf   \        P                  ! R4      p^)pVR8X  d­   \	        V\        4       4      P                  V4      p	V'       d�   VRJ d   RR0M
\        V4      p
V
RR0,
          pV'       d   \        R4      hRV
9   d   V	P                  P                  4        RV
9   d&   \        P                  ! V	P                  4      V	n
        Mb\        T\        4       \        4       \        ^R	^ RR
7      V'       g   VR8X  d   \        4       M
\!        ^4      RRRVR7	      P                  V4      p	VR8X  d   \#        VR7      P                  V4      pM'\%        \'        WƒR7      VRR7      P                  V4      p\(        SV `U  Wœ4       W n        W`n        Wpn        R# )r  r  r  Nr  TÚ	scale_pyrÚsubpixzNThe SIFT pyramid backend supports compile_modules=['scale_pyr', 'subpix'] onlyr÷   ©Údouble_imagerC   )Úresp_moduleÚsubpix_moduleÚscale_pyr_moduler  Úscale_space_responseÚminima_are_also_goodÚmr_sizer$  r  r  r  r  )rÝ   r-   r4   rP   r+   r)   r‚   r{   r'  ÚcompileÚ_refiner&   r    r   r   r   r   r*   rµ   r,   r»   r¼   rû   r  rü   )r¾   r	  rû   r
  rP   r$  r  rü   rž   rØ   ÚselectedÚunknownr½   r¿   s   &&&&&&&&     €r8   r¼   ÚSIFTFeatureScaleSpace.__init__`  sœ  ø€ ð Ð%9Ô9ÜÐ@ÐASÑ@VÐWÓXÐXÜ%Ð&7Ô8ØŠ>Ü—\’\ %Ó(ˆFØˆ
Ø Ô*Ü.¨|Ô=NÓ=PÓQ×TÑTÐU[Ó\ˆHßØ6EÈÓ6M˜K¨Ñ2ÔSVÐWfÓSg�Ø" k°8Ð%<Õ<�ßÜ$Ð%uÓvÐvØ (Ô*ð ×&Ñ&×.Ñ.Ô0Ø˜xÔ'Ü',§}¢}°X×5EÑ5EÓ'F�HÔ$øä)ØÜ#›IÜ.Ó0Ü!-¨a°°bÀtÔ!Lß(/Ð3EÈÔ3Rœ7œ9ÔXcÐdfÓXgØ%)Ø%)ØØ /ô
÷ ‰b�‹jð ð  Ô*Ü2¸HÔE×HÑHÈÓP‰Jä&Ü¨*ÔHØ%Ø%)ô÷ ‰b�‹jð	 ô
 	‰Ñ˜Ô.ØŒØ"4ÔØ!2Ör:   c          	      óº   <€ V ^8„  d   QhRS[ P                  RS[S[ P                  ,          RS[S[ P                  S[ P                  S[ P                  3,          /# rà   râ   )r7   r¸   s   "€r8   r9   r%  —  sO   ø€ ÷ cñ cÙ—<‘<ðcÙ'/±·±Õ'=ðcá	‰u�|‰|™UŸ\™\©5¯<©<Ð7Õ	8ñcr:   c                óö  <€ V P                   R8X  d*   \        SV `	  W4      w  r4pW4\        WPP                  4      3# VP
                  ^,          ^8X  d   \        V4      MTpV P                  P                  W`P                  P                  V4      w  rCrxrš\        W0P                  4      pV P                  WƒWšV P                  R7      w  r5W4\        VP                  VP                  4      V P                  4      3# )zcDetect and describe SIFT features; the ``"pyramid"`` backend reuses the detector's Gaussian images.r  r  )r  r»   rÊ   r=   rü   r¥   r   rØ   Ú_detect_with_pyramidr	  r   rÙ   r½   rû   r‚   rT   )r¾   rœ   rá   r?   rä   r1   ÚgrayÚ_r  ÚoctavesÚlevelsr¿   s   &&&        €r8   rÊ   ÚSIFTFeatureScaleSpace.forward—  s×   ø€ ð ×"Ñ" gÔ-Ü+0©7©?¸3Ó+EÑ(ˆD˜[Ø¤O°K×AWÑAWÓ$XÐXÐXØ(+¯	©	°!­¸Ô(9Ô Ô$¸sˆØ7;·}±}×7YÑ7YØ—-‘-×,Ñ,¨dó8
Ñ4ˆ	˜ Wô ˜×0Ñ0Ó1ˆØ ŸO™O¨G¸7ÐTX×T`ÑT`˜OÓaÑˆØ¤°·±¸s¿y¹yÓ0IÈ4×KaÑKaÓ bÐbÐbr:   )r  rü   rû   )r  FTNFr  r<   ri   rè   rÔ   s   @@r8   r"  r"    s)   ù‡ € ñF÷P53õ 53÷nc÷ cõ cr:   r"  c                   óF   a a€ ] tR tRt oRtRV3R lV 3R llltRtVtV ;t# )ÚGFTTAffNetHardNeti§  aƒ  Detect GFTT corners over scale with AffNet shapes and HardNet descriptors.

``feature = GFTTAffNetHardNet(2048)`` loads pretrained AffNet and HardNet in evaluation mode. ``lafs, responses,
descs = feature(img)`` takes grayscale images ``(B, 1, H, W)``; convert color images with
:func:`~kornia.color.rgb_to_grayscale` first. It returns affine LAFs ``(B, N, 2, 3)``, Shi-Tomasi responses
``(B, N)``, strongest first, and unit-norm HardNet descriptors ``(B, N, 128)``. Use :func:`laf_is_filled` to keep
detections and discard padding. For blobs, use :class:`HesAffNetHardNet` or :class:`DoGAffNetHardNet`.

Convention:
    A :class:`~kornia.feature.LocalFeature`, whose Convention block gives the output contract, of grayscale
    images ``(B, 1, H, W)``: a :class:`~kornia.feature.ScaleSpaceDetector` with the
    :class:`~kornia.feature.CornerGFTT` response, its maxima only and ``mr_size=6``, whose LAFs get their affine
    shape from :class:`~kornia.feature.LAFAffNetShapeEstimator`, then their orientation from ``LAFOrienter(19)``
    unless ``upright``, and are described by :class:`~kornia.feature.HardNet` on 32 x 32 patches.

Args:
    num_features: the number of slots per image; the strongest detections fill them, the rest are padding.
    upright: if ``True``, skip the orientation estimation and return upright frames.
    device: the device of the detector and descriptor modules. Default: CPU.
    compile_modules: the detector sub-modules to wrap with :func:`torch.compile`, see
        :class:`~kornia.feature.ScaleSpaceDetector`.

See Also:
    - :class:`HesAffNetHardNet`: the same pipeline on Hessian blobs, 2048 slots by default.
    - :class:`DoGAffNetHardNet`: the same shapes and descriptors on DoG blobs, which
      ``LightGlueMatcher("dog_affnet_hardnet")`` matches.
    - :class:`CornerGFTT`: the corner response it detects on.
    - :class:`ScaleSpaceDetector`: its detector.
    - :class:`LAFAffNetShapeEstimator`: the AffNet shape estimation it runs before the orientation.
    - :class:`HardNet`: its descriptor, run on 32 x 32 patches through :class:`LAFDescriptor`.
    - :class:`LocalFeature`: its base class, which gives the output contract.

c                óˆ   <€ V ^8„  d   QhRS[ RS[RS[S[S[P
                  R3,          RS[S[S[S[,          3,          RR/# ©r0   r	  rû   rP   Nr$  r3   ©rQ   r    r	   r6   r4   rP   r   )r7   r¸   s   "€r8   r9   ÚGFTTAffNetHardNet.__annotate__Ê  óZ   ø€ ÷ ñ áðñ ðñ ‘c™5Ÿ<™<¨Ð-Õ.ð	ñ
 ™t¡T©#¥Y˜Õ/ðð 
ñr:   c                óŽ  <€ Vf   \         P                  ! R4      p\        T\        4       \	        ^R^ R^R7      V'       d   \        4       M
\        ^4      \        RRR7      P                  4       RRRVR7	      P                  V4      p\        R ^ RR	7      P                  V4      p\        SV `1  WV4       V P                  4        R # ©
Nr  r÷   T)r*  Úextra_levelsF©Úpreserve_orientationrC   )r+  r-  r  r  r.  r/  r0  r$  r  )r4   rP   r&   r#   r   r   r   r   ru   r‚   rµ   r»   r¼   ©r¾   r	  rû   rP   r$  rØ   r½   r¿   s   &&&&&  €r8   r¼   ÚGFTTAffNetHardNet.__init__Ê  s§   ø€ ð Š>Ü—\’\ %Ó(ˆFÜ%ØÜ"›ä)¨!¨S°"À4ÐVWÔXß$+”w”y´¸R³Ü.¨tÈ%ÔP×UÑUÓWØ!&Ø!&ØØ+ô
÷ ‰"ˆV‹*ð 	ô # 4°BÈTÔR×UÑUÐV\Ó]ˆ
Ü‰Ñ˜Ô.Ø�	‰	Žr:   r_   )r  FNFr   rÔ   s   @@r8   r?  r?  §  s   ù‡ € ñ ÷D÷ õ r:   r?  c                   óF   a a€ ] tR tRt oRtRV3R lV 3R llltRtVtV ;t# )ÚHesAffNetHardNetiä  aÍ  Detect Hessian blobs over scale with AffNet shapes and HardNet descriptors.

``feature = HesAffNetHardNet(2048)`` loads pretrained AffNet and HardNet in evaluation mode. ``lafs, responses,
descs = feature(img)`` takes grayscale images ``(B, 1, H, W)``; convert color images with
:func:`~kornia.color.rgb_to_grayscale` first. It returns affine LAFs ``(B, N, 2, 3)``, Hessian responses
``(B, N)``, strongest first, and unit-norm HardNet descriptors ``(B, N, 128)``. Use :func:`laf_is_filled` to keep
detections and discard padding. For corners use :class:`GFTTAffNetHardNet`; for LightGlue-compatible DoG blobs,
use :class:`DoGAffNetHardNet`.

Convention:
    A :class:`~kornia.feature.LocalFeature`, whose Convention block gives the output contract, of grayscale
    images ``(B, 1, H, W)``: a :class:`~kornia.feature.ScaleSpaceDetector` with the
    :class:`~kornia.feature.BlobHessian` response, its maxima only and ``mr_size=6``, whose LAFs get their affine
    shape from :class:`~kornia.feature.LAFAffNetShapeEstimator`, then their orientation from ``LAFOrienter(19)``
    unless ``upright``, and are described by :class:`~kornia.feature.HardNet` on 32 x 32 patches.

Args:
    num_features: the number of slots per image; the strongest detections fill them, the rest are padding.
    upright: if ``True``, skip the orientation estimation and return upright frames.
    device: the device of the detector and descriptor modules. Default: CPU.
    compile_modules: the detector sub-modules to wrap with :func:`torch.compile`, see
        :class:`~kornia.feature.ScaleSpaceDetector`.

See Also:
    - :class:`GFTTAffNetHardNet`: the same pipeline on Shi-Tomasi corners, 8000 slots by default.
    - :class:`DoGAffNetHardNet`: the same shapes and descriptors on DoG blobs, which
      ``LightGlueMatcher("dog_affnet_hardnet")`` matches.
    - :class:`BlobHessian`: the blob response it detects on.
    - :class:`ScaleSpaceDetector`: its detector, with this response by default.
    - :class:`LAFAffNetShapeEstimator`: the AffNet shape estimation it runs before the orientation.
    - :class:`HardNet`: its descriptor, run on 32 x 32 patches through :class:`LAFDescriptor`.
    - :class:`LocalFeature`: its base class, which gives the output contract.

c                óˆ   <€ V ^8„  d   QhRS[ RS[RS[S[S[P
                  R3,          RS[S[S[S[,          3,          RR/# rA  rB  )r7   r¸   s   "€r8   r9   ÚHesAffNetHardNet.__annotate__  rD  r:   c                óŽ  <€ Vf   \         P                  ! R4      p\        T\        4       \	        ^R^ R^R7      V'       d   \        4       M
\        ^4      \        RRR7      P                  4       RRRVR7	      P                  V4      p\        R ^ RR	7      P                  V4      p\        SV `1  WV4       V P                  4        R # rF  )r4   rP   r&   r"   r   r   r   r   ru   r‚   rµ   r»   r¼   rJ  s   &&&&&  €r8   r¼   ÚHesAffNetHardNet.__init__  s§   ø€ ð Š>Ü—\’\ %Ó(ˆFÜ%ØÜ#›ä)¨!¨S°"À4ÐVWÔXß$+”w”y´¸R³Ü.¨tÈ%ÔP×UÑUÓWØ!&Ø!&ØØ+ô
÷ ‰"ˆV‹*ð 	ô # 4°BÈTÔR×UÑUÐV\Ó]ˆ
Ü‰Ñ˜Ô.Ø�	‰	Žr:   r_   ©i   FNFr   rÔ   s   @@r8   rM  rM  ä  s   ù‡ € ñ!÷F÷ õ r:   rM  c                ó¶   € V ^8„  d   QhR\         R\        R\        \        P                  ,          R\
        \        \        \        ,          3,          R\        /# )r0   r	  rû   r  r$  r3   )	rQ   r    r   r
   rZ   r	   r   r6   r&   )r7   s   "r8   r9   r9   "  sP   € ÷ ñ Üðäðô œŸ™Õ#ðô œ4¤¤c¥˜?Õ+ð	ô
 ñr:   c                óœ   € \        T \        4       \        4       \        ^R^ RR7      V'       d   \	        4       M
\        ^4      VRRRVR7
      # )z]Return the 6-sigma DoG detector of the ``"patch"`` backend of :class:`SIFTFeatureScaleSpace`.r÷   Tr)  rC   )	r+  r,  r-  r  r  r.  r/  r0  r$  )r&   r    r   r   r   r   )r	  rû   r  r$  s   &&&&r8   Ú_dog_detectorrU  "  sI   € ô ØÜ“IÜ&Ó(ä% a¨¨b¸tÔDß '”7”9¬[¸«_ØØ!Ø!ØØ'ôð r:   c                   óF   a a€ ] tR tRt oRtRV3R lV 3R llltRtVtV ;t# )Ú
DoGHardNeti8  aŒ	  Detect DoG blobs over scale and describe them with HardNet, without affine adaptation.

``feature = DoGHardNet(2048)`` loads pretrained HardNet in evaluation mode. ``lafs, responses, descs =
feature(img)`` takes grayscale images ``(B, 1, H, W)``. It returns 12-sigma DoG LAFs ``(B, N, 2, 3)``, absolute
DoG responses ``(B, N)``, strongest first, and unit-norm HardNet descriptors ``(B, N, 128)``. Use
:func:`laf_is_filled` to keep detections and discard padding before calling ``LightGlueMatcher("doghardnet")``.
Choose :class:`DoGAffNetHardNet` for affine shapes or :class:`SIFTFeatureScaleSpace` for SIFT descriptors.

Convention:
    - A :class:`~kornia.feature.LocalFeature`, whose Convention block gives the output contract. The detector is
      the DoG :class:`~kornia.feature.ScaleSpaceDetector` of :class:`~kornia.feature.SIFTFeatureScaleSpace`'s
      ``"patch"`` backend, and the orientation is estimated on its 6-sigma frames. The returned LAFs are those
      frames scaled by two (``scaling_coef=2``), to 12 sigma or six times OpenCV's ``KeyPoint.size``, and
      :class:`~kornia.feature.HardNet` describes them on 32 x 32 patches.
    - The image must have one channel, ``(B, 1, H, W)``: convert a color image with
      :func:`~kornia.color.rgb_to_grayscale` first.

Args:
    num_features: the number of slots per image; the strongest detections fill them, the rest are padding.
    upright: if ``True``, skip the orientation estimation and return upright frames.
    device: the device of the detector and descriptor modules. Default: CPU.
    compile_modules: the detector sub-modules to wrap with :func:`torch.compile`, see
        :class:`~kornia.feature.ScaleSpaceDetector`.

See Also:
    - :class:`DoGAffNetHardNet`: the same detections with AffNet shapes, estimated before the orientation.
    - :class:`SIFTFeatureScaleSpace`: the same detections with SIFT descriptors, at 6 sigma, with its
      ``"patch"`` backend.
    - :class:`ScaleSpaceDetector`: its detector, on a :class:`BlobDoG` response.
    - :class:`BlobDoG`: the scale-space DoG response it detects on.
    - :class:`HardNet`: its descriptor, run on 32 x 32 patches through :class:`LAFDescriptor`.
    - :class:`LightGlueMatcher`: its ``"doghardnet"`` weights match these features.
    - :class:`KeyNetHardNet`: HardNet descriptors of KeyNet detections, one image per call.
    - :class:`LocalFeature`: its base class, which gives the output contract.

c                óˆ   <€ V ^8„  d   QhRS[ RS[RS[S[S[P
                  R3,          RS[S[S[S[,          3,          RR/# rA  rB  )r7   r¸   s   "€r8   r9   ÚDoGHardNet.__annotate__^  sZ   ø€ ÷ ñ áðñ ðñ ‘c™5Ÿ<™<¨Ð-Õ.ð	ñ
 ™t¡T©#¥Y˜Õ/ðð 
ñr:   c                óð   <€ Vf   \         P                  ! R4      p\        WR V4      P                  V4      p\	        R ^ RR7      P                  V4      p\
        SV `  WVRR7       V P                  4        R # )Nr  Tr  rD   ©rÙ   )r4   rP   rU  r‚   rµ   r»   r¼   ru   rJ  s   &&&&&  €r8   r¼   ÚDoGHardNet.__init__^  sg   ø€ ð Š>Ü—\’\ %Ó(ˆFÜ  ¸¸oÓN×QÑQÐRXÓYˆÜ" 4°BÈTÔR×UÑUÐV\Ó]ˆ
Ü‰Ñ˜¸CÐÔ@Ø�	‰	Žr:   r_   rR  r   rÔ   s   @@r8   rW  rW  8  s   ù‡ € ñ#÷J÷ õ r:   rW  c                   óF   a a€ ] tR tRt oRtRV3R lV 3R llltRtVtV ;t# )ÚDoGAffNetHardNetim  am  Detect DoG blobs over scale with AffNet shapes and HardNet descriptors.

``feature = DoGAffNetHardNet(2048)`` loads pretrained AffNet and HardNet in evaluation mode. ``lafs, responses,
descs = feature(img)`` takes grayscale images ``(B, 1, H, W)``. It returns the outputs of :class:`DoGHardNet`,
with affine LAF shapes adapted by AffNet before orientation. Use :func:`laf_is_filled` to keep detections and
discard padding before calling ``LightGlueMatcher("dog_affnet_hardnet")``. Choose :class:`GFTTAffNetHardNet` or
:class:`HesAffNetHardNet` for corners or Hessian blobs.

Convention:
    As :class:`~kornia.feature.DoGHardNet`, with the affine shape of each 6-sigma DoG frame estimated by
    :class:`~kornia.feature.LAFAffNetShapeEstimator` before its orientation. The scale of the returned LAFs, the
    square root of their determinant, is again 12 sigma. The image must have one channel, ``(B, 1, H, W)``.

Args:
    num_features: the number of slots per image; the strongest detections fill them, the rest are padding.
    upright: if ``True``, skip the orientation estimation and return upright frames.
    device: the device of the detector and descriptor modules. Default: CPU.
    compile_modules: the detector sub-modules to wrap with :func:`torch.compile`, see
        :class:`~kornia.feature.ScaleSpaceDetector`.

See Also:
    - :class:`DoGHardNet`: the same detections and descriptors without affine adaptation.
    - :class:`LAFAffNetShapeEstimator`: the AffNet shape estimation it runs before the orientation.
    - :class:`ScaleSpaceDetector`: its detector, on a :class:`BlobDoG` response.
    - :class:`HardNet`: its descriptor, run on 32 x 32 patches through :class:`LAFDescriptor`.
    - :class:`LightGlueMatcher`: its ``"dog_affnet_hardnet"`` mode matches these features.
    - :class:`GFTTAffNetHardNet`: the same shapes and descriptors on Shi-Tomasi corners.
    - :class:`HesAffNetHardNet`: the same shapes and descriptors on Hessian blobs.
    - :class:`KeyNetAffNetHardNet`: the same shapes and descriptors on KeyNet detections, one image per call.
    - :class:`LocalFeature`: its base class, which gives the output contract.

c                óˆ   <€ V ^8„  d   QhRS[ RS[RS[S[S[P
                  R3,          RS[S[S[S[,          3,          RR/# rA  rB  )r7   r¸   s   "€r8   r9   ÚDoGAffNetHardNet.__annotate__�  sZ   ø€ ÷ ñ áðñ ðñ ‘c™5Ÿ<™<¨Ð-Õ.ð	ñ
 ™t¡T©#¥Y˜Õ/ðð 
ñr:   c                ó$  <€ Vf   \         P                  ! R4      p\        RRR7      P                  4       p\	        WWT4      P                  V4      p\        R ^ RR7      P                  V4      p\        SV `!  WgRR7       V P                  4        R # )Nr  TFrH  r  rD   r[  )	r4   rP   r   ru   rU  r‚   rµ   r»   r¼   )	r¾   r	  rû   rP   r$  r  rØ   r½   r¿   s	   &&&&&   €r8   r¼   ÚDoGAffNetHardNet.__init__�  sz   ø€ ð Š>Ü—\’\ %Ó(ˆFÜ,¨TÈÔN×SÑSÓUˆ
Ü  ¸
ÓT×WÑWÐX^Ó_ˆÜ" 4°BÈTÔR×UÑUÐV\Ó]ˆ
Ü‰Ñ˜¸CÐÔ@Ø�	‰	Žr:   r_   rR  r   rÔ   s   @@r8   r^  r^  m  s   ù‡ € ñ÷B÷ õ r:   r^  c                   óF   a a€ ] tR tRt oRtRV3R lV 3R llltRtVtV ;t# )ÚKeyNetHardNetiŸ  a›	  Detect KeyNet keypoints and describe them with HardNet, without affine adaptation.

``feature = KeyNetHardNet(2048)`` loads pretrained KeyNet, OriNet and HardNet in evaluation mode. ``lafs,
responses, descs = feature(img)`` takes one grayscale image ``(1, 1, H, W)`` in ``[0, 1]``; a batch or color image
raises. It returns LAFs ``(1, N, 2, 3)``, KeyNet responses ``(1, N)``, strongest first, and unit-norm HardNet
descriptors ``(1, N, 128)``. Use :func:`laf_is_filled` to keep detections and discard padding. Choose
:class:`KeyNetAffNetHardNet` for AffNet shapes and its LightGlue weights. For batches, use :class:`DoGHardNet`.

Convention:
    A :class:`~kornia.feature.LocalFeature`, whose Convention block gives the output contract, of one grayscale
    image per call, ``(1, 1, H, W)``: a :class:`~kornia.feature.KeyNetDetector`, whose LAFs get their
    orientation from :class:`~kornia.feature.OriNet` on 32 x 32 patches unless ``upright``, and are described by
    :class:`~kornia.feature.HardNet` on 32 x 32 patches. ``scale_laf`` is the ``scaling_coef`` of
    :class:`~kornia.feature.LocalFeature`: it multiplies the detector's LAFs before the description.

Args:
    num_features: the number of slots; the strongest detections fill them, the rest are padding.
    upright: if ``True``, skip the orientation estimation and return upright frames.
    device: the device of the detector and descriptor modules. Default: CPU.
    scale_laf: the multiplier of the detector's LAFs before the description. Must be positive.
    compile_model: wrap the KeyNet response and the non-maxima suppression with :func:`torch.compile`, see
        :class:`~kornia.feature.KeyNetDetector`.
    score_threshold: the KeyNet response a detection has to exceed. Must be non-negative.

Raises:
    ValueError: if ``scale_laf`` is not positive or ``score_threshold`` is negative.

See Also:
    - :class:`KeyNetAffNetHardNet`: the same detections with AffNet shapes, estimated before the orientation.
    - :class:`KeyNetDetector`: its detector.
    - :class:`KeyNet`: the learned response it detects on.
    - :class:`OriNet`: the learned orientation, run on each LAF's patch through :class:`LAFOrienter`.
    - :class:`HardNet`: its descriptor, run on 32 x 32 patches through :class:`LAFDescriptor`.
    - :class:`DoGHardNet`: HardNet descriptors of DoG detections, for a batch of images.
    - :class:`LocalFeature`: its base class, which gives the output contract.

c                ón   <€ V ^8„  d   QhRS[ RS[RS[S[S[P
                  R3,          RS[RS[RS[RR/# ©	r0   r	  rû   rP   Nr   r  r  r3   ©rQ   r    r	   r6   r4   rP   rÚ   )r7   r¸   s   "€r8   r9   ÚKeyNetHardNet.__annotate__Æ  sa   ø€ ÷ ñ áðñ ðñ ‘c™5Ÿ<™<¨Ð-Õ.ð	ñ
 ðñ ðñ ðð 
ñr:   c                óB  <€ Vf   \         P                  ! R4      pV'       d   \        4       M\        \	        R4      R7      p\        RVVVVR7      P                  V4      p\        R ^ RR7      P                  V4      p	\        S
V `%  W‰V4       V P                  4        R # )Nr  T©Úangle_detector)r	  r  r  r  r  )r4   rP   r   r   r   r   r‚   rµ   r»   r¼   ru   ©r¾   r	  rû   rP   r   r  r  r  rØ   r½   r¿   s   &&&&&&&   €r8   r¼   ÚKeyNetHardNet.__init__Æ  sˆ   ø€ ð Š>Ü—\’\ %Ó(ˆFß")”W”Y¬{Ì&ÐQUË,Ô/Wˆ
Ü!ØØ%Ø!Ø'Ø+ô
÷ ‰"ˆV‹*ð 	ô # 4°BÈTÔR×UÑUÐV\Ó]ˆ
Ü‰Ñ˜¨yÔ9Ø�	‰	Žr:   r_   ©r  FNrç   Fr  r   rÔ   s   @@r8   rd  rd  Ÿ  s   ù‡ € ñ$÷L÷ õ r:   rd  c                   óF   a a€ ] tR tRt oRtRV3R lV 3R llltRtVtV ;t# )ÚKeyNetAffNetHardNetiÞ  a«  Detect KeyNet keypoints with AffNet shapes and HardNet descriptors.

``feature = KeyNetAffNetHardNet(2048)`` loads pretrained KeyNet, AffNet, OriNet and HardNet in evaluation mode.
``lafs, responses, descs = feature(img)`` takes one grayscale image ``(1, 1, H, W)`` in ``[0, 1]``. It returns
the outputs of :class:`KeyNetHardNet`, with affine LAF shapes adapted by AffNet before orientation. Use
:func:`laf_is_filled` to keep detections and discard padding before calling
``LightGlueMatcher("keynet_affnet_hardnet")``. For batches, use :class:`DoGAffNetHardNet`.

.. image:: _static/img/keynet_affnet.jpg

Convention:
    As :class:`~kornia.feature.KeyNetHardNet`, with the affine shape of each frame estimated by
    :class:`~kornia.feature.LAFAffNetShapeEstimator` before its orientation.

Args:
    num_features: the number of slots; the strongest detections fill them, the rest are padding.
    upright: if ``True``, skip the orientation estimation and return upright frames.
    device: the device of the detector and descriptor modules. Default: CPU.
    scale_laf: the multiplier of the detector's LAFs before the description. Must be positive.
    compile_model: wrap the KeyNet response and the non-maxima suppression with :func:`torch.compile`, see
        :class:`~kornia.feature.KeyNetDetector`.
    score_threshold: the KeyNet response a detection has to exceed. Must be non-negative.

Raises:
    ValueError: if ``scale_laf`` is not positive or ``score_threshold`` is negative.

See Also:
    - :class:`KeyNetHardNet`: the same detections and descriptors without affine adaptation.
    - :class:`KeyNetDetector`: its detector.
    - :class:`LAFAffNetShapeEstimator`: the AffNet shape estimation it runs before the orientation.
    - :class:`OriNet`: the learned orientation, run on each LAF's patch through :class:`LAFOrienter`.
    - :class:`HardNet`: its descriptor, run on 32 x 32 patches through :class:`LAFDescriptor`.
    - :class:`LightGlueMatcher`: its ``"keynet_affnet_hardnet"`` weights match these features.
    - :class:`DoGAffNetHardNet`: the same shapes and descriptors on DoG detections, for a batch of images.
    - :class:`LocalFeature`: its base class, which gives the output contract.

c                ón   <€ V ^8„  d   QhRS[ RS[RS[S[S[P
                  R3,          RS[RS[RS[RR/# rf  rg  )r7   r¸   s   "€r8   r9   Ú KeyNetAffNetHardNet.__annotate__  sa   ø€ ÷ ñ áðñ ðñ ‘c™5Ÿ<™<¨Ð-Õ.ð	ñ
 ðñ ðñ ðð 
ñr:   c           
     óv  <€ Vf   \         P                  ! R4      pV'       d   \        4       M\        \	        R4      R7      p\        RVV\        RRR7      P                  4       VVR7      P                  V4      p\        R ^ RR7      P                  V4      p	\        S
V `-  W‰V4       V P                  4        R # )Nr  Trj  FrH  )r	  r  r  r  r  r  )r4   rP   r   r   r   r   r   ru   r‚   rµ   r»   r¼   rl  s   &&&&&&&   €r8   r¼   ÚKeyNetAffNetHardNet.__init__  s›   ø€ ð Š>Ü—\’\ %Ó(ˆFß")”W”Y¬{Ì&ÐQUË,Ô/Wˆ
Ü!ØØ%Ø!Ü.¨tÈ%ÔP×UÑUÓWØ'Ø+ô
÷ ‰"ˆV‹*ð 	ô # 4°BÈTÔR×UÑUÐV\Ó]ˆ
Ü‰Ñ˜¨yÔ9Ø�	‰	Žr:   r_   rn  r   rÔ   s   @@r8   rp  rp  Þ  s   ù‡ € ñ$÷L÷ õ r:   rp  c                   ó|   a a€ ] tR tRt oRtV3R lV 3R lltRV3R lR lltV3R lR ltV3R	 lR
 ltRt	Vt
V ;t# )ÚLocalFeatureMatcheri  aO  Detect, describe and match the local features of two images with a descriptor matcher.

``matcher = LocalFeatureMatcher(local_feature, DescriptorMatcher("snn", 0.8))`` builds the module and
``out = matcher({"image0": img0, "image1": img1})`` runs ``local_feature`` on both batches of images, which the
:class:`LocalFeature` presets take as grayscale ``(B, 1, H, W)``, except :class:`SIFTFeature`,
:class:`KeyNetHardNet` and :class:`KeyNetAffNetHardNet`, which take one image per call, ``(1, 1, H, W)``. It
matches the descriptors of each pair of images and returns a dict of the matches of all pairs: ``keypoints0``
and ``keypoints1`` ``(NC, 2)``, ``lafs0`` and ``lafs1`` ``(1, NC, 2, 3)``, ``confidence`` ``(NC,)`` and the pair
of each match, ``batch_indexes`` ``(NC,)``. Features already computed for an image can be passed instead of
running ``local_feature`` on it. For a matcher that reads the LAFs, such as :class:`LightGlueMatcher`, call it on
the outputs of the local feature yourself; for matching without a detector, use :class:`LoFTR`.

Convention:
    - ``keypoints0`` and ``keypoints1`` are the centres ``(x, y)`` of the returned LAF tensors ``lafs0`` and
      ``lafs1``, respectively; see :func:`~kornia.feature.laf_from_center_scale_ori` and
      :ref:`Local features <local-features-conventions>` for the LAF frame.
      ``confidence`` is ``1 - dists`` of the matcher (see :func:`~kornia.feature.match_nn`).
    - All-zero LAFs, the padding slots of kornia's detectors (see :func:`~kornia.feature.laf_is_filled`), are
      dropped before matching.
    - ``matcher`` is called as ``matcher(descriptors0, descriptors1)`` for each image pair, so it has to be a
      descriptor-only matcher such as :class:`~kornia.feature.DescriptorMatcher`;
      :class:`~kornia.feature.GeometryAwareDescriptorMatcher` and :class:`~kornia.feature.LightGlueMatcher`
      need LAFs and do not fit.

Args:
    local_feature: Local feature detector and descriptor, called as ``local_feature(image, mask)`` and returning
        ``(lafs, responses, descriptors)`` like :class:`~kornia.feature.LocalFeature`. See
        :class:`~kornia.feature.GFTTAffNetHardNet`.
    matcher: Descriptor matcher, see :class:`~kornia.feature.DescriptorMatcher`.

Returns:
    Dict[str, torch.Tensor]: Dictionary with image correspondences and confidence scores.

See Also:
    - :class:`LocalFeature`: the detector and descriptor pipeline that ``local_feature`` usually is.
    - :class:`DescriptorMatcher`: the descriptor-only matcher it takes.
    - :class:`LightGlueMatcher`: a learned matcher, which takes the LAFs and the image sizes as well.
    - :class:`LoFTR`: matches two images directly, without a detector.
    - :class:`~kornia.geometry.ransac.RANSAC`: the next step, which keeps the matches one geometric model
      explains.

Example:
    >>> img1 = torch.rand(1, 1, 320, 200)
    >>> img2 = torch.rand(1, 1, 128, 128)
    >>> input = {"image0": img1, "image1": img2}
    >>> gftt_hardnet_matcher = LocalFeatureMatcher(
    ...     GFTTAffNetHardNet(10), kornia.feature.DescriptorMatcher('snn', 0.8)
    ... )
    >>> out = gftt_hardnet_matcher(input)

c                óR   <€ V ^8„  d   QhRS[ P                  RS[ P                  RR/# )r0   Úlocal_featureÚmatcherr3   N)r
   rZ   )r7   r¸   s   "€r8   r9   Ú LocalFeatureMatcher.__annotate__S  s*   ø€ ÷ ñ ¡b§i¡ið ¹"¿)¹)ð Èñ r:   c                ó\   <€ \         SV `  4        Wn        W n        V P	                  4        R # ri   )r»   r¼   rx  ry  ru   )r¾   rx  ry  r¿   s   &&&€r8   r¼   ÚLocalFeatureMatcher.__init__S  s"   ø€ Ü‰ÑÔØ*ÔØŒØ�	‰	Žr:   c                óŽ   <€ V ^8„  d   QhRS[ P                  RS[S[ P                  ,          RS[S[S[ P                  3,          /# )r0   Úimagerá   r3   )r4   r5   r   r   r6   )r7   r¸   s   "€r8   r9   rz  Y  sG   ø€ ÷ Kñ K¡e§l¡lð K¹(Á5Ç<Á<Õ:Pð KÑ\`ÑadÑfk×frÑfrÐarÕ\sñ Kr:   c                ó:   € V P                  W4      w  r4pRVRVRV/# )z#Extract features from simple image.r?   rä   r1   )rx  )r¾   r~  rá   Úlafs0Úresps0Údescs0s   &&&   r8   Úextract_featuresÚ$LocalFeatureMatcher.extract_featuresY  s*   € à $× 2Ñ 2°5Ó ?Ñˆ�vØ˜˜{¨F°MÀ6ÐJÐJr:   c                ó–   <€ V ^8„  d   QhRS[ S[S[P                  R3,          RS[P                  RS[S[S[P                  3,          /# )r0   rP   NrT   r3   )r	   r6   r4   rP   rT   r   r5   )r7   r¸   s   "€r8   r9   rz  ^  sI   ø€ ÷ 
ñ 
¡e©C±·±¸tÐ,CÕ&Dð 
ÉUÏ[É[ð 
Ñ]aÑbeÑgl×gsÑgsÐbsÕ]tñ 
r:   c                óT  € R\         P                  ! ^ ^WR7      R\         P                  ! ^ ^WR7      R\         P                  ! ^^ ^^WR7      R\         P                  ! ^^ ^^WR7      R\         P                  ! ^ WR7      R\         P                  ! ^ V\         P                  R7      /# )a-  Create an empty output structure when no correspondences are found.

Args:
    device: Device on which empty tensors should be allocated.
    dtype: Floating-point dtype used for keypoints/LAF/confidence.

Returns:
    Dictionary with correctly typed empty tensors for all expected
    output fields.
Ú
keypoints0rS   Ú
keypoints1r€  Úlafs1Ú
confidenceÚbatch_indexes)r4   r©   Úlong)r¾   rP   rT   s   &&&r8   Úno_match_outputÚ#LocalFeatureMatcher.no_match_output^  s†   € ð œ%Ÿ+š+ a¨°6ÔGØœ%Ÿ+š+ a¨°6ÔGð ”U—[’[  A q¨!°FÔHØ”U—[’[  A q¨!°FÔHØœ%Ÿ+š+ a°ÔDØœUŸ[š[¨°6ÄÇÁÔLð	
ð 		
r:   c                óz   <€ V ^8„  d   QhRS[ S[S[P                  3,          RS[ S[S[P                  3,          /# )r0   Údatar3   )r   r6   r4   r5   )r7   r¸   s   "€r8   r9   rz  t  s;   ø€ ÷ E
ñ E
™D¡¡e§l¡lÐ!2Õ3ð E
¹¹SÁ%Ç,Á,Ð=NÕ8Oñ E
r:   c                óh  € VR,          P                   ^ ,          pRV9  g   RV9  dg   VP                  R4      pVe'   VP                  4       ^8X  d   VP                  ^4      pV P	                  VR,          V4      pVR,          VR,          reMVR,          VR,          reRV9  g   RV9  dg   VP                  R	4      pVe'   VP                  4       ^8X  d   VP                  ^4      pV P	                  VR
,          V4      pVR,          VR,          r©MVR,          VR,          r©\        VP                   R,          VP                   R,          8H  R\        VP                   4       R\        VP                   4       24       \        V	P                   R,          V
P                   R,          8H  R\        V	P                   4       R\        V
P                   4       24       \        V4      p\        V	4      p. p. p. p. p. p. p\        V4      p\        V	4      p\        V4       EF½  pVV,          pVV,          pVV,          V,          pV
V,          V,          pVV,          V,          pVV,          V,          pVV,          V,          pV	V,          V,          pVP                   ^ ,          ^ 8X  g   VP                   ^ ,          ^ 8X  d   K¨  V P                  VV4      w  pp\        V4      ^ 8X  d   KÏ  VVR,          ,          p VVR,          ,          p!VVR,          ,          p"VVR,          ,          p#VP                  RV,
          4       V\        P                  ! \        V4      VP                  \        P                   R7      ,          p$VP                  V 4       VP                  V!4       VP                  V"4       VP                  V#4       VP                  V$4       EKÀ  	  \        V4      ^ 8X  dÍ   V P#                  VR,          P                  VR,          P$                  4      p%V%R,          P'                  VP$                  4      V%R,          P'                  VP$                  4      uV%R&   V%R&   V%R,          P'                  V	P$                  4      V%R,          P'                  V	P$                  4      uV%R&   V%R&   V%# R\        P(                  ! V^ R7      P+                  R^4      R\        P(                  ! V^ R7      P+                  R^4      R\        P(                  ! V^ R7      P+                  ^R^^4      R\        P(                  ! V^ R7      P+                  ^R^^4      R\        P(                  ! V^ R7      P+                  R4      R\        P(                  ! V^ R7      P+                  R4      /# )a[  Run forward.

Args:
    data: dictionary containing the input data in the following format:

Keyword Args:
    image0: left image with shape ``(N, 1, H1, W1)``. Required also with ``lafs0`` and ``descriptors0``:
        its first dimension gives the number of image pairs.
    image1: right image with shape ``(N, 1, H2, W2)``; not read when ``lafs1`` and ``descriptors1`` are
        given.
    mask0 (optional): left image mask. '0' suppresses detection, with shape
        ``(N, H1, W1)`` or ``(N, 1, H1, W1)``.
    mask1 (optional): right image mask. '0' suppresses detection, with shape
        ``(N, H2, W2)`` or ``(N, 1, H2, W2)``.
    lafs0 (optional): pre-extracted LAFs of image0, ``(N, M0, 2, 3)``. When ``lafs0`` and
        ``descriptors0`` are both given, they are matched and ``local_feature`` does not run on image0.
    descriptors0 (optional): pre-extracted descriptors of image0, ``(N, M0, D)``.
    lafs1 (optional): pre-extracted LAFs of image1, ``(N, M1, 2, 3)``; with ``descriptors1``, as for image0.
    descriptors1 (optional): pre-extracted descriptors of image1, ``(N, M1, D)``.

Returns:
    - ``keypoints0``, matching keypoints from image0 ``(NC, 2)``.
    - ``keypoints1``, matching keypoints from image1 ``(NC, 2)``.
    - ``confidence``, ``1 - descriptor distance`` ``(NC,)``. This lies in :math:`[0, 1]`
      only for the ratio-based ``DescriptorMatcher`` modes (``snn``, ``smnn``); ``nn`` and
      ``mnn`` return raw distances, which are unbounded for an arbitrary descriptor, so the
      confidence has no lower bound in general -- it goes at least down to -1, the value
      reached by unit-norm descriptors, whose distance tops out at 2.0.
    - ``lafs0``, matching LAFs from image0 ``(1, NC, 2, 3)``.
    - ``lafs1``, matching LAFs from image1 ``(1, NC, 2, 3)``.
    - ``batch_indexes``, batch indexes for the keypoints and lafs ``(NC,)``.

Úimage0r€  Údescriptors0Úmask0r?   r1   r‰  Údescriptors1Úmask1Úimage1:Nr0   Nz<lafs0 and descriptors0 must describe the same features, got z and z<lafs1 and descriptors1 must describe the same features, got rç   rS   r‡  rˆ  ©ÚdimrŠ  r‹  )ºNNNr   )rš  r£   rE   )r¥   Úgetr™  Ú	unsqueezerƒ  r   Útupler   r   Úrangery  ÚlenÚappendr4   ÚonesrP   rŒ  r�  rT   r‚   Úcatr«   )&r¾   r�  Únum_image_pairsr”  Úfeats_dict0r€  r‚  r–  Úfeats_dict1r‰  Údescs1r‡  rˆ  Úout_keypoints0Úout_keypoints1Úout_confidenceÚout_batch_indexesÚ	out_lafs0Ú	out_lafs1Úfilled0Úfilled1Ú	batch_idxÚvalid0Úvalid1Úcurrent_descs0Úcurrent_descs1Úcurrent_keypoints0Úcurrent_keypoints1Úcurrent_lafs0Úcurrent_lafs1ÚdistsÚidxsÚcurrent_keypoints_0Úcurrent_keypoints_1Úcurrent_lafs_0Úcurrent_lafs_1Ú
batch_idxsÚouts&   &&                                    r8   rÊ   ÚLocalFeatureMatcher.forwardt  sð  € ðD  $ H�~×3Ñ3°AÕ6ˆà˜4Ô ^¸4Ô%?à—H‘H˜WÓ%ˆEØÒ  U§Y¡Y£[°AÔ%5ØŸ™¨Ó*�Ø37×3HÑ3HÈÈhÍÐY^Ó3_ˆKØ'¨Õ/°¸]Õ1K‘6à  �M¨4°Õ+?�6à˜4Ô ^¸4Ô%?Ø—H‘H˜WÓ%ˆEØÒ  U§Y¡Y£[°AÔ%5ØŸ™¨Ó*�Ø37×3HÑ3HÈÈhÍÐY^Ó3_ˆKØ'¨Õ/°¸]Õ1K‘6à  �M¨4°Õ+?�6ô
 	Ø�K‰K˜�O˜vŸ|™|¨BÕ/Ñ/ðÜ˜Ÿ™Ó%Ð& e¬E°&·,±,Ó,?Ð+@ðBô	
ô
 	Ø�K‰K˜�O˜vŸ|™|¨BÕ/Ñ/ðÜ˜Ÿ™Ó%Ð& e¬E°&·,±,Ó,?Ð+@ðBô	
ô $2°%Ó#8ˆ
Ü#1°%Ó#8ˆ
à-/ˆØ-/ˆØ-/ˆØ02ÐØ(*ˆ	Ø(*ˆ	ô   Ó&ˆÜ Ó&ˆä˜×/ˆIØ˜YÕ'ˆFØ˜YÕ'ˆFØ# IÕ.¨vÕ6ˆNØ# IÕ.¨vÕ6ˆNØ!+¨IÕ!6°vÕ!>ÐØ!+¨IÕ!6°vÕ!>ÐØ! )Õ,¨VÕ4ˆMØ! )Õ,¨VÕ4ˆMð ×#Ñ# AÕ&¨!Ô+¨~×/CÑ/CÀAÕ/FÈ!Ô/KÙàŸ,™, ~°~ÓF‰KˆE�4Ü�4‹y˜AŒ~Ùà"4°T¸$µZÕ"@ÐØ"4°T¸$µZÕ"@ÐØ*¨4°­:Õ6ˆNØ*¨4°­:Õ6ˆNà×!Ñ! #¨¥+Ô.Ø"¤U§Z¢Z´°E³
À:×CTÑCTÔ\a×\fÑ\fÔ%gÕgˆJØ×!Ñ!Ð"5Ô6Ø×!Ñ!Ð"5Ô6Ø×Ñ˜^Ô,Ø×Ñ˜^Ô,Ø×$Ñ$ Z×0ñ= 0ô@ Ð Ó! QÔ&Ø×&Ñ& t¨H¥~×'<Ñ'<¸dÀ8½n×>RÑ>RÓSˆCà.1°,Õ.?×.BÑ.BÀ5Ç;Á;Ó.OÐQTÐU\ÕQ]×Q`ÑQ`Ðaf×alÑalÓQmÐ+ˆC�Ñ˜s 7™|Ø.1°,Õ.?×.BÑ.BÀ5Ç;Á;Ó.OÐQTÐU\ÕQ]×Q`ÑQ`Ðaf×alÑalÓQmÐ+ˆC�Ñ˜s 7™|ØˆJð œ%Ÿ)š) N¸Ô:×?Ñ?ÀÀAÓFØœ%Ÿ)š) N¸Ô:×?Ñ?ÀÀAÓFØ”U—Y’Y˜y¨aÔ0×5Ñ5°a¸¸QÀÓBØ”U—Y’Y˜y¨aÔ0×5Ñ5°a¸¸QÀÓBØœ%Ÿ)š) N¸Ô:×?Ñ?ÀÓCØœUŸYšYÐ'8¸aÔ@×EÑEÀbÓIð
ð 	
r:   )rx  ry  ri   )rÄ   rÍ   rÎ   rÏ   rÐ   r¼   rƒ  r�  rÊ   rÑ   rÒ   rÓ   rÔ   s   @@r8   rv  rv    s=   ù‡ € ñ2÷hó ÷Kò K÷

ð 
÷,E
÷ E
ð E
r:   rv  c                   óp   a a€ ] tR tRt oRt. R	OtR
V3R lV 3R llltRV3R lR lltV3R ltRt	Vt
V ;t# )ÚLightGlueMatcheriü  aW  Match descriptors and LAFs with LightGlue, called like GeometryAwareDescriptorMatcher.

``matcher = LightGlueMatcher("disk")`` loads the LightGlue weights trained for that local feature, and
``scores, idxs = matcher(desc1, desc2, lafs1, lafs2, hw1, hw2)`` takes the descriptors ``(B1, D)`` and
``(B2, D)`` of two images (or ``(1, B1, D)`` and ``(1, B2, D)``), their LAFs ``(1, B1, 2, 3)`` and
``(1, B2, 2, 3)`` in pixels and, optionally, the image sizes ``(H, W)``, and returns LightGlue's matching scores
``(B3, 1)``, higher for better matches, and the index pairs ``(B3, 2)``, in the format of
:class:`GeometryAwareDescriptorMatcher`. The descriptors must come from the feature the weights were trained for,
see ``feature_name`` in the Convention block. To pass batches of
keypoints in dicts and read every output of the network, use :class:`LightGlue`; for an exported ONNX model, use
:class:`OnnxLightGlue`. It is based on the original code of "LightGlue: Local Feature Matching at Light Speed",
see :cite:`LightGlue2023` for more details.

Convention:
    - ``lafs1`` and ``lafs2`` use the pixel convention of :func:`~kornia.feature.laf_from_center_scale_ori`
      (see :ref:`Local features <local-features-conventions>`), and their centres go to LightGlue unchanged as
      the keypoints. ``hw1`` and ``hw2`` are the ``(H, W)`` of each image, which become LightGlue's
      ``image_size`` ``(W, H)``; without them, the image size is taken as the largest keypoint coordinates of
      that image, ``(max x, max y)``.
    - Choose ``feature_name`` for the source of the descriptors (case-insensitive). The network receives the
      following data besides keypoints:

      - ``"aliked"``: use the 128-D descriptors of :class:`ALIKED`. The 64-D ``"aliked-t16"`` descriptors are
        incompatible with these weights.
      - ``"dedodeb"``, ``"dedodeg"``: use the ``B``, respectively ``G``, descriptors of :class:`DeDoDe`. Build
        the LAFs at keypoints minus 0.5, because DeDoDe puts pixel ``i`` at ``i + 0.5``.
      - ``"disk"``, ``"raco-aliked"``, ``"superpoint"``, ``"xfeat"``: use descriptors from the named feature and
        no additional LAF attributes. For ``"xfeat"``, pass the 64-D
        descriptors of :meth:`~kornia.feature.XFeat.detectAndCompute` and LAFs centred on its keypoints, such as
        ``laf_from_center_scale_ori(keypoints[None])``, and call the matcher under ``torch.no_grad()`` or
        ``torch.inference_mode()``: it raises on XFeat's inference tensors with gradients enabled
        (`#6533 <https://github.com/kornia/kornia/issues/6533>`_).
      - ``"sift"``: use :class:`SIFTFeatureScaleSpace` with ``descriptor_layout="opencv"``. The weights expect
        the scale and orientation of the COLMAP keypoints they were trained on: the negated
        LAF orientation in :math:`(-\pi, \pi]`, and a sixth of the LAF scale, which is the detection sigma for
        6-sigma DoG frames such as :class:`~kornia.feature.SIFTFeatureScaleSpace`'s. The descriptors must be in
        OpenCV's SIFT layout, which these weights expect, while kornia's SIFT descriptors use another order of the
        same values: create the feature with ``descriptor_layout="opencv"``, or convert the descriptors with
        ``convert_sift_descriptor_layout(descs, "kornia", "opencv")``
        (:func:`~kornia.feature.convert_sift_descriptor_layout`).
      - ``"doghardnet"``, ``"dog_affnet_hardnet"``: use :class:`DoGHardNet` or :class:`DoGAffNetHardNet`.
        Pass the LAFs the HardNet descriptors were computed on, at
        the scale the weights were trained with: 12 sigma, six times OpenCV's ``KeyPoint.size`` and twice the
        6-sigma DoG frames of :class:`~kornia.feature.SIFTFeatureScaleSpace`. :class:`~kornia.feature.DoGHardNet`
        and :class:`~kornia.feature.DoGAffNetHardNet` return such LAFs and their descriptors; with another
        6-sigma DoG detector, apply :func:`~kornia.feature.scale_laf` with ``2.0`` to its LAFs before describing
        them. The network takes a sixth of the LAF scale, which is ``KeyPoint.size`` for these frames, and the
        LAF orientation in :math:`[0, 2\pi)`.
      - ``"keynet_affnet_hardnet"``: use :class:`KeyNetAffNetHardNet`. The network receives the ends of the two
        LAF axes, ``c + A[:, 0]`` and ``c + A[:, 1]``,
        normalised like the keypoints.
    - The first returned value is LightGlue's matching score, not a distance: higher is better, and only matches
      scoring above ``filter_threshold`` (0.1 by default) are returned. The index rows are ``(index in desc1,
      index in desc2)``. Fewer than two descriptors on either side give no match.
    - All-zero padding LAFs are not filtered out: such a slot reaches the network as a keypoint at ``(0, 0)``.
      Drop them with :func:`~kornia.feature.laf_is_filled` first.

Args:
    feature_name: type of feature for matching, one of ``known_modes``.
    params: keyword arguments of :class:`~kornia.feature.LightGlue`, such as ``filter_threshold``.

See Also:
    - :class:`LightGlue`: takes batches of keypoints in dictionaries and returns all network outputs.
    - :class:`OnnxLightGlue`: runs an exported LightGlue model for one image pair.
    - :class:`LocalFeatureMatcher`: matches local features with a descriptor-only matcher.
    - :class:`LoFTR`: matches images directly, without a detector.
    - :class:`GeometryAwareDescriptorMatcher`: offers FGINN and AdaLAM with the same call.

c                ó:   <€ V ^8„  d   QhRS[ RS[S[,          RR/# )r0   r@   Úparamsr3   N)r6   r   r   )r7   r¸   s   "€r8   r9   ÚLightGlueMatcher.__annotate__Q  s'   ø€ ÷ 	ñ 	¡Sð 	¹8ÁD½>ð 	ÐUYñ 	r:   c                óü   <€ VP                  4       p\        SV `	  V4       W0n        Vf   / pW n        \        V P                  3/ VB V n        V P                  P                  '       g   V P                  4        R # R # ri   )	Úlowerr»   r¼   r@   rÄ  r   ry  rt   ru   )r¾   r@   rÄ  Úfeature_name_r¿   s   &&& €r8   r¼   ÚLightGlueMatcher.__init__Q  sh   ø€ Ø)×/Ñ/Ó1ˆÜ‰Ñ˜Ô'Ø)ÔØŠ>ØˆFØŒÜ  ×!2Ñ!2Ñ=°fÑ=ˆŒØ�|‰|×$×$Ð$Ø�I‰IŽKñ %r:   c                ó  <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  RS[ P                  RS[S[S[S[3,          ,          RS[S[S[S[3,          ,          RS[S[ P                  S[ P                  3,          /# )r0   Údesc1Údesc2r‰  Úlafs2Úhw1Úhw2r3   )r4   r5   r   r   rQ   )r7   r¸   s   "€r8   r9   rÅ  \  s–   ø€ ÷ 0Dñ 0Dá�|‰|ð0Dñ �|‰|ð0Dñ �|‰|ð	0Dñ
 �|‰|ð0Dñ ‘e™C¡˜H•oÕ&ð0Dñ ‘e™C¡˜H•oÕ&ð0Dñ 
‰u�|‰|™UŸ\™\Ð)Õ	*ñ0Dr:   c                óÆ  € VP                   R,          ^8  g   VP                   R,          ^8  d   \        V4      # \        V4      p\        V4      p\        VP                   4      ^8X  d   VP	                  ^ 4      p\        VP                   4      ^8X  d   VP	                  ^ 4      pVP
                  p	Vf*   VP                  ^R7      ^ ,          P                  R^4      M
\        WY4      p
Vf*   VP                  ^R7      ^ ,          P                  R^4      M
\        Wi4      pRRVRVRVRV
/RRVRVRVRV//pV P                  P                  P                  '       dC   RV3RV33 F6  w  rÞ\        WàP                  4      w  ppWÍ,          P                  VVR7       K8  	  V P                  V4      pVR	,          ^ ,          P                  R^4      VR
,          ^ ,          3# )a™  Run forward.

Args:
    desc1: Batch of descriptors of a shape ``(B1, D)``, or ``(1, B1, D)`` for a batch of one.
    desc2: Batch of descriptors of a shape ``(B2, D)``, or ``(1, B2, D)`` for a batch of one.
    lafs1: LAFs of a shape ``(1, B1, 2, 3)``.
    lafs2: LAFs of a shape ``(1, B2, 2, 3)``.
    hw1: ``(H, W)`` of the first image; see the Convention block.
    hw2: ``(H, W)`` of the second image; see the Convention block.

Return:
    - LightGlue's matching score of each match, higher is better, shape of ``(B3, 1)``.
    - Long torch.Tensor indexes of matching descriptors in desc1 and desc2,
        shape of ``(B3, 2)`` where :math:`0 <= B3 <= B1`.

r˜  r’  Ú	keypointsr?   r1   Ú
image_sizer—  )rK   rL   ÚscoresÚmatcheséþÿÿÿrE   )r¥   r   r   rŸ  rœ  rP   ÚmaxrF   rV   ry  ÚconfÚadd_scale_orirM   r@   r   )r¾   rË  rÌ  r‰  rÍ  rÎ  rÏ  rˆ  Ú
keypoints2ÚdevÚsize1Úsize2Ú
input_dictr~  r?   rK   rL   Úpreds   &&&&&&&           r8   rÊ   ÚLightGlueMatcher.forward\  s¸  € ð2 �K‰K˜�O˜aÔ U§[¡[°¥_°qÔ%8Ü˜UÓ#Ð#Ü# EÓ*ˆ
Ü# EÓ*ˆ
Üˆu�{‰{Ó˜qÔ Ø—O‘O AÓ&ˆEÜˆu�{‰{Ó˜qÔ Ø—O‘O AÓ&ˆEØ�l‰lˆØ;>º;�
—‘ 1�Ó% aÕ(×0Ñ0°°QÔ7ÔL_Ð`cÓLiˆØ;>º;�
—‘ 1�Ó% aÕ(×0Ñ0°°QÔ7ÔL_Ð`cÓLiˆà�{ J°¸¸}ÈeÐUaÐchÐiØ�{ J°¸¸}ÈeÐUaÐchÐið
ˆ
ð
 �<‰<×Ñ×*×*Ð*Ø!)¨5Ð 1°H¸eÐ3DÓE‘�Ü<¸T×CTÑCTÓU‘�˜ØÕ!×(Ñ(°¸TÐ(ÖBñ  Fð �|‰|˜JÓ'ˆð �H�~˜aÕ ×(Ñ(¨¨QÓ/°°iµÀÕ1CÐCÐCr:   c                óF   <€ V ^8„  d   Qh/ S[ S[S[,          ,          ;R&   # )r0   Úknown_modes)r   r   r6   )r7   r¸   s   "€r8   r9   rÅ  ü  s   ø‡ ‚ ñN ™$™s�)Õ$ñ òO r:   )r@   ry  rÄ  )ÚalikedÚdedodebÚdedodegÚdiskÚdog_affnet_hardnetÚ
doghardnetÚkeynet_affnet_hardnetzraco-alikedrB   Ú
superpointÚxfeat)rå  N)NN)rÄ   rÍ   rÎ   rÏ   rÐ   rá  r¼   rÊ   Ú__annotate_func__rÑ   rÒ   rÓ   rÔ   s   @@r8   rÂ  rÂ  ü  s1   ù‡ € ñDòL(€K÷	õ 	÷0Dò 0D÷A … r:   rÂ  )rÌ   T)Xr‰   rw   rI   r¦   Útypingr   r   r   r   r   r   r	   r4   r
   Úkornia.colorr   Úkornia.core.checkr   r   Úkornia.core.opsr   Úkornia.geometry.subpixr   Úkornia.geometry.transformr   Úaffine_shaper   Úhardnetr   Úkeynetr   Úlafr   r   r   r   r   r   Ú	lightgluer   Úmatchingr   r   Úorientationr   r   r   rä   r    r!   r"   r#   Úscale_space_detectorr$   r%   r&   r'   rB   r(   Úsift.scale_spacer)   r*   r+   Úsiftdescr,   r-   r.   r=   rM   rV   rš   r³   rZ   rµ   rÖ   rê   rù   r  r"  r?  rM  rU  rW  r^  rd  rp  rv  rÂ  r_   r:   r8   Ú<module>rü     sr  ðó$ Û Û Û ß H× HÑ Hã Ý å )ß <Ý +Ý 3Ý 2å 1Ý Ý "÷÷ õ !ß ?ß 5Ñ 5ß FÓ F÷ó õ ,ß cÑ cß cÑ cõpõ
Eõ,Oõ.÷bPDôfFk�B—I‘Iô FkôRP(�2—9‘9ô P(ôf%˜"Ÿ)™)ô %ôU�<ô Uô2rK�,ô rKôjMc˜Lô Mcô`:˜ô :ôz;�|ô ;õ|ô,2�ô 2ôj/�|ô /ôd<�Lô <ô~=˜,ô =ô@[
˜"Ÿ)™)ô [
ô|PDÐ5ö PDr:   