U
    ¯Ê¹jóÂ  ã                a   @   sê  d Z ddlmZ 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mZmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZ d	d
l m!Z! d	dl"m#Z#m$Z$ d	dl%m&Z&m'Z'm(Z( dgZ)G dd„ dej*ƒZ+G dd„ dej*ƒZ,G dd„ dej*ƒZ-G dd„ dej*ƒZ.dÄdd„Z/dd„ Z0dÅdd„Z1dÆdd„Z2dÇd d!„Z3e&e2d"d#d$dd%�e2d"d#d$dd%�e2d&d"d$d#d'�e2d(d"d$d#d'�e2d)d"d$d#d'�e2d*d"d$d#d'�e2d+d"d$d#d'�e2d,d"d#d$dd-�e2d"d#d$dd%�e2d.d"d#d$dd-�e2d/d"d#d$dd-�e2d0d"d#d$dd-�e2d"d1d2dd3d4�e2d"d1d2dd3d4�e2d"d#d5d6�e2d"d#d5d6�e2d"d#d5d6�e2d7d"d$dd'�e2d8d"d$dd'�e2d9d"d$dd'�e2d:d"d$dd'�e2d;d"d$dd'�e2d<d"d$dd'�e2d=d"d$dd'�e2d>d"d$dd'�e2d?d"d$dd'�e2d@d"d1d2dd3dA�e2dBd"d1d2dd3dA�e2dCd"d1d2dd3dA�e2dDd"d1d2dd3dA�e2dEd"d1d2dd3dA�e2dFd"dGdH�e2dId"dGdH�e2dJd"dGdH�e2dKd"dGdH�e2dLd"dGdH�e3dMd"d$dd'�e3dNd"d1d2dd3dA�e3dOd"d$dd'�e3dPd"d1d2dd3dA�e3dQd"d$dd'�e3dRd"d1d2dd3dA�e3dSd"d$dd'�e3dTd"d1d2dd3dA�e3dUd"d1d2dd3dA�e3dVd"dWdXdd3dA�e3dYd"d$d#d'�e3dZd"d$d#d'�e3d[d"d$d#d'�e3d\d"d$dd'�e3d]d"d$dd'�e3d^d"d$dd'�e3d_d"d$dd'�e3d`d"d$dd'�e3dad"ddH�e3dbd"ddH�e3dcd"ddH�e3ddd"ddH�e3ded"ddH�e3dfd"ddH�e3dgd"ddH�e3dhd"ddH�e2ƒ e2d"eedidjddk�e2d"eed1d2dd3dl�e2d"eedmdnddk�e2d"eed1d2dd3dl�e2d"eedidjddk�e2d"eed1d2ddk�e2d"eedidjddk�e2d"eed1d2dd3dl�e2d"eedidjddk�e2d"eed5didjddo�e2d"eed5dmdnddo�e2d"eed5d1d2dd3dp�e2d"eed5d1d2dd3dp�e2d"eed5didjddo�e2dqdreedidjddsdt�e2dudreedidjddsdt�e2dvdreedidjddsdt�e2dwdreedmdnddsdt�e2dxdreedmdnddsdt�e2dydreedidjddzdt�e2d{dreedmdnddzdt�e2d|dreedmdnddzdt�e2d}dreedidjdd~dt�e2ddreedidjdd~dt�d€œWƒZ4e'dÈe.d�œd‚dƒ„ƒZ5e'dÉe.d�œd„d…„ƒZ6e'dÊe.d�œd†d‡„ƒZ7e'dËe.d�œdˆd‰„ƒZ8e'dÌe.d�œdŠd‹„ƒZ9e'dÍe.d�œdŒd�„ƒZ:e'dÎe.d�œdŽd�„ƒZ;e'dÏe.d�œd�d‘„ƒZ<e'dÐe.d�œd’d“„ƒZ=e'dÑe.d�œd”d•„ƒZ>e'dÒe.d�œd–d—„ƒZ?e'dÓe.d�œd˜d™„ƒZ@e'dÔe.d�œdšd›„ƒZAe'dÕe.d�œdœd�„ƒZBe'dÖe.d�œdždŸ„ƒZCe'd×e.d�œd d¡„ƒZDe'dØe.d�œd¢d£„ƒZEe'dÙe.d�œd¤d¥„ƒZFe'dÚe.d�œd¦d§„ƒZGe'dÛe.d�œd¨d©„ƒZHe'dÜe.d�œdªd«„ƒZIe'dÝe.d�œd¬d­„ƒZJe'dÞe.d�œd®d¯„ƒZKe'dße.d�œd°d±„ƒZLe'dàe.d�œd²d³„ƒZMe(eNd´dµd¶d·d¸d¹dºd»d¼d½d¾d¿dÀdÁdÂdÃœƒ dS )áax   ConvNeXt

Papers:
* `A ConvNet for the 2020s` - https://arxiv.org/pdf/2201.03545.pdf
@Article{liu2022convnet,
  author  = {Zhuang Liu and Hanzi Mao and Chao-Yuan Wu and Christoph Feichtenhofer and Trevor Darrell and Saining Xie},
  title   = {A ConvNet for the 2020s},
  journal = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  year    = {2022},
}

* `ConvNeXt-V2 - Co-designing and Scaling ConvNets with Masked Autoencoders` - https://arxiv.org/abs/2301.00808
@article{Woo2023ConvNeXtV2,
  title={ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders},
  author={Sanghyun Woo, Shoubhik Debnath, Ronghang Hu, Xinlei Chen, Zhuang Liu, In So Kweon and Saining Xie},
  year={2023},
  journal={arXiv preprint arXiv:2301.00808},
}

