+
    öäûj‡  ã                   ó„   € ^ RI 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 ^ RIHt  ! R	 R
]	4      tR# )é    )ÚAnyÚDictÚOptionalN)Úrandom_generator)ÚAugmentationBase2D)Ú_samples_half_in_float32Ú_to_device_nonblocking)Úcreate_meshgrid)Úeuclidean_distance)Úremapc                   óš   a a€ ] tR t^t oRtR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V3R
 lR llt	Rt
VtV ;t# )ÚRandomFisheyeaK  Add a random radial (fisheye) distortion, applied per sample with probability ``p`` (default 0.5).

``output = RandomFisheye(...)(input)`` radially distorts each selected image of shape ``(B, C, H, W)``.

Args:
    center_x: Ranges to sample respect to x-coordinate center with shape (2,).
    center_y: Ranges to sample respect to y-coordinate center with shape (2,).
    gamma: Ranges to sample for the gamma values respect to optical center with shape (2,).
    same_on_batch: apply the same transformation across the batch.
    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).

.. image:: _static/img/RandomFisheye.png

Convention:
    Coordinates are normalized to ``[-1, 1]`` with corner pixel centers at the endpoints.
    At output coordinate ``(x, y)``, let ``r`` be its distance from the sampled center.
    The input sampling coordinate is ``(x * (1 + r**gamma), y * (1 + r**gamma))``:
    the center changes the distance, but scaling is about the coordinate origin.
    Sampling is bilinear with zero padding and ``align_corners=True``; these settings are fixed.
    There is no ``transform_matrix`` or ``inverse``. A ``mask``, keypoint or box data key raises
    ``NotImplementedError`` identifying this augmentation, even at ``p=0``
    (`#4420 <https://github.com/kornia/kornia/issues/4420>`_).

See Also:
    - :class:`RandomPerspective`: samples a projective rather than radial warp.

Examples:
    >>> import torch
    >>> img = torch.ones(1, 1, 2, 2)
    >>> center_x = torch.tensor([-.3, .3])
    >>> center_y = torch.tensor([-.3, .3])
    >>> gamma = torch.tensor([.9, 1.])
    >>> out = RandomFisheye(center_x, center_y, gamma)(img)
    >>> out.shape
    torch.Size([1, 1, 2, 2])

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

