+
    åûjÕN  ã                   óx  a € R t$0 t ^ RIt^ RIHtHt ^ RI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 ^RIHt ^R	IHtHtHtHtHtHtHtHt / t] ^ k ]! R
R4      R.]R
&    ! R R]P:                  4      tR R ltR R lt RR R llt! ! R R]P:                  4      t" ! R R]P:                  4      t#R# )é    N)ÚDictÚOptional)Únn)ÚKORNIA_CHECK_LAFÚKORNIA_CHECK_SHAPE)Úhf_urlÚload_state_dict_from_url)Úget_gaussian_kernel2d)ÚSpatialGradient)Ú_patch_conv_layout)Úellipse_to_lafÚextract_patches_from_pyramidÚget_laf_orientationÚget_laf_scaleÚlaf_is_validÚmake_uprightÚ	scale_lafÚset_laf_orientationÚaffnetz
AffNet.pthzEhttps://github.com/ducha-aiki/affnet/raw/master/pretrained/AffNet.pthc                   ój   a a€ ] tR t^0t 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
# )
ÚPatchAffineShapeEstimatora"  Estimate the affine shape of patches from the second-moment matrix of their gradients.

``abc = PatchAffineShapeEstimator(patch_size)(patches)`` takes ``(B, 1, patch_size, patch_size)`` patches and
returns the second-moment matrix of each patch's Gaussian-weighted gradients as the ellipse coefficients
``(a, b, c)`` that :func:`ellipse_to_laf` reads, ``(B, 1, 3)``, divided by the largest entry, as in
:cite:`baumberg2000`. It returns coefficients, not LAFs: to adapt LAFs on an image, use
:class:`LAFAffineShapeEstimator`, which runs it on each LAF's patch.

For float16 and bfloat16 inputs, the gradients, Gaussian weighting, moments, and normalization are computed
in float32; for a float64 input, the Gaussian weighting is built in float64.
The output keeps the input dtype.

Convention:
    - The output :math:`(a, b, c)` is :math:`(\langle g_x^2 \rangle, \langle g_x g_y \rangle,
      \langle g_y^2 \rangle)`, the means over the patch of the products of its Sobel gradients, x right and
      y down, each gradient weighted by a Gaussian centred on the patch. It is divided by its largest entry, which
      is therefore 1. When two of the three entries are below ``eps`` before that division -- a flat or
      low-contrast patch, or one whose gradient lies along an image axis -- the output is :math:`(1, 0, 1)`, a
      circle.
    - The patch must be ``patch_size`` pixels square.
    - Known defects: a negative :math:`b` counts as below ``eps``, so a patch and its mirror image can get a thin
      ellipse and a circle (`#5824 <https://github.com/kornia/kornia/issues/5824>`_).

Args:
    patch_size: the input image patch size.
    eps: for safe division.

See Also:
    - :class:`LAFAffineShapeEstimator`: runs it on each LAF's patch and adapts the LAF's shape to the result.
    - :class:`LAFAffNetShapeEstimator`: a learned shape, which AffNet predicts on each LAF's patch.
    - :class:`PatchDominantGradientOrientation`: the orientation of a patch, from the same Sobel gradients.
    - :func:`ellipse_to_laf`: turns a centre and these coefficients into a LAF.