Original code and weights from:
* https://github.com/facebookresearch/ConvNeXt, original copyright below
* https://github.com/facebookresearch/ConvNeXt-V2, original copyright below

Model defs atto, femto, pico, nano and _ols / _hnf variants are timm originals.

Modifications and additions for timm hacked together by / Copyright 2022, Ross Wightman
é    )ÚOrderedDict)Úpartial)ÚCallableÚOptionalÚTupleÚUnionN)ÚIMAGENET_DEFAULT_MEANÚIMAGENET_DEFAULT_STDÚOPENAI_CLIP_MEANÚOPENAI_CLIP_STD)Útrunc_normal_ÚAvgPool2dSameÚDropPathÚMlpÚGlobalResponseNormMlpÚLayerNorm2dÚ	LayerNormÚcreate_conv2dÚget_act_layerÚmake_divisibleÚ	to_ntuple)ÚNormMlpClassifierHeadÚClassifierHeadé   )Úbuild_model_with_cfg)Únamed_applyÚcheckpoint_seq)Úgenerate_default_cfgsÚregister_modelÚregister_model_deprecationsÚConvNeXtc                       s&   e Zd Zd‡ fdd„	Zdd„ Z‡  ZS )Ú
Downsampler   c                    sŒ   t ƒ  ¡  |dkr|nd}|dks*|dkrX|dkr>|dkr>tntj}|d|ddd�| _n
t ¡ | _||kr~t||ddd�| _n
t ¡ | _d S )Nr   é   TF)Z	ceil_modeZcount_include_pad)Ústride)	ÚsuperÚ__init__r   ÚnnZ	AvgPool2dÚpoolÚIdentityr   Úconv)ÚselfÚin_chsÚout_chsr#   ÚdilationZ
avg_strideZavg_pool_fn©Ú	__class__© úS/var/www/html/bwave/python/venv/lib/python3.8/site-packages/timm/models/convnext.pyr%   <   s    

zDownsample.__init__c                 C   s   |   |¡}|  |¡}|S ©N)r'   r)   ©r*   Úxr0   r0   r1   ÚforwardJ   s    

zDownsample.forward)r   r   ©Ú__name__Ú
__module__Ú__qualname__r%   r5   Ú__classcell__r0   r0   r.   r1   r!   :   s   r!   c                       sl   e Zd ZdZdeee eeeeeeef f ee	e	e	ee ee
ef ee edœ‡ fdd„Zdd„ Z‡  ZS )ÚConvNeXtBlockaa   ConvNeXt Block
    There are two equivalent implementations:
      (1) DwConv -> LayerNorm (channels_first) -> 1x1 Conv -> GELU -> 1x1 Conv; all in (N, C, H, W)
      (2) DwConv -> Permute to (N, H, W, C); LayerNorm (channels_last) -> Linear -> GELU -> Linear; Permute back

    Unlike the official impl, this one allows choice of 1 or 2, 1x1 conv can be faster with appropriate
    choice of LayerNorm impl, however as model size increases the tradeoffs appear to change and nn.Linear
    is a better choice. This was observed with PyTorch 1.10 on 3090 GPU, it could change over time & w/ different HW.
    Né   r   ©r   r   é   FTç�íµ ÷Æ°>Úgeluç        )r+   r,   Úkernel_sizer#   r-   Ú	mlp_ratioÚconv_mlpÚ	conv_biasÚuse_grnÚls_init_valueÚ	act_layerÚ
norm_layerÚ	drop_pathc              	      s  t ƒ  ¡  |p|}tdƒ|ƒ}t|ƒ}|s6|r2tnt}t|	r@tnt|d�}|| _	t
|||||d d|d�| _||ƒ| _||t|| ƒ|d�| _|
dk	rªt |
t |¡ ¡nd| _||ksÐ|dksÐ|d |d krèt||||d d	�| _n
t ¡ | _|d
k�rt|ƒnt ¡ | _dS )a[  

        Args:
            in_chs: Block input channels.
            out_chs: Block output channels (same as in_chs if None).
            kernel_size: Depthwise convolution kernel size.
            stride: Stride of depthwise convolution.
            dilation: Tuple specifying input and output dilation of block.
            mlp_ratio: MLP expansion ratio.
            conv_mlp: Use 1x1 convolutions for MLP and a NCHW compatible norm layer if True.
            conv_bias: Apply bias for all convolution (linear) layers.
            use_grn: Use GlobalResponseNorm in MLP (from ConvNeXt-V2)
            ls_init_value: Layer-scale init values, layer-scale applied if not None.
            act_layer: Activation layer.
            norm_layer: Normalization layer (defaults to LN if not specified).
            drop_path: Stochastic depth probability.
        r"   )Zuse_convr   T)rB   r#   r-   Z	depthwiseÚbias)rH   Nr   )r#   r-   rA   )r$   r%   r   r   r   r   r   r   r   Úuse_conv_mlpr   Úconv_dwÚnormÚintÚmlpr&   Ú	ParameterÚtorchZonesÚgammar!   Úshortcutr(   r   rJ   )r*   r+   r,   rB   r#   r-   rC   rD   rE   rF   rG   rH   rI   rJ   Z	mlp_layerr.   r0   r1   r%   [   s0    !
ù	
" 
zConvNeXtBlock.__init__c                 C   s˜   |}|   |¡}| jr*|  |¡}|  |¡}n4| dddd¡}|  |¡}|  |¡}| dddd¡}| jd k	r€| | j dddd¡¡}|  |¡|  	|¡ }|S )Nr   r"   é   r   éÿÿÿÿ)
rM   rL   rN   rP   ZpermuterS   ÚmulÚreshaperJ   rT   )r*   r4   rT   r0   r0   r1   r5   –   s    




