+
    åûjvR  ã                   ó˜  a € R t&0 t ^ RIt^ RIHtHt ^ RIt^ RIHu Ht	 ^ RIHt ^ RI
HtHt ^ RIHtHt ^ RIHt ^ RIHtHt ^ RIHt ^R	IHt ^R
IHtHtHt ^RIHtHt / t ] ^ k ]! RR4      R.] R&    ! R R]PB                  4      t" ! R R]PB                  4      t# ! R R]PB                  4      t$ ! R R]PB                  4      t%R# )é    N)ÚDictÚOptional)Únn)ÚKORNIA_CHECK_LAFÚKORNIA_CHECK_SHAPE)Úhf_urlÚload_state_dict_from_url)Ú_autocast_disabled)Úget_gaussian_discrete_kernel1dÚget_gaussian_kernel2d)Úrad2deg)Ú_patch_conv_layout)Úextract_patches_from_pyramidÚget_laf_orientationÚset_laf_orientation)Ú_exact_first_order_gradientÚ_gradient_magnitude_orientationÚorinetz
OriNet.pthzEhttps://github.com/ducha-aiki/affnet/raw/master/pretrained/OriNet.pthc                   ó6   a € ] tR t^*t o RtV 3R lR ltRtV tR# )ÚPassLAFaq  Return LAFs unchanged, in place of an orientation or affine shape estimator.

``out = PassLAF()(laf, img)`` takes ``(B, N, 2, 3)`` LAFs and an image and returns its ``laf`` argument itself, not
a copy, without reading ``img``. It is the default ``ori_module`` and ``aff_module`` of
:class:`ScaleSpaceDetector`, :class:`MultiResolutionDetector` and :class:`KeyNetDetector`, and the ``ori_module``
that keeps features upright. To estimate the orientation, use :class:`LAFOrienter`; to estimate the affine shape,
:class:`LAFAffineShapeEstimator` or :class:`LAFAffNetShapeEstimator`.

See Also:
    - :class:`LAFOrienter`: rotates each LAF by the orientation estimated on its image patch.
    - :class:`LAFAffineShapeEstimator`: adapts each LAF's shape to the second-moment matrix of its patch.
    - :class:`LAFAffNetShapeEstimator`: adapts each LAF's shape with the learned AffNet.

c                óh   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  /# ©é   ÚlafÚimgÚreturn©ÚtorchÚTensor)ÚformatÚ__classdict__s   "€ÚVC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\feature\orientation.pyÚ__annotate__ÚPassLAF.__annotate__:   s.   ø€ ÷ ñ ™5Ÿ<™<ð ©e¯l©lð ¹u¿|¹|ñ ó    c                ó   € V# )zpRun forward.

Args:
    laf: ``(B, N, 2, 3)``
    img: not used.

Returns:
    LAF, unchanged ``(B, N, 2, 3)``

© )Úselfr   r   s   &&&r"   ÚforwardÚPassLAF.forward:   s	   € ð ˆ
r%   r'   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r)   Ú__static_attributes__Ú__classdictcell__)r!   s   @r"   r   r   *   s   ø‡ € ñ÷ö r%   r   c                   ó|   a a€ ] tR t^Ht 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V3R lR	 ltR
t	Vt
V ;t# )Ú PatchDominantGradientOrientationaè  Estimate the orientation of patches from the peak of their histogram of gradient directions.

``angles = PatchDominantGradientOrientation(patch_size)(patches)`` takes ``(B, 1, patch_size, patch_size)``
patches and returns the direction of each patch's dominant gradient, ``(B,)`` in radians, 0 for a gradient that
points to the right: the peak, refined between bins, of a ``num_angular_bins``-bin histogram of the gradient
directions, each pixel weighted by its gradient magnitude and a Gaussian centred on the patch, as in SIFT's
orientation assignment. It returns one angle per patch, that of the highest peak. To orient LAFs on an image, run
it through :class:`LAFOrienter`, whose default it is; for a learned estimate, use :class:`OriNet` instead.

