
    9iU                         S SK Jr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TupleUnionN   )pipeline_requires_extra   )	DetResult)	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S\
\\\   \R                   \\R                      4   S\	\
\\4      S\	\   S\	\
\\\\4   4      S\	\   S	\4S jjrSrU =r$ )_ObjectDetectionPipeline   zObject Detection PipelineNconfigdevice	pp_optionuse_hpip
hpi_configreturnc                    > [         TU ]  X#XES9  US   S   n0 nSU;   a  US   US'   SU;   a  US   US'   SU;   a  US   US'   SU;   a  US   US'   SU;   a  US   US'   U R                  " U40 UD6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ObjectDetection	thresholdimg_size
layout_nmslayout_unclip_ratiolayout_merge_bboxes_modeN)super__init__create_model	det_model)	selfr   r   r   r   r   	model_cfgmodel_kwargs	__class__s	           u/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/paddlex/inference/pipelines/object_detection/pipeline.pyr%   !_ObjectDetectionPipeline.__init__    s    * 	 	 	
 <():;	)#(1+(>L%"'0'<L$9$)2<)@L& I-2;<Q2RL./%27@*8L34 **9EE    inputr   r!   r"   r#   c              +   P   #    U R                   " U4UUUUS.UD6 Sh  vN   g N7f)aL  Predicts object 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.
    img_size (Optional[Union[int, Tuple[int, int]]]): The size of the input image. Default is None.
    threshold (Optional[float]): The threshold value to filter out low-confidence predictions. Default is None.
    layout_nms (bool, optional): Whether to use layout-aware NMS. Defaults to False.
    layout_unclip_ratio (Optional[Union[float, Tuple[float, float]]], optional): The ratio of unclipping the bounding box.
        Defaults to None.
        If it's a single number, then both width and height are used.
        If it's a tuple of two numbers, then they are used separately for width and height respectively.
        If it's None, then no unclipping will be performed.
    layout_merge_bboxes_mode (Optional[str], optional): The mode for merging bounding boxes. Defaults to None.
    **kwargs: Additional keyword arguments that can be passed to the function.
Returns:
    DetResult: The predicted detection results.
)r   r!   r"   r#   Nr'   )r(   r/   r   r!   r"   r#   kwargss          r,   predict _ObjectDetectionPipeline.predictH   s;     4 >>
! 3%=
 
 	
 	
s   &$&r1   )NNFN)NNNN)__name__
__module____qualname____firstlineno____doc__r   strr   boolr   r   r   r   r%   r   npndarrayfloatdictr   r   r3   __static_attributes____classcell__)r+   s   @r,   r   r      s   #
 +/AE&F&F &F )	&F
 &F U4S>9#<=>&F 
&F &FV 37%)KO26!
S$s)RZZbjj1AAB!
 E%+./!
 TN	!

 &eE53F,F&GH!
 #+3-!
 
!
 !
r.   r   cvc                   .    \ rS rSrSr\S 5       rS rSrg)ObjectDetectionPipelinel   object_detectionc                     [         $ )N)r   )r(   s    r,   _pipeline_cls%ObjectDetectionPipeline._pipeline_clsp   s    ''r.   c                 2    US   S   R                  SS5      $ )Nr   r   
batch_size   )get)r(   r   s     r,   _get_batch_size'ObjectDetectionPipeline._get_batch_sizet   s     l#$56::<KKr.    N)	r5   r6   r7   r8   entitiespropertyrH   rN   r@   rP   r.   r,   rD   rD   l   s    !H( (Lr.   rD   )typingr   r   r   r   r   r   numpyr<   
utils.depsr
   models.object_detection.resultr   utils.benchmarkr   	utils.hpir   utils.pp_optionr   	_parallelr   baser   time_methodsr   rD   rP   r.   r,   <module>r]      sn    ; :  2 7 ( " 4 @  L
| L
 L
^ LF L Lr.   