+
    öäû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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)ÚGeometricAugmentationBase2D)ÚResampleÚSamplePadding)Ú_as_tensor_nonblocking)Úget_affine_matrix2dÚwarp_affinec            
       óè   a a€ ] tR t^t oRtRRR]P                  P                  RR]P                  P                  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V3R lR lltRtVtV ;t# )ÚRandomAffineaL  Warp images by a random 2D affine transformation, applied per sample with probability ``p`` (default 0.5).

``output = RandomAffine(degrees, ...)(input)`` warps each image of shape ``(B, C, H, W)`` with one sampled
affine transform about its center.

.. image:: _static/img/RandomAffine.png

.. note::
    Unlike torchvision's ``RandomAffine``, which transforms every image, this class transforms each sample with
    probability ``p``, 0.5 by default; with ``same_on_batch=True`` one draw decides for the whole batch. Pass
    ``p=1.0`` to transform every sample.

Args:
    degrees: Range of degrees to select from.
        If degrees is a number instead of sequence like (min, max), the range of degrees
        will be (-degrees, +degrees). Set to 0 to deactivate rotations.
    translate: tuple of maximum absolute fraction for horizontal
        and vertical translations. For example translate=(a, b), then horizontal shift
        is randomly sampled in the range -img_width * a < dx < img_width * a and vertical shift is
        randomly sampled in the range -img_height * b < dy < img_height * b. 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), the scale is randomly sampled from the range a <= scale_x <= b, c <= scale_y <= d.
        Will keep original scale by default.
    shear: Range of degrees to select from.
        If float, a shear parallel to the x axis in the range (-shear, +shear) will be applied.
        If (a, b), a shear parallel to the x axis in the range (a, b) will be applied.
        If (a, b, c, d), then x-axis shear in (shear[0], shear[1]) and y-axis shear in (shear[2], shear[3])
        will be applied. Will not apply shear by default.
    resample: resample mode from "nearest" (0) or "bilinear" (1).
    padding_mode: padding mode from "torch.zeros" (0), "border" (1), "reflection" (2) or "fill" (3).
    fill_value: the value to be filled in the padding area when padding_mode="fill".
        Can be a float, int, or a torch.Tensor of shape (C) or (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).

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

Convention:
    - See :class:`~kornia.augmentation.GeometricAugmentationBase2D` for coordinates, defaults and inverse.
    - ``translate=(a, b)`` samples pixel offsets from ``[-a W, a W]`` and ``[-b H, b H]``; positive offsets
      move content right and down.
    - a positive ``degrees`` rotates the displayed image clockwise, unlike :class:`RandomRotation`
      (:doc:`/get-started/conventions`, `#4408 <https://github.com/kornia/kornia/issues/4408>`_).
    - ``shear`` draws degrees, converted to radians and applied about the image center with the sign and the
      x-then-y order of :func:`~kornia.geometry.transform.get_shear_matrix2d`, as
      :class:`~kornia.geometry.transform.Affine` applies its ``shear``.
    - in :class:`~kornia.augmentation.container.AugmentationSequential`, a ``fill_value`` with more than one
      element pads only the image: masks are padded with zero, forward and inverse, unless
      ``extra_args[DataKey.MASK]`` sets their ``fill_value``; a one-element ``fill_value`` applies to both.

.. note::
    This function internally uses :func:`kornia.geometry.transform.warp_affine`.

See Also:
    - :class:`RandomRotation`: samples rotation without translation, scaling or shear.
    - :class:`RandomPerspective`: samples a projective four-corner warp.
    - :class:`RandomAffine3D`: applies the corresponding sampled transform to volumes.

Examples:
    >>> import torch
    >>> rng = torch.manual_seed(0)
    >>> input = torch.rand(1, 1, 3, 3)
    >>> aug = RandomAffine((-15., 20.), p=1.)
    >>> out = aug(input)
    >>> out, aug.transform_matrix
    (tensor([[[[0.3961, 0.7310, 0.1574],
              [0.1781, 0.3074, 0.5648],
              [0.4804, 0.8379, 0.4234]]]]), tensor([[[ 0.9923, -0.1241,  0.1319],
             [ 0.1241,  0.9923, -0.1164],
             [ 0.0000,  0.0000,  1.0000]]]))
    >>> aug.inverse(out)
    tensor([[[[0.3890, 0.6573, 0.1865],
              [0.2063, 0.3074, 0.5459],
              [0.3892, 0.7896, 0.4224]]]])
    >>> input
    tensor([[[[0.4963, 0.7682, 0.0885],
              [0.1320, 0.3074, 0.6341],
              [0.4901, 0.8964, 0.4556]]]])

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

