o
    0j                     @   sz   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 deZdS )    )AnyDictOptionalUnion   )pipeline_requires_extra   )	HPIConfigPaddlePredictorOption)DocVLMResult)	benchmark   )BasePipelineZ
multimodalc                       s   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dZdedefddZdd Z  ZS )DocUnderstandingPipelinezDoc Understanding PipelineZdoc_understandingNFdeviceengineengine_config	pp_optionuse_hpip
hpi_configconfigr   r   r   r   r   r   returnc          
   	      sH   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   Z
SubModulesZDocUnderstandingZmodel_config_errorz)config error for doc_understanding_model!N )super__init__getZcreate_modeldoc_understanding_model)
selfr   r   r   r   r   r   r   kwargsZdoc_understanding_model_config	__class__r   w/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddlex/inference/pipelines/doc_understanding/pipeline.pyr      s   
z!DocUnderstandingPipeline.__init__inputc                 k   s    | j |fi |E dH  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   r   r   r"   predictH   s   
z DocUnderstandingPipeline.predictc                 C   s   | j   d S )N)r   close)r   r   r   r"   r%   T   s   zDocUnderstandingPipeline.close)__name__
__module____qualname____doc__entitiesr   r   strr   r
   boolr   r	   r   r   r$   r%   __classcell__r   r   r    r"   r      s8    	)r   N)typingr   r   r   r   Z
utils.depsr   modelsr	   r
   Zmodels.doc_vlm.resultr   Zutils.benchmarkr   baser   Ztime_methodsr   r   r   r   r"   <module>   s   