Convention:
    - The angle is that of the dominant gradient, which points toward brighter values, counter-clockwise on
      screen with image y pointing down: :math:`-\operatorname{atan2}(g_y, g_x)` in pixel coordinates. A gradient
      pointing down the patch gives :math:`-\pi / 2`. :class:`~kornia.feature.LAFOrienter` adds the angle to the
      LAF orientation.
    - The angle is not wrapped into :math:`(-\pi, \pi]`: it can exceed :math:`\pi` by up to
      ``pi / num_angular_bins``.
    - A patch whose Sobel gradients are all exactly zero, such as an all-zero patch, gets the angle
      :math:`\pi` from its empty histogram, as does any constant patch. A nearly flat patch gets an arbitrary angle
      set by rounding noise, such as a patch sampled from a flat image region by
      :func:`~kornia.feature.extract_patches_from_pyramid`.
    - A float16 or bfloat16 patch is computed in float32, whatever the module's dtype and any enclosing autocast,
      and only the returned angle is cast back: the histogram bins of a textured patch are subnormal in float16.
      A float32 patch under autocast gets its float32 result.
    - The backward casts the patch gradient to float16 too, so a gradient above 65504 becomes ``inf`` for a patch of
      very low amplitude. Through :func:`~kornia.feature.extract_patches_from_pyramid` it reaches the image gradient
      as ``inf`` and NaN.

Args:
    patch_size: size of the (square) input patch.
    num_angular_bins: number of histogram bins.
    eps: for safe division, and arctan.

Note:
    Each gradient pixel is accumulated into its two neighbouring histogram bins with
    ``scatter_add_``. On CUDA that accumulation uses atomics, so two calls on identical input
    can differ at the ulp level, and a patch whose two strongest bins are nearly tied can
    return the neighbouring peak. ``torch.use_deterministic_algorithms(True)`` selects the
    deterministic kernel and restores run-to-run reproducibility.

See Also:
    - :class:`OriNet`: a learned orientation of 32 x 32 patches.
    - :class:`LAFOrienter`: samples each LAF's patch, runs this module on it by default and rotates the LAF.
    - :class:`PatchAffineShapeEstimator`: the affine shape of a patch, from the second moments of the same Sobel
      gradients.

