
    9i_                         S SK r S SKrSSKJrJrJrJr  SSKJrJ	r	J
r
  SSKJr  SSKJrJr  SSKJr  S	S
SSSSSSSSSS.r/ SQr " S S\5      r " S S\5      rg)    N   )add_simple_inference_argsget_subcommand_argsperform_simple_inferencestr2bool)DeprecatedOptionAction
deprecatedwarn_deprecated_param)logger   )PaddleXPipelineWrapperPipelineCLISubcommandExecutor)create_config_from_structuretext_detection_model_dirtext_det_limit_side_lentext_det_limit_typetext_det_threshtext_det_box_threshtext_det_unclip_ratiotext_recognition_model_dirtext_recognition_batch_sizeuse_textline_orientationtextline_orientation_model_dirtextline_orientation_batch_sizedet_model_dirdet_limit_side_lendet_limit_typedet_db_threshdet_db_box_threshdet_db_unclip_ratiorec_model_dirrec_batch_numuse_angle_clscls_model_dircls_batch_num)PP-OCRv3PP-OCRv4PP-OCRv5c                      ^  \ 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 jrSSSSSSSSSSS.
S jr\	" S5      S	 5       r
\S
 5       rS rS rSrU =r$ )	PaddleOCR7   Nc           	        > Ub   U[         ;  a  [        SU S[          S35      e[        [        S UUU
U45      5      (       aJ  Uc  UbC  U R	                  UU5      u  nnUb  Uc$  [        S[        U5       S[        U5       S35      eUnUn
OUc  Ub  [        R                  " SSS	9  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_UUUUUUUS.En0 nUR                  5        Hb  u  n n!U [        ;   aM  [        U    n"[        U U"5        U"U;   d   [        U"5       S35       eUU"   b  [        SU  SU" S35      eU!UU"'   M]  U!UU '   Md     UU l        [        T#U ]4  " S 0 UD6  g )!NzInvalid OCR version: z. Supported values are .c                 
    U S L $ N )ps    X/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/paddleocr/_pipelines/ocr.py<lambda>$PaddleOCR.__init__.<locals>.<lambda>]   s    !t)    z)No models are available for the language z and OCR version z^`lang` and `ocr_version` will be ignored when model names or model directories are not `None`.r   )
stacklevel#doc_orientation_classify_model_name"doc_orientation_classify_model_dirdoc_unwarping_model_namedoc_unwarping_model_dirtext_detection_model_namer   textline_orientation_model_namer   r   text_recognition_model_namer   r   use_doc_orientation_classifyuse_doc_unwarpingr   r   r   )r   r   r   text_det_input_shapetext_rec_score_threshreturn_word_boxtext_rec_input_shapez is not a valid parameter name.`z` and `z` are mutually exclusive.r1   )_SUPPORTED_OCR_VERSIONS
ValueErrorallmap_get_ocr_model_namesreprwarningswarnitems_DEPRECATED_PARAM_NAME_MAPPINGr
   _paramssuper__init__)$selfr8   r9   r:   r;   r<   r   r=   r   r   r>   r   r   r?   r@   r   r   r   r   r   r   rA   rB   rC   rD   langocr_versionkwargsdet_model_namerec_model_nameparamsbase_paramsnamevalnew_name	__class__s$                                      r3   rR   PaddleOCR.__init__8   s   < "{:Q'Q'}4KLcKddef  #-,/.	

 

 ;#:151J1J+2. ")^-C$CDJ<O`aefqar`sstu  -;).<+;#:t 

13V
02T
 '(@
 &'>	

 ()B
 '(@
 ./N
 -.L
 ./N
 *+F
 )*D
 *+F
 +,H
  !2
 '(@
  &'>!
" "#6#
$  /#6%:$8%:.$81
4 ID#559$?%dH5&F8n%%DEF&(#/$D6
2KL  $'x $'D! ( ';'r6   c                     g)NOCRr1   rS   s    r3   _paddlex_pipeline_name PaddleOCR._paddlex_pipeline_name       r6   
r?   r@   r   r   r   r   r   r   rB   rC   c       
         H    U R                   R                  UUUUUUUUU	U
US9$ Nrf   )paddlex_pipelinepredictrS   inputr?   r@   r   r   r   r   r   r   rB   rC   s               r3   predict_iterPaddleOCR.predict_iter   sC     $$,,)E/%=$; 3+ 3"7"7+ - 
 	
r6   c       
         F    [        U R                  UUUUUUUUU	U
US95      $ rh   )listrm   rk   s               r3   rj   PaddleOCR.predict   sE     -I"3)A(?$7 /$7&;&; /  
 	
r6   zPlease use `predict` instead.c                 (    U R                   " U40 UD6$ r0   )rj   )rS   imgrV   s      r3   ocrPaddleOCR.ocr   s    ||C*6**r6   c                     [        5       $ r0   )PaddleOCRCLISubcommandExecutor)clss    r3   get_cli_subcommand_executor%PaddleOCR.get_cli_subcommand_executor   s    -//r6   c           
      N   0 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   _SU R                   S   =(       d    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(   S).En[        U5      $ )*NzISubPipelines.DocPreprocessor.SubModules.DocOrientationClassify.model_namer8   zHSubPipelines.DocPreprocessor.SubModules.DocOrientationClassify.model_dirr9   z?SubPipelines.DocPreprocessor.SubModules.DocUnwarping.model_namer:   z>SubPipelines.DocPreprocessor.SubModules.DocUnwarping.model_dirr;   z#SubModules.TextDetection.model_namer<   z"SubModules.TextDetection.model_dirr   z)SubModules.TextLineOrientation.model_namer=   z(SubModules.TextLineOrientation.model_dirr   z)SubModules.TextLineOrientation.batch_sizer   z%SubModules.TextRecognition.model_namer>   z$SubModules.TextRecognition.model_dirr   z%SubModules.TextRecognition.batch_sizer   z9SubPipelines.DocPreprocessor.use_doc_orientation_classifyr?   z.SubPipelines.DocPreprocessor.use_doc_unwarpingr@   use_doc_preprocessorr   z'SubModules.TextDetection.limit_side_lenr   r   r   r   r   rA   rB   rC   rD   )z#SubModules.TextDetection.limit_typezSubModules.TextDetection.threshz#SubModules.TextDetection.box_threshz%SubModules.TextDetection.unclip_ratioz$SubModules.TextDetection.input_shapez'SubModules.TextRecognition.score_threshz*SubModules.TextRecognition.return_word_boxz&SubModules.TextRecognition.input_shape)rP   r   )rS   	STRUCTUREs     r3   _get_paddlex_config_overrides'PaddleOCR._get_paddlex_config_overrides   sl   C
WY]YeYe5ZC
 WX\XdXd4Y	C
 Nt||*PC
 Mdll)OC
 24<<+4C
  1$,,*3!C
& 81:'C
, 709-C
2 81:3C
8 4T\\-69C
> 3DLL,5?C
D 4T\\-6EC
J H.JKC
P =dll#?QC
V #DLL1O$P %1||/0YC
Z '5O(P[C
\ 6t||)8]C
b 48<<@U3V/3||<M/N37<<@U3V59\\'6 59LL&5 8<||'8 ;?,,!; 7;ll&7AC
	H ,I66r6   c                 0   / SQn/ SQn/ SQn/ SQn/ SQn/ SQnUc  SnUc#  U/ SQU-   U-   U-   U-   U-   ;   a  S	nO	X;   a  S
nOgUS	:X  av  Su  pUS;   a  Sn
O]US:X  a  Sn
OTX;   a  Sn	OLX;   a  Sn	ODX;   a  Sn	O<X;   a  Sn	O4X;   a  Sn	O,US:X  a  Sn	O#US:X  a  Sn	OUS:X  a  Sn	OUS:X  a  Sn	OUS:X  a  Sn	U	b  U	 S3n
SU
4$ US:X  a  US:X  a  gUS:X  a  ggS n	X;   a  Sn	OX;   a  Sn	OX;   a  Sn	OX;   a  Sn	OX;   a  Un	S n
U	S:X  a  Sn
S!U
4$ U	b  U	 S 3n
S!U
4$ )"N)1afazbscscydadeesetfrgahrhuidisitkulaltlvmimsmtnlnoocpiplptrors_latinskslsqsvswtltruzvifrenchgermanfieugllbrmcaqu)arfaugurpsr   sdbal)rubeuk)!r   rs_cyrillicr   bgr   mnabqadykbdavadarinhchelbeleztabkkkytgmkttcvbamhrmoudmkvosbuaxaltyvsahkaa)himrnebhmaiangbhomahscknewgomsabgc)chenkoreanjapanchinese_chttekatar   )	r   r   r   r   r   thelr   r   r)   r'   )NN)r   r   r   zPP-OCRv5_server_recr   zen_PP-OCRv5_mobile_reclatineslavarabiccyrillic
devanagarir   r   r   r   r   z_PP-OCRv5_mobile_reczPP-OCRv5_server_detr(   )PP-OCRv4_mobile_detzPP-OCRv4_mobile_rec)r   zen_PP-OCRv4_mobile_reczPP-OCRv3_mobile_recz_PP-OCRv3_mobile_reczPP-OCRv3_mobile_detr1   )rS   rT   ppocr_versionLATIN_LANGSARABIC_LANGSESLAV_LANGSCYRILLIC_LANGSDEVANAGARI_LANGSSPECIFIC_LANGSrec_langrX   s              r3   rJ   PaddleOCR._get_ocr_model_names4  s   2
f I("
F
	
 <D 
    !! ###$ !+) * "J&'1$H55!6!9$"$"%#'%)'!##$,:-A!B(.88j(t|CF! H""%#'%)')#H!N4!6 ).88 %$,:-A!B(.88r6   )rP   )NNNNNNNNNNNNNNNNNNNNNNNNNN)__name__
__module____qualname____firstlineno__rR   propertyrc   rm   rj   r	   rt   classmethodry   r~   rJ   __static_attributes____classcell__)r^   s   @r3   r+   r+   7   s     -1+/!% $"&!%(,'+(,$(#'$(%)!% $  "!"!7k(Z   &*!% $  ""
B &*!% $  ""
> /0+ 1+ 0 0E7NK9 K9r6   r+   c                   0    \ rS rSr\S 5       rS rS rSrg)rw   i  c                     g)Nrt   r1   rb   s    r3   subparser_name-PaddleOCRCLISubcommandExecutor.subparser_name  re   r6   c                 x   [        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,S-S.9  UR                  S/[
        S0S9  UR                  S1[        S2S9  UR                  S3S+[        S,S4S.9  UR                  S5[        S6S9  UR                  S7[        [        S8S99  [        [        [        [
        [
        [
        [        [        [        [        [        S:.n[        R                  5        H2  u  p4X2;   d   U5       eUR                  S;U-   [        [        S<U S=3S>9  M4     g )?Nz%--doc_orientation_classify_model_namez<Name of the document image orientation classification model.)typehelpz$--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--text_detection_model_namez!Name of the text detection model.z--text_detection_model_dirz+Path to the text detection model directory.z!--textline_orientation_model_namez7Name of the text line orientation classification model.z --textline_orientation_model_dirzAPath to the text line orientation classification model directory.z!--textline_orientation_batch_sizez>Batch size for the text line orientation classification model.z--text_recognition_model_namez#Name of the text recognition model.z--text_recognition_model_dirz-Path to the text recognition model directory.z--text_recognition_batch_sizez*Batch size for the text recognition model.z--use_doc_orientation_classifyz9Whether to use document image orientation classification.z--use_doc_unwarpingz$Whether to use text image unwarping.z--use_textline_orientationz4Whether to use text line orientation classification.z--text_det_limit_side_lenzUThis sets a limit on the side length of the input image for the text detection model.z--text_det_limit_typezxThis determines how the side length limit is applied to the input image before feeding it into the text deteciton model.z--text_det_threshzDetection pixel threshold for the text detection model. Pixels with scores greater than this threshold in the output probability map are considered text pixels.z--text_det_box_threshzDetection box threshold for the text detection model. A detection result is considered a text region if the average score of all pixels within the border of the result is greater than this threshold.z--text_det_unclip_ratiozText detection expansion coefficient, which expands the text region using this method. The larger the value, the larger the expansion area.z--text_det_input_shape   )CHWz(Input shape of the text detection model.)nargsr  metavarr  z--text_rec_score_threshz^Text recognition threshold. Text results with scores greater than this threshold are retained.z--return_word_boxz<Whether to return the coordinates of the recognition result.z--text_rec_input_shapez*Input shape of the text recognition model.z--langz/Language in the input image for OCR processing.z--ocr_versionzPP-OCR version to use.)r  choicesr  r   z--z[Deprecated] Please use `--z
` instead.)actionr  r  )
r   add_argumentstrintr   floatrF   rO   rN   r   )rS   	subparserdeprecated_arg_typesr[   r]   s        r3   _update_subparser0PaddleOCRCLISubcommandExecutor._update_subparser  s   !),3O 	 	

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

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

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

 	)4 	 	

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

 	/J 	 	

 	.T 	 	

 	/Q 	 	

 	+6 	 	

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

 	+= 	 	

 	,L 	 	

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

 	(G 	 	

 	'h 	 	

 	# L 	 	

 	 t 	 	

 	# [ 	 	

 	% _ 	 	

 	$#; 	 	
 	%q 	 	

 	O 	 	

 	$#= 	 	
 	3%V 	 	
 	+)	 	 	
 !"%!"!&#(  %   
 =BBDND/55/""t-28*JG	 #  Er6   c                 $   [        U5      n[        R                  5        H]  u  p4X2;   d   eX#   nX$   nUb0  Ub-  [        R                  " SX45        [
        R                  " S5        Ub  ML  UR                  U5        M_     [        [        U5        g )Nz)`--%s` and `--%s` are mutually exclusive.r   )
r   rO   rN   r   errorsysexitpopr   r+   )rS   argsrY   r[   r]   r\   new_vals          r3   execute_with_args0PaddleOCRCLISubcommandExecutor.execute_with_args  s    $T*<BBDND>!>,C&G7#6? {

4  E 	!F3r6   r1   N)	r   r  r  r  r  r
  r  r&  r  r1   r6   r3   rw   rw     s      ^@4r6   rw   )r!  rL   
_utils.clir   r   r   r   _utils.deprecationr   r	   r
   _utils.loggingr   baser   r   utilsr   rO   rF   r+   rw   r1   r6   r3   <module>r-     s~   &    
 $ G / 03+&.212/56"  ? H9& H9Vs4%B s4r6   