+
    ùäûj   ã                   ó€   € ^ RI 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Ht ^ RIHt  ! R R	]
4      tR# )
é    )ÚAnyÚDictÚOptionalÚTupleN)Úrandom_generator)ÚIntensityAugmentationBase2D)Ú_learnable_range_boundÚ_load_unowned_learnable_range)Ú_clamp_unit_rangeÚ_to_device_nonblocking)Úadjust_saturationc                   ó\   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	# )	ÚRandomSaturationap
  Scale the HSV saturation of a three-channel image by a random factor.

``output = RandomSaturation(saturation)(input)`` scales only the HSV saturation of each selected image by a
sampled factor. Use :class:`ColorJitter` for torchvision-compatible saturation, which blends the image with its
grayscale, ``factor * input + (1 - factor) * gray``.

.. image:: _static/img/RandomSaturation.png

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

Args:
    p: probability of applying the transformation.
    saturation: the saturation factor to apply.
    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 input must have three channels: the scaling is defined on the HSV saturation, and any other
      channel count raises a ``ValueError`` on the forward pass.
    - the drawn factor reaches :func:`kornia.enhance.adjust_saturation` unchanged, and ``1.0`` is the
      identity, up to rounding, for a pixel in ``[0, 1]``.
    - the HSV saturation is also clamped into ``[0, 1]`` before converting back to RGB.

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

See Also:
    - :class:`RandomHue`: rotates hue instead of scaling saturation.
    - :class:`ColorJiggle`: combines HSV saturation scaling with Kornia color adjustments.
    - :class:`ColorJitter`: uses torchvision-compatible grayscale-blend saturation.

Examples:
    >>> rng = torch.manual_seed(0)
    >>> inputs = torch.rand(1, 3, 3, 3)
    >>> aug = RandomSaturation(saturation = (0.5,2.),p=1.)
    >>> aug(inputs)
    tensor([[[[0.5569, 0.7682, 0.3529],
              [0.4811, 0.3474, 0.7411],
              [0.5028, 0.8964, 0.6772]],
    <BLANKLINE>
             [[0.6323, 0.5358, 0.5265],
              [0.4203, 0.2706, 0.5525],
              [0.5185, 0.7863, 0.8681]],
    <BLANKLINE>
             [[0.3711, 0.4989, 0.6816],
              [0.9152, 0.3971, 0.8742],
              [0.4636, 0.7060, 0.9527]]]])

To apply the exact augmenation again, you may take the advantage of the previous parameter state:

    >>> input = torch.rand(1, 3, 32, 32)
    >>> aug = RandomSaturation((0.8,1.2), p=1.)
    >>> (aug(input) == aug(input, params=aug._params)).all()
    tensor(True)

c          
      óL   <€ V ^8„  d   QhRS[ S[S[3,          RS[RS[RS[RR/# )é   Ú
saturationÚsame_on_batchÚpÚkeepdimÚreturnN)r   ÚfloatÚbool)ÚformatÚ__classdict__s   "€ÚhC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\intensity\saturation.pyÚ__annotate__ÚRandomSaturation.__annotate__]   sM   ø€ ÷ Bñ Bá™%¡˜,Õ'ðBñ ðBñ ð	Bñ
 ðBð 
ñBó    c                óÂ   <€ \         SV `  W2VR 7       \        VRRR7      w  rVpWPn        \        P
                  ! V P                  RWg34      V n        \        V RV4       R# ))r   r   r   r   ç      ð?)ÚcenterÚsaturation_factorN)ÚsuperÚ__init__r	   r   ÚrgÚPlainUniformGeneratorÚ_param_generatorr
   )	Úselfr   r   r   r   Úfactorr!   ÚboundsÚ	__class__s	   &&&&&   €r   r$   ÚRandomSaturation.__init__]   s\   ø€ ô 	‰Ñ˜1À7ÐÔKÜ!7¸
ÀLÐY\Ô!]Ñˆ˜Ø(.ŒÜ "× 8Ò 8¸$¿/¹/ÐK^Ð`fÐ9oÓ pˆÔÜ% d¨L¸&ÖAr   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   )ÚtorchÚTensorr   Ústrr   r   )r   r   s   "€r   r   r   j   sk   ø€ ÷ 	Nñ 	Ná�|‰|ð	Nñ ‘S™%Ÿ,™,Ð&Õ'ð	Nñ ‘C™�H�~ð		Nñ
 ™EŸL™LÕ)ð	Nñ 
�‰ñ	Nr   c                ó�   € \        V4      p\        VR ,          VP                  VP                  4      p\        \	        W4      4      # )r"   )r   r   ÚdeviceÚdtyper   )r(   r.   r/   r0   r1   r"   s   &&&&& r   Úapply_transformÚ RandomSaturation.apply_transformj   sB   € ô " %Ó(ˆÜ2°6Ð:MÕ3NÐPU×P\ÑP\Ð^c×^iÑ^iÓjÐÜ Ô!2°5Ó!LÓMÐMr   )r'   r   ))r    r    Fr    F)N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r$   r8   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r+   r   s   @@r   r   r      s)   ù‡ € ñ=÷~Bõ B÷	N÷ 	Nò 	Nr   r   )Útypingr   r   r   r   r2   Úkornia.augmentationr   r%   Ú&kornia.augmentation._2d.intensity.baser   Ú*kornia.augmentation.utils.param_validationr	   r
   Úkornia.core.utilsr   r   Úkornia.enhance.adjustr   r   © r   r   Ú<module>rI      s0   ð÷$ .Ó -ã å 6Ý Nß lß GÝ 3ôVNÐ2ö VNr   