+
    úäûj.&  ã                   óˆ   € ^ RI t ^ RIHtHtHtHtHt ^ RIt^ RIH	t
 ^ RIHt ^ RIHt ^ RIHt ^ RIHtHt  ! R R	]4      tR# )
é    N)ÚAnyÚDictÚOptionalÚTupleÚUnion)Úrandom_generator)ÚGeometricAugmentationBase3D)ÚResample)Ú_to_device_nonblocking)Úget_affine_matrix3dÚwarp_affine3dc                   ó¦   a a€ ] tR t^t oRtRRR]P                  P                  RRRR3V3R lV 3R llltV3R lR lt	RV3R	 lR
 llt
RtVtV ;t# )ÚRandomAffine3DaN  Warp volumes by a random 3D affine transformation, applied per sample with probability ``p`` (default 0.5).

``output = RandomAffine3D(degrees, ...)(input)`` warps volumes of shape ``(B, C, D, H, W)`` about their center.

Args:
    degrees: Range of yaw (x-axis), pitch (y-axis), roll (z-axis) to select from. The three
        are sampled independently and concatenated into one axis-angle vector, not composed
        as per-axis Euler rotations; see :class:`RandomRotation3D` for the convention.
        If degrees is a number, then yaw, pitch, roll will be generated from the range of (-degrees, +degrees).
        If degrees is a tuple of (min, max), then yaw, pitch, roll will be generated from the range of (min, max).
        If degrees is a list of floats [a, b, c], then yaw, pitch, roll will be generated from (-a, a), (-b, b)
        and (-c, c).
        If degrees is a list of tuple ((a, b), (m, n), (x, y)), then yaw, pitch, roll will be generated from
        (a, b), (m, n) and (x, y).
        Set to 0 to deactivate rotations.
    translate: tuple of maximum absolute fraction for horizontal, vertical and
        depthical translations (dx,dy,dz). For example translate=(a, b, c), then
        horizontal shift will be randomly sampled in the range -img_width * a < dx < img_width * a
        vertical shift will be randomly sampled in the range -img_height * b < dy < img_height * b.
        depthical shift will be randomly sampled in the range -img_depth * c < dz < img_depth * c.
        Will not translate by default.
    scale: scaling factor interval.
        If (a, b) represents isotropic scaling, the scale is randomly sampled from the range a <= scale <= b.
        If ((a, b), (c, d), (e, f)), the scale is randomly sampled from the range a <= scale_x <= b,
        c <= scale_y <= d, e <= scale_z <= f. Will keep original scale by default.
    shears: Range of degrees to select from.
        If shear is a number, a shear to the 6 facets in the range (-shear, +shear) will be applied.
        If shear is a tuple of 2 values, a shear to the 6 facets in the range (shear[0], shear[1]) will be applied.
        If shear is a tuple of 6 values, a shear to the i-th facet in the range (-shear[i], shear[i])
        will be applied.
        If shear is a tuple of 6 tuples, a shear to the i-th facet in the range (shear[i, 0], shear[i, 1])
        will be applied.
    resample: resample mode from "nearest" (0) or "bilinear" (1).
    same_on_batch: apply the same transformation across the batch.
    align_corners: interpolation flag.
    p: probability of applying the transformation to each sample.
    keepdim: whether to keep the output shape the same as input (True) or broadcast it
      to the batch form (False). Default: False.

Shape:
    - Input: ``(C, D, H, W)`` or ``(B, C, D, H, W)``
    - Output: ``(B, C, D, H, W)``

Note:
    Input torch.Tensor must be float and normalized into [0, 1] for the best differentiability support.

Convention:
    See :class:`~kornia.augmentation.GeometricAugmentationBase3D` for the shared 3D geometry contract.

    - each sampled ``degrees`` triple ``(yaw, pitch, roll) = (rx, ry, rz)`` is **one axis-angle vector**
      in degrees and is converted into a single Rodrigues rotation, not composed as per-axis Euler
      rotations; see :class:`RandomRotation3D` for the convention.
    - A positive roll turns a displayed ``H x W`` slice counter-clockwise, and the rotation
      block is the transpose of :class:`RandomRotation3D`'s
      (`#4408 <https://github.com/kornia/kornia/issues/4408>`_).
    - the default is bilinear resampling with ``align_corners=False``.
    - a two-value ``scale=(a, b)`` is isotropic: one factor per sample is drawn from ``[a, b]`` and applied
      to all three axes, as the 2D :class:`~kornia.augmentation.RandomAffine` does. The three-pair form
      ``((a, b), (c, d), (e, f))`` draws each axis independently.

