+
    ùäûjƒ  ã                   ót   € ^ RI Ht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 R]4      tR# )	é    )ÚAnyÚDictÚListÚOptionalÚTupleÚUnionN)Úrandom_generator)ÚIntensityAugmentationBase2D)Ú_clamp_unit_range)Újpeg_codec_differentiablec                   ó\   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	# )	Ú
RandomJPEGa™  Simulate differentiable JPEG coding for RGB images.

``output = RandomJPEG(jpeg_quality, ...)(input)`` simulates JPEG coding for selected RGB images of shape
``(B, 3, H, W)``.

.. image:: _static/img/RandomJPEG.png

See the Convention block on :class:`~kornia.augmentation.IntensityAugmentationBase2D`.
:func:`kornia.color.ycbcr_to_rgb` hard-clamps the decoded RGB values to ``[0, 1]``. The codec's final
soft-clipping call uses bounds ``[0, 255]`` and leaves those RGB values unchanged. The input must have
three channels: the codec works in YCbCr, and any other channel count raises a ``ShapeError``.

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.

Args:
    jpeg_quality: The range of compression rates to be applied.
    p: probability of applying the transformation.
    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)``
    - Output: ``(B, C, H, W)``

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

See Also:
    - :class:`RandomGaussianBlur`: smooths with a filter rather than JPEG coding artifacts.

Examples:
    >>> import torch
    >>> rng = torch.manual_seed(0)
    >>> images = 0.1904 * torch.ones(2, 3, 32, 32)
    >>> aug = RandomJPEG(jpeg_quality=(1.0, 50.0), p=1.)
    >>> images_jpeg = aug(images)

To apply the exact augmenation again, you may take the advantage of the previous parameter state:
    >>> images = 0.1904 * torch.ones(2, 3, 32, 32)
    >>> aug = RandomJPEG(jpeg_quality=20.0, p=1.)  # Samples a JPEG quality from the range [30.0, 70.0]
    >>> (aug(images) == aug(images, params=aug._params)).all()
    tensor(True)

c          
      óŽ   <€ V ^8„  d   QhRS[ S[P                  S[S[S[S[3,          S[S[,          3,          RS[RS[RS[RR/# )é   Újpeg_qualityÚsame_on_batchÚpÚkeepdimÚreturnN)r   ÚtorchÚTensorÚfloatr   r   Úbool)ÚformatÚ__classdict__s   "€ÚbC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\intensity\jpeg.pyÚ__annotate__ÚRandomJPEG.__annotate__M   s\   ø€ ÷ 	?ñ 	?á™EŸL™L©%±±u¹e°|Õ1DÁdÉ5ÅkÐQÕRð	?ñ ð	?ñ ð		?ñ
 ð	?ð 
ñ	?ó    c                ól   <€ \         SV `  W2VR 7       Wn        \        P                  ! V4      V n        R# ))r   r   r   N)ÚsuperÚ__init__r   ÚrgÚJPEGGeneratorÚ_param_generator)Úselfr   r   r   r   Ú	__class__s   &&&&&€r   r"   ÚRandomJPEG.__init__M   s0   ø€ ô 	‰Ñ˜1À7ÐÔKØ(ÔÜ "× 0Ò 0°Ó >ˆÖ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   X   sd   ø€ ÷ ñ á�|‰|ðñ ‘S™%Ÿ,™,Ð&Õ'ðñ ‘C™�H�~ð	ñ
 ™EŸL™LÕ)ðñ 
�‰ñr   c                óX  € VR ,          P                  4       ^ 8X  dq   VP                  ^ ,          ^ 8X  dY   VP                  ^,          ^8X  dA   VP                  R,          ^ 8”  d)   VP                  R,          ^ 8”  d   VP                  4       # \        V4      p\	        WR ,          4      pV# )r   éþÿÿÿéÿÿÿÿ)ÚnumelÚshapeÚcloner   r   )r&   r*   r+   r,   r-   Újpeg_outputs   &&&&& r   Úapply_transformÚRandomJPEG.apply_transformX   s‡   € ð �>Õ"×(Ñ(Ó*¨aÔ/Ø—‘˜A• !Ô#Ø—‘˜A• !Ô#Ø—‘˜B• !Ô#Ø—‘˜B• !Ô#ð —;‘;“=Ð Ü! %Ó(ˆÜ$=¸eÈNÕE[Ó$\ˆØÐr   )r%   r   )g      I@Fg      ð?F)N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r"   r6   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r'   r   s   @@r   r   r      s$   ù‡ € ñ.÷`	?õ 	?÷÷ ò r   r   )Útypingr   r   r   r   r   r   r   Úkornia.augmentationr	   r#   Ú&kornia.augmentation._2d.intensity.baser
   Úkornia.core.utilsr   Úkornia.enhancer   r   © r   r   Ú<module>rF      s+   ð÷$ ;× :ã å 6Ý NÝ /Ý 4ôNÐ,ö Nr   