+
    úäûjÕ.  ã                  ó¨   € ^ RI Ht ^ RIHtHt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 ^ R	IHt R
 R lt ! R R]4      tR# )é    )Úannotations)ÚAnyÚDictÚListÚOptionalÚSequenceÚTupleÚUnionN)Úrandom_generator)ÚGeometricAugmentationBase3D)Ú_pad_with_fill)ÚResample)Ú_to_device_nonblocking)Úcrop_by_transform_mat3dc               ó$   € V ^8„  d   QhRRRRRR/# )é   Úsrcútorch.TensorÚdstÚreturn© )Úformats   "ÚbC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_3d\geometric\crop.pyÚ__annotate__r       s!   € ÷ ñ ˜\ð °ð Àñ ó    c                óØ   € \         P                  ! ^V P                  V P                  R7      P	                  V P
                  ^ ,          ^^4      pVR,          V R,          ,
          VR&   V# )zðReturn the matrix of a crop, which only moves the first ``src`` vertex onto the first ``dst`` vertex.

Solving the perspective system from the eight vertices instead fails for a crop with a size-1 axis, whose
vertices are coplanar (#4705).
)ÚdeviceÚdtype)ºNNNr   ©r   ºNé   Nr"   )ÚtorchÚeyer   r   ÚrepeatÚshape)r   r   Ú	transforms   && r   Ú_crop_translation3dr(       sU   € ô —	’	˜! C§J¡J°c·i±iÔ@×GÑGÈÏ	É	ÐRSÍÐVWÐYZÓ[€IØ˜d�) c¨$¥iÕ/€IˆhÑØÐr   c            	      óº   a € ] tR t^+tRtRR^ R]P                  P                  RRRR3	R V 3R llltR	 R
 lt	RR R llt
R R ltRR R lltR V 3R lltRtV ;t# )ÚRandomCrop3DaÎ  Crop random 3D subvolumes, applied to a batch with probability ``p`` (default 1.0).

``output = RandomCrop3D(size, ...)(input)`` selects patches of ``(D, H, W)`` voxels.

Args:
    p: probability of applying the transformation for the whole batch.
        When skipped, the input is returned without padding or cropping.
    size: Desired output size (out_d, out_h, out_w) of the crop.
        Must be a three-element tuple or list of integers, then
        out_d = size[0], out_h = size[1], out_w = size[2].
    padding: Optional padding on each border of the image.
        Default is None, i.e no padding. If a sequence of length 6 is provided, it is passed to F.pad as
        left, right, top, bottom, front, back borders respectively.
        If a sequence of length 3 is provided, it is used to F.pad left/right,
        top/bottom, front/back borders, respectively.
    pad_if_needed: It will F.pad the image if smaller than the
        desired size to avoid raising an exception. Since cropping is done
        after padding, the padding seems to be done at a random offset.
    fill: Voxel fill value for constant fill. Default is 0. A sequence gives one value per channel,
        so it must be as long as the input's channel dimension. This value is only used when the
        padding_mode is constant, and a sequence requires it.
    padding_mode: Type of padding, passed to F.pad. Should be: constant, reflect, replicate or circular.
        Default is constant.
    resample: resample mode from "nearest" (0) or "bilinear" (1).
    same_on_batch: apply the same transformation across the batch.
    align_corners: interpolation flag.
    keepdim: whether to keep the output shape the same as input (True) or broadcast it
      to the batch form (False).

