
    h?                     l   S SK Jr  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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5      r " S S\	R>                  5      r  " S S\	R>                  5      r! S-S\"S\#S\$S\$S\4
S jjr%S\&\   S\'S\\   S\$S\S\!4S  jr(S!\S".r) " S# S$\5      r* " S% S&\5      r+\" 5       \" S'\*RX                  4S(9SS)S*.S\\*   S\$S\S\!4S+ jj5       5       r-\" 5       \" S'\+RX                  4S(9SS)S*.S\\+   S\$S\S\!4S, jj5       5       r.g).    )Sequence)partial)AnyCallableOptionalN)nnTensor   )Conv2dNormActivationSqueezeExcitation)ImageClassification)_log_api_usage_once   )register_modelWeightsWeightsEnum)_IMAGENET_CATEGORIES)_make_divisible_ovewrite_named_paramhandle_legacy_interface)MobileNetV3MobileNet_V3_Large_WeightsMobileNet_V3_Small_Weightsmobilenet_v3_largemobilenet_v3_smallc                   ^    \ rS rSrS\S\S\S\S\S\S\S	\S
\4S jr\	S\S
\4S j5       r
Srg)InvertedResidualConfig   input_channelskernelexpanded_channelsout_channelsuse_se
activationstridedilation
width_multc
                     U R                  X5      U l        X l        U R                  X95      U l        U R                  XI5      U l        XPl        US:H  U l        Xpl        Xl        g )NHS)	adjust_channelsr   r    r!   r"   r#   use_hsr%   r&   )
selfr   r    r!   r"   r#   r$   r%   r&   r'   s
             V/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/models/mobilenetv3.py__init__InvertedResidualConfig.__init__   s^     #22>N!%!5!56G!T 00J D(     channelsc                     [        X-  S5      $ )N   )r   )r1   r'   s     r-   r*   &InvertedResidualConfig.adjust_channels0   s    x4a88r0   )r&   r!   r   r    r"   r%   r+   r#   N)__name__
__module____qualname____firstlineno__intboolstrfloatr.   staticmethodr*   __static_attributes__ r0   r-   r   r      s    !! ! 	!
 ! ! ! ! ! !* 9# 95 9 9r0   r   c            	          ^  \ rS rSr\" \\R                  S94S\S\	S\R                  4   S\	S\R                  4   4U 4S jjjrS\S	\4S
 jrSrU =r$ )InvertedResidual5   )scale_activationcnf
