o
    {qi-                     @   s`   d dl mZ ddlmZmZmZ ddlmZmZ ddl	m
Z
 G dd deZG d	d
 d
eZdS )    )custom_type   )add_simple_inference_argsget_subcommand_argsperform_simple_inference   )PaddleXPipelineWrapperPipelineCLISubcommandExecutor)create_config_from_structurec                       sT   e Zd Z			d fdd	Zedd Zdd Zdd	 Zed
d Z	dd Z
  ZS )DocUnderstandingNc                    s$   |||d| _ t jdi | d S )N)doc_understanding_model_namedoc_understanding_model_dirdoc_understanding_batch_size )_paramssuper__init__)selfr   r   r   kwargs	__class__r   m/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/paddleocr/_pipelines/doc_understanding.pyr      s
   	zDocUnderstanding.__init__c                 C      dS NZdoc_understandingr   r   r   r   r   _paddlex_pipeline_name*      z'DocUnderstanding._paddlex_pipeline_namec                 K   s   | j j|fi |S N)Zpaddlex_pipelinepredictr   inputr   r   r   r   predict_iter.   s   zDocUnderstanding.predict_iterc                 K   s   t | j|fi |S r   )listr!   r   r   r   r   r   1   s   zDocUnderstanding.predictc                 C   s   t  S r   )%DocUnderstandingCLISubcommandExecutor)clsr   r   r   get_cli_subcommand_executor8   s   z,DocUnderstanding.get_cli_subcommand_executorc                 C   s&   | j d | j d | j d d}t|S )Nr   r   r   )z&SubModules.DocUnderstanding.model_namez%SubModules.DocUnderstanding.model_dirz&SubModules.DocUnderstanding.batch_size)r   r
   )r   Z	STRUCTUREr   r   r   _get_paddlex_config_overrides<   s   z.DocUnderstanding._get_paddlex_config_overrides)NNN)__name__
__module____qualname__r   propertyr   r!   r   classmethodr%   r&   __classcell__r   r   r   r   r      s    

r   c                   @   s4   e Zd ZeeeZedd Zdd Z	dd Z
dS )r#   c                 C   r   r   r   r   r   r   r   subparser_nameN   r   z4DocUnderstandingCLISubcommandExecutor.subparser_namec                 C   s@   t |dd |jdtdd |jdtdd |jdtd	d d S )
NzInput dict, e.g. `{"image": "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png", "query": "Recognize this table"}`.)Z
input_helpz--doc_understanding_model_namez)Name of the document understanding model.)typehelpz--doc_understanding_model_dirz3Path to the document understanding model directory.z--doc_understanding_batch_sizez0Batch size for the document understanding model.)r   add_argumentstr)r   Z	subparserr   r   r   _update_subparserR   s&   
z7DocUnderstandingCLISubcommandExecutor._update_subparserc                 C   s(   t |}| |d |d< tt| d S )Nr    )r   input_validatorr   r   )r   argsparamsr   r   r   execute_with_argsh   s   z7DocUnderstandingCLISubcommandExecutor.execute_with_argsN)r'   r(   r)   staticmethodr   dictr3   r*   r-   r2   r6   r   r   r   r   r#   K   s    
r#   N)Z paddlex.utils.pipeline_argumentsr   Z
_utils.clir   r   r   baser   r	   utilsr
   r   r#   r   r   r   r   <module>   s   1