+
    åûjÃ  ã                   óp   € ^ RI t ^ RI HtHt ^ RIHtHtHt RR R llt ! R R]P                  4      t	]t
R# )	é    N)ÚTensorÚnn)ÚKORNIA_CHECKÚKORNIA_CHECK_IS_TENSORÚKORNIA_CHECK_SHAPEc                ó„   € V ^8„  d   QhR\         P                  R\         P                  R\        R\         P                  /# )é   ÚinputÚtargetÚ	reductionÚreturn)Útorchr   Ústr)Úformats   "ÚYC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\metrics\endpoint_error.pyÚ__annotate__r      sC   € ÷ H\ñ H\”—‘ð H\¤e§l¡lð H\¼sð H\ÔPU×P\ÑP\ñ H\ó    c                ó  € \        V 4       \        V4       \        V RR.4       \        VRR.4       \        V P                  VP                  8H  RV P                   RVP                   24       \        P
                  ! V P                  VP                  4      pV\        P                  \        P                  39   d    V P                  4       VP                  4       rV R	,          VR	,          ,
          ^,          V R
,          VR
,          ,
          ^,          ,           pV^ 8H  p\        P                  ! V\        P                  ! V4      V4      p\        P                  ! V\        P                  ! V4      VP                  4       4      pVR8X  d   VP                  4       pM+VR8X  d   VP                  4       pMVR8X  d   M\!        R4      hV\        P                  \        P                  39   d   VP#                  V4      # T# )a7  Compute the average endpoint error (AEPE) between two flow maps.

``epe = aepe(input, target)`` takes two channel-last flows ``(*, 2)``, such as ``(B, H, W, 2)``, and returns the
mean Euclidean distance between their vectors, in the units of the flow. For an ``h x w`` flow the AEPE is:

.. math::

    \text{AEPE}=\frac{1}{hw}\sum_{i=1, j=1}^{h, w}\sqrt{(I_{i,j,1}-T_{i,j,1})^{2}+(I_{i,j,2}-T_{i,j,2})^{2}}

Convention:
    - A channel-first ``(B, 2, H, W)`` flow must be permuted to ``(B, H, W, 2)`` first: it raises unless
      :math:`W = 2`, where it is read wrongly. :ref:`Losses and metrics <losses-metrics-conventions>` ports
      RAFT's endpoint error.
    - The distance is symmetric in ``input`` and ``target`` and not normalized by the image size.
      ``reduction='mean'`` averages it over every position of every sample at once and ``'sum'`` adds it up,
      both into a 0-d tensor; ``'none'`` returns the ``(*)`` map. There is no valid mask: mask sparse ground
      truth on the ``'none'`` map. An unknown ``reduction`` raises ``NotImplementedError``.
    - :func:`~kornia.metrics.aepe` and :func:`~kornia.metrics.average_endpoint_error` are the same function.
    - Float16 and bfloat16 inputs are computed in float32 and the result is returned in their promoted dtype.

Args:
    input: the predicted flow with shape ``(*, 2)``.
    target: the ground-truth flow with the shape of ``input``.
    reduction: ``'mean'`` (default) averages, ``'sum'`` adds and ``'none'`` keeps the endpoint-error map.

Returns:
    a 0-d tensor, or the map of shape ``(*)`` for ``reduction='none'``.

See Also:
    - :class:`~kornia.metrics.AEPE`: the module form.

Examples:
    >>> ones = torch.ones(4, 4, 2)
    >>> aepe(ones, 1.2 * ones)
    tensor(0.2828)

Reference:
    https://link.springer.com/content/pdf/10.1007/s11263-010-0390-2.pdf

