
    3j
                         % S SK Jr  S SKrS SKJr  S SKJr  0 r\\\4   \S'   S\S'   S\S	'   S
\S'    " S S\R                  5      r
g)    )DictN)nn)KORNIA_CHECK_SHAPEurlszQhttps://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-liberty.paramslibertyzShttps://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-notredame.params	notredamezRhttps://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-yosemite.paramsyosemitec                   z   ^  \ rS rSrSrSrSS\SS4U 4S jjjrS\R                  S\R                  4S	 jr
S
rU =r$ )TFeat   aG  Module, which computes TFeat descriptors of given grayscale patches of 32x32.

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

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

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

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

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

    
pretrainedreturnNc                   > [         TU ]  5         [        R                  " [        R                  " SSS9[        R
                  " SSSS9[        R                  " 5       [        R                  " SSS9[        R
                  " SS	S
S9[        R                  " 5       5      U l        [        R                  " [        R                  " SS5      [        R                  " 5       5      U l
        U(       aI  [        R                  R                  [        S   [        R                  " S5      S9nU R!                  USS9  U R#                  5         g )N   F)affiner      )kernel_size   )r   stride@      i      r   cpu)map_locationT)strict)super__init__r   
SequentialInstanceNorm2dConv2dTanh	MaxPool2dfeaturesLineardescrtorchhubload_state_dict_from_urlr   deviceload_state_dicteval)selfr   pretrained_dict	__class__s      N/home/wildlama/miniconda3/lib/python3.13/site-packages/kornia/feature/tfeat.pyr   TFeat.__init__9   s    a.IIa+GGILLQq1IIb"!,GGI
 ]]299Z#=rwwyI
#ii@@i_d_k_klq_r@sO   >		    inputc                     [        U/ SQ5        U R                  U5      nUR                  UR                  S5      S5      nU R	                  U5      nU$ )N)B132r7   r   )r   r$   viewsizer&   )r-   r3   xs      r0   forwardTFeat.forwardJ   sE    5"89MM% FF166!9b!JJqMr2   )r&   r$   )F)__name__
__module____qualname____firstlineno____doc__
patch_sizeboolr   r'   Tensorr<   __static_attributes____classcell__)r/   s   @r0   r   r      sG    . J4 D  "U\\ ell  r2   r   )typingr   r'   r   kornia.core.checkr   r   str__annotations__Moduler    r2   r0   <module>rN      sR   $    0d38n eYi[ gZ 0BII 0r2   