Shape:
    - Input: ``(C, D, H, W)`` or ``(B, C, D, H, W)``
    - Output: ``(B, C, out_d, out_h, out_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.

    - ``size`` and the output shape are ordered ``(D, H, W)``. A scalar ``padding`` expands to every side;
      three values expand as ``(left/right, top/bottom, front/back)``, and six are passed to
      :func:`torch.nn.functional.pad` as ``(left, right, top, bottom, front, back)`` before the crop is drawn.
    - ``transform_matrix`` maps original input ``(x, y, z)`` coordinates to the crop, including the
      left, top, and front translation from explicit padding and ``pad_if_needed``.
    - its ``p`` is a call-wide gate. Size validation uses the padded input even when the call is skipped: a
      crop larger than the padded volume along any axis, even by one voxel, raises; a crop equal to it is
      valid. An oversized crop raises ``ValueError`` naming ``size`` and the padded input spatial size.
      Unsupported size types, sequences with other than three elements, or Python or NumPy float elements
      raise ``TypeError`` naming ``size`` and the required integer ``(D, H, W)`` values (NumPy integers and
      0-d integer tensors are accepted);
      unlike :class:`CenterCrop3D`, an integer ``size`` remains unsupported
      (`#4417 <https://github.com/kornia/kornia/issues/4417>`_).
      A valid gated-off call returns the input unchanged -- unpadded, at the input shape rather than ``size`` --
      with an identity ``transform_matrix``.
      Defaults are bilinear resampling and ``align_corners=True``.

See Also:
    - :class:`CenterCrop3D`: extracts the deterministic centered subvolume.
    - :class:`RandomCrop`: samples a fixed-size patch from a 2D image.

Examples:
    >>> import torch
    >>> rng = torch.manual_seed(0)
    >>> inputs = torch.randn(1, 1, 3, 3, 3)
    >>> aug = RandomCrop3D((2, 2, 2), p=1.)
    >>> aug(inputs)
    tensor([[[[[-1.1258, -1.1524],
               [-0.4339,  0.8487]],
    <BLANKLINE>
              [[-1.2633,  0.3500],
               [ 0.1665,  0.8744]]]]])

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 = RandomCrop3D((24, 24, 24), p=1.)
    >>> (aug(input) == aug(input, params=aug._params)).all()
    tensor(True)

NFÚconstantTç      ð?c               óD   € 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/# )r   Úsizez&Union[Tuple[int, int, int], List[int]]ÚpaddingzOOptional[Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int]]]Úpad_if_neededzOptional[bool]ÚfillzUnion[float, Sequence[float]]Úpadding_modeÚstrÚresamplezUnion[str, int, Resample]Úsame_on_batchÚboolÚalign_cornersÚpÚfloatÚkeepdimr   ÚNoner   )r   s   "r   r   ÚRandomCrop3D.__annotate__|   sy   € ÷ ?ñ ?à4ð?ð að?ð &ð	?ð
 ,ð?ð ð?ð ,ð?ð ð?ð ð?ð ð?ð ð?ð 
ñ?r   c                ó¢  <€ \         SV `  RWyV
R7       \        V\        \        34      '       dK   \        V4      ^8w  g;   \        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       g   \        RV: R24      hRVR	VR
VRVRVR\        P                  ! V4      RV/V n
        \        P                  ! VR4      V n        R# )z>Initialize the crop and validate its three integer dimensions.r,   )r8   r5   Úp_batchr:   c              3  ó:   "  € T F  p\        VR 4      x € K  	  R# 5i)Ú	__index__N)Úhasattr)Ú.0Úvs   & r   Ú	<genexpr>Ú(RandomCrop3D.__init__.<locals>.<genexpr>Ž   s   é € ÐKrÑmqÐhiÌGÐTUÐWb×LcÐLcÓmqùs   ‚FTzC`size` must be a three-element (D, H, W) sequence of integers. Got Ú.r.   r/   r0   r2   r1   r4   r7   N)ÚsuperÚ__init__Ú
isinstanceÚtupleÚlistÚlenÚallÚ	TypeErrorr   ÚgetÚflagsÚrgÚCropGenerator3DÚ_param_generator)Úselfr.   r/   r0   r1   r2   r4   r5   r7   r8   r:   Ú	__class__s   &&&&&&&&&&&€r   rH   ÚRandomCrop3D.__init__|   s½   ø€ ô 	‰Ñ˜3¨mÐPWÐÔXô ˜$¤¬ ×.Ò.´#°d³)¸q´.ÏËÑKrÑmqÓKrÏÏÊÑKrÑmqÓKr×HrÒHrÜÐaÐbfÑaiÐijÐkÓlÐlà�DØ�wØ˜]Ø˜LØ�DØœŸš XÓ.Ø˜]ð
ˆŒ
ô !#× 2Ò 2°4¸Ó >ˆÖr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r&   úTuple[int, ...]rP   úDict[str, Any]r   zList[List[int]]r   )r   s   "r   r   r<   ›   s"   € ÷ ñ  oð ¸nð ÐQ`ñ r   c           	     ó0  € . pVRR w  rEpVR,          pVEeR   \        V\        4      '       d   WwWwWw.pMÍ\        V\        \        34      '       dD   \	        V4      ^8X  d4   V^ ,          V^ ,          V^,          V^,          V^,          V^,          .pMn\        V\        \        34      '       dD   \	        V4      ^8X  d4   V^ ,          V^,          V^,          V^,          V^,          V^,          .pM\        RV R24      hVP                  V4       WG^,          V^,          ,           ,          pWW^,          V^,          ,           ,          pWg^ ,          V^,          ,           ,          pVR,          '       dV   WBR,          ^ ,          8  dB   VP                  ^ ^ ^ ^ VR,          ^ ,          V,
          VR,          ^ ,          V,
          .4       VR,          '       dV   WRR,          ^,          8  dB   VP                  ^ ^ VR,          ^,          V,
          VR,          ^,          V,
          ^ ^ .4       VR,          '       dV   WbR,          ^,          8  dB   VP                  VR,          ^,          V,
          VR,          ^,          V,
          ^ ^ ^ ^ .4       V# )zDCompute successive padding steps without modifying the input volume.Nr/   zD`padding` must be an integer, 3-element-list or 6-element-list. Got rF   r0   r.   éýÿÿÿ)rI   ÚintrJ   rK   rL   Ú
ValueErrorÚappend)rT   r&   rP   Úpadding_stepsÚdepthÚheightÚwidthr/   s   &&&     r   Ú_compute_paddingÚRandomCrop3D._compute_padding›   s9  € à)+ˆØ$ R S˜zÑˆ�uØ˜	Õ"ˆØÓÜ˜'¤3×'Ò'Ø"¨W¸wÐP‘Ü˜G¤e¬T ]×3Ò3¼¸G»ÈÔ8IØ" 1�: w¨q¥z°7¸1µ:¸wÀq½zÈ7ÐSTÍ:ÐW^Ð_`ÕWaÐb‘Ü˜G¤e¬T ]×3Ò3¼¸G»ÈÔ8IØ" 1�: w¨q¥z°7¸1µ:¸wÀq½zÈ7ÐSTÍ:ÐW^Ð_`ÕWaÐb‘ä Ð#gÐhoÐgpÐpqÐ!rÓsÐsØ× Ñ  Ô)Ø˜Q•Z '¨!¥*Õ,Õ,ˆEØ˜a•j 7¨1¥:Õ-Õ-ˆFØ˜Q•Z '¨!¥*Õ,Õ,ˆEà�×!Ô! e°F­m¸AÕ.>Ô&>Ø× Ñ  ! Q¨¨1¨e°F­m¸AÕ.>ÀÕ.FÈÈfÍÐVWÕHXÐ[`ÕH`Ð!aÔbà�×!Ô! f°V­}¸QÕ/?Ô&?Ø× Ñ  ! Q¨¨f­°aÕ(8¸6Õ(AÀ5ÈÅ=ÐQRÕCSÐV\ÕC\Ð^_ÐabÐ!cÔdà�×!Ô! e°F­m¸AÕ.>Ô&>Ø× Ñ  %¨¥-°Õ"2°UÕ":¸EÀ&½MÈ!Õ<LÈuÕ<TÐVWÐYZÐ\]Ð_`Ð!aÔbàÐr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úinputr   rP   zOptional[Dict[str, Any]]r   r   )r   s   "r   r   r<   ¹   s#   € ÷ ñ  \ð Ð:Rð Ð^jñ r   c                	ó¸   € Vf   V P                   MTpV P                  \        VP                  4      V4       F  p\	        WVR,          VR,          4      pK   	  V# )Nr1   r2   )rP   rc   rJ   r&   r   )rT   rf   rP   r/   s   &&& r   Úprecrop_paddingÚRandomCrop3D.precrop_padding¹   sP   € Ø#šm�—
’
°ˆà×,Ñ,¬U°5·;±;Ó-?ÀÖGˆGÜ" 5°5¸µ=À%ÈÕBWÓXŠEñ Hð ˆr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   rf   r   ÚparamsúDict[str, torch.Tensor]rP   rY   r   r   )r   s   "r   r   r<   Á   s,   € ÷ 
8ñ 
8Ø!ð
8Ø+Bð
8ØKYð
8à	ñ
8r   c                	ó   € \        VR ,          VP                  VP                  4      p\        VR,          VP                  VP                  4      p\        WE4      pV P	                  \        VP                  4      V4       FW  pVR;;,          V^ ,          ,          uu&   VR;;,          V^,          ,          uu&   VR;;,          V^,          ,          uu&   KY  	  VP                  VP                  ^ ,          RR4      # )r   r   )r   r   r"   )r   é   r"   )r   r   r"   éÿÿÿÿ)r   r   r   r(   rc   rJ   r&   Úexpand)rT   rf   rk   rP   r   r   r'   r/   s   &&&&    r   Úcompute_transformationÚ#RandomCrop3D.compute_transformationÁ   s¾   € ô % V¨E¥]°E·L±LÀ%Ç+Á+ÓNˆÜ$ V¨E¥]°E·L±LÀ%Ç+Á+ÓNˆÜ'¨Ó1ˆ	Ø×,Ñ,¬U°5·;±;Ó-?ÀÖGˆGØ�g× '¨!¥*Õ,ÓØ�g× '¨!¥*Õ,ÓØ�g× '¨!¥*Õ,Õñ Hð ×Ñ §¡¨A¥°°BÓ7Ð7r   c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R/# )
r   rf   r   rk   rl   rP   rY   r'   zOptional[torch.Tensor]r   r   )r   s   "r   r   r<   Í   s<   € ÷ 
ñ 
àð
ð (ð
ð ð	
ð
 *ð
ð 
ñ
r   c                	óF  € \        V\        P                  4      '       g   \        R \	        V4       24      hVP                  4       pV P                  \        VP                  4      V4       Fe  pVR;;,          VR,          V^ ,          ,          VR,          V^,          ,          ,           VR,          V^,          ,          ,           ,          uu&   Kg  	  V P                  W4      p\        WVR,          VR,          P                  P                  4       VR,          R7      # )	z1Expected the transform to be a torch.Tensor. Got r.   r4   r7   )Úmoder7   r    )r   r!   r   )r   r!   rn   )r   r!   r   )rI   r#   ÚTensorrN   ÚtypeÚclonerc   rJ   r&   rh   r   ÚnameÚlower)rT   rf   rk   rP   r'   r/   s   &&&&& r   Úapply_transformÚRandomCrop3D.apply_transformÍ   só   € ô ˜)¤U§\¡\×2Ò2ÜÐOÔPTÐU^ÓP_ÐO`ÐaÓbÐbð —O‘OÓ%ˆ	Ø×,Ñ,¬U°5·;±;Ó-?ÀÖGˆGØ�h×Ø˜(Õ# g¨a¥jÕ0°9¸XÕ3FÈÐQRÍÕ3SÕSÐV_Ð`hÕViÐlsÐtuÕlvÕVvÕvõÕñ Hð ×$Ñ$ UÓ2ˆÜ&Ø˜e F�m°%¸
Õ2C×2HÑ2H×2NÑ2NÓ2PÐ`eÐfuÕ`vô
ð 	
r   c               ó    € V ^8„  d   QhRRRR/# )r   Úbatch_shaperX   r   rl   r   )r   s   "r   r   r<   â   s   € ÷ ?ñ ?¨oð ?ÐBYñ ?r   c                	óŠ  <€ \        V4      pV P                  WP                  4       F�  pVR;;,          V^,          V^,          ,           ,          uu&   VR;;,          V^,          V^,          ,           ,          uu&   VR;;,          V^ ,          V^,          ,           ,          uu&   Kƒ  	  \        SV `  \        V4      4      # )r"   r[   éþÿÿÿro   )rK   rc   rP   rG   Úforward_parametersrJ   )rT   r~   Úpadded_shaper/   rU   s   &&  €r   r�   ÚRandomCrop3D.forward_parametersâ   s•   ø€ ä˜KÓ(ˆØ×,Ñ,¨[¿*¹*ÖEˆGØ˜× ¨¥
¨W°Q­ZÕ 7Õ7ÓØ˜× ¨¥
¨W°Q­ZÕ 7Õ7ÓØ˜× ¨¥
¨W°Q­ZÕ 7Õ7Õñ Fô ‰wÑ)¬%°Ó*=Ó>Ð>r   )rS   rP   )N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚBILINEARry   rH   rc   rh   rq   r{   r�   Ú__static_attributes__Ú__classcell__)rU   s   @r   r*   r*   +   s]   ø† ñNðf dhØ(-Ø./Ø&Ø.6×.?Ñ.?×.DÑ.DØ#Ø"ØØ÷?ò ?õ>÷<õ
8÷
÷*?ö ?r   r*   )Ú
__future__r   Útypingr   r   r   r   r   r	   r
   r#   Úkornia.augmentationr   rQ   Ú&kornia.augmentation._3d.geometric.baser   Ú!kornia.augmentation.utils.helpersr   Úkornia.constantsr   Úkornia.core.utilsr   Úkornia.geometryr   r(   r*   r   r   r   Ú<module>r”      s<   ðõ$ #ç D× DÑ Dã å 6Ý NÝ <Ý %Ý 4Ý 3õô~?Ð.ö ~?r   