+
    ùäûj|  ã                   óˆ   € ^ RI t ^ 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# )
é    N)ÚAnyÚDictÚOptionalÚTuple)Úrandom_generator)ÚIntensityAugmentationBase2D)Ú_learnable_range_boundÚ_load_unowned_learnable_range)Ú_clamp_unit_rangeÚ_to_device_nonblocking)Ú
adjust_huec                   ó\   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	# )	Ú	RandomHueaš  Rotate the hue of a three-channel image by a random number of turns.

``output = RandomHue(hue)(input)`` samples an HSV hue rotation for each selected image.

The shift is in turns of the hue circle, the unit of torchvision's ``adjust_hue`` ``hue_factor``, so a
torchvision hue range carries over unchanged.

.. image:: _static/img/RandomHue.png

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

Args:
    hue: the hue shift, in turns of the hue circle, restricted to the closed ``[-0.5, 0.5]``. If ``hue``
      is a single number ``x`` the shift is sampled from ``[-x, x]``, and ``x`` above ``0.5`` raises; a
      tuple gives the range directly, and one outside the bound raises as well.
    same_on_batch: apply the same transformation across the batch.
    p: probability of applying the transformation.
    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 shift is computed in HSV, and any other channel count raises
      a ``ValueError`` on the forward pass.
    - the drawn shift is in turns of the hue circle, and the class multiplies it by ``2 * pi`` before
      calling :func:`kornia.enhance.adjust_hue`, which takes radians. Passing the same number
      straight to that primitive shifts the hue by a different amount.
    - the HSV hue shift preserves the clamped input pixel's largest and smallest channel, up to rounding.

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

See Also:
    - :class:`RandomSaturation`: scales HSV saturation without rotating hue.
    - :class:`ColorJiggle`: combines hue rotation with other Kornia color adjustments.
    - :class:`ColorJitter`: combines hue rotation with torchvision-compatible color adjustments.

Examples:
    >>> rng = torch.manual_seed(0)
    >>> inputs = torch.rand(1, 3, 3, 3)
    >>> aug = RandomHue(hue = (-0.5,0.5),p=1.)
    >>> aug(inputs)
    tensor([[[[0.3993, 0.2823, 0.6816],
              [0.6117, 0.2090, 0.4081],
              [0.4693, 0.5529, 0.9527]],
    <BLANKLINE>
             [[0.1610, 0.5962, 0.4971],
              [0.9152, 0.3971, 0.8742],
              [0.4194, 0.6771, 0.7162]],
    <BLANKLINE>
             [[0.6323, 0.7682, 0.0885],
              [0.0223, 0.1689, 0.2939],
              [0.5185, 0.8964, 0.4556]]]])

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

    >>> input = torch.rand(1, 3, 32, 32)
    >>> aug = RandomHue((-0.2,0.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/# )é   ÚhueÚsame_on_batchÚpÚkeepdimÚreturnN)r   ÚfloatÚbool)ÚformatÚ__classdict__s   "€ÚaC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\intensity\hue.pyÚ__annotate__ÚRandomHue.__annotate__b   s>   ø€ ÷ ;ñ ;Ù™¡˜Õ&ð;ÙDHð;ÙUZð;Ùkoð;à	ñ;ó    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   )ÚboundsÚ
hue_factorN)g      à¿g      à?)ÚsuperÚ__init__r	   r   ÚrgÚPlainUniformGeneratorÚ_param_generatorr
   )	Úselfr   r   r   r   ÚfactorÚcenterr    Ú	__class__s	   &&&&&   €r   r#   ÚRandomHue.__init__b   sZ   ø€ ô 	‰Ñ˜1À7ÐÔKÜ!7¸¸UÈ;Ô!WÑˆ˜Ø!'ŒÜ "× 8Ò 8¸$¿(¹(ÀLÐRXÐ9aÓ bˆÔÜ% d¨E°6Ö: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   )ÚtorchÚTensorr   Ústrr   r   )r   r   s   "€r   r   r   k   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^,          \
        P                  ,          4      4      # )r!   )r   r   ÚdeviceÚdtyper   ÚmathÚpi)r'   r-   r.   r/   r0   r!   s   &&&&& r   Úapply_transformÚRandomHue.apply_transformk   sI   € ô " %Ó(ˆÜ+¨F°<Õ,@À%Ç,Á,ÐPU×P[ÑP[Ó\ˆ
Ü ¤¨EÀµ>ÄDÇGÁGÕ3KÓ!LÓMÐMr   )r&   r   ))ç        r;   Fg      ð?F)N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r#   r9   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r*   r   s   @@r   r   r      s(   ù‡ € ñA÷F;õ ;÷	N÷ 	Nò 	Nr   r   )r7   Útypingr   r   r   r   r1   Ú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>rK      s3   ðó$ ß -Ó -ã å 6Ý Nß lß GÝ ,ôVNÐ+ö VNr   