NFg      à?c                ó,  <€ V ^8„  d   QhRS[ S[P                  S[S[S[S[3,          3,          RS[S[ S[P                  S[S[S[3,          3,          ,          RS[S[ S[P                  S[S[S[3,          S[S[S[S[S[3,          3,          ,          RS[S[ S[P                  S[S[S[S[3,          3,          ,          RS[ S[S[S[3,          RS[	RS[	RS[ S[S[S[
3,          R	S[S[ S[S[S[P                  3,          ,          R
S[RS[	RR/# )é   ÚdegreesÚ	translateÚscaleÚshearÚresampleÚsame_on_batchÚalign_cornersÚpadding_modeÚ
fill_valueÚpÚkeepdimÚreturnN)r   ÚtorchÚTensorÚfloatr   r   ÚstrÚintr
   Úboolr   )ÚformatÚ__classdict__s   "€ÚdC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\geometric\affine.pyÚ__annotate__ÚRandomAffine.__annotate__{   s1  ø€ ÷ 
ñ 
á‘u—|‘|¡U©E±%¹°,Õ,?Ð?Õ@ð
ñ ™E¡%§,¡,±±e¹U°lÕ0CÐ"CÕDÕEð
ñ ™™eŸl™l©E±%¹°,Õ,?ÁÁuÉeÑUZÑ\aÐGaÕAbÐbÕcÕdð	
ñ
 ™™eŸl™l©E±5¹Á¸Õ3FÐFÕGÕHð
ñ ™™S¡(Ð*Õ+ð
ñ ð
ñ ð
ñ ™C¡¡mÐ3Õ4ð
ñ ™U¡5©#©u¯|©|Ð#;Õ<Õ=ð
ñ ð
ñ ð
ð 
ñ
ó    c                óD  <€ \         SV `  W¦VR 7       \        P                  ! WW44      V n        V	e7   \        V	\        P                  4      '       g   \        P                  ! V	4      p	R\        P                  ! V4      R\        P                  ! V4      RVRV	/V n        R# ))r   r   r   Nr   r   r   r   )ÚsuperÚ__init__ÚrgÚAffineGeneratorÚ_param_generatorÚ
isinstancer   r    Ú	as_tensorr
   Úgetr   Úflags)Úselfr   r   r   r   r   r   r   r   r   r   r   Ú	__class__s   &&&&&&&&&&&&€r'   r-   ÚRandomAffine.__init__{   s„   ø€ ô 	‰Ñ˜1À7ÐÔKÜ46×4FÒ4FÀwÐ[`Ó4hˆÔàÒ!¬*°ZÄÇÁ×*NÒ*NÜŸš¨Ó4ˆJð œŸš XÓ.ØœM×-Ò-¨lÓ;Ø˜]Ø˜*ð	
ˆŽ
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Úparamsr4   r   )r   r    r   r"   r   )r%   r&   s   "€r'   r(   r)   –   sN   ø€ ÷ 
ñ 
Ù—\‘\ð
Ù+/±±U·\±\Ð0AÕ+Bð
ÙKOÑPSÑUXÐPXÍ>ð
á	�‰ñ
r*   c           
     ó<  € \         P                  R ,          p\        VR,          VP                  VP                  4      V,          p\        VR,          VP                  VP                  4      V,          p\        \        VR,          VP                  VP                  4      \        VR,          VP                  VP                  4      \        VR,          VP                  VP                  4      \        VR,          VP                  VP                  4      VV4      # )g     €f@Úshear_xÚshear_yÚtranslationsÚcenterr   Úangle)ÚmathÚpir   ÚdeviceÚdtyper   )r5   r9   r:   r4   Údeg2rad_factorr<   r=   s   &&&&   r'   Úcompute_transformationÚ#RandomAffine.compute_transformation–   sÈ   € ô !%§¡¨%¥ˆÜ(¨°	Õ):¸E¿L¹LÈ%Ï+É+ÓVÐYgÕgˆÜ(¨°	Õ):¸E¿L¹LÈ%Ï+É+ÓVÐYgÕgˆÜ"Ü" 6¨.Õ#9¸5¿<¹<ÈÏÉÓUÜ" 6¨(Õ#3°U·\±\À5Ç;Á;ÓOÜ" 6¨'¥?°E·L±LÀ%Ç+Á+ÓNÜ" 6¨'¥?°E·L±LÀ%Ç+Á+ÓNØØó
ð 	
r*   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   r9   r:   r4   Ú	transformr   )r   r    r   r"   r   r   )r%   r&   s   "€r'   r(   r)   ¨   sd   ø€ ÷ 
ñ 
á�|‰|ð
ñ ‘S™%Ÿ,™,Ð&Õ'ð
ñ ‘C™�H�~ð	
ñ
 ™EŸL™LÕ)ð
ñ 
�‰ñ
r*   c           
     ó^  € VP                   w   rVp\        V\        P                  4      '       g   \	        R \        V4       R24      h\        VVR,          Wg3VR,          P                  P                  4       VR,          VR,          P                  P                  4       VR,          R7      # )ú0Expected the `transform` be a torch.Tensor. Got Ú.r   r   r   r   )r   r   r   )ºNNN:Nr   NrM   )	Úshaper1   r   r    Ú	TypeErrorÚtyper   ÚnameÚlower)r5   r9   r:   r4   rI   Ú_ÚheightÚwidths   &&&&&   r'   Úapply_transformÚRandomAffine.apply_transform¨   sœ   € ð $Ÿk™kÑˆˆ1�eÜ˜)¤U§\¡\×2Ò2ÜÐNÌtÐT]ËÐN_Ð_`ÐaÓbÐbäØØ�hÕØˆOØ�*Õ×"Ñ"×(Ñ(Ó*Ø Õ0Ø˜~Õ.×3Ñ3×9Ñ9Ó;Ø˜\Õ*ô
ð 	
r*   c                óÀ   <€ V ^8„  d   QhRS[ P                  RS[S[S[3,          RS[S[ P                  ,          RS[S[S[S[3,          ,          RS[ P                  /# )r   r9   r4   rI   Úsizer   )r   r    r   r"   r   r   r   r#   )r%   r&   s   "€r'   r(   r)   ½   sc   ø€ ÷ 
ñ 
á�|‰|ð
ñ ‘C™�H�~ð
ñ ™EŸL™LÕ)ð	
ñ
 ‘u™S¡#˜X•Õ'ð
ñ 
�‰ñ
r*   c           
     ó  € \        V\        P                  4      '       g   \        R \	        V4       R24      hV P                  VV P                  \        P                  ! W1P                  VP                  R7      VR7      # )rK   rL   )rC   rD   )r:   rI   r4   )
r1   r   r    rO   rP   rV   Ú_paramsr2   rC   rD   )r5   r9   r4   rI   rY   s   &&&&&r'   Úinverse_transformÚRandomAffine.inverse_transform½   sl   € ô ˜)¤U§\¡\×2Ò2ÜÐNÌtÐT]ËÐN_Ð_`ÐaÓbÐbØ×#Ñ#ØØ—<‘<Ü—o’o i¿¹ÈEÏKÉKÔXØð	 $ó 
ð 	
r*   )r0   r4   )N)NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r
   ÚBILINEARrQ   r   ÚZEROSr-   rF   rV   r\   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r6   r&   s   @@r'   r   r      ss   ù‡ € ñZð~ IMØgkØKOØ.6×.?Ñ.?×.DÑ.DØ#Ø#Ø7D×7JÑ7J×7OÑ7OØ@DØØ÷
õ 
÷6
ð 
÷$
ò 
÷*
÷ 
ò 
r*   r   )rA   Útypingr   r   r   r   r   r   Úkornia.augmentationr   r.   Ú&kornia.augmentation._2d.geometric.baser	   Úkornia.constantsr
   r   Úkornia.core.utilsr   Úkornia.geometry.transformr   r   r   © r*   r'   Ú<module>ro      s1   ðó$ ß 4Õ 4ã å 6Ý Nß 4Ý 4ß Fôm
Ð.ö m
r*   