o
    ôj;"  ã                   @   s€  d dl mZ d dlmZmZ d dlZd dlmZ d dlm  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G dd„ dejƒZdedee dededef
dd„ZedddœZG dd„ deƒZG dd„ deƒZ eƒ edej!fd�dd d!œdee dededefd"d#„ƒƒZ"eƒ ede j!fd�dd d!œdee  dededefd$d%„ƒƒZ#dS )&é    )Úpartial)ÚAnyÚOptionalNé   )ÚImageClassification)Ú_log_api_usage_onceé   )Úregister_modelÚWeightsÚWeightsEnum)Ú_IMAGENET_CATEGORIES)Ú_ovewrite_named_paramÚhandle_legacy_interface)Ú
SqueezeNetÚSqueezeNet1_0_WeightsÚSqueezeNet1_1_WeightsÚsqueezenet1_0Úsqueezenet1_1c                
       sH   e Zd Z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 )ÚFireÚinplanesÚsqueeze_planesÚexpand1x1_planesÚexpand3x3_planesÚreturnNc                    sv   t ƒ  ¡  || _tj||dd�| _tjdd�| _tj||dd�| _tjdd�| _	tj||ddd�| _
tjdd�| _d S )Nr   ©Úkernel_sizeT©Úinplaceé   )r   Úpadding)ÚsuperÚ__init__r   ÚnnÚConv2dÚsqueezeÚReLUÚsqueeze_activationÚ	expand1x1Úexpand1x1_activationÚ	expand3x3Úexpand3x3_activation)Úselfr   r   r   r   ©Ú	__class__© ún/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/torchvision/models/squeezenet.pyr!      s   
zFire.__init__Úxc                 C   s8   |   |  |¡¡}t |  |  |¡¡|  |  |¡¡gd¡S ©Nr   )r&   r$   ÚtorchÚcatr(   r'   r*   r)   ©r+   r0   r.   r.   r/   Úforward   s    ÿzFire.forward)	Ú__name__Ú
__module__Ú__qualname__Úintr!   r2   ÚTensorr5   Ú__classcell__r.   r.   r,   r/   r      s    "
r   c                	       sF   e Zd Zd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   Ú1_0éè  ç      à?ÚversionÚnum_classesÚdropoutr   Nc                    s6  t ƒ  ¡  t| ƒ || _|dkrht tjddddd�tjdd�tjdddd	�t	dd
ddƒt	dd
ddƒt	ddddƒtjdddd	�t	ddddƒt	ddddƒt	ddddƒt	ddddƒtjdddd	�t	ddddƒ¡| _
nd|dkrÄt tjddddd�tjdd�tjdddd	�t	dd
ddƒt	dd
ddƒtjdddd	�t	ddddƒt	ddddƒtjdddd	�t	ddddƒt	ddddƒt	ddddƒt	ddddƒ¡| _
ntd|› d�ƒ‚tjd| jdd�}t tj|d�|tjdd�t d¡¡| _|  ¡ D ]+}t|tjƒ�r||u �rtj|jddd� nt |j¡ |jd u�rt |jd¡ qíd S )Nr<   r   é`   é   r   )r   ÚstrideTr   )r   rD   Ú	ceil_modeé   é@   é€   é    é   é0   éÀ   i€  i   Ú1_1zUnsupported SqueezeNet version z: 1_0 or 1_1 expectedr   r   )Úp)r   r   g        g{®Gáz„?)ÚmeanÚstdr   )r    r!   r   r@   r"   Ú
Sequentialr#   r%   Ú	MaxPool2dr   ÚfeaturesÚ
ValueErrorÚDropoutÚAdaptiveAvgPool2dÚ
classifierÚmodulesÚ
isinstanceÚinitÚnormal_ÚweightÚkaiming_uniform_ÚbiasÚ	constant_)r+   r?   r@   rA   Z
final_convÚmr,   r.   r/   r!   %   sb   

ó
óÿ
€ùzSqueezeNet.__init__r0   c                 C   s    |   |¡}|  |¡}t |d¡S r1   )rS   rW   r2   Úflattenr4   r.   r.   r/   r5   ^   s   

zSqueezeNet.forward)r<   r=   r>   )r6   r7   r8   Ústrr9   Úfloatr!   r2   r:   r5   r;   r.   r.   r,   r/   r   $   s     9r   r?   ÚweightsÚprogressÚkwargsr   c                 K   sN   |d urt |dt|jd ƒƒ t| fi |¤Ž}|d ur%| |j|dd�¡ |S )Nr@   Ú
categoriesT)re   Ú
check_hash)r   ÚlenÚmetar   Úload_state_dictÚget_state_dict)r?   rd   re   rf   Úmodelr.   r.   r/   Ú_squeezenetd   s   rn   z@https://github.com/pytorch/vision/pull/49#issuecomment-277560717zXThese weights reproduce closely the results of the paper using a simple training recipe.)rg   ÚrecipeÚ_docsc                
   @   óD   e Zd Zedeedd�i e¥dddddd	œid
ddœ¥d�ZeZdS )r   z>https://download.pytorch.org/models/squeezenet1_0-b66bff10.pthéà   ©Ú	crop_size)é   ru   i¨ úImageNet-1Kg²�ï§ÆM@g{®GáT@©zacc@1zacc@5gh‘í|?5ê?gé&1¬@©Úmin_sizeÚ
num_paramsÚ_metricsÚ_opsÚ
_file_size©ÚurlÚ
transformsrj   N©	r6   r7   r8   r
   r   r   Ú_COMMON_METAÚIMAGENET1K_V1ÚDEFAULTr.   r.   r.   r/   r   |   ó&    
ÿþÿõýr   c                
   @   rq   )r   z>https://download.pytorch.org/models/squeezenet1_1-b8a52dc0.pthrr   rs   )é   r†   i(Ú rv   gX9´ÈM@g-²�ï'T@rw   g¼t“VÖ?gÑ"Ûù~ê@rx   r~   Nr�   r.   r.   r.   r/   r   ‘   r…   r   Ú
pretrained)rd   T)rd   re   c                 K   ó   t  | ¡} td| |fi |¤ŽS )aÖ  SqueezeNet model architecture from the `SqueezeNet: AlexNet-level
    accuracy with 50x fewer parameters and <0.5MB model size
    <https://arxiv.org/abs/1602.07360>`_ paper.

    Args:
        weights (:class:`~torchvision.models.SqueezeNet1_0_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.SqueezeNet1_0_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.squeezenet.SqueezeNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/squeezenet.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.SqueezeNet1_0_Weights
        :members:
    r<   )r   Úverifyrn   ©rd   re   rf   r.   r.   r/   r   ¦   s   
r   c                 K   rˆ   )a/  SqueezeNet 1.1 model from the `official SqueezeNet repo
    <https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1>`_.

    SqueezeNet 1.1 has 2.4x less computation and slightly fewer parameters
    than SqueezeNet 1.0, without sacrificing accuracy.

    Args:
        weights (:class:`~torchvision.models.SqueezeNet1_1_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.SqueezeNet1_1_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.squeezenet.SqueezeNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/squeezenet.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.SqueezeNet1_1_Weights
        :members:
    rM   )r   r‰   rn   rŠ   r.   r.   r/   r   Ã   s   
r   )$Ú	functoolsr   Útypingr   r   r2   Útorch.nnr"   Ztorch.nn.initrZ   Ztransforms._presetsr   Úutilsr   Ú_apir	   r
   r   Ú_metar   Ú_utilsr   r   Ú__all__ÚModuler   r   rb   Úboolrn   r‚   r   r   rƒ   r   r   r.   r.   r.   r/   Ú<module>   sl    @ÿþýü
ûýÿÿÿÿþÿÿÿÿþ