c                ó*   <€ V ^8„  d   QhRS[ RS[RR/# )é   Ú
patch_sizeÚepsÚreturnN)ÚintÚfloat)ÚformatÚ__classdict__s   "€ÚWC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\feature\affine_shape.pyÚ__annotate__Ú&PatchAffineShapeEstimator.__annotate__T   s"   ø€ ÷ 
ñ 
¡3ð 
±%ð 
ÀDñ 
ó    c                ó*  <€ \         SV `  4        Wn        \        R ^4      V n        W n        \        V P                  4      \        P                  ! R4      ,          pV P                  R\        V P                  V P                  3W33R4      RR7       R# )Úsobelç       @Ú	weightingTF)Ú
persistentN)ÚsuperÚ__init__r   r   Úgradientr   r   ÚmathÚsqrtÚregister_bufferr
   )Úselfr   r   ÚsigmaÚ	__class__s   &&& €r!   r+   Ú"PatchAffineShapeEstimator.__init__T   sv   ø€ Ü‰ÑÔØ)ŒÜ#2°7¸AÓ#>ˆŒØŒÜ˜TŸ_™_Ó-´·	²	¸#³Õ>ˆà×ÑØÜ! 4§?¡?°D·O±OÐ"DÀuÀnÐVZÓ[Øð 	ö 	
r$   c                ó    <€ V ^8„  d   QhRS[ /# ©r   r   ©Ústr)r   r    s   "€r!   r"   r#   a   s   ø€ ÷ Zñ Z™#ñ Zr$   c                óh   € V P                   P                   R V P                   RV P                   R2# )ú(patch_size=z, eps=Ú))r2   Ú__name__r   r   ©r0   s   &r!   Ú__repr__Ú"PatchAffineShapeEstimator.__repr__a   s0   € Ø—.‘.×)Ñ)Ð*¨,°t·±Ð6GÀvÈdÏhÉhÈZÐWXÐYÐYr$   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r   Úpatchr   ©ÚtorchÚTensor)r   r    s   "€r!   r"   r#   d   s#   ø€ ÷ 3'ñ 3'™UŸ\™\ð 3'©e¯l©lñ 3'r$   c           	     óF  € \        VRR\        V P                  4      \        V P                  4      .4       VP                  pV\        P
                  \        P                  39   d   VP                  4       pV\        P
                  \        P                  \        P                  39   dm   \        V P                  4      \        P                  ! R4      ,          p\        V P                  V P                  3W33RVP                  VP                  R7      pM1V P                  P                  VP                  VP                  R7      pV P                  V4      V,          pVR,          pVR	,          p\        P                   ! VP#                  ^4      P%                  ^R7      P%                  ^RR7      Wg,          P%                  ^R7      P%                  ^RR7      VP#                  ^4      P%                  ^R7      P%                  ^RR7      .^R7      pW€P&                  8  P)                  ^RR7      ^8¬  p	VP+                  . R
O4      P-                  ^^^4      p
\        P.                  ! WšV4      pWˆP1                  ^RR7      ^ ,          ,          pVP                  V4      # )z{Run forward.

Args:
    patch: ``(B, 1, patch_size, patch_size)``

Returns:
    torch.Tensor: ellipse_shape ``(B, 1, 3)``

ÚBÚ1r'   T)ÚdeviceÚdtype©Údim©rJ   Úkeepdim)ºNNNrM   r   )rM   rM   é   ©ç      ð?ç        rP   )r   r7   r   rH   rB   Úfloat16Úbfloat16r   Úfloat64r-   r.   r
   rG   r(   Útor,   ÚcatÚpowÚmeanr   ÚsumÚ
new_tensorÚviewÚwhereÚmax)r0   r@   rH   r1   r(   ÚgradsÚgxÚgyÚellipse_shapeÚbad_maskÚcircular_shapes   &&         r!   ÚforwardÚ!PatchAffineShapeEstimator.forwardd   s  € ô 	˜5 3¨¬S°·±Ó-AÄ3ÀtÇÁÓCWÐ"XÔYØ—‘ˆØ”U—]‘]¤E§N¡NÐ3Ô3à—K‘K“MˆEØ”U—]‘]¤E§N¡N´E·M±MÐBÔBô ˜$Ÿ/™/Ó*¬T¯YªY°s«^Õ;ˆEÜ-Ø—‘ $§/¡/Ð2Ø�ØØ—|‘|Ø—k‘kô‰Ið Ÿ™×)Ñ)°·±ÀUÇ[Á[Ð)ÓQˆIØ"Ÿm™m¨EÓ2°YÕ>ˆà  �>ˆØ  �>ˆäŸ	š	à—‘�q“	—‘ 1�Ó%×*Ñ*¨q¸$Ð*Ó?Ø•—‘ 1�Ó%×*Ñ*¨q¸$Ð*Ó?Ø—‘�q“	—‘ 1�Ó%×*Ñ*¨q¸$Ð*Ó?ðð
 ô
ˆð "§H¡HÑ,×1Ñ1°aÀÐ1ÓFÈ!ÑKˆà&×1Ñ1²/ÓB×GÑGÈÈ1ÈaÓPˆÜŸš H¸mÓLˆà%×(9Ñ(9¸aÈÐ(9Ó(NÈqÕ(QÕQˆØ×Ñ Ó&Ð&r$   )r   r,   r   )é   g»½×Ùß|Û=©r;   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r+   r=   rd   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r2   r    s   @@r!   r   r   0   s0   ù‡ € ñ!÷F
õ 
÷Zð Z÷3'÷ 3'ð 3'r$   r   c                óŽ   € V ^8„  d   QhR\         P                  R\        \         P                  \         P                  3,          /# )r   Úlafr   )rB   rC   Útuple)r   s   "r!   r"   r"   š   s4   € ÷ Lñ L”u—|‘|ð L¬¬e¯l©l¼E¿L¹LÐ.HÕ(Iñ Lr$   c                 ó¤  € \        V 4      ( pV P                  R R.RR ..4      P                  ! . V P                  R,          ORNRN5!  p\        P
                  ! V R,          P                  4       V R,          \        P                  ! V R,          4      4      p\        P                  ! W#.RR7      p\        P
                  ! VR,          W@4      V3# )rP   rQ   ºNr   NrI   éÿÿÿÿ©.ºr   é   N©.NN)	r   rZ   ÚexpandÚshaperB   r\   ÚisfiniteÚ
zeros_likerV   )rq   ÚinvalidÚunitÚcenterÚreplacements   &    r!   Ú_sanitize_lafr‚   š   s¬   € Ü˜CÓ Ð €GØ�>‰>˜C ˜:¨¨S zÐ2Ó3×:Ò:ÐR¸C¿I¹IÀb½MÐRÈ2ÐRÈrÓR€DÜ�[Š[˜˜X�×/Ñ/Ó1°3°xµ=Ä%×BRÒBRÐSVÐW_ÕS`ÓBaÓb€FÜ—)’)˜T˜N°Ô3€KÜ�;Š;�w˜Õ/°ÓBÀGÐKÐKr$   c                óx   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  /# )r   Ú	shape_lafÚframer   rA   )r   s   "r!   r"   r"   ¢   s2   € ÷ Uñ U¤5§<¡<ð U¼¿¹ð UÌÏÉñ Ur$   c                 ó�   € VR,          \        V4      ,          p\        P                  ! W R,          ,          V R,          .RR7      # ).rI   ©.rt   ).:r   NNru   )r   rB   rV   )r„   r…   Úframe_shapes   && r!   Ú_compose_with_framer‰   ¢   s;   € ð
 ˜•.¤=°Ó#7Õ7€KÜ�9Š9�k¨gÕ$6Õ6¸	À'Õ8JÐKÐQSÔTÐTr$   c                ó°   € V ^8„  d   QhR\         P                  R\         P                  R\        R\         P                  R\        R\         P                  /# )r   Úlaf_outrq   Úpreserve_orientationÚbadÚmake_candidate_uprightr   )rB   rC   Úbool)r   s   "r!   r"   r"   «   s\   € ÷ Eñ EÜ�\‰\ðEä	�‰ðEô ðEô 
