
    9i
                     `    S SK rS SKJr  S SKJrJr  S SKrS SK	J
r
Jr  S SKJr   " S S5      rg)    N)abstractmethod)ListUnion)read_configsnapshot_download)Configc                       \ rS rSrS\4S jr\S\\\   \\\	      4   S\\   4S j5       r
S\4S jr\S	\	4S
 j5       r\SS j5       rSrg)InferFramework   model_id_or_dirc                 p   [         R                  R                  U5      (       a  Xl        O[	        U5      U l        U R                  U5      n[        U R                  5      nUR                  S5      nUb  U=(       d    U R                  U5      n[         R                  R                  U R                  S5      n[         R                  R                  U5      (       aD  [        R                  " U5      nUR                  S5      nUb  U=(       d    U R                  U5      nU(       d  [        SU 35      eg)zg
Args:
    model_id_or_dir(`str`): The model id of the modelhub or a local dir containing model files.
z
model.typeNzconfig.json
model_typez"Model accelerating not supported: )ospathexists	model_dirr   model_type_supportedr   safe_getjoinisfiler   	from_file
ValueError)selfr   kwargsmodel_supportedconfigr   config_files          d/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/modelscope/pipelines/accelerate/base.py__init__InferFramework.__init__   s   
 77>>/**,N.?DN33OD$T^^4__\2
!- 1J1J2Oggll4>>=A77>>+&&%%k2F6J%"1 # T5N5N6  4_4EFH H     promptsreturnc                     g)z
Args:
    prompts(`Union[List[str], List[List[int]]]`):
        The string batch or the token list batch to input to the model.
Returns:
    The answers in list according to the input prompt batch.
N )r   r"   r   s      r   __call__InferFramework.__call__)   s     	r!   r   c                     g)NFr%   )r   r   s     r   r   #InferFramework.model_type_supported5   s    r!   major_versionc                 J    [         R                  R                  5       u  pX:  $ )z%Check the GPU compatibility.
        )torchcudaget_device_capability)r*   major_s      r   check_gpu_compatibility&InferFramework.check_gpu_compatibility8   s!     ::335%%r!   c                 X    US:X  a  SSK Jn  U" U40 UD6nX%l        U$ [        SU 35      e)zInstantiate the model wrapped by an accelerate framework.
Args:
    model_id_or_dir(`str`): The model id of the modelhub or a local dir containing model files.
    framework(`str`): The framework to use.
Returns:
    The wrapped model.
vllm   )VllmzFramework not supported: )r4   r6   llm_frameworkr   )clsr   	frameworkr   r6   r4   s         r   from_pretrainedInferFramework.from_pretrained?   s<     "262D!*K8DEEr!   )r   N)r4   )__name__
__module____qualname____firstlineno__strr   r   r   r   intr&   r   staticmethodr1   classmethodr:   __static_attributes__r%   r!   r   r
   r
      s    H H8 	d3id3i&@ A 	"3i	 	s  &s & & F Fr!   r
   )os.pathr   abcr   typingr   r   
torch.cudar,   
modelscoper   r   modelscope.utils.configr   r
   r%   r!   r   <module>rK      s%        5 *CF CFr!   