+
    åûj2  ã                   óà   a € R t0 t ^ RIHtHtHt ^ RIt^ RIHt ^ RIHt ^RI	H
t
 RR/t] ^ k  ! R R	]P                  4      t ! R
 R]P                  4      t ! R R]P                  4      tR# )é    )ÚAnyÚOptionalÚTupleN)Únn)Úload_state_dict_from_url)Úvgg19_bnÚdinov2_vitl14zNhttps://dl.fbaipublicfiles.com/dinov2/dinov2_vitl14/dinov2_vitl14_pretrain.pthc                   óp   a a€ ] tR t^#t oRtR]P                  3V3R lV 3R llltV3R lR ltRt	Vt
V ;t# )ÚVGG19z¨Implement the VGG19 encoder for feature encoding.

Args:
    amp: Whether to use automatic mixed precision.
    amp_dtype: The data type for automatic mixed precision.
Fc                ó>   <€ V ^8„  d   QhRS[ RS[P                  RR/# )é   ÚampÚ	amp_dtypeÚreturnN)ÚboolÚtorchÚdtype)ÚformatÚ__classdict__s   "€ÚYC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\feature\dedode\encoder.pyÚ__annotate__ÚVGG19.__annotate__+   s'   ø€ ÷ #ñ #™Dð #±U·[±[ð #ÐUYñ #ó    c                ó¤   <€ \         SV `  4        \        P                  ! \	        4       P
                  R ,          4      V n        Wn        W n        R# ):Né(   NN)	ÚsuperÚ__init__r   Ú
ModuleListr   ÚfeaturesÚlayersr   r   )Úselfr   r   Ú	__class__s   &&&€r   r   ÚVGG19.__init__+   s5   ø€ Ü‰ÑÔÜ—m’m¤H£J×$7Ñ$7¸Õ$<Ó=ˆŒàŒØ"Žr   c                ó4   <€ V ^8„  d   QhRS[ P                  /# ©r   Úx©r   ÚTensor)r   r   s   "€r   r   r   2   s   ø€ ÷  ñ  ™Ÿ™ñ  r   c                ó´  € \         P                  ! RV P                  ;'       d    VP                  V P                  R7      ;_uu_ 4        . p. pV P
                   FZ  p\        V\        P                  4      '       d0   VP                  V4       VP                  VP                  RR 4       V! V4      pK\  	  W43uuRRR4       #   + '       g   i     R# ; i)aÞ  Run this DeDoDe module forward.

Args:
    x: Input image tensor with shape ``(B, 3, H, W)`` (BGR or RGB).
    **kwargs: Additional keyword arguments accepted for compatibility with the shared encoder interface. They
        are not used by this VGG19 batch-normalized backbone wrapper.

Returns:
    Tuple of ``(features, sizes)`` where ``features`` is a list of intermediate feature maps
    captured before each max-pool, and ``sizes`` is a list of their spatial dimensions.
Úcuda)Úenabledr   Néþÿÿÿ)r   Úautocastr   Úis_cudar   r    Ú
isinstancer   Ú	MaxPool2dÚappendÚshape)r!   r&   ÚkwargsÚfeatsÚsizesÚlayers   &&,   r   ÚforwardÚVGG19.forward2   s•   € ô �^Š^˜F¨D¯H©H×,BÐ,B¸¿¹È$Ï.É.×YÖYØˆEØˆEØŸœ�Ü˜e¤R§\¡\×2Ò2Ø—L‘L ”OØ—L‘L §¡¨¨ Ô.Ù˜!“H’ñ	 %ð
 �<÷ Z×Y×YÓYús   Á
