
    YhK                     P   U d dl mZ d dl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e	j                  Zd=deeeef                  dede	j        f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Z#deddd Z$ G d! d"e          Z% G d# d$e          Z& G d% d&e          Z' G d' d(e          Z( G d) d*e          Z) G d+ d,e          Z* G d- d.e          Z+ G d/ d0e          Z, e             ed1e%j-        f2          dd3d4dee%         dededefd5                        Z. e             ed1e&j-        f2          dd3d4dee&         dededefd6                        Z/ e             ed1e'j-        f2          dd3d4dee'         dededefd7                        Z0 e             ed1e(j-        f2          dd3d4dee(         dededefd8                        Z1 e             ed1e)j-        f2          dd3d4dee)         dededefd9                        Z2 e             ed1e*j-        f2          dd3d4dee*         dededefd:                        Z3 e             ed1e+j-        f2          dd3d4dee+         dededefd;                        Z4 e             ed1e,j-        f2          dd3d4dee,         dededefd<                        Z5dS )>    )partial)Anycast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                   f     e Zd Z	 ddej        dedededd	f
 fd
Zde	j
        de	j
        fdZ xZS )r     T      ?featuresnum_classesinit_weightsdropoutreturnNc                    t                                                       t          |            || _        t	          j        d          | _        t	          j        t	          j        dd          t	          j	        d          t	          j
        |          t	          j        dd          t	          j	        d          t	          j
        |          t	          j        d|                    | _        |rQ|                                 D ]=}t          |t          j                  rTt          j                            |j        dd           |j        %t          j                            |j        d	           qt          |t          j                  rKt          j                            |j        d
           t          j                            |j        d	           t          |t          j                  rKt          j                            |j        d	d           t          j                            |j        d	           =d S d S )N)   r,   i b  i   T)pfan_outrelu)modenonlinearityr   r   g{Gz?)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__s         h/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/torchvision/models/vgg.pyr3   zVGG.__init__$   s    	D!!! +F33-Ik4((GDMMJ!!!IdD!!GDMMJ!!!IdK((
 
  	1\\^^ 
1 
1a++ 	1G++AH9SY+ZZZv)))!&!4442>22 1G%%ah222G%%afa000029-- 1GOOAHa666G%%afa000	1 	1
1 
1    xc                     |                      |          }|                     |          }t          j        |d          }|                     |          }|S )Nr   )r&   r6   torchflattenr;   )rF   rK   s     rI   forwardzVGG.forwardA   sI    MM!LLOOM!QOOArJ   )r$   Tr%   )__name__
__module____qualname__r4   Moduleintboolfloatr3   rM   TensorrO   __classcell__)rH   s   @rI   r   r   #   s        hk1 1	1031JN1`e1	1 1 1 1 1 1: %,        rJ   r   Fcfg
batch_normr*   c                 d   g }d}| D ]}|dk    r|t          j        dd          gz  }#t          t          |          }t          j        ||dd          }|r.||t          j        |          t          j        d          gz  }n||t          j        d          gz  }|}t          j        | S )	N   Mr   )kernel_sizestrider   )r^   paddingT)inplace)r4   	MaxPool2dr   rT   r>   rD   r9   r7   )rY   rZ   layersin_channelsvconv2ds         rI   make_layersrg   I   s     FK 
 
88r|!<<<==FFS!AY{A1aHHHF :62>!#4#4bgd6K6K6KLL6274#8#8#899KK=&!!rJ   )@   r]      r]      rj   r]      rk   r]   rk   rk   r]   )rh   rh   r]   ri   ri   r]   rj   rj   r]   rk   rk   r]   rk   rk   r]   )rh   rh   r]   ri   ri   r]   rj   rj   rj   r]   rk   rk   rk   r]   rk   rk   rk   r]   )rh   rh   r]   ri   ri   r]   rj   rj   rj   rj   r]   rk   rk   rk   rk   r]   rk   rk   rk   rk   r]   )ABDEcfgsweightsprogresskwargsc                 &   |;d|d<   |j         d         )t          |dt          |j         d                              t          t	          t
          |          |          fi |}|*|                    |                    |d                     |S )NFr(   
categoriesr'   )rZ   T)rr   
check_hash)metar   lenr   rg   rp   load_state_dictget_state_dict)rY   rZ   rq   rr   rs   models         rI   _vggr|   b   s    !&~<%1!&-W\,=W9X9XYYYDI*===HHHHEg44hSW4XXYYYLrJ   )    r}   zUhttps://github.com/pytorch/vision/tree/main/references/classification#alexnet-and-vggzNThese weights were trained from scratch by using a simplified training recipe.)min_sizeru   recipe_docsc            
       `    e Zd Z ed eed          i edddddid	d
d          ZeZdS )r   z6https://download.pytorch.org/models/vgg11-8a719046.pth   	crop_sizeihUImageNet-1KgzGAQ@gx&1(V@zacc@1zacc@5V-o@g=
ףp@
num_params_metrics_ops
_file_sizeurl
transformsrw   N	rP   rQ   rR   r   r   r	   _COMMON_METAIMAGENET1K_V1DEFAULT rJ   rI   r   r   u   s        GD7.#>>>

###     
 
 
  M  GGGrJ   r   c            
       `    e Zd Z ed eed          i edddddid	d
d          ZeZdS )r   z9https://download.pytorch.org/models/vgg11_bn-6002323d.pthr   r   ijr   gHzQ@gp=
sV@r   r   gjt@r   r   Nr   r   rJ   rI   r   r              GG7.#>>>