c                ó0   <€ V ^8„  d   QhRS[ RS[ RS[RR/# )r   Ú
patch_sizeÚnum_angular_binsÚepsr   N)ÚintÚfloat)r    r!   s   "€r"   r#   Ú-PatchDominantGradientOrientation.__annotate__x   s*   ø€ ÷ 
ñ 
¡3ð 
¹sð 
Éeð 
Ð_cñ 
r%   c           	     óæ  <€ \         SV `  4        Wn        W n        W0n        \
        P                  ! ^^^^RRR7      V n        \        P                  ! 4       ;_uu_ 4        \        ^R4      V P                  P                  R&   RRR4       \        V P                  4      R,          pV P                  R\        V P                  V P                  3WD3R	4      RR
7       R#   + '       g   i     Ld; i)é   FÚcircular)Úkernel_sizeÚpaddingÚbiasÚpadding_modegš™™™™™ù?ºNNNNg      @Ú	weightingT)Ú
persistent)ÚsuperÚ__init__r5   Únum_ang_binsr7   r   ÚConv1dÚangular_smoothr   Úno_gradr   Úweightr9   Úregister_bufferr   )r(   r5   r6   r7   ÚsigmaÚ	__class__s   &&&& €r"   rF   Ú)PatchDominantGradientOrientation.__init__x   s·   ø€ Ü‰ÑÔØ$ŒØ,ÔØŒÜ Ÿiši¨¨1¸!ÀQÈUÐakÔlˆÔÜ�]Š]�_�_Ü,JÈ1ÈcÓ,RˆD×Ñ×&Ñ& qÑ)÷ ä˜TŸ_™_Ó-°Õ3ˆà×ÑØÜ! 4§?¡?°D·O±OÐ"DÀuÀnÐVZÓ[Øð 	ö 	
÷	 �_ús   Á $C Ã C0	c                ó    <€ V ^8„  d   QhRS[ /# ©r   r   ©Ústr)r    r!   s   "€r"   r#   r:   ˆ   s   ø€ ÷ 
ñ 
™#ñ 
r%   c                ó‚   € V P                   P                   R V P                   RV P                   RV P                   R2# )ú(patch_size=z, num_ang_bins=z, eps=Ú))rN   r+   r5   rG   r7   ©r(   s   &r"   Ú__repr__Ú)PatchDominantGradientOrientation.__repr__ˆ   sE   € à�~‰~×&Ñ&Ð' |°D·O±OÐ3DÀOÐTX×TeÑTeÐSfÐflÐmq×muÑmuÐlvÐvwÐxð	
r%   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# ©r   Úpatchr   r   )r    r!   s   "€r"   r#   r:   �   s'   ø€ ÷ sñ s™UŸ\™\ð s©e¯l©lñ sr%   c           
     óV  € \        V. RO4       VP                  4       w  r#rEW@P                  8w  g   WPP                  8w  g   V^8w  d7   \        RV P                   RV P                   RVP                  4        24      h\	        VP
                  P                  4      ;_uu_ 4        V P                  VP                  \        P                  ! VP                  \        P                  4      4      4      P                  VP                  4      uuRRR4       #   + '       g   i     R# ; i)z�Run forward.

Args:
    patch: ``(B, 1, patch_size, patch_size)``; another size raises ``TypeError``.

Returns:
    angle in radians: ``(B,)``

z#input shape should be must be [Bx1xÚxz]. Got N©ÚBÚ1ÚHÚW)r   Úsizer5   Ú	TypeErrorr
   ÚdeviceÚtypeÚ_dominant_angleÚtor   Úpromote_typesÚdtypeÚfloat32)r(   r\   Ú_ÚCHrc   rb   s   &&    r"   r)   Ú(PatchDominantGradientOrientation.forward�   s×   € ô 	˜5Ò"6Ô7Ø—j‘j“l‰ˆˆqØ—‘Ô  a¯?©?Ô&:ÀÀaÄÜØ5°d·o±oÐ5FÀaÈÏÉÐGXÐX_Ð`e×`jÑ`jÓ`lÐ_mÐnóð ô   §¡× 1Ñ 1×2Õ2Ø×'Ñ'¨¯©´×1DÒ1DÀUÇ[Á[ÔRW×R_ÑR_Ó1`Ó(aÓb×eÑeÐfk×fqÑfqÓr÷ 3×2×2Ó2ús   Â&A&DÄD(	c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# r[   r   )r    r!   s   "€r"   r#   r:   £   s+   ø€ ÷ @nñ @n¡U§\¡\ð @n±e·l±lñ @nr%   c           	     ó  € VP                  4       w   r#pV P                  P                  VP                  4      P                  VP                  4      pV P
                  P                  P                  VP                  4      P                  VP                  4      pV P
                  P                  pVe5   VP                  VP                  4      P                  VP                  4      p\        VR4      pVR,          p	VR	,          p
\        WšV P                  4      w  r¼Wµ,          p\        V P                  4      V\        P                  ,           ,          R\        P                  ,          ,          p\        P                   ! V4      pWÞ,
          pWàP                  ,          pV^,           V P                  ,          pRV,
          V,          pWû,          p\        P"                  ! VP$                  ^ ,          V P                  VP                  VP                  R7      pVP'                  ^VP)                  ^4      P+                  4       V P                  ,          VP)                  ^4      4       VP'                  ^VP)                  ^4      P+                  4       V P                  ,          VP)                  ^4      4       VW4,          ,          P-                  R
^V P                  4      pV P
                  P.                  pV P
                  P0                  R8w  d@   \2        P4                  ! VV^ ,          V^ ,          3V P
                  P0                  R7      pRp\2        P6                  ! VVVV P
                  P8                  VV P
                  P:                  V P
                  P<                  4      P-                  R
V P                  4      pVP?                  ^4      w  ppV P                  V,           ^,
          V P                  ,          pV^,           V P                  ,          p\        P@                  ! V^VPC                  R
^4      4      PC                  R
4      pTp\        P@                  ! V^VPC                  R
^4      4      PC                  R
4      pVV,           RV,          ,
          pV^ 8g  p\        PD                  ! VV\        PF                  ! V4      4      p\        PD                  ! VRVV,
          ,          V,          \        PH                  ! V4      4      pR\        P                  ,          VP                  VP                  4      V,           ,          \        V P                  4      ,          \        P                  ,
          ) # )zUReturn the refined histogram peak of float32 or float64 patches, ``(B,)`` in radians.Úsobelg       @g      ð?)rf   rk   Úzeros)Úmodeg      à?)rB   rB   r   )rB   rB   r<   éÿÿÿÿ)r   )%rd   rC   ri   rk   rf   rI   rK   r@   r   r   r7   r9   rG   ÚmathÚpir   Úfloorrs   ÚshapeÚscatter_add_ÚflattenÚlongÚviewr?   rA   ÚFÚpadÚconv1dÚstrideÚdilationÚgroupsÚmaxÚgatherÚreshapeÚwhereÚ	ones_likeÚ
zeros_like)r(   r\   rm   rc   rb   rC   Úangular_smooth_weightÚangular_smooth_biasÚgradsÚgxÚgyÚmagÚoriÚo_bigÚbo0_bigÚwo1_bigÚbo1_bigÚwo0_bigÚang_binsÚangular_smooth_paddingÚvaluesÚindicesÚindices_leftÚindices_rightÚleftÚcenterÚrightÚdenomÚhas_peakÚ
safe_denomÚc_subpixs   &&                             r"   rh   Ú0PatchDominantGradientOrientation._dominant_angle£   s'  € à—Z‘Z“\‰
ˆˆ1�ð —N‘N×%Ñ% e§k¡kÓ2×5Ñ5°e·l±lÓCˆ	Ø $× 3Ñ 3× :Ñ :× =Ñ =¸e¿k¹kÓ J× MÑ MÈeÏlÉlÓ [ÐØ"×1Ñ1×6Ñ6ÐØÒ*Ø"5×"8Ñ"8¸¿¹Ó"E×"HÑ"HÈÏÉÓ"VÐÜ9¸%ÀÓIˆà  �>ˆØ  �>ˆä2°2¸4¿8¹8ÓD‰ˆØ�oˆä�d×'Ñ'Ó(¨C´$·'±'­MÕ:¸cÄDÇGÁG½mÕLˆÜ—+’+˜eÓ$ˆØ•/ˆØ×-Ñ-Õ-ˆØ˜Q•; $×"3Ñ"3Õ3ˆØ˜•= CÕ'ˆØ•-ˆô —;’;˜uŸ{™{¨1�~¨t×/@Ñ/@ÈÏÉÐ]b×]hÑ]hÔiˆð 	×Ñ˜a §¡°Ó!3×!8Ñ!8Ó!:¸T×=NÑ=NÕ!NÐPW×P_ÑP_Ð`aÓPbÔcØ×Ñ˜a §¡°Ó!3×!8Ñ!8Ó!:¸T×=NÑ=NÕ!NÐPW×P_ÑP_Ð`aÓPbÔcØ ¥Õ&×,Ñ,¨R°°D×4EÑ4EÓFˆØ!%×!4Ñ!4×!<Ñ!<ÐØ×Ñ×+Ñ+¨wÔ6Ü—u’uØØ'¨Õ*Ð,BÀ1Õ,EÐFØ×(Ñ(×5Ñ5ôˆHð
 &*Ð"Ü—8’8ØØ!ØØ×Ñ×&Ñ&Ø"Ø×Ñ×(Ñ(Ø×Ñ×&Ñ&ó
÷ ‰$ˆr�4×$Ñ$Ó
%ð 	ð #Ÿ,™, q›/‰ˆ�Ø×)Ñ)¨GÕ3°aÕ7¸4×;LÑ;LÕLˆØ  1�¨×(9Ñ(9Õ9ˆÜ�|Š|˜H a¨×)=Ñ)=¸bÀ!Ó)DÓE×MÑMÈbÓQˆØˆÜ—’˜X q¨-×*?Ñ*?ÀÀAÓ*FÓG×OÑOÐPRÓSˆð �u•˜s V�|Õ+ˆØ˜A‘:ˆä—[’[ ¨5´%·/²/À%Ó2HÓIˆ
Ü—;’;˜x¨°°uµÕ)=À
Õ)JÌE×L\ÒL\Ð]bÓLcÓdˆØœŸ™•- 7§:¡:¨e¯k©kÓ#:¸XÕ#EÕFÌÈt×O`ÑO`ÓIaÕaÔei×elÑelÕlÐmÐmr%   )rI   r7   rG   r5   )é    é$   ç:Œ0âŽyE>)r+   r,   r-   r.   r/   rF   rX   r)   rh   r0   r1   Ú__classcell__©rN   r!   s   @@r"   r3   r3   H   s@   ù‡ € ñ-÷^
õ 
÷ 
ð 
÷
sð s÷,@n÷ @nð @nr%   r3   c                   óx   a a€ ] tR t^æt oRtR	V3R lV 3R lllt]R
V3R lR ll4       tV3R lR ltRt	Vt
V ;t# )ÚOriNetaá  Estimate the orientation of 32 x 32 patches with the learned OriNet CNN.

``angles = OriNet()(patches)`` builds the network with its pretrained weights, in eval mode, and takes
``(B, 1, 32, 32)`` patches and returns a learned canonical orientation per patch, ``(B,)`` in radians, in the
sense of the angle of :class:`PatchDominantGradientOrientation`; its zero is learned, so on a patch it need not
match the dominant gradient direction. ``pretrained=False`` leaves the weights random. To orient LAFs, pass it to
:class:`LAFOrienter` as ``angle_detector``, as :class:`KeyNetHardNet` and :class:`KeyNetAffNetHardNet` do. For an
estimate that needs no weights, use :class:`PatchDominantGradientOrientation` instead. This is based on the
original code from the paper "Repeatability Is Not Enough: Learning Discriminative Affine Regions via
Discriminability". See :cite:`AffNet2018` for more details.

Convention:
    - With the pretrained weights, the angle turns with the patch content, in the sense of
      :class:`~kornia.feature.PatchDominantGradientOrientation`: content turned counter-clockwise on screen
      increases the angle. See :class:`~kornia.feature.LAFOrienter` for its use.
    - Each patch is normalised first: its mean is subtracted and the result is divided by its standard deviation
      plus ``1e-6``. An offset of its intensity therefore does not change the angle, and a positive gain changes it
      only through that ``1e-6``: little on a textured patch, more as the patch flattens, up to ``pi`` rad on a
      nearly flat one. An inverted patch generally gets a different angle.

Args:
    pretrained: Download and set pretrained weights to the model.
    eps: to avoid division by zero in atan2.

Returns:
    Angle in radians.

Shape:
    - Input: ``(B, 1, 32, 32)``
    - Output: ``(B,)``

See Also:
    - :class:`PatchDominantGradientOrientation`: the hand-crafted dominant gradient direction, with no weights.
    - :class:`LAFOrienter`: runs it on each LAF's patch, as ``angle_detector``, and rotates the LAF.
    - :class:`LAFAffNetShapeEstimator`: AffNet, the affine shape network of the same paper.

Examples:
    >>> input = torch.rand(16, 1, 32, 32)
    >>> orinet = OriNet(pretrained=False).eval()
    >>> angle = orinet(input) # 16

c                ó*   <€ V ^8„  d   QhRS[ RS[RR/# )r   Ú
pretrainedr7   r   N)Úboolr9   )r    r!   s   "€r"   r#   ÚOriNet.__annotate__  s"   ø€ ÷ ñ ¡4ð ±Uð Àdñ r%   c                ó  <€ \         SV `  4        \        P                  ! \        P                  ! ^^^^RR7      \        P
                  ! ^RR7      \        P                  ! 4       \        P                  ! ^^^^^RR7      \        P
                  ! ^RR7      \        P                  ! 4       \        P                  ! ^^ ^^^RR7      \        P
                  ! ^ RR7      \        P                  ! 4       \        P                  ! ^ ^ ^^^RR7      \        P
                  ! ^ RR7      \        P                  ! 4       \        P                  ! ^ ^@^^^RR7      \        P
                  ! ^@RR7      \        P                  ! 4       \        P                  ! ^@^@^^^RR7      \        P
                  ! ^@RR7      \        P                  ! 4       \        P                  ! R4      \        P                  ! ^@^^^^RR7      \        P                  ! 4       \        P                  ! ^4      4      V n
        W n        V'       dY   \        \        R,          \        P                  ! R4      R	7      pV P!                  VR
,          RR7       V P#                  4        R# R# )r<   F)r>   r?   r@   )Úaffine)r>   r�   r?   r@   g      Ð?Tr   Úcpu)Úmap_locationÚ
state_dict)ÚstrictN)rE   rF   r   Ú
SequentialÚConv2dÚBatchNorm2dÚReLUÚDropoutÚTanhÚAdaptiveAvgPool2dÚfeaturesr7   r	   Úurlsr   rf   Úload_state_dictÚeval)r(   r¬   r7   Úpretrained_dictrN   s   &&& €r"   rF   ÚOriNet.__init__  s°  ø€ Ü‰ÑÔÜŸšÜ�IŠI�a˜¨°A¸EÔBÜ�NŠN˜2 eÔ,Ü�GŠG‹IÜ�IŠI�b˜"¨!°A¸qÀuÔMÜ�NŠN˜2 eÔ,Ü�GŠG‹IÜ�IŠI�b˜"¨!°A¸qÀuÔMÜ�NŠN˜2 eÔ,Ü�GŠG‹IÜ�IŠI�b˜"¨!°A¸qÀuÔMÜ�NŠN˜2 eÔ,Ü�GŠG‹IÜ�IŠI�b˜"¨!°A¸qÀuÔMÜ�NŠN˜2 eÔ,Ü�GŠG‹IÜ�IŠI�b˜"¨!°A¸qÀuÔMÜ�NŠN˜2 eÔ,Ü�GŠG‹IÜ�JŠJ�tÓÜ�IŠI�b˜!¨°1¸aÀdÔKÜ�GŠG‹IÜ× Ò  Ó#ó-
ˆŒð0 ŒçÜ6´t¸Hµ~ÔTY×T`ÒT`ÐafÓTgÔhˆOØ× Ñ  °Õ!>ÀuÐ ÔMØ�I‰IŽKñ r%   c                óT   <€ V ^8„  d   QhRS[ P                  RS[RS[ P                  /# )r   r^   r7   r   )r   r   r9   )r    r!   s   "€r"   r#   r®   4  s*   ø€ ÷ 7ñ 7™EŸL™Lð 7©uð 7ÁÇÁñ 7r%   c                óÊ   € \         P                  ! V RRR7      p\         P                  ! V RRR7      pWP                  4       ,
          VP                  4       V,           ,          # )zMSubtract each patch's mean and divide by its standard deviation plus ``eps``.T)ÚdimÚkeepdim)éýÿÿÿéþÿÿÿru   )r   ÚmeanÚstdÚdetach)r^   r7   ÚmpÚsps   &&  r"   Ú_normalize_inputÚOriNet._normalize_input3  sH   € ô �ZŠZ˜˜|°TÔ:ˆÜ�YŠY�q˜l°DÔ9ˆð —I‘I“K• B§I¡I£K°#Õ$5Õ6Ð6r%   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# r[   r   )r    r!   s   "€r"   r#   r®   >  s'   ø€ ÷ Añ A™UŸ\™\ð A©e¯l©lñ Ar%   c                óî   € V P                  \        V P                  V4      4      4      P                  R^4      p\        P
                  ! VR,          R,           VR,          V P                  ,           4      # )z‰Run forward.

Args:
    patch: ``(B, 1, 32, 32)``, the patch size the weights were trained on.

Returns:
    angle in radians: ``(B,)``

r¦   ru   )rB   r   )rB   r<   )r¼   r   rÍ   r}   r   Úatan2r7   )r(   r\   Úxys   && r"   r)   ÚOriNet.forward>  sX   € ð �]‰]Ô-¨d×.CÑ.CÀEÓ.JÓKÓL×QÑQÐRTÐVWÓXˆÜ�{Š{˜2˜d�8 d�?¨B¨t­H°t·x±xÕ,?Ó@Ð@r%   )r7   r¼   )Tr¦   )g�íµ ÷Æ°>)r+   r,   r-   r.   r/   rF   ÚstaticmethodrÍ   r)   r0   r1   r§   r¨   s   @@r"   rª   rª   æ   sA   ù‡ € ñ)÷Võ ðB ÷7ñ 7ó ð7÷A÷ Að Ar%   rª   c                   ój   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V3R lR ltR	tVt	V ;t
# )ÚLAFOrienteriL  a¯	  Orient LAFs by the angle that a patch orientation estimator finds in each LAF's patch.

