+
    åûj!  ã                  ól   € ^ RI Ht ^ RIt^ RIHt ^ RIHt R	R R llt ! R R]P                  4      tR# )
é    )ÚannotationsN)Únn)Úmetricsc               ó8   € V ^8„  d   QhRRRRRRRRRRR	R
RR
RR/# )é   Úimg1útorch.TensorÚimg2Úwindow_sizeÚintÚmax_valÚfloatÚepsÚ	reductionÚstrÚpaddingÚreturn© )Úformats   "ÚPC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\losses\ssim3d.pyÚ__annotate__r      sX   € ÷ ?ñ ?Ø
ð?à
ð?ð ð?ð ð	?ð
 
ð?ð ð?ð ð?ð ñ?ó    c                óP  € \        V\        4      '       d   \        V4      p\        P                  ! WW#WF4      p\
        P                  ! RV,
          ^,          ^ ^R7      pVR8X  d   VP                  4       pV# VR8X  d   VP                  4       pV# VR8X  d    V# \        R4      h)aÝ  Compute the DSSIM loss between two volumes from their SSIM map.

``loss = ssim3d_loss(img1, img2, window_size)`` maps the SSIM of two ``(B, C, D, H, W)`` volumes to a
dissimilarity in :math:`[0, 1]`, as :func:`~kornia.losses.ssim_loss` does for images.

.. math::

  \text{loss}(x, y) = \operatorname{clamp}\left(\frac{1 - \text{SSIM}(x, y)}{2}, 0, 1\right)

Convention:
    See the Convention block of :func:`~kornia.metrics.ssim3d` for the window, the border and ``max_val``, and
    that of :func:`~kornia.losses.ssim_loss` for the loss.

Args:
    img1: first volume with shape ``(B, C, D, H, W)``.
    img2: second volume with the same shape.
    window_size: size of the Gaussian window in voxels, a positive odd integer.
    max_val: data range :math:`L` of the volumes, a Python float or int.
    eps: term added to the denominator of the SSIM.
    reduction: ``'mean'`` (default) averages the loss, ``'sum'`` adds it, ``'none'`` keeps the SSIM map's shape.
    padding: ``'same'`` or ``'valid'``, as in :func:`~kornia.metrics.ssim3d`.

Returns:
    the loss, a scalar or, for ``reduction='none'``, with the shape of the SSIM map.

See Also:
    - :class:`~kornia.losses.SSIM3DLoss`: the module form.
    - :func:`~kornia.metrics.ssim3d`: the SSIM map itself, not the dissimilarity.
    - :func:`~kornia.losses.ssim_loss`: the same loss for images.

Examples:
    >>> input1 = torch.rand(1, 4, 5, 5, 5)
    >>> input2 = torch.rand(1, 4, 5, 5, 5)
    >>> loss = ssim3d_loss(input1, input2, 5)

ç      ð?)ÚminÚmaxÚmeanÚsumÚnonezInvalid reduction option.)
Ú
isinstancer   r   r   Ússim3dÚtorchÚclampr   r   ÚNotImplementedError)	r   r
   r   r   r   r   r   Ússim_mapÚlosss	   &&&&&&&  r   Ússim3d_lossr'      s¤   € ôZ �'œ3×ÒÜ˜“.ˆô %Ÿ^š^¨D¸ÈcÓ[€Hô �;Š;˜˜h�¨!Õ+°¸Ô:€Dà�FÔØ�y‰y‹{ˆð €Kð 
�eÔ	Ø�x‰x‹zˆð €Kð 
�fÔ	Øð €Kô "Ð"=Ó>Ð>r   c                  óB   a € ] tR t^\tRtRR V 3R llltR R ltRtV ;t# )Ú
SSIM3DLossa   Compute the DSSIM loss between two volumes from their SSIM map (module form).

``criterion = SSIM3DLoss(window_size, ...)`` stores its arguments, and ``loss = criterion(img1, img2)`` is
:func:`~kornia.losses.ssim3d_loss` on two ``(B, C, D, H, W)`` volumes.

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

Args:
    window_size: size of the Gaussian window in voxels, a positive odd integer.
    max_val: data range :math:`L` of the volumes, a Python float or int.
    eps: term added to the denominator of the SSIM.
    reduction: ``'mean'`` (default), ``'sum'`` or ``'none'``, as in :func:`~kornia.losses.ssim3d_loss`.
    padding: ``'same'`` or ``'valid'``, as in :func:`~kornia.metrics.ssim3d`.

Shape:
    - img1: ``(B, C, D, H, W)``.
    - img2: ``(B, C, D, H, W)``.
    - Output: a scalar or, for ``reduction='none'``, the shape of the SSIM map.

See Also:
    - :func:`~kornia.losses.ssim3d_loss`: the one-call form.
    - :class:`~kornia.metrics.SSIM3D`: the SSIM map itself, not the dissimilarity.
    - :class:`~kornia.losses.SSIMLoss`: the same loss for images.

Examples:
    >>> input1 = torch.rand(1, 4, 5, 5, 5)
    >>> input2 = torch.rand(1, 4, 5, 5, 5)
    >>> criterion = SSIM3DLoss(5)
    >>> loss = criterion(input1, input2)

c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r   r   r   r   r   r   r   r   r   r   ÚNoner   )r   s   "r   r   ÚSSIM3DLoss.__annotate__~   s<   € ÷ $ñ $Øð$Ø).ð$Ø;@ð$ØUXð$Øloð$à	ñ$r   c                	ó`   <€ \         SV `  4        Wn        W n        W0n        W@n        WPn        R # )N)ÚsuperÚ__init__r   r   r   r   r   )Úselfr   r   r   r   r   Ú	__class__s   &&&&&&€r   r/   ÚSSIM3DLoss.__init__~   s*   ø€ ô 	‰ÑÔØ +ÔØ%ŒØŒØ'ŒØ#Žr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r	   r
   r   r   )r   s   "r   r   r,   ˆ   s&   € ÷ oñ o˜Lð o°ð oÀñ or   c           	     ó†   € \        WV P                  V P                  V P                  V P                  V P
                  4      # )aö  Compute SSIM loss between two 3D image or volume tensors.

Args:
    img1: First volume batch with shape ``(B, C, D, H, W)``, where
        :math:`B` is batch size, :math:`C` is channel count,
        :math:`D` is depth, :math:`H` is height, and :math:`W` is
        width.
    img2: Second volume batch with the same shape as ``img1``.

Returns:
    SSIM3D loss tensor reduced according to ``self.reduction``. Lower
    values indicate stronger local structural agreement between the two
    volumes.
)r'   r   r   r   r   r   )r0   r   r
   s   &&&r   ÚforwardÚSSIM3DLoss.forwardˆ   s5   € ô ˜4 t×'7Ñ'7¸¿¹ÀtÇxÁxÐQU×Q_ÑQ_Ðae×amÑamÓnÐnr   )r   r   r   r   r   ©r   gê-�™—q=r   Úsame)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r/   r5   Ú__static_attributes__Ú__classcell__)r1   s   @r   r)   r)   \   s   ø† ñ÷B$ò $÷oó or   r)   r7   )	Ú
__future__r   r"   r   Úkorniar   r'   ÚModuler)   r   r   r   Ú<module>rC      s+   ðõ$ #ã Ý å ÷?ôD;o�—‘ö ;or   