
    ?pj3G                     x    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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)v1v1.5v1.6r   )nativezvllm-serverzsglang-serverzfastdeploy-serverzmlx-vlm-serverzllama-cpp-serverc                     ^  \ rS rSr\SSSSSSSSSSSSSSSSSSSSSSSSSSS4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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SSSSSS.S jr	S	 r
 SS
 jr\S 5       rS rSrU =r$ )PaddleOCRVL%   Nc                 \  > U[         ;  a  [        SU S[          S35      eU
b   U
[        ;  a  [        SU
 S[         S35      e[        5       R	                  5       nUR                  S5        UR                  S5        UR                  S5        UU l        Xl        [        TU ]$  " S	0 UD6  g )
NzInvalid pipeline version: z. Supported versions are .z/Invalid backend for the VL recognition module: z. Supported values are selfpipeline_versionkwargs )
_AVAILABLE_PIPELINE_VERSIONS
ValueError_SUPPORTED_VL_BACKENDSlocalscopypop_paramsr   super__init__) r   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vl_rec_api_model_namevl_rec_api_key#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use_seal_recognitionuse_ocr_for_image_blockformat_block_contentmerge_layout_blocksmarkdown_ignore_labels
use_queuesr   params	__class__s                                   ]/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/paddleocr/_pipelines/paddleocr_vl.pyr    PaddleOCRVL.__init__&   s    @ #??,-=,>>WXtWuuvw  %.@V*VA.AQQhi  iA  AB  C  

6

%&

8 0"6"    c                     U R                   S:X  a  gU R                   S:X  a  gU R                   S:X  a  g[        SU R                    35      e)Nr   zPaddleOCR-VLr   zPaddleOCR-VL-1.5r   zPaddleOCR-VL-1.6zUnknown pipeline version: )r   AssertionErrorr   s    r>   _paddlex_pipeline_name"PaddleOCRVL._paddlex_pipeline_nameY   sO      D(!""f,%""f,% #=d>S>S=T!UVVr@   auto)r2   r3   r4   r5   r6   r7   r#   r$   r%   r&   layout_shape_moder;   prompt_labelr8   repetition_penaltytemperaturetop_p
min_pixels
max_pixelsmax_new_tokensr9   r:   vlm_extra_argsc                    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_SU_SU_SU_SU_SU_SU_SU_UD6$ Nr2   r3   r4   r5   r6   r7   r#   r$   r%   r&   rG   r;   rH   r8   rI   rJ   rK   rL   rM   rN   r9   r:   rO   )paddlex_pipelinepredictr   inputr2   r3   r4   r5   r6   r7   r#   r$   r%   r&   rG   r;   rH   r8   rI   rJ   rK   rL   rM   rN   r9   r:   rO   r   s                             r>   predict_iterPaddleOCRVL.predict_iterd   s   : $$,,
)E
 0
 "6	

 #8
 "6
 %<
 .
 "
 !4
 &>
 0
 "
 &
 "6
   2!
" $#
$ %
& "'
( ")
* *+
, !4-
. $:/
0 *3
 	
r@   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_SU_SU_SU_SU_SU_SU_SU_UD65      $ rQ   )listrV   rT   s                             r>   rS   PaddleOCRVL.predict   s   : -I #4 &:	
 '< &: )@ "2 & %8 *B #4 & * &:  $6!" (#$ %& &'( &)*  .+, %8-. (>/0  .3
 	
r@   c                 8    U R                   R                  U5      $ N)rR   concatenate_markdown_pages)r   markdown_lists     r>   r]   &PaddleOCRVL.concatenate_markdown_pages   s    $$??NNr@   c           	      L    [        U R                  R                  UUUUS95      $ )N)merge_tablesrelevel_titlesconcatenate_pages)rY   rR   restructure_pages)r   res_listra   rb   rc   s        r>   rd   PaddleOCRVL.restructure_pages   s6     !!33)-"3	 4 
 	
r@   c                     [        5       $ r\   ) PaddleOCRVLCLISubcommandExecutor)clss    r>   get_cli_subcommand_executor'PaddleOCRVL.get_cli_subcommand_executor   s    /11r@   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   U R                   S   U R                   S    U R                   S!   U R                   S"   U R                   S#   U R                   S$   U R                   S%   U R                   S&   S'.En[        U5      $ )(Nz9SubPipelines.DocPreprocessor.use_doc_orientation_classifyr2   z.SubPipelines.DocPreprocessor.use_doc_unwarpingr3   use_doc_preprocessorr4   r5   r8   r9   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(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r6   r7   )z-SubModules.VLRecognition.genai_config.backendz0SubModules.VLRecognition.genai_config.server_urlz5SubModules.VLRecognition.genai_config.max_concurrencyz>SubModules.VLRecognition.genai_config.client_kwargs.model_namez;SubModules.VLRecognition.genai_config.client_kwargs.api_keyzISubPipelines.DocPreprocessor.SubModules.DocOrientationClassify.model_namezHSubPipelines.DocPreprocessor.SubModules.DocOrientationClassify.model_dirz?SubPipelines.DocPreprocessor.SubModules.DocUnwarping.model_namez>SubPipelines.DocPreprocessor.SubModules.DocUnwarping.model_dirr6   r7   )r   r
   )r   	STRUCTUREs     r>   _get_paddlex_config_overrides)PaddleOCRVL._get_paddlex_config_overrides   s   <