###    !
 
 
  M  GGGrJ   r   c            
       `    e Zd Z ed eed          i edddddid	d
d          ZeZdS )r   z6https://download.pytorch.org/models/vgg13-19584684.pthr   r   i(&r   gZd{Q@g9vOV@r   V-&@gQ@r   r   Nr   r   rJ   rI   r   r              GD7.#>>>

###    !
 
 
  M  GGGrJ   r   c            
       `    e Zd Z ed eed          i edddddid	d
d          ZeZdS )r   z9https://download.pytorch.org/models/vgg13_bn-abd245e5.pthr   r   i(=r   g/$Q@g-V@r   r   g=
ףp@r   r   Nr   r   rJ   rI   r   r      s        GG7.#>>>

###     
 
 
  M  GGGrJ   r   c                       e Zd Z ed eed          i edddddid	d
d          Z ed eeddd          i edddd ed           ed          did	ddd          Z	eZ
dS )r   z6https://download.pytorch.org/models/vgg16-397923af.pthr   r   i(+?r   gSQ@g rV@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   ru   r   r   r   r   r   )rP   rQ   rR   r   r   r	   r   r   rV   IMAGENET1K_FEATURESr   r   rJ   rI   r   r      s       GD7.#>>>

###    !
 
 
  M  "'W7,7	
 
 


#M"U5\\"U5\\    !
 
 
  : GGGrJ   r   c            
       `    e Zd Z ed eed          i edddddid	d
d          ZeZdS )r   z9https://download.pytorch.org/models/vgg16_bn-6c64b313.pthr   r   i(L?r   gףp=
WR@g/$V@r   r   grh~@r   r   Nr   r   rJ   rI   r   r      r   rJ   r   c            
       `    e Zd Z ed eed          i edddddid	d
d          ZeZdS )r   z6https://download.pytorch.org/models/vgg19-dcbb9e9d.pthr   r   i(0r   gMbR@gMbV@r   oʡ3@g rh @r   r   Nr   r   rJ   rI   r   r   
  r   rJ   r   c            
       `    e Zd Z ed eed          i edddddid	d
d          ZeZdS )r   z9https://download.pytorch.org/models/vgg19_bn-c79401a0.pthr   r   i([r   gˡER@gSV@r   r   g/$!@r   r   Nr   r   rJ   rI   r   r     s        GG7.#>>>

###    !
 
 
  M  GGGrJ   r   
pretrained)rq   T)rq   rr   c                 V    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:
    rl   F)r   verifyr|   rq   rr   rs   s      rI   r   r   2  3    * ""7++GUGX88888rJ   c                 V    t                               |           } t          dd| |fi |S )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:
    rl   T)r   r   r|   r   s      rI   r   r   L  3    * %%g..GT7H77777rJ   c                 V    t                               |           } t          dd| |fi |S )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:
    rm   F)r   r   r|   r   s      rI   r   r   f  r   rJ   c                 V    t                               |           } t          dd| |fi |S )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:
    rm   T)r   r   r|   r   s      rI   r   r     r   rJ   c                 V    t                               |           } t          dd| |fi |S )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:
    rn   F)r   r   r|   r   s      rI   r   r     r   rJ   c                 V    t                               |           } t          dd| |fi |S )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:
    rn   T)r   r   r|   r   s      rI   r    r      r   rJ   c                 V    t                               |           } t          dd| |fi |S )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:
    ro   F)r   r   r|   r   s      rI   r!   r!     r   rJ   c                 V    t                               |           } t          dd| |fi |S )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:
    ro   T)r   r   r|   r   s      rI   r"   r"     r   rJ   )F)6	functoolsr   typingr   r   r   r   rM   torch.nnr4   transforms._presetsr	   utilsr
   _apir   r   r   _metar   _utilsr   r   __all__rS   r   liststrrT   rU   r7   rg   rp   dict__annotations__r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r   rJ   rI   <module>r      sE          - - - - - - - - - - - -        5 5 5 5 5 5 ' ' ' ' ' ' 6 6 6 6 6 6 6 6 6 6 ' ' ' ' ' ' B B B B B B B B  *# # # # #") # # #L" "T%S/* " " " " " "$ 
J	I	I	R	R	R	a	a	a	p	p	p	* *d3U38_%%&   c t h{.C t _b gj     &ea	     K   (    {   (    K   (    {   (. . . . .K . . .b    {   (    K   (    {   ( ,0K!LMMM04t 9 9 9h}- 9 9WZ 9_b 9 9 9 NM 90 ,0@0N!OPPP6:T 8 8 8"23 8d 8]` 8eh 8 8 8 QP 80 ,0K!LMMM04t 9 9 9h}- 9 9WZ 9_b 9 9 9 NM 90 ,0@0N!OPPP6:T 8 8 8"23 8d 8]` 8eh 8 8 8 QP 80 ,0K!LMMM04t 9 9 9h}- 9 9WZ 9_b 9 9 9 NM 90 ,0@0N!OPPP6:T 8 8 8"23 8d 8]` 8eh 8 8 8 QP 80 ,0K!LMMM04t 9 9 9h}- 9 9WZ 9_b 9 9 9 NM 90 ,0@0N!OPPP6:T 8 8 8"23 8d 8]` 8eh 8 8 8 QP 8 8 8rJ   