o
    oi
                     @   sp   U d dl mZ d dlZd dlmZ d dlmZ i Zeeef ed< ded< ded	< d
ed< G dd dej	Z
dS )    )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                       sF   e Zd ZdZdZddeddf fddZd	ejdejfd
dZ	  Z
S )TFeata  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

        F
pretrainedreturnNc                    s   t    ttjdddtjddddt tjdddtjdd	d
dt | _tt	ddt | _
|rMtjjtd tdd}| j|dd |   d S )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__ H/home/ubuntu/.local/lib/python3.10/site-packages/kornia/feature/tfeat.pyr   9   s   
zTFeat.__init__inputc                 C   s8   t |g d | |}||dd}| |}|S )N)B132r2   r   )r   r    viewsizer"   )r)   r/   xr-   r-   r.   forwardJ   s
   

zTFeat.forward)F)__name__
__module____qualname____doc__
patch_sizeboolr   r#   Tensorr7   __classcell__r-   r-   r+   r.   r	      s
    r	   )typingr   r#   r   kornia.core.checkr   r   str__annotations__Moduler	   r-   r-   r-   r.   <module>   s   