G.J<
 =dll#?	<
 #DLL1O$P %1||/0<
 #DLL1G$H<
 $T\\2I%J<
 #DLL1G$H<
 "4<<0E#F<
 %dll3K&L<
 $,,|4<
 4T\\-6<
$ 3DLL,5%<
* 3DLLAS4T+<
, 4T\\,5O-<
. =dll%?/<
4 B4<<*D5<
: 24<<@S3T;<
< 1$,,?Q2R=<
> >B\\ > AE#A FJ\\(F OSll'O LP<< L Z^YeYe5Z Y]XdXd4Y PT||*P OSll)O %)LL1G$H'+||4M'Nw<
	z ,I66r@   )r   r   )TTF)__name__
__module____qualname____firstlineno___DEFAULT_PIPELINE_VERSIONr    propertyrD   rV   rS   r]   rd   classmethodrj   ro   __static_attributes____classcell__)r=   s   @r>   r   r   %   s?    3$(#' !%#",0+/!% $%)!"! $! #;1#f W W &*!"! $ !% ! #57
z &*!"! $ !% ! #59
vO SX

 2 2>7 >7r@   r   c                   0    \ rS rSr\S 5       rS rS rSrg)rh   i,  c                     g)N
doc_parserr   rC   s    r>   subparser_name/PaddleOCRVLCLISubcommandExecutor.subparser_name-  s    r@   c                 "   [        U5        UR                  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[        S8S9S:9  UR                  S;[        S<S9  UR                  S=[        S>S?S@9  UR                  SA[        SBS9  UR                  SC[
        SDS9  UR                  SE[
        SFS9  UR                  SG[
        SHS9  UR                  SI[        SJS9  UR                  SK[        SLS9  UR                  SM[        SNS9  g )ONz--pipeline_version)typedefaultchoicesz--layout_detection_model_namez"Name of the layout analysis model.)r   helpz--layout_detection_model_dirz,Path to the layout analysis model directory.z--layout_thresholdz.Score threshold for the layout analysis model.z--layout_nmsz&Whether to use NMS in layout analysis.z--layout_unclip_ratioz*Expansion coefficient for layout analysis.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.)r   r   r   z--vl_rec_server_urlz-Server URL used by the VL recognition module.z--vl_rec_max_concurrencyz,Maximum concurrency for making VLM requests.z--vl_rec_api_model_namezModel name for the VLM server.z--vl_rec_api_keyzAPI key for the VLM server.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 analysis.z--use_chart_recognitionz!Whether to use chart recognition.z--use_seal_recognitionz Whether to use seal recognition.z--use_ocr_for_image_blockz$Whether to use OCR for image blocks.z--format_block_contentz,Whether to format block content to Markdown.z--merge_layout_blockszWhether to merge layout blocks.z--markdown_ignore_labels+z3List of layout labels to ignore in Markdown output.)r   nargsr   z--use_queuesz2Whether to use queues for asynchronous processing.z--layout_shape_moderF   zMode for layout shape.)r   r   r   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.z--max_new_tokensz.Maximum number of tokens generated by the VLM.)	r   add_argumentstrru   r   floatr   r   int)r   	subparsers     r>   _update_subparser2PaddleOCRVLCLISubcommandExecutor._update_subparser1  sL   !), -0	 	 	
 	+5 	 	

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

 	 A 	 	

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

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

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

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

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

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

 	%1 	 	

 	. 	 	
 	3O 	 	

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

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

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

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

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

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

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

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

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

 	#2 	 	

 	&F	 	 	
 	E 	 	
 	!)	 	 	
 	, 	 	

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

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

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

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

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

 	A 	 	
r@   c                 <    [        U5      n[        [        U1 SkS9  g )N>   rK   rM   rL   rJ   rH   rN   rG   rI   )predict_param_names)r   r   r   )r   argsr<   s      r>   execute_with_args2PaddleOCRVLCLISubcommandExecutor.execute_with_args  s    $T* 	!	
r@   r   N)	rq   rr   rs   rt   rv   r}   r   r   rx   r   r@   r>   rh   rh   ,  s      @
D
r@   rh   N)
_utils.clir   r   r   r   baser   r	   utilsr
   r   ru   r   r   rh   r   r@   r>   <module>r      sM     H /  6 "  D7( D7NV
'D V
r@   