o
    0j                     @   s   d dl mZmZmZmZmZ d dl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ListOptionalUnionN   )pipeline_requires_extra   )	HPIConfigPaddlePredictorOption)	DetResult)	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deeee ejeej f dedeeeef df defddZ  ZS )OpenVocabularyDetectionPipelinez"Open Vocabulary Detection PipelineZopen_vocabulary_detectionNFdeviceengineengine_config	pp_optionuse_hpip
hpi_configconfigr   r   r   r   r   r   returnc          
   	      sR   t  jd||||||d| |di dddi}	| |	| _|	d | _dS )	a#  Initializes the open vocabulary detection 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OpenVocabularyDetectionZmodel_config_errorz(config error for doc_ori_classify_model!
thresholdsN )super__init__getZcreate_modelopen_vocabulary_detection_modelr   )
selfr   r   r   r   r   r   r   kwargsZ&open_vocabulary_detection_model_config	__class__r   /var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddlex/inference/pipelines/open_vocabulary_detection/pipeline.pyr   !   s$   
z(OpenVocabularyDetectionPipeline.__init__inputpromptr   c                 k   s    | j |||dE dH  dS )a}  Predicts open vocabulary detection results for the given input.

        Args:
            input (Union[str, list[str], np.ndarray, list[np.ndarray]]): The input image(s) or path(s) to the images.
            prompt (str): The text prompt used to describe the objects.
            thresholds (dict | None): Threshold values for different models. If provided, these will override any default threshold values set during initialization. Default is None.
            **kwargs: Additional keyword arguments that can be passed to the function.

        Returns:
            DetResult: The predicted open vocabulary detection results.
        )r&   r   N)r   )r    r%   r&   r   r!   r   r   r$   predictM   s   z'OpenVocabularyDetectionPipeline.predict)N)__name__
__module____qualname____doc__entitiesr   r   strr   r   boolr   r
   r   r   npZndarrayfloatr   r'   __classcell__r   r   r"   r$   r      sH    	0r   )typingr   r   r   r   r   numpyr/   Z
utils.depsr   modelsr
   r   Zmodels.object_detection.resultr   Zutils.benchmarkr   baser   Ztime_methodsr   r   r   r   r$   <module>   s   