``lafs = LAFOrienter(patch_size)(laf, img)`` takes ``(B, N, 2, 3)`` LAFs in pixels and their grayscale images
``(B, 1, H, W)``, samples each LAF's ``patch_size`` patch with :func:`extract_patches_from_pyramid`, runs
``angle_detector`` on it, :class:`PatchDominantGradientOrientation` with ``num_angular_bins`` bins by default, and
returns the ``(B, N, 2, 3)`` LAFs rotated by the angles found. Passed to a detector as ``ori_module``, it runs after
the ``aff_module``. To keep the LAFs upright, pass :class:`PassLAF` instead; to rotate them by known angles, use
:func:`rotate_laf`.

Convention:
    - Each LAF's patch (:func:`~kornia.feature.extract_patches_from_pyramid`) gives an angle, measured in the
      patch, and the output orientation is the input orientation plus that angle, converted to degrees, modulo
      360 degrees. :func:`~kornia.feature.get_laf_orientation` reads it back in ``[-180, 180]``. The centre, the
      scale and the upright shape (:func:`~kornia.feature.make_upright`) of the LAF are kept.
    - For an isotropic LAF with positive determinant, the default angle detector turns the LAF's x axis onto the
      dominant
      gradient, whatever the input orientation: content turned 30 degrees counter-clockwise on screen turns the
      output orientation by +30, the sign of :func:`~kornia.feature.laf_from_center_scale_ori`
      (see :ref:`Local features <local-features-conventions>` for the orientation convention).

