+
    öäûj‰  ã                   óT   € ^ RI HtHtHtHt ^ RIt^ RIHt ^ RIHt  ! R R]4      t	R# )é    )ÚAnyÚDictÚOptionalÚTupleN)ÚTensor)ÚGeometricAugmentationBase2Dc                   ó„   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
t	Vt
V ;t# )ÚPadToaÒ  Pad or crop an image batch to a requested size. Always occurs (p=1.0).

``output = PadTo(size)(input)`` pads or crops the right and bottom edges of an image batch
``(B, C, H, W)`` to ``size``. Set ``crop_if_exceeds=False`` to keep oversized axes unchanged;
use :class:`Resize` when the content itself should be resampled.

Args:
    size: a tuple of ints in the format (height, width) that give the spatial
        dimensions to pad inputs to.
    pad_mode: the type of padding to perform on the image (valid values
        are those accepted by torch.nn.functional.pad)
    pad_value: fill value for 'constant' padding applied to the image
    keepdim: whether to keep the output shape the same as input (True) or broadcast it
             to the batch form (False).
    crop_if_exceeds: if True (default), an input dimension larger than ``size`` is cropped to ``size``. If
        False, that dimension passes through unchanged, so the output is at least ``size`` on each axis and its
        shape depends on the input.

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

.. note::
    This function internally uses :func:`torch.nn.functional.pad`.

Convention:
    See :class:`~kornia.augmentation.GeometricAugmentationBase2D` for coordinates, defaults and inverse.
    This operation always runs and pads on the right and bottom, using ``pad_mode`` and ``pad_value``. With the
    default ``crop_if_exceeds=True``, a target smaller than the input crops that axis instead, so a target can pad
    one axis while cropping the other. With ``crop_if_exceeds=False``, that axis passes through unchanged.

    ``inverse()`` restores the prior input shape on every axis. It exactly removes right/bottom padding, and it
    regrows a cropped axis at the right/bottom with zeros, as the crop augmentations' inverses do: the discarded
    pixels cannot be recovered. The transformation matrix is identity, because every kept pixel keeps its
    coordinates, so keypoints and boxes are neither moved nor clipped when cropping puts them outside the canvas.

.. image:: _static/img/PadTo.png

See Also:
    - :class:`Resize`: resamples an image to a requested size.

Examples:
    >>> import torch
    >>> img = torch.tensor([[[[0., 0., 0.],
    ...                       [0., 0., 0.],
    ...                       [0., 0., 0.]]]])
    >>> pad = PadTo((4, 5), pad_value=1.)
    >>> out = pad(img)
    >>> out
    tensor([[[[0., 0., 0., 1., 1.],
              [0., 0., 0., 1., 1.],
              [0., 0., 0., 1., 1.],
              [1., 1., 1., 1., 1.]]]])
    >>> pad.inverse(out)
    tensor([[[[0., 0., 0.],
              [0., 0., 0.],
              [0., 0., 0.]]]])

    >>> crop = PadTo((2, 4))
    >>> crop.inverse(crop(torch.ones(1, 1, 3, 3)))
    tensor([[[[1., 1., 1.],
              [1., 1., 1.],
              [0., 0., 0.]]]])

    >>> img_large = torch.zeros(1, 1, 4, 4)
    >>> PadTo((2, 2), crop_if_exceeds=False)(img_large).shape
    torch.Size([1, 1, 4, 4])

