
    9i3                     l    S SK JrJrJrJr  SSKJrJr  SSKJ	r	  / SQr
 " S S\5      r " S S	\5      rg
)   )add_simple_inference_argsget_subcommand_argsperform_simple_inferencestr2bool   )PaddleXPipelineWrapperPipelineCLISubcommandExecutor)create_config_from_structure)nativezvllm-serverzsglang-serverzfastdeploy-serverc                      ^  \ rS rSr                    SU 4S jjr\S 5       rSSSSSSSSSSSSSSSSS.S jrSSSSSSSSSSSSSSSSS.S jrS r	\
S	 5       rS
 rSrU =r$ )PaddleOCRVL   Nc                    > U	b   U	[         ;  a  [        SU	 S[          S35      e[        5       R                  5       nUR	                  S5        UR	                  S5        UU l        [        TU ]  " S0 UD6  g )Nz/Invalid backend for the VL recognition module: z. Supported values are .selfkwargs )_SUPPORTED_VL_BACKENDS
ValueErrorlocalscopypop_paramssuper__init__)r   layout_detection_model_namelayout_detection_model_dirlayout_threshold
layout_nmslayout_unclip_ratiolayout_merge_bboxes_modevl_rec_model_namevl_rec_model_dirvl_rec_backendvl_rec_server_urlvl_rec_max_concurrency#doc_orientation_classify_model_name"doc_orientation_classify_model_dirdoc_unwarping_model_namedoc_unwarping_model_diruse_doc_orientation_classifyuse_doc_unwarpinguse_layout_detectionuse_chart_recognitionformat_block_contentr   params	__class__s                          a/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/paddleocr/_pipelines/paddleocr_vl.pyr   PaddleOCRVL.__init__   s    0 %.@V*VA.AQQhi  iA  AB  C  

6

8"6"    c                     g)NzPaddleOCR-VLr   r   s    r2   _paddlex_pipeline_name"PaddleOCRVL._paddlex_pipeline_nameA   s    r4   )r+   r,   r-   r.   r   r   r    r!   
use_queuesprompt_labelr/   repetition_penaltytemperaturetop_p
min_pixels
max_pixelsc                    U R                   R                  " U40 SU_SU_SU_SU_SU_SU_SU_SU	_S	U
_S
U_SU_SU_SU_SU_SU_SU_UD6$ Nr+   r,   r-   r.   r   r   r    r!   r9   r:   r/   r;   r<   r=   r>   r?   )paddlex_pipelinepredictr   inputr+   r,   r-   r.   r   r   r    r!   r9   r:   r/   r;   r<   r=   r>   r?   r   s                      r2   predict_iterPaddleOCRVL.predict_iterE   s    , $$,,
)E
 0
 "6	

 #8
 .
 "
 !4
 &>
 "
 &
 "6
  2
 $
 
  "!
" "%
 	
r4   c                    [        U R                  " U40 SU_SU_SU_SU_SU_SU_SU_SU	_S	U
_S
U_SU_SU_SU_SU_SU_SU_UD65      $ rA   )listrF   rD   s                      r2   rC   PaddleOCRVL.predictp   s    , -I #4 &:	
 '< "2 & %8 *B & * &: $6 (   &!" &%
 	
r4   c                 8    U R                   R                  U5      $ N)rB   concatenate_markdown_pages)r   markdown_lists     r2   rM   &PaddleOCRVL.concatenate_markdown_pages   s    $$??NNr4   c                     [        5       $ rL   ) PaddleOCRVLCLISubcommandExecutor)clss    r2   get_cli_subcommand_executor'PaddleOCRVL.get_cli_subcommand_executor   s    /11r4   c                    0 SU R                   S   _SU R                   S   _SU R                   S   =(       d    U R                   S   _SU R                   S   _SU R                   S   _SU R                   S   _S	U R                   S
   _SU R                   S   _SU R                   S   _SU R                   S   _SU R                   S   _SU R                   S   _SU R                   S   _SU R                   S   _SU R                   S   _SU R                   S   _SU R                   S   _U R                   S   U R                   S    U R                   S!   S".En[        U5      $ )#Nz9SubPipelines.DocPreprocessor.use_doc_orientation_classifyr+   z.SubPipelines.DocPreprocessor.use_doc_unwarpingr,   use_doc_preprocessorr-   r.   r/   z%SubModules.LayoutDetection.model_namer   z$SubModules.LayoutDetection.model_dirr   z$SubModules.LayoutDetection.thresholdr   z%SubModules.LayoutDetection.layout_nmsr   z.SubModules.LayoutDetection.layout_unclip_ratior    z3SubModules.LayoutDetection.layout_merge_bboxes_moder!   z#SubModules.VLRecognition.model_namer"   z"SubModules.VLRecognition.model_dirr#   z-SubModules.VLRecognition.genai_config.backendr$   z0SubModules.VLRecognition.genai_config.server_urlr%   zISubPipelines.DocPreprocessor.SubModules.DocOrientationClassify.model_namer'   r(   r)   r*   )zHSubPipelines.DocPreprocessor.SubModules.DocOrientationClassify.model_dirz?SubPipelines.DocPreprocessor.SubModules.DocUnwarping.model_namez>SubPipelines.DocPreprocessor.SubModules.DocUnwarping.model_dir)r   r
   )r   	STRUCTUREs     r2   _get_paddlex_config_overrides)PaddleOCRVL._get_paddlex_config_overrides   s   .
