o
    ôjK  ã                   @   sœ  U d dl mZ 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 ddlmZ ddlmZmZmZ dd	lmZ dd
lmZmZ g d¢ZG dd„ dejƒZdGd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ededee dededefdd„Z#ded d!d"œZ$G d#d$„ d$eƒZ%G d%d&„ d&eƒZ&G d'd(„ d(eƒZ'G d)d*„ d*eƒZ(G d+d,„ d,eƒZ)G d-d.„ d.eƒZ*G d/d0„ d0eƒZ+G d1d2„ d2eƒZ,eƒ ed3e%j-fd4�dd5d6œdee% dededefd7d8„ƒƒZ.eƒ ed3e&j-fd4�dd5d6œdee& dededefd9d:„ƒƒZ/eƒ ed3e'j-fd4�dd5d6œdee' dededefd;d<„ƒƒZ0eƒ ed3e(j-fd4�dd5d6œdee( dededefd=d>„ƒƒZ1eƒ ed3e)j-fd4�dd5d6œdee) dededefd?d@„ƒƒZ2eƒ ed3e*j-fd4�dd5d6œdee* dededefdAdB„ƒƒZ3eƒ ed3e+j-fd4�dd5d6œdee+ dededefdCdD„ƒƒZ4eƒ ed3e,j-fd4�dd5d6œdee, dededefdEdF„ƒƒZ5dS )Hé    )Úpartial)ÚAnyÚcastÚDictÚListÚOptionalÚUnionNé   )ÚImageClassification)Ú_log_api_usage_onceé   )Úregister_modelÚWeightsÚWeightsEnum)Ú_IMAGENET_CATEGORIES)Ú_ovewrite_named_paramÚhandle_legacy_interface)ÚVGGÚVGG11_WeightsÚVGG11_BN_WeightsÚVGG13_WeightsÚVGG13_BN_WeightsÚVGG16_WeightsÚVGG16_BN_WeightsÚVGG19_WeightsÚVGG19_BN_WeightsÚvgg11Úvgg11_bnÚvgg13Úvgg13_bnÚvgg16Úvgg16_bnÚvgg19Úvgg19_bnc                       sN   e Zd Z	ddej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 )r   éè  Tç      à?ÚfeaturesÚnum_classesÚinit_weightsÚdropoutÚreturnNc                    s"  t ƒ  ¡  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ƒr^tjj|jddd� |jd ur]tj |jd	¡ q>t|tjƒrutj |jd
¡ tj |jd	¡ q>t|tjƒrŒt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   r   g{®Gáz„?)ÚsuperÚ__init__r   r&   ÚnnÚAdaptiveAvgPool2dÚavgpoolÚ
SequentialÚLinearÚReLUÚDropoutÚ
classifierÚmodulesÚ
isinstanceÚConv2dÚinitÚkaiming_normal_ÚweightÚbiasÚ	constant_ÚBatchNorm2dÚnormal_)Úselfr&   r'   r(   r)   Úm©Ú	__class__© úg/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/torchvision/models/vgg.pyr2   $   s:   





ù	
€€õzVGG.__init__Úxc                 C   s.   |   |¡}|  |¡}t |d¡}|  |¡}|S )Nr   )r&   r5   ÚtorchÚflattenr:   )rE   rK   rI   rI   rJ   ÚforwardA   s
   


zVGG.forward)r$   Tr%   )Ú__name__Ú
__module__Ú__qualname__r3   ÚModuleÚintÚboolÚfloatr2   rL   ÚTensorrN   Ú__classcell__rI   rI   rG   rJ   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 )	Né   ÚMr	   )Úkernel_sizeÚstrider   )r\   ÚpaddingT)Úinplace)r3   Ú	MaxPool2dr   rS   r=   rC   r8   r6   )rX   rY   ÚlayersÚin_channelsÚvÚconv2drI   rI   rJ   Úmake_layersI   s   