Ú*Ú2z/input and target shapes must be the same. Got: z and ÚmeanÚsumÚnonezInvalid reduction option.).r   ).é   )r   r   r   Úshaper   Úpromote_typesÚdtypeÚfloat16Úbfloat16ÚfloatÚwhereÚ	ones_likeÚ
zeros_likeÚsqrtr   r   ÚNotImplementedErrorÚto)r
   r   r   Úoutput_dtypeÚsq_distÚis_matchÚsafe_sq_distÚepes   &&&     r   Úaeper,      s�  € ôR ˜5Ô!Ü˜6Ô"Ü�u˜s C˜jÔ)Ü�v  S˜zÔ*ÜØ�‰�v—|‘|Ñ#Ð'VÐW\×WbÑWbÐVcÐchÐio×iuÑiuÐhvÐ%wôô ×&Ò& u§{¡{°F·L±LÓA€LàœŸ™¤u§~¡~Ð6Ô6ØŸ™› v§|¡|£~ˆvà˜V•} v¨f¥~Õ5¸!Õ;¸uÀV½}ÈvÐV\Í~Õ?]ÐbcÕ>cÕc€Gð
 ˜!‰|€HÜ—;’;˜x¬¯ª¸Ó)AÀ7ÓK€LÜ—+’+˜h¬×(8Ò(8¸Ó(AÀ<×CTÑCTÓCVÓW€Cà�FÔØ�h‰h‹j‰Ø	�eÔ	Ø�g‰g‹i‰Ø	�fÔ	Øä!Ð"=Ó>Ð>à#/´E·M±MÄ5Ç>Á>Ð3RÔ#Rˆ3�6‰6�,ÓÐ[ÐX[Ð[r   c                   óX   a a€ ] tR t^ct 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	# )ÚAEPEa  Compute the average endpoint error (AEPE) between two flow maps (module form).

``criterion = AEPE(reduction)`` stores ``reduction``, and ``epe = criterion(input, target)`` is
:func:`~kornia.metrics.aepe` on two ``(*, 2)`` flows.

Convention:
    See the Convention block of :func:`~kornia.metrics.aepe`.

Args:
    reduction: ``'mean'`` (default), ``'sum'`` or ``'none'``, as in :func:`~kornia.metrics.aepe`.

Shape:
    - input: ``(*, 2)``.
    - target: ``(*, 2)``.
    - output: ``()`` for ``'mean'`` and ``'sum'``, ``(*)`` for ``'none'``.

See Also:
    - :func:`~kornia.metrics.aepe`: the one-call form.

Examples:
    >>> input1 = torch.rand(1, 4, 5, 2)
    >>> input2 = torch.rand(1, 4, 5, 2)
    >>> epe = AEPE(reduction="mean")
    >>> epe = epe(input1, input2)

c                ó$   <€ V ^8„  d   QhRS[ RR/# )r	   r   r   N)r   )r   Ú__classdict__s   "€r   r   ÚAEPE.__annotate__   s   ø€ ÷ (ñ (¡#ð (°4ñ (r   c                ó0   <€ \         SV `  4        Wn        R # )N)ÚsuperÚ__init__r   )Úselfr   Ú	__class__s   &&€r   r4   ÚAEPE.__init__   s   ø€ Ü‰ÑÔØ'Žr   c                óh   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  /# )r	   r
   r   r   )r   r   )r   r0   s   "€r   r   r1   ƒ   s.   ø€ ÷ 3ñ 3™UŸ\™\ð 3±5·<±<ð 3ÁEÇLÁLñ 3r   c                ó.   € \        WV P                  4      # )a  Compute average endpoint error between vector fields.

Args:
    input: Predicted vector field with shape ``(B, H, W, 2)``.
    target: Target vector field with the same shape as ``input``.

Returns:
    Endpoint-error tensor reduced according to ``self.reduction``.
    The endpoint error is the Euclidean distance between predicted and
    target vectors at each spatial location.
)r,   r   )r5   r
   r   s   &&&r   ÚforwardÚAEPE.forwardƒ   s   € ô �E 4§>¡>Ó2Ð2r   )r   ©r   )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r4   r:   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r6   r0   s   @@r   r.   r.   c   s#   ù‡ € ñ÷6(õ (÷3÷ 3ð 3r   r.   r<   )r   r   r   Úkornia.core.checkr   r   r   r,   ÚModuler.   Úaverage_endpoint_error© r   r   Ú<module>rI      s4   ðó$ ß ç VÑ V÷H\ôV,3ˆ2�9‰9ô ,3ð^ Ò r   