zConvNeXtBlock.forward)Nr<   r   r=   r>   FTFr?   r@   NrA   )r7   r8   r9   Ú__doc__rO   r   r   r   ÚfloatÚboolÚstrr   r%   r5   r:   r0   r0   r.   r1   r;   P   s:               ò
ò;r;   c                       s&   e Zd Zd‡ fd	d
„	Zdd„ Z‡  ZS )ÚConvNeXtStager<   r"   r=   Nç      ð?FTr@   c                    s  t ƒ  ¡  d| _||ks0|dks0|d |d kr’|dksH|d |d krLdnd}|d dkr`dnd}t ||ƒt|||||d ||
d�¡| _|}n
t ¡ | _|p¨dg| }g }t|ƒD ]<}| 	t
||||d || ||	|
|||	rä|n|d�¡ |}q¶tj|Ž | _d S )	NFr   r   r"   Zsame)rB   r#   r-   ÚpaddingrK   rA   )r+   r,   rB   r-   rJ   rG   rD   rE   rF   rH   rI   )r$   r%   Úgrad_checkpointingr&   Ú
Sequentialr   Ú
downsampler(   ÚrangeÚappendr;   Úblocks)r*   r+   r,   rB   r#   Údepthr-   Údrop_path_ratesrG   rD   rE   rF   rH   rI   Únorm_layer_clZds_ksÚpadZstage_blocksÚir.   r0   r1   r%   ª   sJ    
  ùþ

õzConvNeXtStage.__init__c                 C   s6   |   |¡}| jr(tj ¡ s(t| j|ƒ}n
|  |¡}|S r2   )rb   r`   rR   ÚjitZis_scriptingr   re   r3   r0   r0   r1   r5   ä   s
    

zConvNeXtStage.forward)r<   r"   r"   r=   Nr^   FTFr@   NNr6   r0   r0   r.   r1   r]   ¨   s               ñ:r]   c                       sî   e Zd ZdZd&eeeeeedf eedf eeeedf f ee	 eee	e
ee e
e
e
eeef eeeef  ee	 e	e	dœ‡ fdd„Zejjd'dd„ƒZejjd(dd„ƒZejjdd„ ƒZd)dd„Zdd „ Zd*e
d!œd"d#„Zd$d%„ Z‡  ZS )+r    zl ConvNeXt
        A PyTorch impl of : `A ConvNet for the 2020s`  - https://arxiv.org/pdf/2201.03545.pdf
    rU   éè  Úavgé    ©rU   rU   é	   rU   ©é`   éÀ   é€  é   r<   r?   Úpatchr>   r^   FNTr@   rA   .)Úin_chansÚnum_classesÚglobal_poolÚoutput_strideÚdepthsÚdimsÚkernel_sizesrG   Ú	stem_typeÚ
patch_sizeÚhead_init_scaleÚhead_norm_firstÚhead_hidden_sizerD   rE   rF   rH   rI   Únorm_epsÚ	drop_rateÚdrop_path_ratec           "         sÈ  t ƒ  ¡  |dkst‚tdƒ|ƒ}|dkr\t}|r6|nt}|dk	r€t||d�}t||d�}n$|shtdƒ‚|}|dk	r€t||d�}|| _|| _g | _	|	dksžt‚|	dkrÖt
 t
j||d |
|
|d	�||d ƒ¡| _|
}ndd
|	krît|d d ƒn|d }t
 t
j||ddd|d�t
j||d ddd|d�||d ƒ¡| _d}t
 ¡ | _dd„ t d|t|ƒ¡ |¡D ƒ}g }|d }|}d}tdƒD ]Â}|dk�sš|dk�rždnd}||k�rÂ|dk�rÂ||9 }d}||9 }|dk�rØdnd} || }!| t||!|| || |f|| || |||||||d�¡ |!}|  j	t||d|› �d�g7  _	�q‚t
j|Ž | _|| _|�rŒ|�rht‚|| jƒ| _t| j||| jd�| _n&t
 ¡ | _t| j|||| j|dd�| _ttt|d�| ƒ dS )a  
        Args:
            in_chans: Number of input image channels.
            num_classes: Number of classes for classification head.
            global_pool: Global pooling type.
            output_stride: Output stride of network, one of (8, 16, 32).
            depths: Number of blocks at each stage.
            dims: Feature dimension at each stage.
            kernel_sizes: Depthwise convolution kernel-sizes for each stage.
            ls_init_value: Init value for Layer Scale, disabled if None.
            stem_type: Type of stem.
            patch_size: Stem patch size for patch stem.
            head_init_scale: Init scaling value for classifier weights and biases.
            head_norm_first: Apply normalization before global pool + head.
            head_hidden_size: Size of MLP hidden layer in head if not None and head_norm_first == False.
            conv_mlp: Use 1x1 conv in MLP, improves speed for small networks w/ chan last.
            conv_bias: Use bias layers w/ all convolutions.
            use_grn: Use Global Response Norm (ConvNeXt-V2) in MLP.
            act_layer: Activation layer type.
            norm_layer: Normalization layer type.
            drop_rate: Head pre-classifier dropout rate.
            drop_path_rate: Stochastic depth drop rate.
        )é   é   rn   r>   N)ÚepszcIf a norm_layer is specified, conv MLP must be used so all norm expect rank-4, channels-first input)rv   ÚoverlapÚoverlap_tieredrv   r   )rB   r#   rK   Ztieredr"   rU   r   )rB   r#   r_   rK   c                 S   s   g | ]}|  ¡ ‘qS r0   )Útolist)Ú.0r4   r0   r0   r1   Ú
