+
    ùäûjš  ã                   ól   € ^ 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 ^ RIHt  ! R R]
4      tR# )	é    )ÚAnyÚDictÚOptionalÚTupleN)Úrandom_generator)ÚIntensityAugmentationBase2D)Ú_clamp_unit_range)ÚStableDiffusionDissolvingc                   ó\   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	# )	ÚRandomDissolvingaÊ
  Dissolve images with a Stable Diffusion model, applied to the whole batch with probability ``p`` (default 0.5).

``output = RandomDissolving(step_range, version, ...)(input)`` applies one sampled reverse-diffusion step to the
selected batch of images. It needs the optional ``diffusers`` dependency and a compatible Stable Diffusion model.

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

Based on :cite:`shi2024dissolving`, the dissolving transformation is essentially applying one-step
reverse diffusion. Our implementation currently supports the HuggingFace implementations of SD 1.4, SD 1.5
and SD XL; once ``diffusers`` is importable, any other ``version`` raises ``NotImplementedError``
with the unsupported value and the supported versions
(without it, construction fails on the optional-dependency prompt before the version is looked at).

.. list-table::
    :widths: 32 32 32
    :header-rows: 1

    * - SD 1.4
      - SD 1.5
      - SD XL
    * - .. figure:: https://raw.githubusercontent.com/kornia/data/main/dslv-sd-1.4.png
      - .. figure:: https://raw.githubusercontent.com/kornia/data/main/dslv-sd-1.5.png
      - .. figure:: https://raw.githubusercontent.com/kornia/data/main/dslv-sd-xl.png

Args:
    p: probability of applying the transformation, drawn once for the whole batch.
    version: the version of the stable diffusion model. Options: ``"1.4"``, ``"1.5"``, ``"xl"``.
    step_range: the step range of the diffusion model steps. Higher the step, stronger
                the dissolving effects.
    keepdim: whether to keep the output shape the same as input (True) or broadcast it
             to the batch form (False).
    **kwargs: additional arguments for `.from_pretrained` for HF StableDiffusionPipeline.

Shape:
    - Input: ``(C, H, W)`` or ``(B, C, H, W)``.
    - 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 clamped input is encoded by the Stable Diffusion VAE; its decoded result is also clamped.

.. note::
    The transform is delegated to ``kornia.filters.StableDiffusionDissolving``, which the constructor
    builds: instantiating this class needs the optional ``diffusers`` package and, on a cold cache,
    downloads a Stable Diffusion checkpoint at that point -- the ``from_pretrained`` call is in that
    class's own constructor, not on the first forward.

See Also:
    - :class:`RandomErasing`: removes a rectangle without a diffusion model.
    - :class:`~kornia.filters.StableDiffusionDissolving`: the model itself, with a step you choose and an input it
      does not clamp.

c                óR   <€ V ^8„  d   QhRS[ S[S[3,          RS[RS[RS[RS[RR/# )é   Ú
step_rangeÚversionÚpÚkeepdimÚkwargsÚreturnN)r   ÚfloatÚstrÚboolr   )ÚformatÚ__classdict__s   "€ÚhC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\intensity\dissolving.pyÚ__annotate__ÚRandomDissolving.__annotate__T   sX   ø€ ÷ mñ má™%¡˜,Õ'ðmñ ðmñ ð	mñ
 ðmñ ðmð 
ñmó    c                ó¬   <€ \         SV `  VR VR7       Wn        \        V3/ VB V n        \
        P                  ! V P                  RRR34      V n        R# )T)r   Úsame_on_batchr   Ústep_range_factorN)ÚsuperÚ__init__r   r
   Ú_dslvÚrgÚPlainUniformGeneratorÚ_param_generator)Úselfr   r   r   r   r   Ú	__class__s   &&&&&,€r   r"   ÚRandomDissolving.__init__T   sR   ø€ ô 	‰Ñ˜1¨D¸'ÐÔBØ$ŒÜ.¨wÑA¸&ÑAˆŒ
Ü "× 8Ò 8¸$¿/¹/ÐK^Ð`dÐfjÐ9kÓ lˆÖ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   r   r   r   )r   r   s   "€r   r   r   a   sk   ø€ ÷ bñ bá�|‰|ðbñ ‘S™%Ÿ,™,Ð&Õ'ðbñ ‘C™�H�~ð	bñ
 ™EŸL™LÕ)ðbñ 
�‰ñbr   c                ó    € \        V4      p\        V P                  WR ,          ^ ,          P                  4       P                  4       4      4      # )r    )r	   r#   ÚlongÚitem)r'   r+   r,   r-   r.   s   &&&&&r   Úapply_transformÚ RandomDissolving.apply_transforma   s?   € ô " %Ó(ˆÜ  §¡¨EÐ:MÕ3NÈqÕ3Q×3VÑ3VÓ3X×3]Ñ3]Ó3_Ó!`ÓaÐar   )r#   r&   r   ))éd   iô  z1.5g      à?F)N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r"   r4   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r(   r   s   @@r   r   r      s)   ù‡ € ñ5÷nmõ m÷b÷ bò br   r   )Útypingr   r   r   r   r/   Úkornia.augmentationr   r$   Ú&kornia.augmentation._2d.intensity.baser   Úkornia.core.utilsr	   Úkornia.filtersr
   r   © r   r   Ú<module>rE      s-   ð÷$ .Ó -ã å 6Ý NÝ /Ý 4ôMbÐ2ö Mbr   