norm_layer.se_layerc                   > [         TU ]  5         SUR                  s=::  a  S::  d  O  [        S5      eUR                  S:H  =(       a    UR                  UR
                  :H  U l        / nUR                  (       a  [        R                  O[        R                  nUR                  UR                  :w  a0  UR                  [        UR                  UR                  SUUS95        UR                  S:  a  SOUR                  nUR                  [        UR                  UR                  UR                  UUR                  UR                  UUS95        UR                   (       a;  [#        UR                  S-  S5      nUR                  U" UR                  U5      5        UR                  [        UR                  UR
                  SUS S95        [        R$                  " U6 U l        UR
                  U l        UR                  S:  U l        g )Nr   r
   zillegal stride valuekernel_sizerE   activation_layer)rI   r%   r&   groupsrE   rJ      r3   )superr.   r%   
ValueErrorr   r"   use_res_connectr+   r   	HardswishReLUr!   appendr   r&   r    r#   r   
Sequentialblock_is_cn)	r,   rD   rE   rF   layersrJ   r%   squeeze_channels	__class__s	           r-   r.   InvertedResidual.__init__7   s    	SZZ$1$344"zzQY33E3EIYIY3Y"$+.::2<<277   C$6$66MM$&&)) !)%5 llQ&CJJ %%%%JJ,,%!1		
 ::.s/D/D/I1MMM(3#8#8:JKL 	 %%s'7'7QS]pt	
 ]]F+
,,jj1nr0   inputreturnc                 R    U R                  U5      nU R                  (       a  X!-  nU$ N)rT   rO   )r,   rZ   results      r-   forwardInvertedResidual.forwardo   s%    E"OFr0   )rU   rT   r"   rO   )r5   r6   r7   r8   r   SElayerr   Hardsigmoidr   r   Moduler.   r	   r_   r>   __classcell__rX   s   @r-   rA   rA   5   sl     .5Wr~~-^	6%#6% S"))^,6% 3		>*	6% 6%pV   r0   rA   c                      ^  \ rS rSr    SS\\   S\S\S\\S\	R                  4      S\\S\	R                  4      S	\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   v   Ninverted_residual_settinglast_channelnum_classesrT   .rE   dropoutkwargsr[   c                   > [         TU ]  5         [        U 5        U(       d  [        S5      e[	        U[
        5      (       a/  [        U Vs/ s H  n[	        U[        5      PM     sn5      (       d  [        S5      eUc  [        nUc  [        [        R                  SSS9n/ n	US   R                  n
U	R                  [        SU
SS	U[        R                   S
95        U H  nU	R                  U" X5      5        M     US   R"                  nSU-  nU	R                  [        UUSU[        R                   S95        [        R$                  " U	6 U l        [        R(                  " S5      U l        [        R$                  " [        R,                  " X5      [        R                   " SS9[        R.                  " USS9[        R,                  " X#5      5      U l        U R3                  5        GH  n[	        U[        R4                  5      (       ab  [        R6                  R9                  UR:                  SS9  UR<                  b+  [        R6                  R?                  UR<                  5        M  M  [	        U[        R                  [        R@                  45      (       aU  [        R6                  RC                  UR:                  5        [        R6                  R?                  UR<                  5        GM	  [	        U[        R,                  5      (       d  GM+  [        R6                  RE                  UR:                  SS5        [        R6                  R?                  UR<                  5        GM     gs  snf )a  
MobileNet V3 main class

Args:
    inverted_residual_setting (List[InvertedResidualConfig]): Network structure
    last_channel (int): The number of channels on the penultimate layer
    num_classes (int): Number of classes
    block (Optional[Callable[..., nn.Module]]): Module specifying inverted residual building block for mobilenet
    norm_layer (Optional[Callable[..., nn.Module]]): Module specifying the normalization layer to use
    dropout (float): The droupout probability
z1The inverted_residual_setting should not be emptyzDThe inverted_residual_setting should be List[InvertedResidualConfig]NgMbP?g{Gz?)epsmomentumr      r
   )rI   r%   rE   rJ      r   rH   T)inplace)prs   fan_out)mode)#rM   r.   r   rN   
isinstancer   allr   	TypeErrorrA   r   r   BatchNorm2dr   rR   r   rP   r"   rS   featuresAdaptiveAvgPool2davgpoolLinearDropout
classifiermodulesConv2dinitkaiming_normal_weightbiaszeros_	GroupNormones_normal_)r,   rh   ri   rj   rT   rE   rk   rl   srV   firstconv_output_channelsrD   lastconv_input_channelslastconv_output_channelsmrX   s                  r-   r.   MobileNetV3.__init__w   s{   * 	D!(PQQ0(;;D]^D]qZ#9:D]^__bcc=$E UTJJ"$ %>a$@$O$O! )%!#		
 -CMM%01 - #<B"?"L"L#$'>#>  '(%!#	
 v.++A.--II.=LL&JJ$/IIl0	
 A!RYY''''y'A66%GGNN166* &A=>>ahh'qvv&Aryy))!T2qvv&  g _s   M.xc                     U R                  U5      nU R                  U5      n[        R                  " US5      nU R	                  U5      nU$ )Nr   )r{   r}   torchflattenr   r,   r   s     r-   _forward_implMobileNetV3._forward_impl   s@    MM!LLOMM!QOOAr0   c                 $    U R                  U5      $ r]   )r   r   s     r-   r_   MobileNetV3.forward   s    !!!$$r0   )r}   r   r{   )i  NNg?)r5   r6   r7   r8   listr   r9   r   r   r   rc   r<   r   r.   r	   r   r_   r>   rd   re   s   @r-   r   r   v   s    
  489=Y'#'(>#?Y' Y' 	Y'
 bii01Y' Xc299n56Y' Y' Y' 
Y' Y'vv & % %F % %r0   r   archr'   reduced_taildilatedrl   c                    U(       a  SOSnU(       a  SOSn[        [        US9n[        [        R                  US9nU S:X  a  U" SSSSSSSS5      U" SSS	S
SSSS5      U" S
SSS
SSSS5      U" S
SSSSSSS5      U" SSSSSSSS5      U" SSSSSSSS5      U" SSSSSSSS5      U" SSSSSSSS5      U" SSSSSSSS5      U" SSSSSSSS5      U" SSSSSSSS5      U" SSSSSSSS5      U" SSSSU-  SSSU5      U" SU-  SSU-  SU-  SSSU5      U" SU-  SSU-  SU-  SSSU5      /n	U" SU-  5      n
X4$ U S:X  a  U" SSSSSSSS5      U" SSSS
SSSS5      U" S
SSS
SSSS5      U" S
SSSSSSS5      U" SSSSSSSS5      U" SSSSSSSS5      U" SSSSSSSS5      U" SSSSSSSS5      U" SSS SU-  SSSU5      U" SU-  SS!U-  SU-  SSSU5      U" SU-  SS!U-  SU-  SSSU5      /n	U" S"U-  5      n
X4$ [        S#U  35      e)$Nr
   r   )r'   r      rp   FRE@      H      (   Tx      P   r)         i  p   i     i  i   r   X   `   0      i   i@  i   zUnsupported model type )r   r   r*   rN   )r   r'   r   r   rl   reduce_dividerr&   
bneck_confr*   rh   ri   s              r-   _mobilenet_v3_confr      s:    'QANqH/JGJ4DDQ[\O##r1b"eT1a8r1b"eT1a8r1b"eT1a8r1b"dD!Q7r1c2tT1a8r1c2tT1a8r1c2udAq9r1c2udAq9r1c2udAq9r1c2udAq9r1c3dAq9sAsCtQ:sAsC>$94q(Ssn,a1F~H]_ceiklnvwsn,a1F~H]_ceiklnvw%
!" 't~'=>& %22% 
%	%r1b"dD!Q7r1b"eT1a8r1b"eT1a8r1b"dD!Q7r1c2tT1a8r1c2tT1a8r1c2tT1a8r1c2tT1a8r1c2#7tQQr^+Q~0Er^G[]acgijltur^+Q~0Er^G[]acgijltu%
! 't~'=> %22 24&9::r0   rh   ri   weightsprogressr[   c                     Ub#  [        US[        UR                  S   5      5        [        X40 UD6nUb  UR	                  UR                  USS95        U$ )Nrj   
categoriesT)r   
check_hash)r   lenmetar   load_state_dictget_state_dict)rh   ri   r   r   rl   models         r-   _mobilenet_v3r     s^     fmSl9S5TU1J6JEg44hSW4XYLr0   )r   r   )min_sizer   c                       \ rS rSr\" S\" \SS90 \ES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S
.0SSSS.ES9r	\	r
Srg)r   i)  zChttps://download.pytorch.org/models/mobilenet_v3_large-8738ca79.pth   	crop_sizeiS ^https://github.com/pytorch/vision/tree/main/references/classification#mobilenetv3-large--smallImageNet-1Kg R@g(\V@zacc@1zacc@5g-?gw/5@zJThese weights were trained from scratch by using a simple training recipe.
num_paramsrecipe_metrics_ops
_file_size_docsurl
transformsr   zChttps://download.pytorch.org/models/mobilenet_v3_large-5c1a4163.pth   )r   resize_sizezHhttps://github.com/pytorch/vision/issues/3995#new-recipe-with-reg-tuninggK7R@gNbX9$W@gZd5@a/  
                These weights improve marginally 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/>`_.
            r?   N)r5   r6   r7   r8   r   r   r   _COMMON_METAIMAGENET1K_V1IMAGENET1K_V2DEFAULTr>   r?   r0   r-   r   r   )  s    Q.#>

!v##   e
M$ Q.#3O

!`##   
M, Gr0   r   c                   R    \ rS rSr\" S\" \SS90 \ESSSSS	S
.0SSSS.ES9r\r	Sr
g)r   iU  zChttps://download.pytorch.org/models/mobilenet_v3_small-047dcff4.pthr   r   i& r   r   gnP@g}?5^U@r   gv/?g r#@z}
                These weights improve upon the results of the original paper by using a simple training recipe.
            r   r   r?   N)r5   r6   r7   r8   r   r   r   r   r   r   r>   r?   r0   r-   r   r   U  sY    Q.#>

!v##  
M( Gr0   r   
pretrained)r   T)r   r   c                 `    [         R                  U 5      n [        S0 UD6u  p4[        X4X40 UD6$ )ao  
Constructs a large MobileNetV3 architecture from
`Searching for MobileNetV3 <https://arxiv.org/abs/1905.02244>`__.

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

.. autoclass:: torchvision.models.MobileNet_V3_Large_Weights
    :members:
)r   )r   verifyr   r   r   r   rl   rh   ri   s        r-   r   r   m  :    2 )//8G.@.`Y_.`+2'^W]^^r0   c                 `    [         R                  U 5      n [        S0 UD6u  p4[        X4X40 UD6$ )ao  
Constructs a small MobileNetV3 architecture from
`Searching for MobileNetV3 <https://arxiv.org/abs/1905.02244>`__.

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

.. autoclass:: torchvision.models.MobileNet_V3_Small_Weights
    :members:
)r   )r   r   r   r   r   s        r-   r   r     r   r0   )g      ?FF)/collections.abcr   	functoolsr   typingr   r   r   r   r   r	   ops.miscr   r   ra   transforms._presetsr   utilsr   _apir   r   r   _metar   _utilsr   r   r   __all__r   rc   rA   r   r;   r<   r:   r   r   r9   r   r   r   r   r   r   r   r?   r0   r-   <module>r      s   $  * *   I 5 ' 6 6 ' S S9 98>ryy >Bg%")) g%V UZ.3
.3 .36:.3MQ.3eh.3b#$:; k" 	
  & &) )X 0 ,0J0X0X!YZ7;d_34_GK_^a__ [ _: ,0J0X0X!YZ7;d_34_GK_^a__ [ _r0   