
    {-j                         d dl mZmZmZmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZ dd	lmZ ej         ed
           G d de                                  ZdS )    )AnyDictOptionalUnion   )pipeline_requires_extra   )	HPIConfigPaddlePredictorOption)DocVLMResult)	benchmark   )BasePipeline
multimodalc                        e Zd ZdZdZddddddddedee         dee         d	eeeef                  d
ee	         de
deeeeef         ef                  ddf fdZdedefdZd Z xZS )DocUnderstandingPipelinezDoc Understanding Pipelinedoc_understandingNFdeviceengineengine_config	pp_optionuse_hpip
hpi_configconfigr   r   r   r   r   r   returnc          
           t                      j        d||||||d| |                    di                               dddi          }	|                     |	          | _        dS )a  Initializes the doc understanding pipeline.

        Args:
            config (Dict): Configuration dictionary containing model and other parameters.
            device (Optional[str], optional): The device to use for prediction. Defaults to `None`.
            engine (Optional[str], optional): Inference engine. Defaults to `None`.
            engine_config (Optional[Dict[str, Any]], optional): Engine-specific config. Defaults to `None`.
            pp_option (Optional[PaddlePredictorOption], optional): Paddle predictor options.
                Defaults to `None`.
            use_hpip (bool, optional): Whether to use HPIP. Defaults to `False`.
            hpi_config (Optional[Union[Dict[str, Any], HPIConfig]], optional):
                HPIP configuration. Defaults to `None`.
        r   
SubModulesDocUnderstandingmodel_config_errorz)config error for doc_understanding_model!N )super__init__getcreate_modeldoc_understanding_model)selfr   r   r   r   r   r   r   kwargsdoc_understanding_model_config	__class__s             v/var/www/html/banglarbhumi/venv/lib/python3.11/site-packages/paddlex/inference/pipelines/doc_understanding/pipeline.pyr#   z!DocUnderstandingPipeline.__init__   s    2 	 	
'!	
 	
 	
 	
 	
 *0L")E)E)I)I!#NO*
 *
& (,'8'89W'X'X$$$    inputc              +   2   K    | j         |fi |E d{V  dS )a0  Predicts doc understanding results for the given input.

        Args:
            input (dict): The input image and query.
            **kwargs: Additional keyword arguments that can be passed to the function.

        Returns:
            DocVLMResult: The predicted doc understanding results.
        N)r&   )r'   r-   r(   s      r+   predictz DocUnderstandingPipeline.predictH   s;       04/@@@@@@@@@@@@@r,   c                 8    | j                                          d S )N)r&   close)r'   s    r+   r1   zDocUnderstandingPipeline.closeT   s    $**,,,,,r,   )__name__
__module____qualname____doc__entitiesr   r   strr   r   boolr   r
   r#   r   r/   r1   __classcell__)r*   s   @r+   r   r      s0        %$"H !% $2659AE'Y 'Y 'Y'Y 	'Y
 'Y  S#X/'Y 12'Y 'Y U4S>9#<=>'Y 
'Y 'Y 'Y 'Y 'Y 'YR
AT 
A 
A 
A 
A 
A- - - - - - -r,   r   N)typingr   r   r   r   
utils.depsr   modelsr
   r   models.doc_vlm.resultr   utils.benchmarkr   baser   time_methodsr   r!   r,   r+   <module>rA      s    . - - - - - - - - - - - 2 2 2 2 2 2 6 6 6 6 6 6 6 6 1 1 1 1 1 1 ( ( ( ( ( (       &&;- ;- ;- ;- ;-| ;- ;- '& ;- ;- ;-r,   