
    6pj                         S SK Jr  S SKJr  S SK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Jr  \" S	5      r\R(                  S
4S\S\4S jjrg
)    )Trainers)normalize_model_input)is_official_hub_path)check_model_from_owner_group)DEFAULT_MODEL_REVISION)read_config)filter_plugin_in_whitelistregister_modelhub_reporegister_plugins_repo)Registrybuild_from_cfgtrainersNnamedefault_argsc                 ^   [        U S9nU=(       d    0 nUR                  SS5      nUR                  S[        5      n[        U[        5      (       a  [        U5      S:  a  US   OUnUR                  SS5      =(       d    [        U5      n[        U[        5      (       d-  [        U[        5      (       a  [        US   [        5      (       a  [        X4S9(       a  [        U[        5      (       a	  [        X4S9O[        US   US9n[        X45      nU(       a  UR                  S	5      n	UR                  S
S5      n
[        U	5      (       d  U
(       a  U(       d  [        S5      e[        U	5        [        U[        5      (       a  UOUS   n[        X=(       a    U
5        [!        U["        US9$ )at  build trainer given a trainer name

Args:
    name (str, optional):  Trainer name, if None, default trainer
        will be used.
    default_args (dict, optional): Default initialization arguments.
        If ``trust_remote_code`` key is set to True in default_args,
        remote code and plugins declared in the model configuration
        will be allowed to execute.
)typemodelNmodel_revisionr   trust_remote_codeF)revisionpluginsallow_remotea1  Detected plugins or allow_remote field in the model configuration file, but trust_remote_code=True was not explicitly set.
To prevent potential execution of malicious code, loading has been refused.
If you trust this model repository, please pass trust_remote_code=True in default_args to build_trainer().)r   )dictgetr   
isinstancelistlenr   strr   r   r   safe_getr	   RuntimeErrorr   r
   r   TRAINERS)r   r   cfgr   r   model_idr   configuration	model_dirr   r   model_dir_strs               W/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/modelscope/trainers/builder.pybuild_trainerr(      s    D/C%2LWd+E!%%&68NON%e&*, ,03E
Q QxDI $((U$ N'CH'M  %5$''JuQx,E,E? 4>34  4  (0%0a>&;  .eDI'00;,00G.w77'1B&+, , &g.-7	8;.= .=	BKA, &} 78+79#xlCC    )modelscope.metainfor   modelscope.pipelines.builderr   modelscope.pipelines.utilr    modelscope.utils.automodel_utilsr   modelscope.utils.constantr   modelscope.utils.hubr   modelscope.utils.pluginsr	   r
   r   modelscope.utils.registryr   r   r!   defaultr   r   r(    r)   r'   <module>r4      sS    ( > : I < ,= = ?J '..T 0D 0Dd 0Dr)   