
    }-jMF                     r    d dl mZmZmZmZ ddlmZmZ ddlm	Z	  G d de          Z
 G d de          Zd	S )
   )add_simple_inference_argsget_subcommand_argsperform_simple_inferencestr2bool   )PaddleXPipelineWrapperPipelineCLISubcommandExecutor)create_config_from_structurec                        e Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fd	Zed             ZddddddddddddddddddddZddddddddddddddddddddZed	             Z	d
 Z
 xZS )TableRecognitionPipelineV2Nc                      t                                                      }!|!                    d           |!                    d           |!| _         t	                      j        di |  d S )Nselfkwargs )localscopypop_paramssuper__init__)#r   layout_detection_model_namelayout_detection_model_dirtable_classification_model_nametable_classification_model_dir,wired_table_structure_recognition_model_name+wired_table_structure_recognition_model_dir/wireless_table_structure_recognition_model_name.wireless_table_structure_recognition_model_dir&wired_table_cells_detection_model_name%wired_table_cells_detection_model_dir)wireless_table_cells_detection_model_name(wireless_table_cells_detection_model_dir#doc_orientation_classify_model_name"doc_orientation_classify_model_dirdoc_unwarping_model_namedoc_unwarping_model_dirtext_detection_model_name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_nametext_recognition_model_dirtext_recognition_batch_sizetext_rec_score_threshuse_doc_orientation_classifyuse_doc_unwarpinguse_layout_detectionuse_ocr_modelr   params	__class__s#                                     i/var/www/html/banglarbhumi/venv/lib/python3.11/site-packages/paddleocr/_pipelines/table_recognition_v2.pyr   z#TableRecognitionPipelineV2.__init__   se    F 

6