Args:
    patch_size: side of the square patch sampled for each LAF.
    num_angular_bins: number of histogram bins of the default angle detector; not used when ``angle_detector``
      is given.
    angle_detector: Patch orientation estimator, e.g. :class:`~kornia.feature.PatchDominantGradientOrientation`
      or :class:`~kornia.feature.OriNet`.

See Also:
    - :class:`PatchDominantGradientOrientation`: the default ``angle_detector``, the dominant gradient direction.
    - :class:`OriNet`: a learned ``angle_detector`` for 32 x 32 patches.
    - :class:`PassLAF`: keeps the input orientation, for upright features.
    - :func:`rotate_laf`: rotates LAFs by known angles, as this module does with the estimated ones.
    - :class:`LAFAffineShapeEstimator`: estimates the affine shape, which a detector runs before this module.
    - :class:`LAFDescriptor`: describes the oriented LAFs, from patches that follow their orientation.

c                óT   <€ V ^8„  d   QhRS[ RS[ RS[S[P                  ,          RR/# )r   r5   r6   Úangle_detectorr   N)r8   r   r   ÚModule)r    r!   s   "€r"   r#   ÚLAFOrienter.__annotate__r  s9   ø€ ÷ 
1ñ 
1Ùð
1Ù69ð
1ÙPXÑY[×YbÑYbÕPcð
1à	ñ
1r%   c                ó¢   <€ \         SV `  4        Wn        W n        V  Vf(   \	        V P                  V P                  4      V n        R # W0n        R # )N)rE   rF   r5   rG   r3   rØ   )r(   r5   r6   rØ   rN   s   &&&&€r"   rF   ÚLAFOrienter.__init__r  sD   ø€ ô 	‰ÑÔØ$ŒØ,ÔÙØÒ!Ü"BÀ4Ç?Á?ÐTX×TeÑTeÓ"fˆDÖà"0Ör%   c                ó    <€ V ^8„  d   QhRS[ /# rQ   rR   )r    r!   s   "€r"   r#   rÚ   ~  s   ø€ ÷ pñ p™#ñ pr%   c                óh   € V P                   P                   R V P                   RV P                   R2# )rU   z, angle_detector=rV   )rN   r+   r5   rØ   rW   s   &r"   rX   ÚLAFOrienter.__repr__~  s5   € Ø—.‘.×)Ñ)Ð*¨,°t·±Ð6GÐGXÐY]×YlÑYlÐXmÐmnÐoÐor%   c                óh   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  /# r   r   )r    r!   s   "€r"   r#   rÚ   �  s.   ø€ ÷ ñ ™5Ÿ<™<ð ©e¯l©lð ¹u¿|¹|ñ r%   c                ó.  € \        V4       \        V. RO4       VP                  ^ 4      VP                  ^ 4      8w  d0   \        RVP                  ^ 4       RVP                  ^ 4       24      hVP                  R,          w  r4\        W!V P                  4      P                  R^V P                  V P                  4      pV P                  V4      P                  W44      p\        V4      P                  V4      p\        V\        V4      V,           4      pV# )zqRun forward.

Args:
    laf: ``(B, N, 2, 3)``
    img: ``(B, 1, H, W)``

Returns:
    LAF_out: ``(B, N, 2, 3)``

z2Batch size of laf and img should be the same. Got z, :Nr   Nr_   ru   )r   r   rd   Ú
ValueErrorry   r   r5   r}   rØ   r   Úview_asr   r   )	r(   r   r   r`   ÚNÚpatchesÚangles_radiansÚ
prev_angleÚlaf_outs	   &&&      r"   r)   ÚLAFOrienter.forward�  sî   € ô 	˜ÔÜ˜3Ò 4Ô5Ø�8‰8�A‹;˜#Ÿ(™( 1›+Ô%ÜÐQÐRU×RZÑRZÐ[\ÓR]ÐQ^Ð^`Ðad×aiÑaiÐjkÓalÐ`mÐnÓoÐoØ�y‰y˜�}‰ˆÜ <¸SÀtÇÁÓ W× \Ñ \Ø��4—?‘? D§O¡Oó!
ˆð (,×':Ñ':¸7Ó'C×'HÑ'HÈÓ'NˆÜ(¨Ó-×5Ñ5°nÓEˆ
Ü 3°C¼ÀÓ9PÐS]Õ9]Ó ^ˆØˆr%   )rØ   rG   r5   )r¤   r¥   N)r+   r,   r-   r.   r/   rF   rX   r)   r0   r1   r§   r¨   s   @@r"   rÖ   rÖ   L  s0   ù‡ € ñ#÷J
1õ 
1÷pð p÷÷ ð r%   rÖ   c                óŽ   € V ^8„  d   Qh/ ^ \         9   d1   \        \        \        \        \        ,          ,          3,          ;R&   # )r   r½   )Ú__conditional_annotations__r   rS   Úlist)r    s   "r"   r#   r#      s*   € ‡�÷" &Ò %„dŒ3””dœ3•i•ÐÕ Ñ %ò# r%   )'rë   rv   Útypingr   r   r   Útorch.nn.functionalr   Ú
functionalr~   Úkornia.core.checkr   r   Úkornia.core.downloadr   r	   Úkornia.core.utilsr
   Úkornia.filtersr   r   Úkornia.geometryr   Ú_layoutr   r   r   r   r   Úsiftdescr   r   r½   rÙ   r   r3   rª   rÖ   r#   )rë   s   @r"   Ú<module>r÷      s£   øð÷$ €ß !ã ß Ð Ý ç Bß AÝ 0ß PÝ #å 'ß WÑ Wß Rà#%€Ó %á
ˆ8�\Ó"ØKð€€X�ôˆb�i‰iô ô<[n r§y¡yô [nô|cAˆR�Y‰Yô cAôLK�"—)‘)ö Kr%   