
    9i                     |    S SK JrJr  S SKJrJrJr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\\S9rg)    )ABCabstractmethod)AnyDictOptionalUnion   )logging)AutoRegisterABCMetaClass   )BasePredictor)	HPIConfig)PaddlePredictorOptionc                      ^  \ rS rSrSrSr    SS\S\S\S\	\
\\\4   \4      S	S4
U 4S
 jjjr\S 5       rS\S	\4S jrS\4S jrS rS rSrU =r$ )BasePipeline   zBase class for all pipelines.

This class serves as a foundation for creating various pipelines.
It includes common attributes and methods that are shared among all
pipeline implementations.
TNdevice	pp_optionuse_hpip
hpi_configreturnc                 R   > [         TU ]  5         Xl        X l        X0l        X@l        g)a  
Initializes the class with specified parameters.

Args:
    device (str, optional): The device to use for prediction. Defaults to None.
    pp_option (PaddlePredictorOption, optional): The options for PaddlePredictor. Defaults to 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.
N)super__init__r   r   r   r   )selfr   r   r   r   argskwargs	__class__s          `/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/paddlex/inference/pipelines/base.pyr   BasePipeline.__init__#   s$    * 	" $    c                     [        S5      e)z
Declaration of an abstract method. Subclasses are expected to
provide a concrete implementation of predict.
Args:
    input: The input data to predict.
    **kwargs: Additional keyword arguments.
z2The method `predict` has not been implemented yet.)NotImplementedErrorr   inputr   s      r   predictBasePipeline.predict>   s     ""VWWr!   configc                    SU;   a  [        US   5      eUR                  SS5      nUR                  SU R                  5      nUR                  SS5      nU R                  b  U=(       d    0 n0 U R                  EUEnUR                  SS5      nSSKJn  [        R                  " S	US
   U45        U R                  b  U R                  R                  5       nOSnU" SUS
   UU R                  UR                  SS5      UUUUS.UD6n	U	$ )z
Create a model instance based on the given configuration.

Args:
    config (Dict): A dictionary containing configuration settings.
    **kwargs: The model arguments that needed to be pass.

Returns:
    BasePredictor: An instance of the model.
model_config_error	model_dirNr   r   genai_configr   )create_predictorzCreating model: %s
model_name
batch_size   )r.   r+   r   r/   r   r   r   r,    )
ValueErrorgetr   r    r-   r
   infor   copyr   )
r   r(   r   r+   r   r   r,   r-   r   models
             r   create_modelBasePipeline.create_modelI   s     6)V$89::JJ{D1	::j$--8ZZd3
??&#)rJ:DOO:z:Jzz.$7')F<,@)+LM >>%++-II  

l+;;zz,2!%

 

 r!   c                 p   SU;   a  [        US   5      eSSKJn  UR                  SU R                  5      nUR                  SS5      nU R
                  b  U=(       d    0 n0 U R
                  EUEnU" UU R                  U R                  b  U R                  R                  5       OU R                  UUS9nU$ )z
Creates a pipeline based on the provided configuration.

Args:
    config (Dict): A dictionary containing the pipeline configuration.

Returns:
    BasePipeline: An instance of the created pipeline.
pipeline_config_errorr0   )create_pipeliner   r   N)r(   r   r   r   r   )	r2   r4   r<   r3   r   r   r   r   r6   )r   r(   r<   r   r   pipelines         r   r<   BasePipeline.create_pipelinew   s     #f,V$;<==%::j$--8ZZd3
??&#)rJ:DOO:z:J";;)-)C##%!
 r!   c                     g )Nr1   )r   s    r   closeBasePipeline.close   s    r!   c                 (    U R                   " U40 UD6$ )a  
Calls the predict method with the given input and keyword arguments.

Args:
    input: The input data to be predicted.
    **kwargs: Additional keyword arguments to be passed to the predict method.

Returns:
    The prediction result from the predict method.
)r&   r$   s      r   __call__BasePipeline.__call__   s     ||E,V,,r!   )r   r   r   r   )NNFN)__name__
__module____qualname____firstlineno____doc___BasePipeline__is_basestrr   boolr   r   r   r   r   r   r   r&   r   r8   r<   r@   rC   __static_attributes____classcell__)r   s   @r   r   r      s     I +/AE%% )% 	%
 U4S>9#<=>% 
% %6 X X,4 ,m ,\d @- -r!   r   )	metaclassN)abcr   r   typingr   r   r   r   utilsr
   utils.subclass_registerr   modelsr   	utils.hpir   utils.pp_optionr   r   r1   r!   r   <module>rW      s0    $ - -  ? " ! 3L-3": L-r!   