c                ó~   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  RS[RS[RS[RR/# )	é   Úcenter_xÚcenter_yÚgammaÚsame_on_batchÚpÚkeepdimÚreturnN)ÚtorchÚTensorÚboolÚfloat)ÚformatÚ__classdict__s   "€ÚeC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\geometric\fisheye.pyÚ__annotate__ÚRandomFisheye.__annotate__M   s]   ø€ ÷ 
ñ 
á—,‘,ð
ñ —,‘,ð
ñ �|‰|ð	
ñ
 ð
ñ ð
ñ ð
ð 
ñ
ó    c                ó  <€ \         SV `  WTR VR7       V P                  V4       V P                  V4       V P                  V4       \        P                  ! VR,          RRR3VR,          RRR3VR,          RRR34      V n        R# )g      ð?)r   r   Úp_batchr   Nr   r   r   ):NNNN)ÚsuperÚ__init__Ú_check_tensorÚrgÚPlainUniformGeneratorÚ_param_generator)Úselfr   r   r   r   r   r   Ú	__class__s   &&&&&&&€r   r%   ÚRandomFisheye.__init__M   s‰   ø€ ô 	‰Ñ˜1À3ÐPWÐÔXØ×Ñ˜8Ô$Ø×Ñ˜8Ô$Ø×Ñ˜5Ô!Ü "× 8Ò 8Ø�gÕ 
¨D°$Ð7Ø�gÕ 
¨D°$Ð7Ø�7�^˜W d¨DÐ1ó!
ˆÖr!   c                ó8   <€ V ^8„  d   QhRS[ P                  RR/# )r   Údatar   N)r   r   )r   r   s   "€r   r   r    `   s#   ø€ ÷ Xñ X¡%§,¡,ð X°4ñ Xr!   c                ó  € \        V\        P                  4      '       g   \        R \	        V4       24      h\        VP                  4      ^8w  d4   VP                  ^ ,          ^8w  d   \        RVP                   R24      hR# R# )z1Invalid input type. Expected torch.Tensor - got: z)torch.Tensor must be of shape (2,). Got: Ú.N)Ú
isinstancer   r   Ú	TypeErrorÚtypeÚlenÚshapeÚ
ValueError)r*   r.   s   &&r   r&   ÚRandomFisheye._check_tensor`   sn   € Ü˜$¤§¡×-Ò-ÜÐOÔPTÐUYÓPZÈ|Ð\Ó]Ð]äˆt�z‰z‹?˜aÔ D§J¡J¨q¥M°QÔ$6ÜÐHÈÏÉÈÐTUÐVÓWÐWñ %7Ñ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   ÚinputÚparamsÚflagsÚ	transformr   ©r   r   r   Ústrr   r   )r   r   s   "€r   r   r    g   sk   ø€ ÷ mñ má�|‰|ðmñ ‘S™%Ÿ,™,Ð&Õ'ðmñ ‘C™�H�~ð	mñ
 ™EŸL™LÕ)ðmñ 
�‰ñmr!   c                óö  € VP                   p\        V4      '       d   VP                  4       pVP                  w  rgr‰VP                   \        P
                  8X  d   \        P
                  MR p
\        W‰RV
R7      p\        VR,          VP                  VP                   4      p\        VR	,          VP                  VP                   4      p\        VR,          P                  V^^4      VP                  VP                   4      p\        VR,          P                  V^^4      VP                  VP                   4      p\        VR,          P                  V^^4      VP                  VP                   4      p\        \        P                  ! Wï3R
R7      \        P                  ! WÍ3R
R7      4      pWÌVV,          ,          ,           pWÝVV,          ,          ,           p\        WVRRR7      P                  V4      # )NT)Únormalized_coordinatesÚdtyper   r   r   )Údim)rA   Úalign_corners).r   ).é   éÿÿÿÿ)rB   r   r   r5   r   Úfloat64r
   r	   ÚdeviceÚviewr   Ústackr   Úto)r*   r:   r;   r<   r=   Ú	out_dtypeÚBÚ_ÚHÚWÚ
grid_dtypeÚgridÚfield_xÚfield_yr   r   r   Údistances   &&&&&             r   Úapply_transformÚRandomFisheye.apply_transformg   s€  € ð —K‘Kˆ	Ü# E×*Ò*Ø—K‘K“MˆEà—[‘[‰
ˆˆaà&+§k¡k´U·]±]Ô&B”U—]’]Èˆ
Ü˜q¸DÈ
ÔSˆÜ(¨¨f­°u·|±|ÀUÇ[Á[ÓQˆÜ(¨¨f­°u·|±|ÀUÇ[Á[ÓQˆä)¨&°Õ*<×*AÑ*AÀ!ÀQÈÓ*JÈEÏLÉLÐZ_×ZeÑZeÓfˆÜ)¨&°Õ*<×*AÑ*AÀ!ÀQÈÓ*JÈEÏLÉLÐZ_×ZeÑZeÓfˆÜ& v¨g¥×';Ñ';¸A¸qÀ!Ó'DÀeÇlÁlÐTY×T_ÑT_Ó`ˆä%Ü�KŠK˜Ð,°"Ô5´u·{²{ÀGÐCUÐ[]Ô7^ó
ˆð  h°¥oÕ5Õ5ˆØ h°¥oÕ5Õ5ˆÜ�U WÀTÐY]Ô^×aÑaÐbkÓlÐlr!   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                  /# r9   r>   )r   r   s   "€r   r   r    …   ód   ø€ ÷ 

ñ 

á�|‰|ð

ñ ‘S™%Ÿ,™,Ð&Õ'ð

ñ ‘C™�H�~ð	

ñ
 ™EŸL™LÕ)ð

ñ 
�‰ñ

r!   c                óD   € \        \        V 4      P                   R24      h)z=Reject mask inputs, which this augmentation does not support.úP does not support mask inputs. See https://github.com/kornia/kornia/issues/4420.©ÚNotImplementedErrorr3   Ú__name__©r*   r:   r;   r<   r=   s   &&&&&r   Úapply_transform_maskÚ"RandomFisheye.apply_transform_mask…   ó'   € ô "Ü�D‹z×"Ñ"Ð#Ð#sÐtó
ð 	
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                  /# r9   r>   )r   r   s   "€r   r   r    ‘   rY   r!   c                óD   € \        \        V 4      P                   R24      h)z?Reject mask inputs even when the transformation is not applied.r[   r\   r_   s   &&&&&r   Úapply_non_transform_maskÚ&RandomFisheye.apply_non_transform_mask‘   rb   r!   )r)   )Fg      à?F)N)r^   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r%   r&   rV   r`   re   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r+   r   s   @@r   r   r      sF   ù‡ € ñ,÷\
õ 
÷&Xð X÷mò m÷<

ò 

÷

÷ 

ò 

r!   r   )Útypingr   r   r   r   Úkornia.augmentationr   r'   Úkornia.augmentation._2d.baser   Úkornia.core.utilsr   r	   Úkornia.geometry.gridr
   Úkornia.geometry.linalgr   Úkornia.geometry.transformr   r   © r!   r   Ú<module>rv      s1   ð÷$ 'Ñ &ã å 6Ý ;ß NÝ 0Ý 5Ý +ô}
Ð&ö }
r!   