See Also:
    - :class:`RandomRotation3D`: samples a 3D rotation without translation, scale or shear.
    - :class:`RandomAffine`: applies the corresponding transform to 2D images.

Examples:
    >>> import torch
    >>> rng = torch.manual_seed(0)
    >>> input = torch.rand(1, 1, 3, 3, 3)
    >>> aug = RandomAffine3D((15., 20., 20.), p=1.)
    >>> aug(input), aug.transform_matrix
    (tensor([[[[[0.4503, 0.4763, 0.1680],
               [0.2029, 0.4267, 0.3515],
               [0.3195, 0.5436, 0.3706]],
    <BLANKLINE>
              [[0.5255, 0.3508, 0.4858],
               [0.0795, 0.1689, 0.4220],
               [0.5306, 0.7234, 0.6879]],
    <BLANKLINE>
              [[0.2971, 0.2746, 0.3471],
               [0.4924, 0.4960, 0.6460],
               [0.3187, 0.4556, 0.7596]]]]]), tensor([[[ 0.9722, -0.0603,  0.2262, -0.1381],
             [ 0.1131,  0.9669, -0.2286,  0.1486],
             [-0.2049,  0.2478,  0.9469,  0.0102],
             [ 0.0000,  0.0000,  0.0000,  1.0000]]]))

To apply the exact augmenation again, you may take the advantage of the previous parameter state:
    >>> input = torch.rand(1, 3, 32, 32, 32)
    >>> aug = RandomAffine3D((15., 20., 20.), p=1.)
    >>> (aug(input) == aug(input, params=aug._params)).all()
    tensor(True)

