o
    oi,                     @   s  U d dl mZmZmZmZmZmZ d dlZd dlmZ d dl	m
Z
 G dd dej
Zd(deeeef  d	ed
ejfddZg dg dg dg ddZeeeeeef  f ed< d)ded	edee ded
ef
ddZdddee ded
efddZdddee ded
efddZdddee ded
efddZdddee ded
efddZdddee ded
efd d!Zdddee ded
efd"d#Zdddee ded
efd$d%Zdddee ded
efd&d'ZdS )*    )AnyDictListOptionalUnioncastN)nn)Modulec                       sL   e Zd Z	ddededededd	f
 fd
dZdej	dej	fddZ
  ZS )VGG  T      ?featuresnum_classesinit_weightsdropoutreturnNc                    s  t    || _td| _ttddtdtj	|dtddtdtj	|dtd|| _
|r|  D ]P}t|tjrZtjj|jddd |jd urYtj|jd	 q:t|tjrqtj|jd
 tj|jd	 q:t|tjrtj|jd	d tj|jd	 q:d S d S )N)   r   i b  i   T)pfan_outrelu)modenonlinearityr      g{Gz?)super__init__r   r   AdaptiveAvgPool2davgpool
SequentialLinearReLUDropout
classifiermodules
isinstanceConv2dinitkaiming_normal_weightbias	constant_BatchNorm2dnormal_)selfr   r   r   r   m	__class__ M/home/ubuntu/.local/lib/python3.10/site-packages/kornia/feature/dedode/vgg.pyr      s8   





	
zVGG.__init__xc                 C   s.   |  |}| |}t|d}| |}|S )Nr   )r   r   torchflattenr!   )r,   r2   r0   r0   r1   forward7   s
   


zVGG.forward)r   Tr   )__name__
__module____qualname__r	   intboolfloatr   r3   Tensorr5   __classcell__r0   r0   r.   r1   r
      s    r
   Fcfg
batch_normr   c                 C   s   g }d}| D ]<}|dkr|t jdddg7 }qtt|}t j||ddd}|r6||t |t jddg7 }n
||t jddg7 }|}qt j| S )	zMake model layers.   M   )kernel_sizestrider   )rC   paddingT)inplace)r   	MaxPool2dr   r9   r$   r*   r   r   )r>   r?   layersin_channelsvconv2dr0   r0   r1   make_layers?   s   

rL   )@   rA      rA      rO   rA      rP   rA   rP   rP   rA   )rM   rM   rA   rN   rN   rA   rO   rO   rA   rP   rP   rA   rP   rP   rA   )rM   rM   rA   rN   rN   rA   rO   rO   rO   rA   rP   rP   rP   rA   rP   rP   rP   rA   )rM   rM   rA   rN   rN   rA   rO   rO   rO   rO   rA   rP   rP   rP   rP   rA   rP   rP   rP   rP   rA   )ABDEcfgsweightskwargsc                 K   s    t tt|  |dfi |}|S )N)r?   )r
   rL   rU   )r>   r?   rV   rW   modelr0   r0   r1   _vggY   s   rY   )rV   c                 K      t dd| fi |S )aq  VGG-11 from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG11_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG11_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG11_Weights
        :members:

    rQ   FrY   rV   rW   r0   r0   r1   vgg11^      r]   c                 K   rZ   )a}  VGG-11-BN from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG11_BN_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG11_BN_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG11_BN_Weights
        :members:

    rQ   Tr[   r\   r0   r0   r1   vgg11_bnu   r^   r_   c                 K   rZ   )aq  VGG-13 from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG13_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG13_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG13_Weights
        :members:

    rR   Fr[   r\   r0   r0   r1   vgg13   r^   r`   c                 K   rZ   )a}  VGG-13-BN from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG13_BN_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG13_BN_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG13_BN_Weights
        :members:

    rR   Tr[   r\   r0   r0   r1   vgg13_bn   r^   ra   c                 K   rZ   )aq  VGG-16 from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG16_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG16_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG16_Weights
        :members:

    rS   Fr[   r\   r0   r0   r1   vgg16   r^   rb   c                 K   rZ   )a}  VGG-16-BN from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG16_BN_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG16_BN_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG16_BN_Weights
        :members:

    rS   Tr[   r\   r0   r0   r1   vgg16_bn   r^   rc   c                 K   rZ   )aq  VGG-19 from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG19_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG19_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG19_Weights
        :members:

    rT   Fr[   r\   r0   r0   r1   vgg19   r^   rd   c                 K   rZ   )a}  VGG-19_BN from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG19_BN_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG19_BN_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG19_BN_Weights
        :members:

    rT   Tr[   r\   r0   r0   r1   vgg19_bn   r^   re   )F)N)typingr   r   r   r   r   r   r3   r   kornia.corer	   r
   strr9   r:   r   rL   rU   __annotations__rY   r]   r_   r`   ra   rb   rc   rd   re   r0   r0   r0   r1   <module>   s(   "&%"$       $