o
    0j
                     @   s@   d dl mZmZmZmZ d dlZddlmZ G dd deZ	dS )    )AnyDictListUnionN   )ImageFeatureRunnerPredictorc                	       s`   e Zd ZdZdddedededdf fd	d
Zdeee	e
jf  dee	ef fddZ  ZS )FaceFeaturePredictorzDFaceFeaturePredictor that inherits from ImageFeatureRunnerPredictor.F)flipargsr	   kwargsreturnNc                   s   t  j|i | || _dS )a!  Initializes ClasPredictor.

        Args:
            *args: Arbitrary positional arguments passed to the superclass.
            flip: Whether to perform face flipping during inference. Default is False.
            **kwargs: Arbitrary keyword arguments passed to the superclass.
        N)super__init__r	   )selfr	   r
   r   	__class__ p/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddlex/inference/models/face_feature/predictor.pyr      s   
zFaceFeaturePredictor.__init__
batch_datac           	      C   s   | j d |jd}| j d |d}| j d |d}| j d |d}| j d |d}| j|d}| jrP| jdd	 |D d}tt|D ]}|| ||  ||< qC| jd
 |}|j|j||dS )a  
        Process a batch of data through the preprocessing, inference, and postprocessing.

        Args:
            batch_data (List[Union[str, np.ndarray], ...]): A batch of input data (e.g., image file paths).

        Returns:
            dict: A dictionary containing the input path, raw image, class IDs, scores, and label names for every instance of the batch. Keys include 'input_path', 'input_img', 'class_ids', 'scores', and 'label_names'.
        ZRead)ZimgsZResizeZ	NormalizeZToCHWZToBatch)xc                 S   s   g | ]	}t j|d dqS )   )Zaxis)npr	   ).0datar   r   r   
<listcomp>5   s    z0FaceFeaturePredictor.process.<locals>.<listcomp>ZNormalizeFeatures)Z
input_pathZ
page_indexZ	input_imgfeature)	ZpreprocessorsZ	instancesrunnerr	   rangelenZpostprocessorsZinput_pathsZpage_indexes)	r   r   Zbatch_raw_imgsZ
batch_imgsr   Zbatch_predsZbatch_preds_flippedifeaturesr   r   r   process$   s    
zFaceFeaturePredictor.process)__name__
__module____qualname____doc__r   boolr   r   r   strr   Zndarrayr   r!   __classcell__r   r   r   r   r      s    $0r   )
typingr   r   r   r   numpyr   Zimage_featurer   r   r   r   r   r   <module>   s   