o
    0j                     @  s   U d 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
mZmZmZ ddlmZ ddlmZ ed	 Zd
ed< ee	edf eeZded< G dd de
ddZefdddZefd ddZdS )!zPModel file paths and format resolution for inference model directory convention.    )annotations)PathLike)Path)LiteralTuple	TypedDictUnioncastget_args)	TypeAlias   )MODEL_FILE_PREFIX)paddleonnxom
paddle_dynsafetensorsr   LocalModelFormat.zTuple[LocalModelFormat, ...]LOCAL_MODEL_FORMATSc                   @  s:   e Zd ZU dZded< ded< ded< ded< ded< d	S )

ModelPathsz7Resolved local model files keyed by `LocalModelFormat`.zTuple[Path, Path]r   r   r   r   r   r   N)__name__
__module____qualname____doc____annotations__ r   r   k/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddlex/inference/models/utils/model_paths.pyr   (   s   
 r   F)total	model_dirUnion[str, PathLike]model_file_prefixstrreturnc                 C  s  t | } i }d }| | d  r| | d }n| | d  r)| | d }|r?| | d  r?|| | d f|d< | | d  rQ| | d |d< | | d  rc| | d |d< | d	  ro| d	 |d
< | d  r{| d |d
< | d  r| d |d< |S )Nz.jsonz.pdmodelz
.pdiparamsr   z.onnxr   z.omr   zmodel_state.pdparamsr   zinference.pdparamszmodel.safetensorsr   )r   exists)r   r    Zmodel_pathsZpd_model_pathr   r   r   get_model_paths2   s,   r$   Union[str, PathLike, Path]
str | Nonec                 C  s6   t t| |}d|v rdS d|v rdS d|v rdS dS )zResolve paddle_static vs paddle_dynamic from actual model files.

    Returns:
        "paddle_static", "paddle_dynamic", or None if no paddle model files found.
    r   Zpaddle_staticr   Zpaddle_dynamicr   N)r$   r   )r   r    pathsr   r   r   &resolve_paddle_engine_from_model_filesO   s   	r(   N)r   r   r    r!   r"   r   )r   r%   r    r!   r"   r&   )r   
__future__r   osr   pathlibr   typingr   r   r   r   r	   r
   Ztyping_extensionsr   	constantsr   r   r   r   r   r$   r(   r   r   r   r   <module>   s$    