
    9i:                         S SK JrJrJrJrJr  S SKrSSKJ	r	  SSK
Jr  SSKJr  SSKJr  SS	KJr  S
SKJr  S
SKJr  \R,                   " S S\5      5       r\	" S5       " S S\5      5       rg)    )AnyDictListOptionalUnionN   )pipeline_requires_extra   )
TopkResult)	benchmark)	HPIConfig)PaddlePredictorOption   )(AutoParallelImageSimpleInferencePipeline)BasePipelinec                      ^  \ rS rSrSr    SS\S\S\S\S\	\
\\\4   \4      S	S4U 4S
 jjjrS\
\\\   \R                   \\R                      4   S	\4S jrSrU =r$ )_ImageClassificationPipeline   zImage Classification PipelineNconfigdevice	pp_optionuse_hpip
hpi_configreturnc                    > [         T	U ]  X#XES9  US   S   n0 nUR                  SS5      =nb  SU0nU R                  " U40 UD6U l        UR                  SS5      U l        g)ah  
Initializes the class with given configurations and options.

Args:
    config (Dict): Configuration dictionary containing model and other parameters.
    device (str): The device to run the prediction on. Default is None.
    pp_option (PaddlePredictorOption): Options for PaddlePaddle predictor. Default is None.
    use_hpip (bool, optional): Whether to use the high-performance
        inference plugin (HPIP) by default. Defaults to False.
    hpi_config (Optional[Union[Dict[str, Any], HPIConfig]], optional):
        The default high-performance inference configuration dictionary.
        Defaults to None.
)r   r   r   r   
SubModulesImageClassificationtopkN   )super__init__getcreate_modelimage_classification_modelr   )
selfr   r   r   r   r   !image_classification_model_configmodel_kwargsr   	__class__s
            y/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/paddlex/inference/pipelines/image_classification/pipeline.pyr!   %_ImageClassificationPipeline.__init__    s    * 	 	 	
 -3<,@AV,W)599&$GGDT"D>L*.*;*;-+
1=+
' 699&!D	    inputc              +   v   #    UR                  SU R                  5      nU R                  XS9 Sh  vN   g N7f)a6  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,   kwargsr   s       r)   predict$_ImageClassificationPipeline.predictB   s2      zz&$)),2252DDDs   /979)r$   r   )NNFN)__name__
__module____qualname____firstlineno____doc__r   strr   boolr   r   r   r   r!   r   npndarrayr   r0   __static_attributes____classcell__)r(   s   @r)   r   r      s    '
 +/AE E E  E )	 E
  E U4S>9#<=> E 
 E  EDE3S	2::tBJJ7GGHE	E Er+   r   cvc                   .    \ rS rSrSr\S 5       rS rSrg)ImageClassificationPipelineS   image_classificationc                     [         $ )N)r   )r%   s    r)   _pipeline_cls)ImageClassificationPipeline._pipeline_clsW   s    ++r+   c                 2    US   S   R                  SS5      $ )Nr   r   
batch_size   )r"   )r%   r   s     r)   _get_batch_size+ImageClassificationPipeline._get_batch_size[   s     l#$9:>>|QOOr+    N)	r2   r3   r4   r5   entitiespropertyrC   rH   r;   rJ   r+   r)   r?   r?   S   s    %H, ,Pr+   r?   )typingr   r   r   r   r   numpyr9   
utils.depsr	   "models.image_classification.resultr   utils.benchmarkr   	utils.hpir   utils.pp_optionr   	_parallelr   baser   time_methodsr   r?   rJ   r+   r)   <module>rW      sn    4 3  2 < ( " 4 @  3E< 3E 3El P"J P Pr+   