NFg      à?c                óR  <€ V ^8„  d   QhRS[ S[P                  S[S[S[S[3,          S[S[S[S[3,          S[S[S[S[3,          S[S[S[3,          S[S[S[3,          3,          3,          RS[S[ S[P                  S[S[S[S[3,          3,          ,          RS[S[ S[P                  S[S[S[3,          S[S[S[S[3,          S[S[S[3,          S[S[S[3,          3,          3,          ,          RS[ S[P                  S[S[S[S[3,          S[S[S[S[S[S[S[3,          S[S[S[S[3,          S[S[S[3,          S[S[S[3,          S[S[S[3,          S[S[S[3,          S[S[S[3,          3,          R3,          RS[ S[S[S[3,          RS[	RS[	R	S[R
S[	RR/
# )é   ÚdegreesÚ	translateÚscaleÚshearsNÚresampleÚsame_on_batchÚalign_cornersÚpÚkeepdimÚreturn)
r   ÚtorchÚTensorÚfloatr   r   ÚstrÚintr
   Úbool)ÚformatÚ__classdict__s   "€ÚdC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_3d\geometric\affine.pyÚ__annotate__ÚRandomAffine3D.__annotate__|   sé  ø€ ÷ +Xñ +XáÙ�L‰LÙÙ‘%™�,ÕÙ‘%™¡Ð%Õ&Ù‘%™™u˜Õ%¡u©U±E¨\Õ':¹EÁ%ÉÀ,Õ<OÐOÕPð	Rõ
ð+Xñ ™E¡%§,¡,±±e¹UÁEÐ6IÕ0JÐ"JÕKÕLð+Xñ ÙÙ—‘™e¡E©5 LÕ1±5¹¹uÁe¸|Õ9LÉeÑTYÑ[`ÐT`ÕNaÑchÑinÑpuÐiuÕcvÐ9vÕ3wÐwõõ
ð+Xñ Ù�L‰LÙÙ‘%™�,ÕÙ‘%™¡¡u©e±UÐ:Õ;ÙÙ‘e™U�lÕ#Ù‘e™U�lÕ#Ù‘e™U�lÕ#Ù‘e™U�lÕ#Ù‘e™U�lÕ#Ù‘e™U�lÕ#ð%õð ðõ
ð+Xñ< ™™S¡(Ð*Õ+ð=+Xñ> ð?+Xñ@ ðA+XñB ðC+XñD ðE+XðF 
ñG+Xó    c
                óÐ   <€ \         S
V `  W†V	R 7       Wn        W@n        W n        W0n        R\        P                  ! V4      RV/V n        \        P                  ! WW44      V n        R# ))r   r   r   r   r   N)ÚsuperÚ__init__r   r   r   r   r
   ÚgetÚflagsÚrgÚAffineGenerator3DÚ_param_generator)Úselfr   r   r   r   r   r   r   r   r   Ú	__class__s   &&&&&&&&&&€r$   r*   ÚRandomAffine3D.__init__|   sZ   ø€ ôH 	‰Ñ˜1À7ÐÔKØŒØŒØ"ŒØŒ
à ¤(§,¢,¨xÓ"8¸/È=ÐYˆŒ
Ü "× 4Ò 4°WÈÓ WˆÖr'   c                óš   <€ V ^8„  d   QhRS[ P                  RS[S[S[ P                  3,          RS[S[S[3,          RS[ P                  /# )r   ÚinputÚparamsr,   r   )r   r   r   r   r   )r"   r#   s   "€r$   r%   r&   ©   sT   ø€ ÷ Lñ LÙ—\‘\ðLÙ+/±±U·\±\Ð0AÕ+BðLÙKOÑPSÑUXÐPXÍ>ðLá	�‰ñLr'   c                óx  € \         P                  R ,          p\        VR,          VR,          VR,          VR,          VR,          V,          VR,          V,          VR,          V,          VR,          V,          VR	,          V,          VR
,          V,          4
      p\        WQP                  VP
                  4      # )g     €f@ÚtranslationsÚcenterr   ÚanglesÚsxyÚsxzÚsyxÚsyzÚszxÚszy)ÚmathÚpir   r   ÚdeviceÚdtype)r0   r4   r5   r,   Údeg2rad_factorÚ	transforms   &&&&  r$   Úcompute_transformationÚ%RandomAffine3D.compute_transformation©   s™   € ô
 !%§¡¨%¥ˆÜ"5Ø�>Õ"Ø�8ÕØ�7�OØ�8ÕØ�5�M˜NÕ*Ø�5�M˜NÕ*Ø�5�M˜NÕ*Ø�5�M˜NÕ*Ø�5�M˜NÕ*Ø�5�M˜NÕ*ó#
ˆ	ô & i·±¸u¿{¹{ÓKÐKr'   c          
      óÄ   <€ V ^8„  d   QhRS[ P                  RS[S[S[ P                  3,          RS[S[S[3,          RS[S[ P                  ,          RS[ P                  /# )r   r4   r5   r,   rE   r   )r   r   r   r   r   r   )r"   r#   s   "€r$   r%   r&   ¾   sd   ø€ ÷ 
ñ 
á�|‰|ð
ñ ‘S™%Ÿ,™,Ð&Õ'ð
ñ ‘C™�H�~ð	
ñ
 ™EŸL™LÕ)ð
ñ 
�‰ñ
r'   c                óV  € \        V\        P                  4      '       g   \        R \	        V4       24      h\        VVR,          VP                  R,          VP                  R,          VP                  R,          3VR,          P                  P                  4       VR,          R7      # )z1Expected the transform to be a torch.Tensor. Got r   r   )r   )ºNNN:Né   NrJ   éýÿÿÿéþÿÿÿéÿÿÿÿ)	Ú
isinstancer   r   Ú	TypeErrorÚtyper   ÚshapeÚnameÚlower)r0   r4   r5   r,   rE   s   &&&&&r$   Úapply_transformÚRandomAffine3D.apply_transform¾   s‰   € ô ˜)¤U§\¡\×2Ò2ÜÐOÔPTÐU^ÓP_ÐO`ÐaÓbÐbäØØ�hÕØ�[‰[˜�_˜eŸk™k¨"�o¨u¯{©{¸2­Ð?Ø�*Õ×"Ñ"×(Ñ(Ó*Ø Õ0ô
ð 	
r'   )r/   r   r,   r   r   r   )N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r
   ÚBILINEARrS   r*   rF   rU   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r1   r#   s   @@r$   r   r      sa   ù‡ € ñ[ðL PTð
 ð Ø.6×.?Ñ.?×.DÑ.DØ#Ø#ØØ÷E+Xõ +X÷ZLð L÷*
÷ 
ò 
r'   r   )r@   Útypingr   r   r   r   r   r   Úkornia.augmentationr   r-   Ú&kornia.augmentation._3d.geometric.baser	   Úkornia.constantsr
   Úkornia.core.utilsr   Ú!kornia.geometry.transform.imgwarpr   r   r   © r'   r$   Ú<module>rg      s1   ðó$ ß 4Õ 4ã å 6Ý NÝ %Ý 4ß Pôp
Ð0ö p
r'   