A1CÃC	)r   r   r    ©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úfloat16r   r7   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r"   r   s   @@r   r   r   #   s.   ù‡ € ñð $)À5Ç=Á=÷ #õ #÷ ÷  ð  r   r   c                   ór   a a€ ] tR t^Jt oRtR]P                  R3V3R lV 3R llltV3R lR ltRt	Vt
V ;t# )	ÚFrozenDINOv2zDImplement a wrapper for a frozen DINOv2 vision transformer backbone.TNc                óP   <€ V ^8„  d   QhRS[ RS[P                  RS[S[,          /# )r   r   r   Údinov2_weights)r   r   r   r   r   )r   r   s   "€r   r   ÚFrozenDINOv2.__annotate__M   s-   ø€ ÷ -ñ -™Dð -±E·K±Kð -ÑaiÑjmÕanñ -r   c                óþ   <€ \         SV `  4        Vf   \        \        R,          RR7      p^RIHp \        R^RR^ R7      pV! R	/ VB P                  4       pVP                  V4       Wn	        W n
        V.V n        R # )
Nr	   Úcpu)Úmap_location)Ú	vit_largei  g      ð?Úmlp)Úimg_sizeÚ
patch_sizeÚinit_valuesÚ	ffn_layerÚblock_chunks© )r   r   r   ÚurlsÚtransformerrL   ÚdictÚevalÚload_state_dictr   r   r	   )r!   r   r   rG   rL   Ú
vit_kwargsr	   r"   s   &&&&   €r   r   ÚFrozenDINOv2.__init__M   s|   ø€ Ü‰ÑÔØÒ!Ü5´d¸?Õ6KÐZ_Ô`ˆNÝ*äØØØØØô
ˆ
ñ "Ñ/ JÑ/×4Ñ4Ó6ˆØ×%Ñ% nÔ5ØŒØ"Œà+˜_ˆÖr   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r%   r'   )r   r   s   "€r   r   rH   a   s   ø€ ÷ ;ñ ;™Ÿ™ñ ;r   c           	     ó,  € VP                   w  r#rEV P                  ;'       d    VP                  pV P                  ^ ,          pV'       dž   VP                  VP                  8w  g&   VP
                  P                  V P                  8w  dB   VP                  V P                  4      P                  VP                  4      V P                  ^ &   VP                  V P                  4      pMuVP                  VP                  8w  g&   VP
                  P                  VP                  8w  d4   VP                  VP                  VP                  4      V P                  ^ &   Tp\        P                  ! 4       ;_uu_ 4        V P                  ^ ,          P                  V4      p	V	R,          P                  ^ ^^4      P                  VRV^,          V^,          4      p
RRR4       X
P                  4       .V^,          V^,          3.3#   + '       g   i     L4; i)a  Run this DeDoDe module forward.

``amp_dtype`` is CUDA mixed precision, as in the other DeDoDe components: on a CUDA input with ``amp=True``
the backbone and the image are cast to ``amp_dtype``. On other devices (CPU, MPS), or with ``amp=False``, the
backbone is cast to the dtype and device of ``x``, so the features come back in the dtype of ``x``.

Args:
    x: Input image tensor with shape ``(B, 3, H, W)``.