8""6"""""    c                     dS Ntable_recognition_v2r   r   s    r8   _paddlex_pipeline_namez1TableRecognitionPipelineV2._paddlex_pipeline_nameD       %%r9   FT)r2   r3   r4   r5   overall_ocr_reslayout_det_resr)   r*   r+   r,   r-   r1   use_e2e_wired_table_rec_model use_e2e_wireless_table_rec_model#use_wired_table_cells_trans_to_html&use_wireless_table_cells_trans_to_htmluse_table_orientation_classify use_ocr_results_with_table_cellsc                     | j         j        |fi d|d|d|d|d|d|d|d|	d	|
d
|d|d|d|d|d|d|d|d||S Nr2   r3   r4   r5   r@   rA   r)   r*   r+   r,   r-   r1   rB   rC   rD   rE   rF   rG   )paddlex_pipelinepredictr   inputr2   r3   r4   r5   r@   rA   r)   r*   r+   r,   r-   r1   rB   rC   rD   rE   rF   rG   r   s                        r8   predict_iterz'TableRecognitionPipelineV2.predict_iterH   s   0 -t$,
 
 
)E)E
 0/
 "6!5	

 (-
 ,O
 *>
 %<$;
 !4 3
 ,O
 !4 3
 #8"7
 #8"7
 +H*G
 .N-M
  1T0S!
" 4Z3Y#
$ ,J+I%
& .N-M)
 
 	
r9   c                    t           | j        |fi d|d|d|d|d|d|d|d|	d	|
d
|d|d|d|d|d|d|d|d||          S rI   )listrN   rL   s                        r8   rK   z"TableRecognitionPipelineV2.predictw   s#   0 D  -I-I #4"3 &:%9	
 ,m !0  .~ )@(? %8$7 !0 %8$7 '<&; '<&; /L.K 2R1Q  5X4W!" 8^7]#$ 0N/M%& 2R1Q) 
 
 	
r9   c                     t                      S N)/TableRecognitionPipelineV2CLISubcommandExecutor)clss    r8   get_cli_subcommand_executorz6TableRecognitionPipelineV2.get_cli_subcommand_executor   s    >@@@r9   c                    i d| j         d         d| j         d         d| j         d         p| j         d         d| j         d         d| j         d         d| j         d	         d
| j         d         d| j         d         d| j         d         d| j         d         d| j         d         d| j         d         d| j         d         d| j         d         d| j         d         d| j         d         d| j         d         | j         d          | j         d!         | j         d"         | j         d#         | j         d$         | j         d%         | j         d&         | j         d'         | j         d(         | j         d)         | j         d*         | j         d+         | j         d,         | j         d-         | j         d.         d/}t          |          S )0Nz9SubPipelines.DocPreprocessor.use_doc_orientation_classifyr2   z.SubPipelines.DocPreprocessor.use_doc_unwarpingr3   use_doc_preprocessorr4   r5   z%SubModules.LayoutDetection.model_namer   z$SubModules.LayoutDetection.model_dirr   z)SubModules.TableClassification.model_namer   z(SubModules.TableClassification.model_dirr   z4SubModules.WiredTableStructureRecognition.model_namer   z3SubModules.WiredTableStructureRecognition.model_dirr   z7SubModules.WirelessTableStructureRecognition.model_namer   z6SubModules.WirelessTableStructureRecognition.model_dirr   z.SubModules.WiredTableCellsDetection.model_namer   z-SubModules.WiredTableCellsDetection.model_dirr    z1SubModules.WirelessTableCellsDetection.model_namer!   z0SubModules.WirelessTableCellsDetection.model_dirr"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   )zISubPipelines.DocPreprocessor.SubModules.DocOrientationClassify.model_namezHSubPipelines.DocPreprocessor.SubModules.DocOrientationClassify.model_dirz?SubPipelines.DocPreprocessor.SubModules.DocUnwarping.model_namez>SubPipelines.DocPreprocessor.SubModules.DocUnwarping.model_dirz;SubPipelines.GeneralOCR.SubModules.TextDetection.model_namez:SubPipelines.GeneralOCR.SubModules.TextDetection.model_dirz?SubPipelines.GeneralOCR.SubModules.TextDetection.limit_side_lenz;SubPipelines.GeneralOCR.SubModules.TextDetection.limit_typez7SubPipelines.GeneralOCR.SubModules.TextDetection.threshz;SubPipelines.GeneralOCR.SubModules.TextDetection.box_threshz=SubPipelines.GeneralOCR.SubModules.TextDetection.unclip_ratioz=SubPipelines.GeneralOCR.SubModules.TextRecognition.model_namez<SubPipelines.GeneralOCR.SubModules.TextRecognition.model_dirz=SubPipelines.GeneralOCR.SubModules.TextRecognition.batch_sizez?SubPipelines.GeneralOCR.SubModules.TextRecognition.score_thresh)r   r
   )r   	STRUCTUREs     r8   _get_paddlex_config_overridesz8TableRecognitionPipelineV2._get_paddlex_config_overrides   s   \
G.J\
 =dl#?	\
 #DL1O$P %1|/0\
 #DL1G$H\
 T\/:\
 4T\-6\
 3DL,5\
" 81:#\
( 709)\
. CDL>E/\
4 B4<=D5\
: Ft|AH;\
@ Edl@GA\
F =dl8?G\
L <T\7>M\
R @;BS\
X ?:AY\
^ Z^Ye5Z Y]Xd4Y PT|*P OSl)O LP<+L KO,*K PT|)P LP<%L HL|!H LP<%L NR\'N NR\-N MQL,M NR\-N PT|'Ps\
 \
 \
	z ,I666r9   )NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN)__name__
__module____qualname__r   propertyr>   rN   rK   classmethodrU   rY   __classcell__)r7   s   @r8   r   r      s        %)#'(,'+59488<7;/3.22615,0+/!% $"&!% $  "$(#'$("%)!A(# (# (# (# (# (#T & & X& &*! $  ""&+).,1/4'+)-+-
 -
 -
 -
 -
f &*! $  ""&+).,1/4'+)-+/
 /
 /
 /
 /
b A A [A^7 ^7 ^7 ^7 ^7 ^7 ^7r9   r   c                   0    e Zd Zed             Zd Zd ZdS )rS   c                     dS r;   r   r=   s    r8   subparser_namez>TableRecognitionPipelineV2CLISubcommandExecutor.subparser_name  r?   r9   c                 *   t          |           |                    dt          d           |                    dt          d           |                    dt          d           |                    dt          d	           |                    d
t          d           |                    dt          d           |                    dt          d           |                    dt          d           |                    dt          d           |                    dt          d           |                    dt          d           |                    dt          d           |                    dt          d           |                    dt          d           |                    dt          d           |                    dt          d            |                    d!t          d"           |                    d#t          d$           |                    d%t          d&           |                    d't          d(           |                    d)t          d*           |                    d+t          d,           |                    d-t          d.           |                    d/t          d0           |                    d1t          d2           |                    d3t          d4           |                    d5t          d6           |                    d7t
          d8           |                    d9t
          d:           |                    d;t
          d<           |                    d=t
          d>           d S )?Nz--layout_detection_model_namez#Name of the layout detection model.)typehelpz--layout_detection_model_dirz-Path to the layout detection model directory.z!--table_classification_model_namez'Name of the table classification model.z --table_classification_model_dirz1Path to the table classification model directory.z.--wired_table_structure_recognition_model_namez4Name of the wired table structure recognition model.z---wired_table_structure_recognition_model_dirz>Path to the wired table structure recognition model directory.z1--wireless_table_structure_recognition_model_namez7Name of the wireless table structure recognition model.z0--wireless_table_structure_recognition_model_dirz(--wired_table_cells_detection_model_namez.Name of the wired table cells detection model.z'--wired_table_cells_detection_model_dirz8Path to the wired table cells detection model directory.z+--wireless_table_cells_detection_model_namez1Name of the wireless table cells detection model.z*--wireless_table_cells_detection_model_dirz;Path to the wireless table cells detection model directory.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--text_detection_model_namez!Name of the text detection model.z--text_detection_model_dirz+Path to the text detection model directory.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_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--text_rec_score_threshzrText recognition threshold used in general OCR. Text results with scores greater than this threshold are retained.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_ocr_modelzWhether to use OCR models.)r   add_argumentstrintfloatr   )r   	subparsers     r8   _update_subparserzATableRecognitionPipelineV2CLISubcommandExecutor._update_subparser  s   !),,,+6 	 	
 	
 	

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

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

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

 	<G 	 	
 	
 	

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

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

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

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

 	5K 	 	
 	
 	

 	9D 	 	
 	
 	

 	8N 	 	
 	
 	
 	3O 	 	
 	
 	

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

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

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

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

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

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

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

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

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

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

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

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

 	% F 	 	
 	
 	
 	,L 	 	
 	
 	

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

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

 	- 	 	
 	
 	
 	
 	
r9   c                 N    t          |          }t          t          |           d S rR   )r   r   r   )r   argsr6   s      r8   execute_with_argszATableRecognitionPipelineV2CLISubcommandExecutor.execute_with_args  s&    $T** !;VDDDDDr9   N)rZ   r[   r\   r]   rb   rk   rn   r   r9   r8   rS   rS     sT        & & X&`
 `
 `
DE E E E Er9   rS   N)
_utils.clir   r   r   r   baser   r	   utilsr
   r   rS   r   r9   r8   <module>rr      s               H G G G G G G G / / / / / /q7 q7 q7 q7 q7!7 q7 q7 q7hiE iE iE iE iE6S iE iE iE iE iEr9   