re   )é@   r[   é€   r[   é   rh   r[   é   ri   r[   ri   ri   r[   )rf   rf   r[   rg   rg   r[   rh   rh   r[   ri   ri   r[   ri   ri   r[   )rf   rf   r[   rg   rg   r[   rh   rh   rh   r[   ri   ri   ri   r[   ri   ri   ri   r[   )rf   rf   r[   rg   rg   r[   rh   rh   rh   rh   r[   ri   ri   ri   ri   r[   ri   ri   ri   ri   r[   )ÚAÚBÚDÚEÚcfgsÚweightsÚprogressÚkwargsc                 K   sp   |d urd|d< |j d d urt|dt|j d ƒƒ ttt|  |d�fi |¤Ž}|d ur6| |j|dd�¡ |S )NFr(   Ú
categoriesr'   )rY   T)rp   Ú
check_hash)Úmetar   Úlenr   re   rn   Úload_state_dictÚget_state_dict)rX   rY   ro   rp   rq   ÚmodelrI   rI   rJ   Ú_vggb   s   ry   )é    rz   zUhttps://github.com/pytorch/vision/tree/main/references/classification#alexnet-and-vggzNThese weights were trained from scratch by using a simplified training recipe.)Úmin_sizerr   ÚrecipeÚ_docsc                	   @   óB   e Zd Zedeedd�i e¥dddddœid	d
dœ¥d�ZeZdS )r   z6https://download.pytorch.org/models/vgg11-8a719046.pthéà   ©Ú	crop_sizeihUëúImageNet-1Kgáz®GAQ@gÕxé&1(V@©zacc@1zacc@5çV-²�o@g=
×£p­@©Ú
num_paramsÚ_metricsÚ_opsÚ
_file_size©ÚurlÚ
transformsrt   N©	rO   rP   rQ   r   r   r
   Ú_COMMON_METAÚIMAGENET1K_V1ÚDEFAULTrI   rI   rI   rJ   r   u   ó$    
ÿþÿöýr   c                	   @   r~   )r   z9https://download.pytorch.org/models/vgg11_bn-6002323d.pthr   r€   ièjër‚   gHáz®—Q@g¤p=
×sV@rƒ   r„   gj¼t“®@r…   rŠ   Nr�   rI   rI   rI   rJ   r   ‰   r‘   r   c                	   @   r~   )r   z6https://download.pytorch.org/models/vgg13-19584684.pthr   r€   i(&îr‚   g¬Zd{Q@g9´Èv¾OV@rƒ   çV-²�&@g…ëQ¸¸@r…   rŠ   Nr�   rI   rI   rI   rJ   r   �   r‘   r   c                	   @   r~   )r   z9https://download.pytorch.org/models/vgg13_bn-abd245e5.pthr   r€   i(=îr‚   g/Ý$�åQ@g-²�ï—V@rƒ   r’   g=
×£p¹@r…   rŠ   Nr�   rI   rI   rI   rJ   r   ±   r‘   r   c                   @   s†   e Zd Zedeedd�i e¥dddddœid	d
dœ¥d�Zedeedddd�i e¥ddddedƒedƒdœid	dddœ¥d�Z	eZ
dS )r   z6https://download.pytorch.org/models/vgg16-397923af.pthr   r€   i(+?r‚   gÙÎ÷SãåQ@gœÄ °r˜V@rƒ   çq=
×£ð.@gî|?5^~€@r…   rŠ   zIhttps://download.pytorch.org/models/vgg16_features-amdegroot-88682ab5.pth)g;pÎˆÒÞÞ?gÌ°�N]Ý?g|
€ñÚ?)çp?r”   r”   )r�   ÚmeanÚstdNz5https://github.com/amdegroot/ssd.pytorch#training-ssdÚnang#Ûù~j~€@a`  
                These weights can't be used for classification because they are missing values in the `classifier`
                module. Only the `features` module has valid values and can be used for feature extraction. The weights
                were trained using the original input standardization method as described in the paper.
            )r†   rr   r|   r‡   rˆ   r‰   r}   )rO   rP   rQ   r   r   r
   rŽ   r�   rU   ZIMAGENET1K_FEATURESr�   rI   rI   rI   rJ   r   Å   sT    
ÿþÿöýüÿþÿó÷r   c                	   @   r~   )r   z9https://download.pytorch.org/models/vgg16_bn-6c64b313.pthr   r€   i(L?r‚   g×£p=
WR@g/Ý$áV@rƒ   r“   g°rh‘í~€@r…   rŠ   Nr�   rI   rI   rI   rJ   r   ö   r‘   r   c                	   @   r~   )r   z6https://download.pytorch.org/models/vgg19-dcbb9e9d.pthr   r€   i(0�r‚   gòÒMbR@gòÒMb¸V@rƒ   çoƒÀÊ¡3@gÅ °rh �@r…   rŠ   Nr�   rI   rI   rI   rJ   r   
  r‘   r   c                	   @   r~   )r   z9https://download.pytorch.org/models/vgg19_bn-c79401a0.pthr   r€   i([�r‚   gË¡E¶ó�R@gÙÎ÷SãõV@rƒ   r˜   g /Ý$!�@r…   rŠ   Nr�   rI   rI   rI   rJ   r     r‘   r   Ú
pretrained)ro   T)ro   rp   c                 K   ó    t  | ¡} tdd| |fi |¤ŽS )ap  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:
    rj   F)r   Úverifyry   ©ro   rp   rq   rI   rI   rJ   r   2  ó   
r   c                 K   rš   )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:
    rj   T)r   r›   ry   rœ   rI   rI   rJ   r   L  r�   r   c                 K   rš   )ap  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:
    rk   F)r   r›   ry   rœ   rI   rI   rJ   r   f  r�   r   c                 K   rš   )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:
    rk   T)r   r›   ry   rœ   rI   rI   rJ   r   €  r�   r   c                 K   rš   )ap  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:
    rl   F)r   r›   ry   rœ   rI   rI   rJ   r    š  r�   r    c                 K   rš   )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:
    rl   T)r   r›   ry   rœ   rI   rI   rJ   r!   ´  r�   r!   c                 K   rš   )ap  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:
    rm   F)r   r›   ry   rœ   rI   rI   rJ   r"   Î  r�   r"   c                 K   rš   )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:
    rm   T)r   r›   ry   rœ   rI   rI   rJ   r#   è  r�   r#   )F)6Ú	functoolsr   Útypingr   r   r   r   r   r   rL   Útorch.nnr3   Ztransforms._presetsr
   Úutilsr   Ú_apir   r   r   Ú_metar   Ú_utilsr   r   Ú__all__rR   r   ÚstrrS   rT   r6   re   rn   Ú__annotations__ry   rŽ   r   r   r   r   r   r   r   r   r�   r   r   r   r   r    r!   r"   r#   rI   rI   rI   rJ   Ú<module>   sn     &&"ü&ü1*******.