�‰ð	Eô
 !ðEô ‡\�\ñEr$   c                 ó\  € \        V4      w  rVW6,          pV'       d   TM
\        V4      pV'       d   TpMZ\        P                  ! \        P                  ! VR,          4      VR,          .RR7      p	\        P
                  ! VR,          W—4      p\        P
                  ! VR,          Wp4      p
\        V4      pV'       d   \        V4      p\        V
4      pV'       d   \        V
4      p
\        W«V,          4      p
V'       d   \        V
X4      p
\        P
                  ! VR,          WŠ4      # ).rI   r‡   rv   ru   ry   )
r‚   r   rB   rV   r}   r\   r   r   r   r   )r‹   rq   rŒ   r�   rŽ   Ú
safe_inputÚinvalid_inputÚsafe_fallbackÚfallbackÚzero_scale_uprightÚsafe_laf_outÚ
scale_origÚori_origÚellipse_scales   &&&&&         r!   Ú_finalize_lafrš   «   sè   € ô !.¨cÓ 2Ñ€JØ
Õ
€Cß"6‘J¼LÈÓ<T€MßØ‰ä"ŸYšY¬×(8Ò(8¸¸W½Ó(FÈÈHÍÐ'VÐ\^Ô_ÐÜ—;’;˜}¨_Õ=Ð?QÓaˆô —;’;˜s ?Õ3°]ÓL€LÜ˜zÓ*€JßÜ& zÓ2ˆÜ! ,Ó/€MßÜ# LÓ1ˆÜ˜\¸Õ+EÓF€LßÜ*¨<¸ÓBˆÜ�;Š;�s˜?Õ+¨XÓDÐDr$   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
# )
ÚLAFAffineShapeEstimatoraI  Adapt the affine shape of LAFs to the second-moment matrix of each LAF's image patch.

``lafs = LAFAffineShapeEstimator(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 through its upright frame, estimates the shape with
``affine_shape_detector`` (:class:`PatchAffineShapeEstimator` by default) and returns the ``(B, N, 2, 3)`` LAFs
with the adapted shape and the input's centres and scales. For the shape that AffNet predicts, use
:class:`LAFAffNetShapeEstimator` instead; to drop the rotation and the reflection and keep the shape, without
reading the image, use :func:`make_upright`.

Convention:
    - Each patch is sampled through the upright form of its LAF (:func:`~kornia.feature.make_upright`), so the
      shape is estimated in the coordinates of that frame, and the output region is the frame composed with the
      estimated shape. The estimated shape's ellipse :math:`A A^\top` is proportional to the inverse of the second
      moment matrix that ``affine_shape_detector`` returns. For an isotropic input LAF (a circle), the output shape
      is the estimated shape itself. An input whose shape already matches the local structure gives a nearly
      isotropic patch, so its shape changes little: one call is one step of the iterative shape adaptation of
      :cite:`baumberg2000`.
    - The centre and the scale of the input LAF are kept. With ``preserve_orientation=True`` (the default) its
      orientation is kept too; otherwise the output is upright, and an orientation estimator such as
      :class:`~kornia.feature.LAFOrienter` can be run after this module.
    - An adapted LAF has a positive determinant: a mirrored input loses its reflection. A LAF that
      :func:`~kornia.feature.laf_is_valid` rejects, such as the all-zero padding of a detector's unfilled slot,
      comes back unchanged with ``preserve_orientation=True``, and with a zero ``A`` and its centre otherwise. A
      valid LAF whose patch gives no finite, positive-definite shape is not adapted either: it comes back
      unchanged with ``preserve_orientation=True``, and as :func:`~kornia.feature.make_upright` returns it
      otherwise.

Args:
    patch_size: the input image patch size.
    affine_shape_detector: Patch affine shape estimator, :class:`~kornia.feature.PatchAffineShapeEstimator`.
    preserve_orientation: if True, the original orientation is preserved.

See Also:
    - :class:`LAFAffNetShapeEstimator`: the same adaptation, with the shape that AffNet predicts.
    - :class:`PatchAffineShapeEstimator`: the default ``affine_shape_detector``, on patches.
    - :func:`make_upright`: drops the rotation and the reflection of a LAF and keeps its shape, without the image.
    - :class:`LAFOrienter`: estimates the orientation, run after this module with ``preserve_orientation=False``.

c                óT   <€ V ^8„  d   QhRS[ RS[S[P                  ,          RS[RR/# )r   r   Úaffine_shape_detectorrŒ   r   N)r   r   r   ÚModuler�   )r   r    s   "€r!   r"   Ú$LAFAffineShapeEstimator.__annotate__ò   s6   ø€ ÷ 9ñ 9Ùð9Ù;CÁBÇIÁIÕ;Nð9Ùmqð9à	ñ9r$   c                ó„   <€ \         SV `  4        Wn        T;'       g    \        V P                  4      V n        W0n        R # )N)r*   r+   r   r   rž   rŒ   )r0   r   rž   rŒ   r2   s   &&&&€r!   r+   Ú LAFAffineShapeEstimator.__init__ò   s8   ø€ ô 	‰ÑÔØ$ŒØ%:×%hÐ%hÔ>WÐX\×XgÑXgÓ>hˆÔ"Ø$8Ö!r$   c                ó    <€ V ^8„  d   QhRS[ /# r5   r6   )r   r    s   "€r!   r"   r    ú   s   ø€ ÷ 
ñ 
™#ñ 
r$   c                ó‚   € V P                   P                   R V P                   RV P                   RV P                   R2# )r9   z, affine_shape_detector=z, preserve_orientation=r:   )r2   r;   r   rž   rŒ   r<   s   &r!   r=   Ú LAFAffineShapeEstimator.__repr__ú   sN   € à�~‰~×&Ñ&Ð'Ø˜4Ÿ?™?Ð+ð ,%Ø%)×%?Ñ%?Ð$@ð A$Ø$(×$=Ñ$=Ð#>¸aðAð	
r$   c                óh   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  /# ©r   rq   Úimgr   rA   )r   r    s   "€r!   r"   r      s3   ø€ ÷ %Kñ %K™5Ÿ<™<ð %K©e¯l©lð %K¹u¿|¹|ñ %Kr$   c                óh  € \        V4       \        V. RO4       VP                  R,          w  r4V P                  p\	        V4      w  rg\        V4      p\        W(VR4      P                  R^WU4      p	V P                  V	4      p
V
R,          V
R,          ,          V
R,          P                  4       ,
          pV
R,          V
R,          V
R,          P                  4       ,          P                  4       ,
          pV
P                  4       P                  RR7      ( VP                  4       ( ,          V
R,          ^ 8*  ,          V
R,          ^ 8*  ,          V^ 8*  ,          V^ 8„  ( ,          pV
P                  . R	O4      p\        P                  ! VR
,          Wê4      p\        P                   ! VP                  R^^4      R,          P#                  ^4      V.^R7      P                  W4^4      p\%        \'        V4      V4      pVP                  W44      \)        V4      ( ,          p\+        VWP,                  V4      # )úqRun forward.

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

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

rt   TrI   ©rE   rF   ÚHÚWru   ).r   ).r   ).rN   rO   ).N)r   r   r{   r   r‚   r   r   r[   rž   Úsquarer.   r|   ÚallrZ   rB   r\   rV   Ú	unsqueezer‰   r   r   rš   rŒ   )r0   rq   r¨   rE   ÚNÚPSr‘   Ú_r…   Úpatchesra   Úellipse_detÚellipse_schurÚ	bad_shaperc   Úsafe_ellipse_shapeÚellipsesr‹   r�   s   &&&                r!   rd   ÚLAFAffineShapeEstimator.forward  sù  € ô 	˜ÔÜ˜3Ò 4Ô5Ø�y‰y˜�}‰ˆØ—/‘/ˆÜ% cÓ*‰ˆ
Ü˜ZÓ(ˆÜ <¸SÈÈTÓ R× WÑ WÐXZÐ\]Ð_aÓ fˆØ&*×&@Ñ&@ÀÓ&IˆØ# FÕ+¨m¸FÕ.CÕCÀmÐTZÕF[×FbÑFbÓFdÕdˆð & fÕ-°¸vÕ1FÈÐW]ÕI^×IcÑIcÓIeÕ1e×0mÑ0mÓ0oÕoˆà×#Ñ#Ó%×)Ñ)¨bÐ)Ó1Ð1Ø×#Ñ#Ó%Ð%õ&à˜VÕ$¨Ñ)õ+ð ˜VÕ$¨Ñ)õ+ð ˜aÑõ	!ð
  Ñ!Ð"õ#ð 	ð '×1Ñ1²/ÓBˆÜ"Ÿ[š[¨°9Õ)=¸~Ó]ÐÜ—9’9˜cŸh™h r¨1¨aÓ0°Õ8×BÑBÀ1ÓEÐGYÐZÐ`aÔb×gÑgÐhiÐnoÓpˆÜ%¤n°XÓ&>ÀÓFˆØ�n‰n˜QÓ"¤l°7Ó&;Ð%;Õ;ˆÜ˜W c×+DÑ+DÀcÓJÐJr$   )rž   r   rŒ   )é    NTrg   ro   s   @@r!   rœ   rœ   É   s1   ù‡ € ñ&÷P9õ 9÷
ð 
÷%K÷ %Kð %K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]RV3R lR ll4       tV3R lR ltR	t	Vt
V ;t# )ÚLAFAffNetShapeEstimatori*  a|  Adapt the affine shape of LAFs to the shape the learned AffNet CNN predicts on each LAF's patch.

``lafs = LAFAffNetShapeEstimator()(laf, img)`` builds AffNet with its pretrained weights, in eval mode, and takes
``(B, N, 2, 3)`` LAFs in pixels and their grayscale images ``(B, 1, H, W)``, predicts each LAF's shape on its
32 x 32 patch, sampled through its upright frame, and returns the ``(B, N, 2, 3)`` LAFs with that shape and the
input's centres and scales. :class:`GFTTAffNetHardNet`, :class:`HesAffNetHardNet`, :class:`DoGAffNetHardNet` and
:class:`KeyNetAffNetHardNet` run it with ``preserve_orientation=False``, before their orientation step. For the
second-moment estimate, which needs no weights, use :class:`LAFAffineShapeEstimator` 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:
    As :class:`~kornia.feature.LAFAffineShapeEstimator`, with AffNet's prediction on a 32 x 32 patch in place of
    the second moment estimate; see its Convention block for the frame the patch is sampled through and for what
    the output keeps of the input LAF.

Args:
    pretrained: Download and set pretrained weights to the model.
    preserve_orientation: if True, the original orientation is preserved.

See Also:
    - :class:`LAFAffineShapeEstimator`: the same adaptation, with the second-moment matrix and no weights.
    - :class:`OriNet`: the orientation network of the same paper.
    - :class:`KeyNetAffNetHardNet`: a local feature that runs it on KeyNet detections, before OriNet and HardNet.

c                ó*   <€ V ^8„  d   QhRS[ RS[ RR/# )r   Ú
pretrainedrŒ   r   N)r�   )r   r    s   "€r!   r"   Ú$LAFAffNetShapeEstimator.__annotate__F  s#   ø€ ÷  9ñ  9¡4ð  9Ádð  9ÐVZñ  9r$   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
        ^ V n        V'       dW   \        \        R,          \        P                  ! R4      R	7      pV P!                  VR
,          RR7       V P#                  4        W n        R# )rN   F)Úkernel_sizeÚpaddingÚbias)Úaffine)rÂ   ÚstriderÃ   rÄ   g      Ð?Tr   Úcpu)Úmap_locationÚ
state_dict)ÚstrictN)r*   r+   r   Ú
SequentialÚConv2dÚBatchNorm2dÚReLUÚDropoutÚTanhÚAdaptiveAvgPool2dÚfeaturesr   r	   ÚurlsrB   rG   Úload_state_dictÚevalrŒ   )r0   r¿   rŒ   Úpretrained_dictr2   s   &&& €r!   r+   Ú LAFAffNetShapeEstimator.__init__F  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Ø$8Ö!r$   c                óT   <€ V ^8„  d   QhRS[ P                  RS[RS[ P                  /# )r   Úxr   r   )rB   rC   r   )r   r    s   "€r!   r"   rÀ   i  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``.TrK   )éýÿÿÿéþÿÿÿru   )rB   rX   ÚstdÚdetach)rÙ   r   ÚmpÚsps   &&  r!   Ú_normalize_inputÚ(LAFAffNetShapeEstimator._normalize_inputh  sH   € ô �ZŠZ˜˜|°TÔ:ˆÜ�YŠY�q˜l°DÔ9ˆð —I‘I“K• B§I¡I£K°#Õ$5Õ6Ð6r$   c                óh   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  /# r§   rA   )r   r    s   "€r!   r"   rÀ   s  s3   ø€ ÷ hñ h™5Ÿ<™<ð h©e¯l©lð h¹u¿|¹|ñ hr$   c           	     ó˜  € \        V4       \        V. RO4       VP                  R,          w  r4V P                  p\	        V4      w  rg\        V4      p\        W(VR4      P                  R^WU4      p	V P                  \        V P                  V	4      4      4      P                  R^4      p
\        P                  ! RV
R,          P                  R^^4      ,           ^ V
R,          P                  R^^4      ,          .^R7      p\        P                  ! V
R	,          P                  R^^4      RV
R
,          P                  R^^4      ,           .^R7      p\        P                  ! W¼.^R7      P                  W4^^4      p\        \        P                  ! WÑR,          .^R7      V4      p\        V4      ( p\!        WáV P"                  VRR7      # )rª   rt   TrP   rI   )rŽ   r«   ru   )rM   r   )rM   rN   )rM   r   )rM   rM   rM   rw   )r   r   r{   r   r‚   r   r   r[   rÒ   r   rá   rB   rV   Úreshaper‰   r   rš   rŒ   )r0   rq   r¨   rE   r±   r²   r‘   r³   r…   r´   ÚxyÚa1Úa2Únew_laf_no_centerÚnew_lafr�   s   &&&             r!   rd   ÚLAFAffNetShapeEstimator.forwards  s†  € ô 	˜ÔÜ˜3Ò 4Ô5Ø�y‰y˜�}‰ˆØ—/‘/ˆÜ% cÓ*‰ˆ
Ü˜ZÓ(ˆÜ <¸SÈÈTÓ R× WÑ WÐXZÐ\]Ð_aÓ fˆØ�]‰]Ô-¨d×.CÑ.CÀGÓ.LÓMÓN×SÑSÐTVÐXYÓZˆÜ�YŠY˜˜b �h×.Ñ.¨r°1°aÓ8Õ8¸!¸bÀ½h×>NÑ>NÈrÐSTÐVWÓ>XÕ:XÐYÐ_`ÔaˆÜ�YŠY˜˜4�×(Ñ(¨¨Q°Ó2°C¸"¸T½(×:JÑ:JÈ2ÈqÐRSÓ:TÕ4TÐUÐ[\Ô]ˆÜ!ŸIšI r h°AÔ6×>Ñ>¸qÀQÈÓJÐÜ%¤e§i¢iÐ1BÈÕDUÐ0VÐ\]Ô&^Ð`eÓfˆÜ˜GÓ$Ð$ˆÜ˜W¨4×+DÑ+DÀcÐbfÔgÐgr$   )rÒ   r   rŒ   )TT)g�íµ ÷Æ°>)r;   rh   ri   rj   rk   r+   Ústaticmethodrá   rd   rl   rm   rn   ro   s   @@r!   r½   r½   *  s@   ù‡ € ñ÷6 9õ  9ðD ÷7ñ 7ó ð7÷h÷ hð hr$   r½   c                óŽ   € V ^8„  d   Qh/ ^ \         9   d1   \        \        \        \        \        ,          ,          3,          ;R&   # )r   rÓ   )Ú__conditional_annotations__r   r7   Úlist)r   s   "r!   r"   r"      s*   € ‡�÷. &Ò %„dŒ3””dœ3•i•ÐÕ Ñ %ò/ r$   )F)%rî   r-   Útypingr   r   rB   r   Úkornia.core.checkr   r   Úkornia.core.downloadr   r	   Úkornia.filters.kernelsr
   Úkornia.filters.sobelr   Ú_layoutr   rq   r   r   r   r   r   r   r   r   rÓ   rŸ   r   r‚   r‰   rš   rœ   r½   r"   )rî   s   @r!   Ú<module>rö      s¤   øð÷$ €ß !ã Ý ç Bß AÝ 8Ý 0å '÷	÷ 	ó 	ð $&€Ó %á
ˆ8�\Ó"ØKð€€X�ôg' §	¡	ô g'õTLõU÷Eô<^K˜bŸi™iô ^KôBah˜bŸi™iö ahr$   