+
    ùäû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_contrastc                   ó\   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	# )	ÚRandomContrasta×
  Scale pixel values by a random contrast factor.

``output = RandomContrast(contrast)(input)`` computes ``input * factor`` for each selected image using a sampled
contrast factor, with clamping enabled by default. Use :class:`ColorJitter` for torchvision-compatible contrast,
which blends the image with its grayscale mean, ``factor * input + (1 - factor) * mean``.

.. image:: _static/img/RandomContrast.png

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

Args:
    contrast: the contrast factor to apply.
    clip_output: if true clip output.
    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:
    - with ``clip_output=True``, input values are clamped into ``[0, 1]`` before the operation
      as well as afterwards. With ``clip_output=False``, the arithmetic is range-independent:
      neither input nor output is clamped.
    - the drawn factor reaches :func:`kornia.enhance.adjust_contrast` unchanged -- it is not re-based the way
      :class:`RandomBrightness` re-bases its own -- so ``1.0`` is the identity: for any input with
      ``clip_output=False``, and for an input in ``[0, 1]`` at the default.
    - at the default ``clip_output=True`` the result is clamped into ``[0, 1]``; with ``clip_output=False``
      the raw product is returned.

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

See Also:
    - :class:`RandomBrightness`: adds an offset instead of scaling values.
    - :class:`ColorJiggle`: combines this raw-value scaling with color adjustments.
    - :class:`ColorJitter`: blends with the grayscale mean as torchvision does.

Examples:
    >>> rng = torch.manual_seed(0)
    >>> inputs = torch.rand(1, 3, 3, 3)
    >>> aug = RandomContrast(contrast = (0.5, 2.), p = 1.)
    >>> aug(inputs)
    tensor([[[[0.2750, 0.4258, 0.0490],
              [0.0732, 0.1704, 0.3514],
              [0.2716, 0.4969, 0.2525]],
    <BLANKLINE>
             [[0.3505, 0.1934, 0.2227],
              [0.0124, 0.0936, 0.1629],
              [0.2874, 0.3867, 0.4434]],
    <BLANKLINE>
             [[0.0893, 0.1564, 0.3778],
              [0.5072, 0.2201, 0.4845],
              [0.2325, 0.3064, 0.5281]]]])

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

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

c                óR   <€ V ^8„  d   QhRS[ S[S[3,          RS[RS[RS[RS[RR/# )é   ÚcontrastÚclip_outputÚsame_on_batchÚpÚkeepdimÚreturnN)r   ÚfloatÚbool)ÚformatÚ__classdict__s   "€ÚfC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\intensity\contrast.pyÚ__annotate__ÚRandomContrast.__annotate___   sP   ø€ ÷ 'ñ 'á™™u˜Õ%ð'ñ ð'ñ ð	'ñ
 ð'ñ ð'ð 
ñ'ó    c                óÎ   <€ \         S	V `  WCVR 7       \        VRRR7      w  rgpW`n        \        P
                  ! V P                  RWx34      V n        \        V RV4       W n        R# ))r   r   r   r   ç      ð?)ÚcenterÚcontrast_factorN)	ÚsuperÚ__init__r	   r   ÚrgÚPlainUniformGeneratorÚ_param_generatorr
   r   )
Úselfr   r   r   r   r   Úfactorr"   ÚboundsÚ	__class__s
   &&&&&&   €r   r%   ÚRandomContrast.__init___   sb   ø€ ô 	‰Ñ˜1À7ÐÔKÜ!7¸À*ÐUXÔ!YÑˆ˜Ø&,ŒÜ "× 8Ò 8¸$¿-¹-ÐIZÐ\bÐ9kÓ lˆÔÜ% d¨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   )ÚtorchÚTensorr   Ústrr   r   )r   r   s   "€r   r   r   o   sk   ø€ ÷ 
Iñ 
Iá�|‰|ð
Iñ ‘S™%Ÿ,™,Ð&Õ'ð
Iñ ‘C™�H�~ð	
Iñ
 ™EŸL™LÕ)ð
Iñ 
�‰ñ
Ir   c                ó¸   € V P                   '       d   \        V4      p\        VR ,          VP                  VP                  4      p\        WV P                   4      # )r#   )r   r   r   ÚdeviceÚdtyper   )r)   r/   r0   r1   r2   r#   s   &&&&& r   Úapply_transformÚRandomContrast.apply_transformo   sL   € ð ××ÐÜ% eÓ,ˆEÜ0°Ð8IÕ1JÈEÏLÉLÐZ_×ZeÑZeÓfˆÜ˜u°t×7GÑ7GÓHÐHr   )r(   r   r   ))r!   r!   TFr!   F)N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r%   r9   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r,   r   s   @@r   r   r      s'   ù‡ € ñ?÷B'õ '÷ 
I÷ 
Iò 
Ir   r   )Útypingr   r   r   r   r3   Ú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>rJ      s0   ð÷$ .Ó -ã å 6Ý Nß lß GÝ 1ô\IÐ0ö \Ir   