
    NgD                     B   d dl Z d dlmZmZmZmZ d dlmZ d dlm	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 g d
ZdefdZddedefdZ	 	 	 	 	 	 	 ddededeeeeeef         ef                  deeeef                  dedee         dee         dee         fdZdS )    N)AnyDictOptionalUnion)urlsplit)set_layer_config   )load_checkpoint)load_model_config_from_hf)PretrainedCfg)is_modelmodel_entrypointsplit_model_name_tag)parse_model_namesafe_model_namecreate_model
model_namec                    |                      d          r|                     dd          } t          |           }|j        dv sJ |j        dk    r|j        |j        fS t
          j                            |j                  d         } d| fS )Nhf_hubhf-hub) timmr   r   )
startswithreplacer   schemepathossplit)r   parseds     P/var/www/html/ai-engine/env/lib/python3.11/site-packages/timm/models/_factory.pyr   r      s    X&& <''(;;
j!!F=22222}  }fk))W]]6;//3
z!!    Tremove_sourcec                 L    d }|rt          |           d         }  ||           S )Nc                 f    d                     d | D                                           d          S )Nr   c              3   F   K   | ]}|                                 r|nd V  dS )_N)isalnum).0cs     r!   	<genexpr>z5safe_model_name.<locals>.make_safe.<locals>.<genexpr>    s3      ??QAIIKK0qqS??????r"   r'   )joinrstrip)names    r!   	make_safez"safe_model_name.<locals>.make_safe   s1    ww??$?????FFsKKKr"   r   )r   )r   r#   r/   s      r!   r   r      s>    L L L 6%j11"5
9Z   r"   Fr   
pretrainedpretrained_cfgpretrained_cfg_overlaycheckpoint_path
scriptable
exportableno_jitc                 6   d |                                 D             }t          |           \  }	} |	dk    rR|r
J d            t          |           \  }} }
|
r0|
                                 D ]\  }}|                    ||           nt	          |           \  } }|r|s|}t          |           st          d| z            t          |           }t          |||          5   |d|||d|}ddd           n# 1 swxY w Y   |rt          ||           |S )	a(  Create a model.

    Lookup model's entrypoint function and pass relevant args to create a new model.

    <Tip>
        **kwargs will be passed through entrypoint fn to ``timm.models.build_model_with_cfg()``
        and then the model class __init__(). kwargs values set to None are pruned before passing.
    </Tip>

    Args:
        model_name: Name of model to instantiate.
        pretrained: If set to `True`, load pretrained ImageNet-1k weights.
        pretrained_cfg: Pass in an external pretrained_cfg for model.
        pretrained_cfg_overlay: Replace key-values in base pretrained_cfg with these.
        checkpoint_path: Path of checkpoint to load _after_ the model is initialized.
        scriptable: Set layer config so that model is jit scriptable (not working for all models yet).
        exportable: Set layer config so that model is traceable / ONNX exportable (not fully impl/obeyed yet).
        no_jit: Set layer config so that model doesn't utilize jit scripted layers (so far activations only).

    Keyword Args:
        drop_rate (float): Classifier dropout rate for training.
        drop_path_rate (float): Stochastic depth drop rate for training.
        global_pool (str): Classifier global pooling type.

    Example:

    ```py
    >>> from timm import create_model

    >>> # Create a MobileNetV3-Large model with no pretrained weights.
    >>> model = create_model('mobilenetv3_large_100')

    >>> # Create a MobileNetV3-Large model with pretrained weights.
    >>> model = create_model('mobilenetv3_large_100', pretrained=True)
    >>> model.num_classes
    1000

    >>> # Create a MobileNetV3-Large model with pretrained weights and a new head with 10 classes.
    >>> model = create_model('mobilenetv3_large_100', pretrained=True, num_classes=10)
    >>> model.num_classes
    10
    ```
    c                     i | ]
\  }}|||S )N )r)   kvs      r!   
<dictcomp>z create_model.<locals>.<dictcomp>_   s    ???tq!ar"   r   zKpretrained_cfg should not be set when sourcing model from Hugging Face Hub.zUnknown model (%s))r4   r5   r6   )r0   r1   r2   Nr9   )
itemsr   r   
setdefaultr   r   RuntimeErrorr   r   r
   )r   r0   r1   r2   r3   r4   r5   r6   kwargsmodel_source
model_argsr:   r;   pretrained_tag	create_fnmodels                   r!   r   r   &   s   r @?v||~~???F/
;;L*x!pp#pppp 2K:1V1V.
J 	("((** ( (1!!!Q''''%9*%E%E"
N 	,. 	,+NJ >/*<=== ,,I	ZJv	V	V	V 
 
	 
!)#9
 
 	
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
  0///Ls   #C<<D D )T)FNNr   NNN)r   typingr   r   r   r   urllib.parser   timm.layersr   _helpersr
   _hubr   _pretrainedr   	_registryr   r   r   __all__strr   boolr   r   r9   r"   r!   <module>rP      s   				 - - - - - - - - - - - - ! ! ! ! ! ! ( ( ( ( ( ( % % % % % % + + + + + + & & & & & & G G G G G G G G G G B
A
A" " " " "! ! !D ! ! ! ! !NR<@!%)%)!%Y YYY !sDcNM'I!JKY "*$sCx.!9	Y
 Y TNY TNY Y Y Y Y Y Yr"   