+
    åûj¢  ã                   óè   a € R t0 t ^ RI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 / t] ^ k ]! RR4      R	.]R
&   ]! RR4      R.]R&   ]! RR4      R.]R&    ! R R]P                  4      tR# )é    )ÚDictN)Únn)ÚKORNIA_CHECK_SHAPE)Úhf_urlÚload_state_dict_from_url)Ú_mark_patch_convolutionsÚ_patch_conv_layoutÚtfeatztfeat-liberty.paramszQhttps://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-liberty.paramsÚlibertyztfeat-notredame.paramszShttps://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-notredame.paramsÚ	notredameztfeat-yosemite.paramszRhttps://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-yosemite.paramsÚyosemitec                   ón   a a€ ] tR t^*t oRt^ tR	V3R lV 3R llltV3R lR ltV3R lR ltRt	Vt
V ;t# )
ÚTFeatað  Describe 32 x 32 grayscale patches with the shallow TFeat CNN, without L2 normalisation.

``tfeat = TFeat()`` builds the network with its pretrained weights (trained on Liberty), in eval mode, and
``descs = tfeat(patches)`` takes grayscale patches ``(B, 1, 32, 32)`` and returns ``(B, 128)`` descriptors with
entries in ``[-1, 1]``, not unit vectors (see the Convention block). It has two convolutions and one linear layer.
For unit-norm descriptors of the same patches, use :class:`HardNet` instead; to describe LAFs on an image, pass it
to :class:`LAFDescriptor`. This is based on the original code from paper "Learning local feature descriptors
with triplets and shallow convolutional neural networks". See :cite:`TFeat2016` for more details.

Convention:
    - It takes the patches of :class:`~kornia.feature.HardNet`, with the intensity rule of HardNet's Convention
      block, but returns the final ``tanh`` layer of the reference implementation without L2 normalisation: each
      entry lies in ``[-1, 1]`` and the rows are not unit vectors. Normalise them where a distance threshold
      assumes unit descriptors.

Args:
    pretrained: Download and set pretrained weights to the model.

Returns:
    torch.Tensor: TFeat descriptor of the patches.

Shape:
    - Input: ``(B, 1, 32, 32)``
    - Output: ``(B, 128)``

See Also:
    - :class:`HardNet`: a deeper network for the same patches, with unit-norm descriptors.
    - :class:`SOSNet`: a deeper network for the same patches that also starts with an ``InstanceNorm2d``.
    - :class:`LAFDescriptor`: runs a patch descriptor such as this one on a patch per LAF of an image.

Examples:
    >>> input = torch.rand(16, 1, 32, 32)
    >>> tfeat = TFeat(pretrained=False).eval()
    >>> descs = tfeat(input) # 16x128

c                ó$   <€ V ^8„  d   QhRS[ RR/# )é   Ú
pretrainedÚreturnN)Úbool)ÚformatÚ__classdict__s   "€ÚPC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\feature\tfeat.pyÚ__annotate__ÚTFeat.__annotate__R   s   ø€ ÷ ñ ¡4ð °4ñ ó    c                óž  <€ \         SV `  4        \        P                  ! \        P                  ! ^RR7      \        P
                  ! ^^ ^R7      \        P                  ! 4       \        P                  ! ^^R7      \        P
                  ! ^ ^@^R7      \        P                  ! 4       4      V n        \        P                  ! \        P                  ! R^€4      \        P                  ! 4       4      V n
        V'       dR   \        \        R,          \        P                  ! R4      R7      pV P                  VRR	7       V P!                  4        R
# R
# )é   F)Úaffine)Úkernel_size)r   Ústrider   Úcpu)Úmap_locationT)ÚstrictNi   )ÚsuperÚ__init__r   Ú
SequentialÚInstanceNorm2dÚConv2dÚTanhÚ	MaxPool2dÚfeaturesÚLinearÚdescrr   ÚurlsÚtorchÚdeviceÚload_state_dictÚeval)Úselfr   Úpretrained_dictÚ	__class__s   && €r   r$   ÚTFeat.__init__R   sÔ   ø€ Ü‰ÑÔÜŸšÜ×Ò˜a¨Ô.Ü�IŠI�a˜¨Ô+Ü�GŠG‹IÜ�LŠL Q¨qÔ1Ü�IŠI�b˜"¨!Ô,Ü�GŠG‹Ió
ˆŒô —]’]¤2§9¢9¨Z¸Ó#=¼r¿wºw»yÓIˆŒ
çÜ6´t¸IµÔUZ×UaÒUaÐbgÓUhÔiˆOØ× Ñ  ¸Ð Ô>Ø�I‰IŽKñ r   c                ó   <€ V ^8„  d   QhRR/# )r   r   r   © )r   r   s   "€r   r   r   c   s   ø€ ÷ ñ ¨ñ r   c                ó0   € \        V P                  4       V # )N)r   r*   )r2   s   &r   Ú__prepare_scriptable__ÚTFeat.__prepare_scriptable__c   s   € Ü  §¡Ô/Øˆr   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r   Úinputr   )r.   ÚTensor)r   r   s   "€r   r   r   g   s#   ø€ ÷ ñ ™UŸ\™\ð ©e¯l©lñ r   c                ó0  € \        V. RO4       TpV P                   FU  p\        V\        P                  4      '       d   \        V4      pM\        VRR4      '       d   \        V4      pV! V4      pKW  	  VP                  ^4      pV P                  V4      # )z®Compute TFeat descriptors for grayscale 32x32 patches.

Args:
    input: Input tensor with shape ``(B, 1, 32, 32)``.

Returns:
    Descriptor tensor with shape ``(B, 128)``.
Ú_patch_conv_inputF)ÚBÚ1Ú32rB   )	r   r*   Ú
isinstancer   r'   r	   ÚgetattrÚflattenr,   )r2   r<   ÚxÚlayers   &&  r   ÚforwardÚTFeat.forwardg   s   € ô 	˜5Ò"8Ô9ØˆØ—]”]ˆEô
 ˜%¤§¡×+Ò+Ü& qÓ)‘Ü˜Ð 3°U×;Ò;Ü& qÓ)�Ù�a“ŠAñ #ð �I‰I�a‹LˆØ�z‰z˜!‹}Ðr   )r,   r*   )T)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú
patch_sizer$   r9   rH   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r4   r   s   @@r   r   r   *   s5   ù‡ € ñ#ðJ €J÷õ ÷"ð ÷÷ ð r   r   c                óŽ   € V ^8„  d   Qh/ ^ \         9   d1   \        \        \        \        \        ,          ,          3,          ;R&   # )r   r-   )Ú__conditional_annotations__r   ÚstrÚlist)r   s   "r   r   r      s,   € × Ñ ÷ &Ò %„dŒ3””dœ3•i•ÐÕ Ñ %ò r   )rT   Útypingr   r.   r   Úkornia.core.checkr   Úkornia.core.downloadr   r   Úkornia.feature._layoutr   r	   r-   ÚModuler   r   )rT   s   @r   Ú<module>r\      sˆ   øð÷$ Ò ã Ý å 0ß Aß Oà#%€Ó %á
ˆ7Ð*Ó+ØWð€€Y�ñ
 ˆ7Ð,Ó-ØYð€€[Ñ ñ
 ˆ7Ð+Ó,ØXð€€ZÑ ôSˆB�I‰Iö Sr   