
    {-j                         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e                      Z e	d           G d de                      ZdS )    )AnyDictListOptionalUnionN   )pipeline_requires_extra   )	HPIConfigPaddlePredictorOption)
TopkResult)	benchmark   )(AutoParallelImageSimpleInferencePipeline)BasePipelinec                       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Zde
eee         ej        eej                 f         defdZ xZS )_ImageClassificationPipelinezImage Classification PipelineNFdeviceengineengine_config	pp_optionuse_hpip
hpi_configconfigr   r   r   r   r   r   returnc          
           t                      j        d||||||d| |d         d         }	i }
|	                    dd          x}d|i}
 | j        |	fi |
| _        |	                    dd          | _        dS )a  Initializes the image classification 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ImageClassificationtopkN    )super__init__getcreate_modelimage_classification_modelr    )selfr   r   r   r   r   r   r   kwargs!image_classification_model_configmodel_kwargsr    	__class__s               y/var/www/html/banglarbhumi/venv/lib/python3.11/site-packages/paddlex/inference/pipelines/image_classification/pipeline.pyr$   z%_ImageClassificationPipeline.__init__   s    2 	 	
'!	
 	
 	
 	
 	
 -3<,@AV,W)599&$GGGDT"D>L*;$*;-+
 +
1=+
 +
' 699&!DD			    inputc              +   z   K   |                     d| j                  }|                     ||          E d{V  dS )af  Predicts image classification 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:
            TopkResult: The predicted top k results.
        r    )r    N)popr    r'   )r(   r/   r)   r    s       r-   predictz$_ImageClassificationPipeline.predictK   sN       zz&$),,225t2DDDDDDDDDDDr.   )__name__
__module____qualname____doc__r   r   strr   r   boolr   r   r$   r   npndarrayr   r2   __classcell__)r,   s   @r-   r   r      s;       '' !% $2659AE*E *E *E*E 	*E
 *E  S#X/*E 12*E *E U4S>9#<=>*E 
*E *E *E *E *E *EXE3S	2:tBJ7GGHE	E E E E E E E Er.   r   cvc                   .    e Zd ZdZed             Zd ZdS )ImageClassificationPipelineimage_classificationc                     t           S )N)r   )r(   s    r-   _pipeline_clsz)ImageClassificationPipeline._pipeline_cls`   s    ++r.   c                 F    |d         d                              dd          S )Nr   r   
batch_size   )r%   )r(   r   s     r-   _get_batch_sizez+ImageClassificationPipeline._get_batch_sized   s#    l#$9:>>|QOOOr.   N)r3   r4   r5   entitiespropertyrA   rE   r"   r.   r-   r>   r>   \   sF        %H, , X,P P P P Pr.   r>   )typingr   r   r   r   r   numpyr9   
utils.depsr	   modelsr   r   "models.image_classification.resultr   utils.benchmarkr   	_parallelr   baser   time_methodsr   r>   r"   r.   r-   <module>rQ      sI   4 3 3 3 3 3 3 3 3 3 3 3 3 3     2 2 2 2 2 2 6 6 6 6 6 6 6 6 < < < < < < ( ( ( ( ( ( @ @ @ @ @ @       =E =E =E =E =E< =E =E =E@ P P P P P"J P P P P Pr.   