+
    åûj‰  ã                  ót   € ^ RI Ht ^ RIt^ RIHt R R ltR R ltR R	 lt ! R
 R]P                  4      tR# )é    )ÚannotationsN)Únnc               ó    € V ^8„  d   QhRRRR/# ©é   Úimgútorch.TensorÚreturn© )Úformats   "ÚVC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\losses\depth_smooth.pyÚ__annotate__r      ó   € ÷ 0ñ 0�\ð 0 lñ 0ó    c                óš   € \        V P                  4      ^8w  d   \        V P                  4      hV RRRRR13,          V R,          ,
          # )é   ºNNNNéÿÿÿÿ)r   r   r   ºé   NN©ÚlenÚshapeÚAssertionError©r   s   &r   Ú_gradient_xr      sB   € Ü
ˆ3�9‰9ƒ~˜ÔÜ˜SŸY™YÓ'Ð'Øˆq�!�Q˜˜˜ˆ|Õ˜s ;Õ/Õ/Ð/r   c               ó    € V ^8„  d   QhRRRR/# r   r   )r   s   "r   r   r   !   r   r   c                óš   € \        V P                  4      ^8w  d   \        V P                  4      hV RRRR1R3,          V R,          ,
          # )r   r   Nr   )r   r   r   r   r   r   s   &r   Ú_gradient_yr   !   sB   € Ü
ˆ3�9‰9ƒ~˜ÔÜ˜SŸY™YÓ'Ð'Øˆq�!�S�b�S˜!ˆ|Õ˜s ;Õ/Õ/Ð/r   c               ó$   € V ^8„  d   QhRRRRRR/# ©r   Úidepthr	   Úimager
   r   )r   s   "r   r   r   '   s'   € ÷ N?ñ N?¨,ð N?¸|ð N?ÐP\ñ N?r   c                ód  € \        V \        P                  4      '       g   \        R\	        V 4       24      h\        V\        P                  4      '       g   \        R\	        V4       24      h\        V P                  4      ^8X  g   \        RV P                   24      h\        VP                  4      ^8X  g   \        RVP                   24      hV P                  RR VP                  RR 8X  g&   \        RV P                   RVP                   24      hV P                  VP                  8X  g&   \        RV P                   RVP                   24      hV P                  VP                  8X  g&   \        R	V P                   RVP                   24      h\        V 4      p\        V 4      p\        V4      p\        V4      p\        P                  ! \        P                  ! \        P                  ! V4      ^R
R7      ) 4      p\        P                  ! \        P                  ! \        P                  ! V4      ^R
R7      ) 4      p\        P                  ! W&,          4      p\        P                  ! W7,          4      p	\        P                  ! V4      \        P                  ! V	4      ,           # )aë  Compute the edge-aware smoothness loss of an inverse depth map.

``loss = inverse_depth_smoothness_loss(idepth, image)`` penalises the horizontal and vertical gradients of
an ``(N, 1, H, W)`` inverse depth. Each is weighted by the exponential of minus the gradient of the
``(N, 3, H, W)`` image, so a depth edge costs little where the image has an edge.

.. math::

    \text{loss} = \operatorname{mean}_{nij} \left| \partial_x d_{nij} \right|
    e^{-\frac{1}{C} \sum_c \left| \partial_x I_{ncij} \right|}
    + \operatorname{mean}_{nij} \left| \partial_y d_{nij} \right|
    e^{-\frac{1}{C} \sum_c \left| \partial_y I_{ncij} \right|}

with forward differences :math:`\partial_x` and :math:`\partial_y`, each mean taken over its own differences.

Convention:
    - ``idepth`` is penalised and ``image`` only sets the weights: a constant inverse depth gives 0 for any image,
      and a constant image gives the plain mean of :math:`|\partial_x d|` plus that of :math:`|\partial_y d|`.
    - The weights use the raw image values, so ``image`` is expected in a unit range: in ``[0, 255]``, a step of
      a few levels already drives its weight to about 0.
    - ``idepth`` is not normalised, so the loss is linear in its scale;
      :ref:`Losses and metrics <losses-metrics-conventions>` shows how to port a normalised smoothness term.
    - Only the rank, ``(H, W)``, device and dtype are validated: the channel counts are not, a batch of one
      broadcasts against the other argument, and swapped arguments return a value.

Args:
    idepth: inverse depth with shape ``(N, 1, H, W)``.
    image: image with shape ``(N, 3, H, W)``, in the dtype of ``idepth``.

Returns:
    the loss, a scalar.

See Also:
    - :class:`~kornia.losses.InverseDepthSmoothnessLoss`: the module form.
    - :func:`~kornia.losses.total_variation`: the smoothness of one image, with no weights.