Returns:
    Tuple of ``([features_16], [(H//14, W//14)])`` where ``features_16`` has shape
    ``(B, 1024, H/14, W/14)``.
Úx_norm_patchtokensi   N)r2   r   r.   r	   ÚdeviceÚ	cls_tokenr   r   Útor   Úinference_modeÚforward_featuresÚpermuteÚreshapeÚclone)r!   r&   ÚBÚ_CÚHÚWÚuse_ampÚbackboneÚbackbone_inputÚdinov2_features_16Úfeatures_16s   &&         r   r7   ÚFrozenDINOv2.forwarda   s‹  € ð —g‘g‰ˆˆqØ—(‘(×(Ð(˜qŸy™yˆØ×%Ñ% aÕ(ˆßØ�‰ !§(¡(Ô*¨h×.@Ñ.@×.FÑ.FÈ$Ï.É.Ô.Xà(0¯©°D·N±NÓ(C×(FÑ(FÀqÇxÁxÓ(P�×"Ñ" 1Ñ%ØŸT™T $§.¡.Ó1‰Nà�‰ !§(¡(Ô*¨h×.@Ñ.@×.FÑ.FÈ!Ï'É'Ô.QØ(0¯©°A·H±H¸a¿g¹gÓ(F�×"Ñ" 1Ñ%ØˆNÜ×!Ò!×#Õ#Ø!%×!3Ñ!3°AÕ!6×!GÑ!GÈÓ!WÐØ,Ð-AÕB×JÑJÈ1ÈaÐQRÓS×[Ñ[Ð\]Ð_cÐefÐjlÕelÐnoÐsuÕnuÓvˆK÷ $ð ×!Ñ!Ó#Ð$¨¨R­°°bµÐ'9Ð&:Ð:Ð:÷ $×#ús   Å:AHÈH	)r   r   r	   r9   rC   s   @@r   rE   rE   J   s-   ù‡ € ÙNà#'À%Ç-Á-Ðqu÷ -õ -÷(;÷ ;ð ;r   rE   c                   óL   a a€ ] tR t^�t oRtRV 3R lltV3R lR ltRtVtV ;t	# )Ú
VGG_DINOv2z=Implement a hybrid encoder combining VGG and DINOv2 features.c                óŠ   <€ Ve   Vf   \        R4      h\        SV `	  4        \        R/ VB V n        \        R/ VB V n        R # )NzInput kwargs pleaserS   )Ú
ValueErrorr   r   r   ÚvggrE   Úfrozen_dinov2)r!   Ú
vgg_kwargsÚdinov2_kwargsr"   s   &&&€r   r   ÚVGG_DINOv2.__init__„   sD   ø€ ØÒ MÒ$9ÜÐ2Ó3Ð3Ü‰ÑÔÜÑ&˜:Ñ&ˆŒÜ)Ñ:¨MÑ:ˆÖr   c                óz   <€ V ^8„  d   QhRS[ P                  RS[S[ P                  S[S[S[3,          3,          /# )r   r&   r   )r   r(   r   Úint)r   r   s   "€r   r   ÚVGG_DINOv2.__annotate__‹   s9   ø€ ÷ @ñ @™Ÿ™ð @©%±·±¹eÁCÉÀH½oÐ0MÕ*Nñ @r   c                ón   € V P                  V4      w  r#V P                  V4      w  rEW$,           W5,           3# )z¾Run this DeDoDe module forward.

Args:
    x: Input image tensor with shape ``(B, 3, H, W)``.

Returns:
    Tuple of combined ``(features, sizes)`` lists from the VGG19 and DINOv2 encoders.
)rt   ru   )r!   r&   Ú	feats_vggÚ	sizes_vggÚfeat_dinov2Úsize_dinov2s   &&    r   r7   ÚVGG_DINOv2.forward‹   s8   € ð  $Ÿx™x¨›{Ñˆ	Ø#'×#5Ñ#5°aÓ#8Ñ ˆØÕ&¨	Õ(?Ð?Ð?r   )ru   rt   )NN)
r:   r;   r<   r=   r>   r   r7   r@   rA   rB   rC   s   @@r   rq   rq   �   s   ù‡ € ÙG÷;÷@÷ @ð @r   rq   c                ób   € V ^8„  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   # )r   rT   )Ú__conditional_annotations__rV   Ústr)r   s   "r   r   r      s&   € × 'Ñ '÷ò „dŒ3”ˆ8…nñ ò (r   )rƒ   Útypingr   r   r   r   r   Úkornia.core.downloadr   rt   r   rT   ÚModuler   rE   rq   r   )rƒ   s   @r   Ú<module>rˆ      sb   øð÷$ (Ö 'ã Ý å 9å ð Ðeð€ó ô
$ ˆB�I‰Iô $ ôN4;�2—9‘9ô 4;ôn@�—‘ö @r   