c                óR   <€ V ^8„  d   QhRS[ S[S[3,          RS[RS[RS[RS[RR/# )é   ÚsizeÚpad_modeÚ	pad_valueÚkeepdimÚcrop_if_exceedsÚreturnN)r   ÚintÚstrÚfloatÚbool)ÚformatÚ__classdict__s   "€ÚaC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\geometric\pad.pyÚ__annotate__ÚPadTo.__annotate__a   sO   ø€ ÷ 
ñ 
á‘C™�H�oð
ñ ð
ñ ð	
ñ
 ð
ñ ð
ð 
ñ
ó    c                óL   <€ \         SV `  R RR VR7       RVRVRVRV/V n        R# )g      ð?T)ÚpÚsame_on_batchÚp_batchr   r   r   r   r   N)ÚsuperÚ__init__Úflags)Úselfr   r   r   r   r   Ú	__class__s   &&&&&&€r   r"   ÚPadTo.__init__a   s8   ø€ ô 	‰Ñ˜3¨d¸CÈÐÔQà�DØ˜Ø˜Ø˜ð	
ˆŽ
r   c                ó^   <€ V ^8„  d   QhRS[ RS[S[S[ 3,          RS[S[S[3,          RS[ /# )r   ÚimageÚparamsr#   r   )r   r   r   r   )r   r   s   "€r   r   r   s   s@   ø€ ÷ +ñ +©Fð +¹DÁÁfÀÕ<Mð +ÑVZÑ[^Ñ`cÐ[cÕVdð +Ñioñ +r   c                ó$   € V P                  V4      # ©N)Úidentity_matrix)r$   r(   r)   r#   s   &&&&r   Úcompute_transformationÚPadTo.compute_transformations   s   € Ø×#Ñ# EÓ*Ð*r   c          
      ót   <€ V ^8„  d   QhRS[ RS[S[S[ 3,          RS[S[S[3,          RS[S[ ,          RS[ /# )r   Úinputr)   r#   Ú	transformr   )r   r   r   r   r   )r   r   s   "€r   r   r   v   sL   ø€ ÷ 
ñ 
Ùð
Ù%)©#©v¨+Õ%6ð
Ù?CÁCÉÀH½~ð
ÙZbÑciÕZjð
á	ñ
r   c                ó\  € VP                   w   rVpVR ,          ^ ,          V,
          pVR ,          ^,          V,
          p	VP                  RR4      '       g   \        V^ 4      p\        V	^ 4      p	\        P                  P
                  P                  V^ V	^ V.VR,          VR,          R7      # )r   r   Tr   r   ©ÚmodeÚvalue)ÚshapeÚgetÚmaxÚtorchÚnnÚ
functionalÚpad)
r$   r0   r)   r#   r1   Ú_ÚheightÚwidthÚ
height_padÚ	width_pads
   &&&&&     r   Úapply_transformÚPadTo.apply_transformv   s¤   € ð $Ÿk™kÑˆˆ1�eØ �-¨Õ*¨VÕ3ˆ
Ø˜v� qÕ)¨EÕ1ˆ	à�y‰yÐ*¨D×1Ò1Ü˜Z¨Ó+ˆJÜ˜I qÓ)ˆIÜ�x‰x×"Ñ"×&Ñ&Ø�A�y ! ZÐ0°u¸ZÕ7HÐPUÐVaÕPbð 'ó 
ð 	
r   c                ó„   <€ V ^8„  d   QhRS[ RS[S[S[3,          RS[S[ ,          RS[S[S[S[3,          ,          RS[ /# )r   r0   r#   r1   r   r   )r   r   r   r   r   r   r   )r   r   s   "€r   r   r   „   s^   ø€ ÷ uñ uáðuñ ‘C™�H�~ðuñ ™FÕ#ð	uñ
 ‘u™S¡#˜X•Õ'ðuñ 
ñur   c                óÜ   € Vf   \        R4      hVP                  RR  w  rV\        P                  P                  P                  V^ V^,          V,
          ^ V^ ,          V,
          .RRR7      # )Nz#`size` has to be a tuple. Got None.Úconstantg        r3   éþÿÿÿ)ÚRuntimeErrorr6   r9   r:   r;   r<   )r$   r0   r#   r1   r   r>   r?   s   &&&&&  r   Úinverse_transformÚPadTo.inverse_transform„   sj   € ð Š<ÜÐDÓEÐEð Ÿ™ B CÐ(‰ˆÜ�x‰x×"Ñ"×&Ñ& u¨q°$°qµ'¸Eµ/À1ÀdÈ1ÅgÐPVÕFVÐ.WÐ^hÐpsÐ&ÓtÐtr   )r#   )rF   r   FTr+   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r"   r-   rB   rI   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r%   r   s   @@r   r
   r
      s<   ù‡ € ñD÷L
õ 
÷$+ð +÷
ò 
÷u÷ uò ur   r
   )
Útypingr   r   r   r   r9   r   Ú&kornia.augmentation._2d.geometric.baser   r
   © r   r   Ú<module>rV      s'   ð÷$ .Ó -ã Ý å NôvuÐ'ö vur   