Examples:
    >>> idepth = torch.rand(1, 1, 4, 5)
    >>> image = torch.rand(1, 3, 4, 5)
    >>> loss = inverse_depth_smoothness_loss(idepth, image)

z-Input idepth type is not a torch.Tensor. Got z,Input image type is not a torch.Tensor. Got z.Invalid idepth shape, we expect BxCxHxW. Got: z-Invalid image shape, we expect BxCxHxW. Got: Nz/idepth and image shapes must be the same. Got: z and z2idepth and image must be in the same device. Got: z1idepth and image must be in the same dtype. Got: T)ÚdimÚkeepdiméþÿÿÿ)Ú
isinstanceÚtorchÚTensorÚ	TypeErrorÚtyper   r   Ú
ValueErrorÚdeviceÚdtyper   r   ÚexpÚmeanÚabs)
r"   r#   Ú	idepth_dxÚ	idepth_dyÚimage_dxÚimage_dyÚ	weights_xÚ	weights_yÚsmoothness_xÚsmoothness_ys
   &&        r   Úinverse_depth_smoothness_lossr;   '   s  € ôV �fœeŸl™l×+Ò+ÜÐGÌÈVËÀ~ÐVÓWÐWä�eœUŸ\™\×*Ò*ÜÐFÄtÈEÃ{ÀmÐTÓUÐUäˆv�|‰|Ó Ô!ÜÐIÈ&Ï,É,ÈÐXÓYÐYäˆu�{‰{Ó˜qÔ ÜÐHÈÏÉÈÐVÓWÐWà�<‰<˜˜Ð §¡¨B¨CÐ 0Ô0ÜÐJÈ6Ï<É<È.ÐX]Ð^c×^iÑ^iÐ]jÐkÓlÐlà�=‰=˜EŸL™LÔ(ÜÐMÈfÏmÉmÈ_Ð\aÐbg×bnÑbnÐaoÐpÓqÐqà�<‰<˜5Ÿ;™;Ô&ÜÐLÈVÏ\É\ÈNÐZ_Ð`e×`kÑ`kÐ_lÐmÓnÐnô *¨&Ó1€IÜ)¨&Ó1€IÜ(¨Ó/€HÜ(¨Ó/€Hô $Ÿiši¬¯ª´E·I²I¸hÓ4GÈQÐX\Ô)]Ð(]Ó^€IÜ#Ÿiši¬¯ª´E·I²I¸hÓ4GÈQÐX\Ô)]Ð(]Ó^€Iô "'§¢¨9Õ+@Ó!A€LÜ!&§¢¨9Õ+@Ó!A€Lä�:Š:�lÓ#¤e§j¢j°Ó&>Õ>Ð>r   c                  ó&   € ] tR t^xtRtR R ltRtR# )ÚInverseDepthSmoothnessLossa·  Compute the edge-aware smoothness loss of an inverse depth map (module form).

``smooth = InverseDepthSmoothnessLoss()`` takes no arguments, and ``loss = smooth(idepth, image)`` is
:func:`~kornia.losses.inverse_depth_smoothness_loss`.

Convention:
    See the Convention block of :func:`~kornia.losses.inverse_depth_smoothness_loss`.

Shape:
    - Inverse Depth: ``(N, 1, H, W)``
    - Image: ``(N, 3, H, W)``
    - Output: scalar

See Also:
    - :func:`~kornia.losses.inverse_depth_smoothness_loss`: the one-call form.

Examples:
    >>> idepth = torch.rand(1, 1, 4, 5)
    >>> image = torch.rand(1, 3, 4, 5)
    >>> smooth = InverseDepthSmoothnessLoss()
    >>> loss = smooth(idepth, image)

c               ó$   € V ^8„  d   QhRRRRRR/# r!   r   )r   s   "r   r   Ú'InverseDepthSmoothnessLoss.__annotate__‘   s!   € ÷ <ñ <˜lð <°<ð <ÀLñ <r   c                ó   € \        W4      # )a¯  Compute image-aware smoothness regularization for inverse depth.

Args:
    idepth: Inverse-depth tensor with shape ``(B, 1, H, W)``.
    image: RGB image tensor with shape ``(B, 3, H, W)`` used to
        reduce the smoothness penalty across visible image edges.

Returns:
    Scalar tensor containing the edge-aware smoothness loss. Smoothness
    is encouraged in flat image regions and relaxed near strong image
    gradients.
)r;   )Úselfr"   r#   s   &&&r   ÚforwardÚ"InverseDepthSmoothnessLoss.forward‘   s   € ô -¨VÓ;Ð;r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rB   Ú__static_attributes__r   r   r   r=   r=   x   s   † ñ÷0<ñ <r   r=   )	Ú
__future__r   r)   r   r   r   r;   ÚModuler=   r   r   r   Ú<module>rL      s1   ðõ$ #ã Ý õ0õ0õN?ôb&< §¡ö &<r   