
    h%                     z   S SK Jr  S SKJrJrJr  S SKrS SKJrJr  SSK	J
r
  SSKJr  SSKJr  S	S
KJrJrJr  S	SKJr  S	SKJrJrJr  / SQr " S S\R4                  5      r " S S\R4                  5      rSS\S.r " S S\5      r\" 5       \" S\R>                  4S9SSS.S\\   S\ S\S\4S jj5       5       r!g)     )partial)AnyCallableOptionalN)nnTensor   )Conv2dNormActivation)ImageClassification)_log_api_usage_once   )register_modelWeightsWeightsEnum)_IMAGENET_CATEGORIES)_make_divisible_ovewrite_named_paramhandle_legacy_interface)MobileNetV2MobileNet_V2_Weightsmobilenet_v2c                      ^  \ rS rSr SS\S\S\S\S\\S\R                  4      S	S4U 4S
 jjjr	S\
S	\
4S jrSrU =r$ )InvertedResidual   Ninpoupstrideexpand_ratio
norm_layer.returnc                 ,  > [         TU ]  5         X0l        US;  a  [        SU 35      eUc  [        R
                  n[        [        X-  5      5      nU R                  S:H  =(       a    X:H  U l        / nUS:w  a)  UR                  [        XSU[        R                  S95        UR                  [        UUUUU[        R                  S9[        R                  " XbSSSSS9U" U5      /5        [        R                  " U6 U l        X l        US:  U l        g )	N)r   r	   z#stride should be 1 or 2 instead of r   kernel_sizer   activation_layer)r   groupsr   r$   r   F)bias)super__init__r   
ValueErrorr   BatchNorm2dintrounduse_res_connectappendr
   ReLU6extendConv2d
Sequentialconvout_channels_is_cn)	selfr   r   r   r   r   
hidden_dimlayers	__class__s	           V/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/models/mobilenetv2.pyr(   InvertedResidual.__init__   s    	B6(KLLJs123
#{{a/>CJ"$1MM$S!PZmomumuv 	 %!%)%'XX 		*1a?3	
  MM6*	qj    xc                 l    U R                   (       a  XR                  U5      -   $ U R                  U5      $ N)r-   r3   r6   r=   s     r:   forwardInvertedResidual.forward<   s*    yy|##99Q<r<   )r5   r3   r4   r   r-   r?   )__name__
__module____qualname____firstlineno__r+   r   r   r   Moduler(   r   rA   __static_attributes____classcell__r9   s   @r:   r   r      sq    sw&!&! &!*-&!=@&!NVW_`cegenen`nWoNp&!	&! &!P   F    r<   r   c                      ^  \ rS rSr       SS\S\S\\\\         S\S\\S\	R                  4      S	\\S\	R                  4      S
\SS4U 4S jjjrS\S\4S jrS\S\4S jrSrU =r$ )r   C   Nnum_classes
width_multinverted_residual_settinground_nearestblock.r   dropoutr    c                   > [         TU ]  5         [        U 5        Uc  [        nUc  [        R
                  nSnSn	Uc  / SQ/ SQ/ SQ/ SQ/ SQ/ S	Q/ S
Q/n[        U5      S:X  d  [        US   5      S:w  a  [        SU 35      e[        X-  U5      n[        U	[        SU5      -  U5      U l
        [        SUSU[        R                  S9/n
U HI  u  pp[        X-  U5      n[        U5       H&  nUS:X  a  UOSnU
R                  U" XUXS95        UnM(     MK     U
R                  [        XR                  SU[        R                  S95        [        R                  " U
6 U l        [        R                  " [        R"                  " US9[        R$                  " U R                  U5      5      U l        U R)                  5        GH  n[+        U[        R,                  5      (       ab  [        R.                  R1                  UR2                  SS9  UR4                  b+  [        R.                  R7                  UR4                  5        M  M  [+        U[        R
                  [        R8                  45      (       aU  [        R.                  R;                  UR2                  5        [        R.                  R7                  UR4                  5        GM	  [+        U[        R$                  5      (       d  GM+  [        R.                  R=                  UR2                  SS5        [        R.                  R7                  UR4                  5        GM     g)a  
MobileNet V2 main class

Args:
    num_classes (int): Number of classes
    width_mult (float): Width multiplier - adjusts number of channels in each layer by this amount
    inverted_residual_setting: Network structure
    round_nearest (int): Round the number of channels in each layer to be a multiple of this number
    Set to 1 to turn off rounding
    block: Module specifying inverted residual building block for mobilenet
    norm_layer: Module specifying the normalization layer to use
    dropout (float): The droupout probability

N    i   )r      r   r   )      r	   r	   )rV   rT      r	   )rV   @      r	   )rV   `   rX   r   )rV      rX   r	   )rV   i@  r   r   r   rZ   zGinverted_residual_setting should be non-empty or a 4-element list, got       ?rX   r	   )r   r   r$   r   )r   r   r"   )pfan_out)modeg{Gz?)r'   r(   r   r   r   r*   lenr)   r   maxlast_channelr
   r/   ranger.   r2   featuresDropoutLinear
classifiermodules
isinstancer1   initkaiming_normal_weightr&   zeros_	GroupNormones_normal_)r6   rM   rN   rO   rP   rQ   r   rR   input_channelrc   re   tcnsoutput_channelir   mr9   s                      r:   r(   MobileNetV2.__init__D   s   0 	D!=$EJ$, 	)% ()Q.#6OPQ6R2SWX2XYZsYtu 
 ((BMR+L3sJ;O,OQ^_ M!
egememn%
 4JA!,Q^]KN1X1f!mVZ[ st .  4 	 00aJikiqiq	
 x0 --JJ!IId''5
 A!RYY''''y'A66%GGNN166* &A=>>ahh'qvv&Aryy))!T2qvv&  r<   r=   c                     U R                  U5      n[        R                  R                  US5      n[        R
                  " US5      nU R                  U5      nU$ )Nr   r   r   )re   r   
functionaladaptive_avg_pool2dtorchflattenrh   r@   s     r:   _forward_implMobileNetV2._forward_impl   sK     MM!MM--a8MM!QOOAr<   c                 $    U R                  U5      $ r?   )r   r@   s     r:   rA   MobileNetV2.forward   s    !!!$$r<   )rh   re   rc   )i  r]   N   NNg?)rC   rD   rE   rF   r+   floatr   listr   r   rG   r(   r   r   rA   rH   rI   rJ   s   @r:   r   r   C   s      ?C489=]']' ]' $,DcO#<	]'
 ]' bii01]' Xc299n56]' ]' 
]' ]'~v & % %F % %r<   r   iz5 r|   )
num_paramsmin_size
categoriesc                       \ rS rSr\" S\" \SS90 \ESSSSS	.0S
SSS.ES9r\" S\" \SSS90 \ESSSSS	.0S
SSS.ES9r	\	r
Srg)r      z=https://download.pytorch.org/models/mobilenet_v2-b0353104.pth   )	crop_sizezQhttps://github.com/pytorch/vision/tree/main/references/classification#mobilenetv2zImageNet-1Kgx&1Q@gMV@)zacc@1zacc@5g$C?g\(+@zXThese weights reproduce closely the results of the paper using a simple training recipe.)recipe_metrics_ops
_file_size_docs)url
transformsmetaz=https://download.pytorch.org/models/mobilenet_v2-7ebf99e0.pth   )r   resize_sizezHhttps://github.com/pytorch/vision/issues/3995#new-recipe-with-reg-tuningg`"	R@gS㥛V@gV-2+@a$  
                These weights improve upon the results of the original paper by using a modified version of TorchVision's
                `new training recipe
                <https://pytorch.org/blog/how-to-train-state-of-the-art-models-using-torchvision-latest-primitives/>`_.
             N)rC   rD   rE   rF   r   r   r   _COMMON_METAIMAGENET1K_V1IMAGENET1K_V2DEFAULTrH   r   r<   r:   r   r      s    K.#>

i##   s
M" K.#3O

`##   
M* Gr<   r   
pretrained)weightsT)r   progressr   r   kwargsr    c                     [         R                  U 5      n U b#  [        US[        U R                  S   5      5        [        S0 UD6nU b  UR                  U R                  USS95        U$ )aq  MobileNetV2 architecture from the `MobileNetV2: Inverted Residuals and Linear
Bottlenecks <https://arxiv.org/abs/1801.04381>`_ paper.

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

.. autoclass:: torchvision.models.MobileNet_V2_Weights
    :members:
rM   r   T)r   
check_hashr   )r   verifyr   ra   r   r   load_state_dictget_state_dict)r   r   r   models       r:   r   r      sk    0 #))'2GfmSl9S5TU!&!Eg44hSW4XYLr<   )"	functoolsr   typingr   r   r   r   r   r   ops.miscr
   transforms._presetsr   utilsr   _apir   r   r   _metar   _utilsr   r   r   __all__rG   r   r   r   r   r   boolr   r   r<   r:   <module>r      s     * *   + 5 ' 6 6 ' S S B- ryy - `k%")) k%^ &'; 'T ,0D0R0R!ST15 -. AE X[   U  r<   