+
    ùäûj�  ã                   ó|   € ^ 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  ! R R	]4      tR# )
é    )ÚAnyÚDictÚOptionalÚTupleÚUnionN)Úrandom_generator)ÚIntensityAugmentationBase2D)Ú_check_filter_min_size)Ú_clamp_unit_range)Ú	sharpnessc                   ó\   a a€ ] tR t^t oRtRV3R lV 3R llltRV3R lR lltRtVtV ;t	# )	ÚRandomSharpnessa-  Blend each sample with a ``3 x 3`` smoothed copy by a random factor, with probability ``p`` (default 0.5).

``output = RandomSharpness(sharpness, ...)(input)`` blends each selected ``(B, C, H, W)`` image with its local
smooth version.

A drawn factor above ``1`` sharpens and a factor below ``1`` blurs; the default
``sharpness=0.5`` draws from ``[0, 0.5]`` and therefore only ever blurs.

.. image:: _static/img/RandomSharpness.png

See the Convention block on :class:`~kornia.augmentation.IntensityAugmentationBase2D`.

Args:
    p: probability of applying the transformation to each sample.
    sharpness: the blend factor between the blurred image and the input. If ``sharpness`` is a single
        non-negative number ``x``, the factor is sampled from ``[0, x]``; a tuple gives the range
        directly.
    same_on_batch: apply the same transformation across the batch.
    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:
    - input values are clamped into ``[0, 1]`` before the operation, and the result is clamped
      into the same range. This applies only to samples selected by the probability gate.
    - the factor blends between the fully blurred image at ``0`` and the input at ``1``, and values
      above ``1`` sharpen. The one-pixel border is copied from the input at every factor, so it is never
      blurred or sharpened, although the final clamp into ``[0, 1]`` applies to it as to the rest.
    - a scalar argument is the upper bound of ``[0, x]``, so the default ``sharpness=0.5`` never reaches the
      identity and only blurs.

.. note::
    The smoothing kernel is a fixed ``3 x 3`` convolved with no padding, so both spatial sides
    must be at least ``3`` pixels; a smaller image raises a ``ValueError`` naming the class and
    the input shape.

.. note::
    This function internally uses :func:`kornia.enhance.sharpness`.

See Also:
    - :class:`RandomBoxBlur`: smooths rather than blends an image with its smoothed copy.

Examples:
    >>> rng = torch.manual_seed(0)
    >>> input = torch.rand(1, 1, 5, 5)
    >>> sharpness = RandomSharpness(1., p=1.)
    >>> sharpness(input)
    tensor([[[[0.4963, 0.7682, 0.0885, 0.1320, 0.3074],
              [0.6341, 0.4810, 0.7367, 0.4177, 0.6323],
              [0.3489, 0.4428, 0.1562, 0.2443, 0.2939],
              [0.5185, 0.6462, 0.7050, 0.2288, 0.2823],
              [0.6816, 0.9152, 0.3971, 0.8742, 0.4194]]]])

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

c          
      óz   <€ V ^8„  d   QhRS[ S[P                  S[S[S[S[3,          3,          RS[RS[RS[RR/# )é   r   Úsame_on_batchÚpÚkeepdimÚreturnN)r   ÚtorchÚTensorÚfloatr   Úbool)ÚformatÚ__classdict__s   "€ÚgC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\intensity\sharpness.pyÚ__annotate__ÚRandomSharpness.__annotate__^   s]   ø€ ÷ kñ ká™Ÿ™¡u©e±E¹5°LÕ.AÐAÕBðkñ ðkñ ð	kñ
 ðkð 
ñkó    c           	     ó~   <€ \         SV `  W2VR 7       \        P                  ! VRR^ \	        R4      334      V n        R# ))r   r   r   r   g        ÚinfN)ÚsuperÚ__init__ÚrgÚPlainUniformGeneratorr   Ú_param_generator)Úselfr   r   r   r   Ú	__class__s   &&&&&€r   r"   ÚRandomSharpness.__init__^   sA   ø€ ô 	‰Ñ˜1À7ÐÔKÜ "× 8Ò 8¸)À[ÐRUÐXYÔ[`ÐafÓ[gÐWhÐ9iÓ jˆÖ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   h   sd   ø€ ÷ (ñ (á�|‰|ð(ñ ‘S™%Ÿ,™,Ð&Õ'ð(ñ ‘C™�H�~ð	(ñ
 ™EŸL™LÕ)ð(ñ 
�‰ñ(r   c                ó^   € \        V4      p\        R V^RR7       VR,          p\        W4      # )r   Úvalid)Úborder_typer   )r   r
   r   )r&   r*   r+   r,   r-   Úfactors   &&&&& r   Úapply_transformÚRandomSharpness.apply_transformh   s2   € ô " %Ó(ˆÜÐ0°%¸ÈÕPØ˜Õ$ˆÜ˜Ó'Ð'r   )r%   )ç      à?Fr5   F)N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r"   r3   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r'   r   s   @@r   r   r      s&   ù‡ € ñ>÷@kõ k÷(÷ (ò (r   r   )Útypingr   r   r   r   r   r   Úkornia.augmentationr   r#   Ú&kornia.augmentation._2d.intensity.baser	   Úkornia.augmentation.utilsr
   Úkornia.core.utilsr   Úkornia.enhancer   r   © r   r   Ú<module>rE      s.   ð÷$ 5Õ 4ã å 6Ý NÝ <Ý /Ý $ôV(Ð1ö V(r   