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 d	dlmZ ejG dd deZe	dG dd deZdS )    )AnyDictListOptionalUnionN   )pipeline_requires_extra   )	HPIConfigPaddlePredictorOption)	UadResult)	benchmark   )(AutoParallelImageSimpleInferencePipeline)BasePipelinec                       s   e 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
eee ejeej f defddZ  ZS )_AnomalyDetectionPipelinez'Image AnomalyDetectionPipeline PipelineNFdeviceengineengine_config	pp_optionuse_hpip
hpi_configconfigr   r   r   r   r   r   returnc          
   	      s<   t  jd||||||d| |d d }	| |	| _dS )a  Initializes the image anomaly detection pipeline.

        Args:
            config (Dict): Configuration dictionary containing various settings.
            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AnomalyDetectionN )super__init__Zcreate_modelanomaly_detetion_model)
selfr   r   r   r   r   r   r   kwargsZanomaly_detetion_model_config	__class__r   w/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddlex/inference/pipelines/anomaly_detection/pipeline.pyr      s   
z"_AnomalyDetectionPipeline.__init__inputc                 k   s    |  |E dH  dS )ad  Predicts anomaly 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.
            **kwargs: Additional keyword arguments that can be passed to the function.

        Returns:
            UadResult: The predicted anomaly results.
        N)r    )r!   r&   r"   r   r   r%   predictE   s   z!_AnomalyDetectionPipeline.predict)__name__
__module____qualname____doc__r   r   strr   r   boolr   r
   r   r   npZndarrayr   r'   __classcell__r   r   r#   r%   r      s<    	&r   Zcvc                   @   s$   e Zd ZdZedd Zdd ZdS )AnomalyDetectionPipelineZanomaly_detectionc                 C   s   t S )N)r   )r!   r   r   r%   _pipeline_clsX   s   z&AnomalyDetectionPipeline._pipeline_clsc                 C   s   |d d  ddS )Nr   r   Z
batch_size   )get)r!   r   r   r   r%   _get_batch_size\   s   z(AnomalyDetectionPipeline._get_batch_sizeN)r(   r)   r*   entitiespropertyr1   r4   r   r   r   r%   r0   T   s
    
r0   )typingr   r   r   r   r   numpyr.   Z
utils.depsr   modelsr
   r   Zmodels.anomaly_detection.resultr   Zutils.benchmarkr   Z	_parallelr   baser   Ztime_methodsr   r0   r   r   r   r%   <module>   s   8