G.J.
 =dll#?	.
 #DLL1O$P %1||/0.
 #DLL1G$H.
 $T\\2I%J.
 #DLL1G$H.
 4T\\-6.
 3DLL,5.
$ 3DLLAS4T%.
& 4T\\,5O'.
( =dll%?).
. B4<<*D/.
4 24<<@S3T5.
6 1$,,?Q2R7.
8 <T\\ >9.
> ?#A?.
D XY]YeYe5ZE.
J Y]XdXd4Y PT||*P OSll)OW.
	^ ,I66r4   )r   )NNNNNNNNNNNNNNNNNNNN)__name__
__module____qualname____firstlineno__r   propertyr7   rF   rC   rM   classmethodrS   rX   __static_attributes____classcell__)r1   s   @r2   r   r      s     %)#' !%#,0+/!% $%)!"!+"#H   &*!" !%!')
^ &*!" !%!'+
ZO 2 207 07r4   r   c                   0    \ rS rSr\S 5       rS rS rSrg)rQ      c                     g)N
doc_parserr   r6   s    r2   subparser_name/PaddleOCRVLCLISubcommandExecutor.subparser_name   s    r4   c                    [        U5        UR                  S[        SS9  UR                  S[        SS9  UR                  S[        SS9  UR                  S[        S	S9  UR                  S
[        SS9  UR                  S[        SS9  UR                  S[        SS9  UR                  S[        SS9  UR                  S[        S[
        S9  UR                  S[        SS9  UR                  S[        SS9  UR                  S[        SS9  UR                  S[        SS9  UR                  S[        SS9  UR                  S[        S S9  UR                  S![        S"S9  UR                  S#[        S$S9  UR                  S%[        S&S9  UR                  S'[        S(S9  UR                  S)[        S*S9  UR                  S+[        S,S9  UR                  S-[        S.S9  UR                  S/[        S0S9  UR                  S1[        S2S9  UR                  S3[        S4S9  UR                  S5[        S6S9  UR                  S7[        S8S9  g )9Nz--layout_detection_model_namez#Name of the layout detection model.)typehelpz--layout_detection_model_dirz-Path to the layout detection model directory.z--layout_thresholdz/Score threshold for the layout detection model.z--layout_nmsz'Whether to use NMS in layout detection.z--layout_unclip_ratioz+Expansion coefficient for layout detection.z--layout_merge_bboxes_modez!Overlapping box filtering method.z--vl_rec_model_namez!Name of the VL recognition model.z--vl_rec_model_dirz+Path to the VL recognition model directory.z--vl_rec_backendz*Backend used by the VL recognition module.)ri   rj   choicesz--vl_rec_server_urlz-Server URL used by the VL recognition module.z--vl_rec_max_concurrencyz,Maximum concurrency for making VLM requests.z%--doc_orientation_classify_model_namez<Name of the document image orientation classification model.z$--doc_orientation_classify_model_dirzFPath to the document image orientation classification model directory.z--doc_unwarping_model_namez'Name of the text image unwarping model.z--doc_unwarping_model_dirz,Path to the image unwarping model directory.z--use_doc_orientation_classifyz9Whether to use document image orientation classification.z--use_doc_unwarpingz$Whether to use text image unwarping.z--use_layout_detectionz Whether to use layout detection.z--use_chart_recognitionz!Whether to use chart recognition.z--format_block_contentz,Whether to format block content to Markdown.z--use_queuesz2Whether to use queues for asynchronous processing.z--prompt_labelzPrompt label for the VLM.z--repetition_penaltyz0Repetition penalty used in sampling for the VLM.z--temperaturez3Temperature parameter used in sampling for the VLM.z--top_pz-Top-p parameter used in sampling for the VLM.z--min_pixelsz3Minimum pixels for image preprocessing for the VLM.z--max_pixelsz3Maximum pixels for image preprocessing for the VLM.)r   add_argumentstrfloatr   r   int)r   	subparsers     r2   _update_subparser2PaddleOCRVLCLISubcommandExecutor._update_subparser   s5   !),+6 	 	

 	*@ 	 	

 	 B 	 	

 	: 	 	

 	#> 	 	

 	(4 	 	
 	!4 	 	

 	 > 	 	

 	=*	 	 	
 	!@ 	 	

 	&? 	 	
 	3O 	 	

 	2Y 	 	

 	(: 	 	

 	'? 	 	
 	,L 	 	

 	!7 	 	

 	$3 	 	

 	%4 	 	

 	$? 	 	

 	E 	 	

 	, 	 	

 	"C 	 	

 	F 	 	

 	@ 	 	

 	F 	 	

 	F 	 	
r4   c                 <    [        U5      n[        [        U1 SkS9  g )N>   r=   r?   r>   r9   r<   r:   r;   )predict_param_names)r   r   r   )r   argsr0   s      r2   execute_with_args2PaddleOCRVLCLISubcommandExecutor.execute_with_argsk  s    $T* !	
r4   r   N)	rZ   r[   r\   r]   r^   rf   rq   rv   r`   r   r4   r2   rQ   rQ      s      M
^
r4   rQ   N)
_utils.clir   r   r   r   baser   r	   utilsr
   r   r   rQ   r   r4   r2   <module>r{      s@     H / Y x7( x7vb
'D b
r4   