<listcomp>G  s     z%ConvNeXt.__init__.<locals>.<listcomp>)r   r"   )rB   r#   r-   rf   rg   rG   rD   rE   rF   rH   rI   rh   zstages.)Znum_chsZ	reductionÚmodule)Ú	pool_typer„   r@   )Zhidden_sizer�   r„   rI   rH   )r€   ) r$   r%   ÚAssertionErrorr   r   r   r   rx   r„   Zfeature_infor&   ra   ÚConv2dÚstemr   ÚstagesrR   ZlinspaceÚsumÚsplitrc   rd   r]   ÚdictZnum_featuresÚnorm_prer   Úheadr(   r   r   Ú_init_weights)"r*   rw   rx   ry   rz   r{   r|   r}   rG   r~   r   r€   r�   r‚   rD   rE   rF   rH   rI   rƒ   r„   r…   rh   Zstem_strideZmid_chsZdp_ratesr“   Zprev_chsZcurr_strider-   rj   r#   Zfirst_dilationr,   r.   r0   r1   r%   ò   s¬    /
ÿ
þ 
ý
"ò$
ü

ù	zConvNeXt.__init__c                 C   s   t d|rdndddgd�S )Nz^stemz^stages\.(\d+))z^stages\.(\d+)\.downsample)r   )z^stages\.(\d+)\.blocks\.(\d+)N)z	^norm_pre)iŸ† )r’   re   )r–   )r*   Zcoarser0   r0   r1   Úgroup_matcherƒ  s    ýþzConvNeXt.group_matcherc                 C   s   | j D ]
}||_qd S r2   )r“   r`   )r*   ÚenableÚsr0   r0   r1   Úset_grad_checkpointingŽ  s    
zConvNeXt.set_grad_checkpointingc                 C   s   | j jS r2   )r˜   Úfc)r*   r0   r0   r1   Úget_classifier“  s    zConvNeXt.get_classifierr   c                 C   s   | j  ||¡ d S r2   )r˜   Úreset)r*   rx   ry   r0   r0   r1   Úreset_classifier—  s    zConvNeXt.reset_classifierc                 C   s"   |   |¡}|  |¡}|  |¡}|S r2   )r’   r“   r—   r3   r0   r0   r1   Úforward_featuresš  s    


zConvNeXt.forward_features©Ú
pre_logitsc                 C   s   |r| j |dd�S |   |¡S )NTr£   )r˜   )r*   r4   r¤   r0   r0   r1   Úforward_head   s    zConvNeXt.forward_headc                 C   s   |   |¡}|  |¡}|S r2   )r¢   r¥   r3   r0   r0   r1   r5   £  s    

zConvNeXt.forward)rU   rl   rm   rn   ro   rq   r<   r?   rv   r>   r^   FNFTFr@   NNrA   rA   )F)T)r   N)F)r7   r8   r9   rY   rO   r\   r   r   r   rZ   r[   r   r%   rR   rk   Úignorerš   r�   rŸ   r¡   r¢   r¥   r5   r:   r0   r0   r.   r1   r    í   sp                        ê


ê 


r^   c                 C   sˆ   t | tjƒr4t| jdd� | jd k	r„tj | j¡ nPt | tjƒr„t| jdd� tj | j¡ |r„d|kr„| jj	 
|¡ | jj	 
|¡ d S )Ng{®Gáz”?)Ústdúhead.)Ú
isinstancer&   r‘   r   ÚweightrK   ÚinitZzeros_ZLinearÚdataZmul_)rŽ   Únamer€   r0   r0   r1   r™   ©  s    
r™   c                 C   s¢  d| ksd| kr| S d| kr$| d } i }d| kr¸dd„ |   ¡ D ƒ}d| krp| d |d< t | d jd	 ¡|d
< nDd| kr´| d |d< | d |d< | d |d< t | d jd	 ¡|d
< |S d	dl}|   ¡ D ]Ô\}}| dd¡}| dd|¡}| dd|¡}| dd¡}| dd¡}d|k�rB| dd¡}| dd¡}| |jd  ¡}| d!d"¡}| d#¡�rf| d$d%¡}|j	d&k�r”d'|k�r”| 
¡ | j}| |¡}|||< qÈ|S )(z Remap FB checkpoints -> timm zhead.norm.weightznorm_pre.weightÚmodelzvisual.trunk.stem.0.weightc                 S   s(   i | ] \}}|  d ¡r| d d¡|“qS )zvisual.trunk.Ú )Ú
startswithÚreplace)rŒ   ÚkÚvr0   r0   r1   Ú
<dictcomp>¿  s     
 
 z(checkpoint_filter_fn.<locals>.<dictcomp>zvisual.head.proj.weightzhead.fc.weightr   zhead.fc.biaszvisual.head.mlp.fc1.weightzhead.pre_logits.fc.weightzvisual.head.mlp.fc1.biaszhead.pre_logits.fc.biaszvisual.head.mlp.fc2.weightNzdownsample_layers.0.zstem.zstages.([0-9]+).([0-9]+)zstages.\1.blocks.\2z#downsample_layers.([0-9]+).([0-9]+)zstages.\1.downsample.\2ZdwconvrM   Zpwconvzmlp.fcZgrnzgrn.betazmlp.grn.biasz	grn.gammazmlp.grn.weightrV   r¨   zhead.fc.znorm.rN   z	head.normr"   r˜   )ÚitemsrR   ZzerosÚshapeÚrer±   ÚsubrX   r°   ÚndimÚ
state_dict)rº   r®   Zout_dictr·   r²   r³   Zmodel_shaper0   r0   r1   Úcheckpoint_filter_fn¶  sF    


r»   Fc                 K   sB   |  dd¡dkr| dd¡ tt| |fttddd�d	œ|—Ž}|S )
NZpretrained_cfgr¯   ZfcmaeZpretrained_strictF)r   r   r"   rU   T)Zout_indicesZflatten_sequential)Zpretrained_filter_fnZfeature_cfg)ÚgetÚ
setdefaultr   r    r»   r–   )ÚvariantÚ
pretrainedÚkwargsr®   r0   r0   r1   Ú_create_convnextà  s      ÿ
ýürÁ   r¯   c                 K   s   | dddddt tdddœ
|–S )	Nrl   ©rU   éà   rÃ   ©r<   r<   ç      ì?Úbicubicústem.0úhead.fc)
Úurlrx   Ú
input_sizeÚ	pool_sizeÚcrop_pctÚinterpolationÚmeanr§   Ú
first_convÚ
classifier©r   r	   ©rÉ   rÀ   r0   r0   r1   Ú_cfgî  s         ûúrÓ   c                 K   s&   | dddddt tdddd	d
ddœ|–S )Nrl   rÂ   rÄ   rÅ   rÆ   rÇ   rÈ   zcc-by-nc-4.0zarXiv:2301.00808zGConvNeXt-V2: Co-designing and Scaling ConvNets with Masked Autoencodersz/https://github.com/facebookresearch/ConvNeXt-V2)rÉ   rx   rÊ   rË   rÌ   rÍ   rÎ   r§   rÏ   rÐ   ÚlicenseZ	paper_idsZ
paper_nameZ
origin_urlrÑ   rÒ   r0   r0   r1   Ú_cfgv2ù  s"          ø	÷rÕ   ztimm/gffffffî?)rU   é   rÖ   )Ú	hf_hub_idrÌ   Útest_input_sizeÚtest_crop_pctzrhttps://github.com/rwightman/pytorch-image-models/releases/download/v0.1-rsb-weights/convnext_atto_d2-01bb0f51.pth)rÉ   r×   rØ   rÙ   zvhttps://github.com/rwightman/pytorch-image-models/releases/download/v0.1-rsb-weights/convnext_atto_ols_a2-78d1c8f3.pthzshttps://github.com/rwightman/pytorch-image-models/releases/download/v0.1-rsb-weights/convnext_femto_d1-d71d5b4c.pthzwhttps://github.com/rwightman/pytorch-image-models/releases/download/v0.1-rsb-weights/convnext_femto_ols_d1-246bf2ed.pthzrhttps://github.com/rwightman/pytorch-image-models/releases/download/v0.1-rsb-weights/convnext_pico_d1-10ad7f0d.pthzvhttps://github.com/rwightman/pytorch-image-models/releases/download/v0.1-rsb-weights/convnext_pico_ols_d1-611f0ca7.pth)rÉ   r×   rÌ   rØ   rÙ   zshttps://github.com/rwightman/pytorch-image-models/releases/download/v0.1-rsb-weights/convnext_nano_d1h-7eb4bdea.pthzwhttps://github.com/rwightman/pytorch-image-models/releases/download/v0.1-rsb-weights/convnext_nano_ols_d1h-ae424a9a.pthzwhttps://github.com/rwightman/pytorch-image-models/releases/download/v0.1-rsb-weights/convnext_tiny_hnf_a2h-ab7e9df2.pth)rU   rt   rt   )é   rÚ   Zsquash)r×   rÊ   rË   rÌ   Ú	crop_modei-.  )r×   rÌ   rx   zDhttps://dl.fbaipublicfiles.com/convnext/convnext_tiny_22k_1k_224.pthzEhttps://dl.fbaipublicfiles.com/convnext/convnext_small_22k_1k_224.pthzDhttps://dl.fbaipublicfiles.com/convnext/convnext_base_22k_1k_224.pthzEhttps://dl.fbaipublicfiles.com/convnext/convnext_large_22k_1k_224.pthzJhttps://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_1k_224_ema.pthzDhttps://dl.fbaipublicfiles.com/convnext/convnext_tiny_1k_224_ema.pthzEhttps://dl.fbaipublicfiles.com/convnext/convnext_small_1k_224_ema.pthzDhttps://dl.fbaipublicfiles.com/convnext/convnext_base_1k_224_ema.pthzEhttps://dl.fbaipublicfiles.com/convnext/convnext_large_1k_224_ema.pthzDhttps://dl.fbaipublicfiles.com/convnext/convnext_tiny_22k_1k_384.pth)rÉ   r×   rÊ   rË   rÌ   rÛ   zEhttps://dl.fbaipublicfiles.com/convnext/convnext_small_22k_1k_384.pthzDhttps://dl.fbaipublicfiles.com/convnext/convnext_base_22k_1k_384.pthzEhttps://dl.fbaipublicfiles.com/convnext/convnext_large_22k_1k_384.pthzJhttps://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_1k_384_ema.pthzAhttps://dl.fbaipublicfiles.com/convnext/convnext_tiny_22k_224.pthiQU  )rÉ   r×   rx   zBhttps://dl.fbaipublicfiles.com/convnext/convnext_small_22k_224.pthzAhttps://dl.fbaipublicfiles.com/convnext/convnext_base_22k_224.pthzBhttps://dl.fbaipublicfiles.com/convnext/convnext_large_22k_224.pthzChttps://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_224.pthzWhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_nano_22k_224_ema.ptzWhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_nano_22k_384_ema.ptzWhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_tiny_22k_224_ema.ptzWhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_tiny_22k_384_ema.ptzWhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_base_22k_224_ema.ptzWhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_base_22k_384_ema.ptzXhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_large_22k_224_ema.ptzXhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_large_22k_384_ema.ptzWhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_huge_22k_384_ema.ptzWhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_huge_22k_512_ema.pt)rU   é   rÜ   )é   rÝ   zUhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_atto_1k_224_ema.ptzVhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_femto_1k_224_ema.ptzUhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_pico_1k_224_ema.ptzUhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_nano_1k_224_ema.ptzUhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_tiny_1k_224_ema.ptzUhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_base_1k_224_ema.ptzVhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_large_1k_224_ema.ptzUhttps://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_huge_1k_224_ema.ptzZhttps://dl.fbaipublicfiles.com/convnext/convnextv2/pt_only/convnextv2_atto_1k_224_fcmae.ptz[https://dl.fbaipublicfiles.com/convnext/convnextv2/pt_only/convnextv2_femto_1k_224_fcmae.ptzZhttps://dl.fbaipublicfiles.com/convnext/convnextv2/pt_only/convnextv2_pico_1k_224_fcmae.ptzZhttps://dl.fbaipublicfiles.com/convnext/convnextv2/pt_only/convnextv2_nano_1k_224_fcmae.ptzZhttps://dl.fbaipublicfiles.com/convnext/convnextv2/pt_only/convnextv2_tiny_1k_224_fcmae.ptzZhttps://dl.fbaipublicfiles.com/convnext/convnextv2/pt_only/convnextv2_base_1k_224_fcmae.ptz[https://dl.fbaipublicfiles.com/convnext/convnextv2/pt_only/convnextv2_large_1k_224_fcmae.ptzZhttps://dl.fbaipublicfiles.com/convnext/convnextv2/pt_only/convnextv2_huge_1k_224_fcmae.pt)rU   é   rÞ   )r†   r†   )r×   rÎ   r§   rÊ   rË   rÌ   )r×   rÎ   r§   rÊ   rË   rÌ   rÛ   )rU   é@  rß   )é
   rà   )r×   rÎ   r§   rx   rÊ   rË   rÌ   )r×   rÎ   r§   rx   rÊ   rË   rÌ   rÛ   z,laion/CLIP-convnext_base_w-laion2B-s13B-b82Kzopen_clip_pytorch_model.biné€  )r×   Zhf_hub_filenamerÎ   r§   rÊ   rË   rÌ   rx   z3laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augregz4laion/CLIP-convnext_base_w-laion_aesthetic-s13B-b82Kz8laion/CLIP-convnext_base_w_320-laion_aesthetic-s13B-b82Kz?laion/CLIP-convnext_base_w_320-laion_aesthetic-s13B-b82K-augregz5laion/CLIP-convnext_large_d.laion2B-s26B-b102K-augregru   z5laion/CLIP-convnext_large_d_320.laion2B-s29B-b131K-ftz:laion/CLIP-convnext_large_d_320.laion2B-s29B-b131K-ft-soupz9laion/CLIP-convnext_xxlarge-laion2B-s34B-b82K-augreg-soupé   z;laion/CLIP-convnext_xxlarge-laion2B-s34B-b82K-augreg-rewind)Wzconvnext_tiny.in12k_ft_in1kzconvnext_small.in12k_ft_in1kzconvnext_atto.d2_in1kzconvnext_atto_ols.a2_in1kzconvnext_femto.d1_in1kzconvnext_femto_ols.d1_in1kzconvnext_pico.d1_in1kzconvnext_pico_ols.d1_in1kzconvnext_nano.in12k_ft_in1kzconvnext_nano.d1h_in1kzconvnext_nano_ols.d1h_in1kzconvnext_tiny_hnf.a2h_in1kzconvnext_tiny.in12k_ft_in1k_384z convnext_small.in12k_ft_in1k_384zconvnext_nano.in12kzconvnext_tiny.in12kzconvnext_small.in12kúconvnext_tiny.fb_in22k_ft_in1kúconvnext_small.fb_in22k_ft_in1kúconvnext_base.fb_in22k_ft_in1kúconvnext_large.fb_in22k_ft_in1kú convnext_xlarge.fb_in22k_ft_in1kzconvnext_tiny.fb_in1kzconvnext_small.fb_in1kzconvnext_base.fb_in1kzconvnext_large.fb_in1kú"convnext_tiny.fb_in22k_ft_in1k_384ú#convnext_small.fb_in22k_ft_in1k_384ú"convnext_base.fb_in22k_ft_in1k_384ú#convnext_large.fb_in22k_ft_in1k_384ú$convnext_xlarge.fb_in22k_ft_in1k_384úconvnext_tiny.fb_in22kúconvnext_small.fb_in22kúconvnext_base.fb_in22kúconvnext_large.fb_in22kúconvnext_xlarge.fb_in22kz#convnextv2_nano.fcmae_ft_in22k_in1kz'convnextv2_nano.fcmae_ft_in22k_in1k_384z#convnextv2_tiny.fcmae_ft_in22k_in1kz'convnextv2_tiny.fcmae_ft_in22k_in1k_384z#convnextv2_base.fcmae_ft_in22k_in1kz'convnextv2_base.fcmae_ft_in22k_in1k_384z$convnextv2_large.fcmae_ft_in22k_in1kz(convnextv2_large.fcmae_ft_in22k_in1k_384z'convnextv2_huge.fcmae_ft_in22k_in1k_384z'convnextv2_huge.fcmae_ft_in22k_in1k_512zconvnextv2_atto.fcmae_ft_in1kzconvnextv2_femto.fcmae_ft_in1kzconvnextv2_pico.fcmae_ft_in1kzconvnextv2_nano.fcmae_ft_in1kzconvnextv2_tiny.fcmae_ft_in1kzconvnextv2_base.fcmae_ft_in1kzconvnextv2_large.fcmae_ft_in1kzconvnextv2_huge.fcmae_ft_in1kzconvnextv2_atto.fcmaezconvnextv2_femto.fcmaezconvnextv2_pico.fcmaezconvnextv2_nano.fcmaezconvnextv2_tiny.fcmaezconvnextv2_base.fcmaezconvnextv2_large.fcmaezconvnextv2_huge.fcmaezconvnextv2_small.untrainedz/convnext_base.clip_laion2b_augreg_ft_in12k_in1kz3convnext_base.clip_laion2b_augreg_ft_in12k_in1k_384z6convnext_large_mlp.clip_laion2b_soup_ft_in12k_in1k_320z6convnext_large_mlp.clip_laion2b_soup_ft_in12k_in1k_384z)convnext_base.clip_laion2b_augreg_ft_in1kz,convnext_base.clip_laiona_augreg_ft_in1k_384z.convnext_large_mlp.clip_laion2b_augreg_ft_in1kz2convnext_large_mlp.clip_laion2b_augreg_ft_in1k_384z*convnext_xxlarge.clip_laion2b_soup_ft_in1kz*convnext_base.clip_laion2b_augreg_ft_in12kz1convnext_large_mlp.clip_laion2b_soup_ft_in12k_320z3convnext_large_mlp.clip_laion2b_augreg_ft_in12k_384z1convnext_large_mlp.clip_laion2b_soup_ft_in12k_384z+convnext_xxlarge.clip_laion2b_soup_ft_in12kzconvnext_base.clip_laion2bz!convnext_base.clip_laion2b_augregzconvnext_base.clip_laionazconvnext_base.clip_laiona_320z$convnext_base.clip_laiona_augreg_320z&convnext_large_mlp.clip_laion2b_augregz&convnext_large_mlp.clip_laion2b_ft_320z+convnext_large_mlp.clip_laion2b_ft_soup_320z"convnext_xxlarge.clip_laion2b_soupz$convnext_xxlarge.clip_laion2b_rewind)Úreturnc                 K   s,   t dddd�}tdd| it |f|Ž—Ž}|S )N©r"   r"   é   r"   ©é(   éP   é    rß   T©r{   r|   rD   Úconvnext_attor¿   )rú   ©r–   rÁ   ©r¿   rÀ   Z
model_argsr®   r0   r0   r1   rú   z  s    rú   c                 K   s.   t ddddd�}tdd| it |f|Ž—Ž}|S )	Nró   rõ   TrŠ   ©r{   r|   rD   r~   Úconvnext_atto_olsr¿   )rþ   rû   rü   r0   r0   r1   rþ   ‚  s    rþ   c                 K   s,   t dddd�}tdd| it |f|Ž—Ž}|S )Nró   ©é0   rr   rs   rt   Trù   Úconvnext_femtor¿   )r  rû   rü   r0   r0   r1   r  Š  s    r  c                 K   s.   t ddddd�}tdd| it |f|Ž—Ž}|S )	Nró   rÿ   TrŠ   rý   Úconvnext_femto_olsr¿   )r  rû   rü   r0   r0   r1   r  ’  s    r  c                 K   s,   t dddd�}tdd| it |f|Ž—Ž}|S )Nró   ©é@   é€   rÞ   rÜ   Trù   Úconvnext_picor¿   )r  rû   rü   r0   r0   r1   r  š  s    r  c                 K   s.   t ddddd�}tdd| it |f|Ž—Ž}|S )	Nró   r  TrŠ   rý   Úconvnext_pico_olsr¿   )r  rû   rü   r0   r0   r1   r  ¢  s    r  c                 K   s,   t dddd�}tdd| it |f|Ž—Ž}|S )N©r"   r"   r†   r"   ©r÷   rø   rß   rá   Trù   Úconvnext_nanor¿   )r
  rû   rü   r0   r0   r1   r
  ª  s    r
  c                 K   s.   t ddddd�}tdd| it |f|Ž—Ž}|S )	Nr  r	  Tr‰   rý   Úconvnext_nano_olsr¿   )r  rû   rü   r0   r0   r1   r  ²  s    r  c                 K   s.   t ddddd�}tdd| it |f|Ž—Ž}|S )Nro   rq   T)r{   r|   r�   rD   Úconvnext_tiny_hnfr¿   )r  rû   rü   r0   r0   r1   r  º  s    r  c                 K   s*   t ddd�}tdd| it |f|Ž—Ž}|S )Nro   rq   ©r{   r|   Úconvnext_tinyr¿   )r  rû   rü   r0   r0   r1   r  Â  s    r  c                 K   s:   t ddddgddddgd�}td
d	| it |f|Ž—Ž}|S )NrU   é   rr   rs   rt   ru   r  Úconvnext_smallr¿   )r  rû   rü   r0   r0   r1   r  É  s    r  c                 K   s:   t ddddgddddgd�}td
d	| it |f|Ž—Ž}|S )NrU   r  r  rÞ   rÜ   râ   r  Úconvnext_baser¿   )r  rû   rü   r0   r0   r1   r  Ð  s    r  c                 K   s:   t ddddgddddgd�}td
d	| it |f|Ž—Ž}|S )NrU   r  rs   rt   ru   é   r  Úconvnext_larger¿   )r  rû   rü   r0   r0   r1   r  ×  s    r  c                 K   s<   t ddddgddddgdd�}td
d	| it |f|Ž—Ž}|S )NrU   r  rs   rt   ru   r  )r{   r|   r‚   Úconvnext_large_mlpr¿   )r  rû   rü   r0   r0   r1   r  Þ  s    r  c                 K   s:   t ddddgddddgd�}td
d	| it |f|Ž—Ž}|S )NrU   r  rÞ   rÜ   râ   i   r  Úconvnext_xlarger¿   )r  rû   rü   r0   r0   r1   r  å  s    r  c                 K   sD   t ddddgddddg| dd	¡d
�}tdd| it |f|Ž—Ž}|S )NrU   r>   é   rt   ru   r  i   rƒ   gñhãˆµøä>)r{   r|   rƒ   Úconvnext_xxlarger¿   )r  )r–   ÚpoprÁ   rü   r0   r0   r1   r  ì  s    &r  c                 K   s0   t dddd dd�}tdd| it |f|Ž—Ž}|S )Nró   rõ   T©r{   r|   rF   rG   rD   Úconvnextv2_attor¿   )r  rû   rü   r0   r0   r1   r  ó  s        ÿr  c                 K   s0   t dddd dd�}tdd| it |f|Ž—Ž}|S )Nró   rÿ   Tr  Úconvnextv2_femtor¿   )r  rû   rü   r0   r0   r1   r  ü  s        ÿr  c                 K   s0   t dddd dd�}tdd| it |f|Ž—Ž}|S )Nró   r  Tr  Úconvnextv2_picor¿   )r  rû   rü   r0   r0   r1   r    s        ÿr  c                 K   s0   t dddd dd�}tdd| it |f|Ž—Ž}|S )Nr  r	  Tr  Úconvnextv2_nanor¿   )r  rû   rü   r0   r0   r1   r    s        ÿr  c                 K   s.   t dddd d�}tdd| it |f|Ž—Ž}|S )Nro   rq   T©r{   r|   rF   rG   Úconvnextv2_tinyr¿   )r  rû   rü   r0   r0   r1   r    s    r  c                 K   s>   t ddddgddddgdd d�}tdd
| it |f|Ž—Ž}|S )NrU   r  rr   rs   rt   ru   Tr  Úconvnextv2_smallr¿   )r   rû   rü   r0   r0   r1   r     s     r   c                 K   s>   t ddddgddddgdd d�}tdd
| it |f|Ž—Ž}|S )NrU   r  r  rÞ   rÜ   râ   Tr  Úconvnextv2_baser¿   )r!  rû   rü   r0   r0   r1   r!  %  s     r!  c                 K   s>   t ddddgddddgdd d�}tdd
| it |f|Ž—Ž}|S )NrU   r  rs   rt   ru   r  Tr  Úconvnextv2_larger¿   )r"  rû   rü   r0   r0   r1   r"  ,  s     r"  c                 K   s>   t ddddgddddgdd d�}tdd
| it |f|Ž—Ž}|S )NrU   r  i`  iÀ  i€  i   Tr  Úconvnextv2_huger¿   )r#  rû   rü   r0   r0   r1   r#  3  s     r#  rã   rä   rå   ræ   rç   rè   ré   rê   rë   rì   rí   rî   rï   rð   rñ   )Zconvnext_tiny_in22ft1kZconvnext_small_in22ft1kZconvnext_base_in22ft1kZconvnext_large_in22ft1kZconvnext_xlarge_in22ft1kZconvnext_tiny_384_in22ft1kZconvnext_small_384_in22ft1kZconvnext_base_384_in22ft1kZconvnext_large_384_in22ft1kZconvnext_xlarge_384_in22ft1kZconvnext_tiny_in22kZconvnext_small_in22kZconvnext_base_in22kZconvnext_large_in22kZconvnext_xlarge_in22k)Nr^   )F)r¯   )r¯   )F)F)F)F)F)F)F)F)F)F)F)F)F)F)F)F)F)F)F)F)F)F)F)F)F)OrY   Úcollectionsr   Ú	functoolsr   Útypingr   r   r   r   rR   Ztorch.nnr&   Z	timm.datar   r	   r
   r   Ztimm.layersr   r   r   r   r   r   r   r   r   r   r   r   r   Z_builderr   Z_manipulater   r   Ú	_registryr   r   r   Ú__all__ÚModuler!   r;   r]   r    r™   r»   rÁ   rÓ   rÕ   Zdefault_cfgsrú   rþ   r  r  r  r  r
  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r!  r"  r#  r7   r0   r0   r0   r1   Ú<module>   s|  '4XE =
*


  þ  þ ý ý ý ý ý  ý  þ  ý  ý  ý   þ   þ þ þ þ ý ý ý ý ý ý ý ý ý   ý   ý   ý   ý   ýýýýýý ý   ý ý   ý ý   ý ý   ý   ý   ý ý ý ý ý ý ý ý ýýýýýýýýý   ý    ý   ý    ý   ý   ý   ý    ý   ý    ý    ý     ý     ý    ý    ü    ü    ü    ü    ü    ü    ü    ü    ü    ü€ € •  uñ