
    }-jP!                        d dl mZ d dlmZ d dlmZmZ ddlmZ  G d de	e          Z
 ee
j        h          Z ee
j        e
j        e
j        e
j        h          Z ee
j        e
j        e
j        h          Zdee
e	f         d	ee
         fd
Zdee
e	f         d	efdZdee
e	f         d	efdZdee
e	f         d	efdZe G d d                      Ze G d d                      Ze G d d                      Zeeef         Zi ddddddddddddd d!d"d#d$d%d&d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4i d5d6d7d8d9d:d;d<d=d>d?d@dAdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\Zd	efd]Zd^ed	d_fd`Z d_S )a    )	dataclass)Enum)OptionalUnion   )InvalidRequestErrorc                   "    e Zd ZdZdZdZdZdZdS )ModelzPP-OCRv5zPP-StructureV3zPaddleOCR-VLzPaddleOCR-VL-1.5zPaddleOCR-VL-1.6N)__name__
__module____qualname__PP_OCRV5PP_STRUCTURE_V3PADDLE_OCR_VLPADDLE_OCR_VL_15PADDLE_OCR_VL_16     \/var/www/html/banglarbhumi/venv/lib/python3.11/site-packages/paddleocr/_api_client/models.pyr
   r
      s+        H&O"M))r   r
   modelreturnc                 r    t          | t                    r| S 	 t          |           S # t          $ r Y d S w xY wN)
isinstancer
   
ValueErrorr   s    r   _coerce_modelr   0   sL    % U||   tts   ( 
66c                 .    t          |           t          v S r   )r   _OCR_MODELSr   s    r   is_ocr_modelr    9   s    ;..r   c                 .    t          |           t          v S r   )r   _DOCUMENT_PARSING_MODELSr   s    r   is_document_parsing_modelr#   =   s    #;;;r   c                 .    t          |           t          v S r   )r   
_VL_MODELSr   s    r   is_vl_modelr&   A   s    :--r   c                       e Zd ZU dZee         ed<   dZee         ed<   dZee         ed<   dZ	ee
         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed	<   dZee         ed
<   dZee         ed<   defdZdS )
OCROptionsNuse_doc_orientation_classifyuse_doc_unwarpinguse_textline_orientationtext_det_limit_side_lentext_det_limit_typetext_det_threshtext_det_box_threshtext_det_unclip_ratiotext_rec_score_thresh	visualizer   c                      t          |           S r   _build_payloadselfs    r   
to_payloadzOCROptions.to_payloadR       d###r   )r   r   r   r)   r   bool__annotations__r*   r+   r,   intr-   strr.   floatr/   r0   r1   r2   dictr8   r   r   r   r(   r(   E   s        37 (4.777(,x~,,,/3htn333-1Xc]111)-#---'+OXe_++++/%///-18E?111-18E?111 $Ix~$$$$D $ $ $ $ $ $r   r(   c                      e Zd ZU dZee         ed<   dZee         ed<   dZee         ed<   dZ	ee         ed<   dZ
ee         ed<   dZee         ed<   dZee         ed<   dZee         ed	<   dZeeeef                  ed
<   dZee         ed<   dZeeeeef                  ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZ ee         ed<   dZ!ee         ed<   dZ"ee         ed<   dZ#ee         ed<   dZ$ee         ed<   dZ%ee         ed<   dZ&ee         ed<   defdZ'dS )PPStructureV3OptionsNr)   r*   r+   use_seal_recognitionuse_table_recognitionuse_formula_recognitionuse_chart_recognitionuse_region_detectionlayout_threshold
layout_nmslayout_unclip_ratiolayout_merge_bboxes_moder,   r-   r.   r/   r0   r1   #use_wired_table_cells_trans_to_html&use_wireless_table_cells_trans_to_htmluse_table_orientation_classify use_ocr_results_with_table_cellsuse_e2e_wired_table_rec_model use_e2e_wireless_table_rec_modelprettify_markdownshow_formula_numberr2   r   c                      t          |           S r   r4   r6   s    r   r8   zPPStructureV3Options.to_payloadt   r9   r   )(r   r   r   r)   r   r:   r;   r*   r+   rB   rC   rD   rE   rF   rG   r   r>   r?   rH   rI   listrJ   r=   r,   r<   r-   r.   r/   r0   r1   rK   rL   rM   rN   rO   rP   rQ   rR   r2   r8   r   r   r   rA   rA   V   s|        37 (4.777(,x~,,,/3htn333+/(4.///,08D>000.2Xd^222,08D>000+/(4.///59huUD[12999!%J%%%>B%tT(9":;BBB.2hsm222-1Xc]111)-#---'+OXe_++++/%///-18E?111-18E?111:>'$>>>=A*HTNAAA59"HTN9997;$htn;;;48!8D>8887;$htn;;;(,x~,,,*.$... $Ix~$$$$D $ $ $ $ $ $r   rA   c                      e Zd ZU dZee         ed<   dZee         ed<   dZee         ed<   dZ	ee         ed<   dZ
ee         ed<   dZeeeef                  ed<   dZee         ed<   dZeeeeef                  ed	<   dZeeeef                  ed
<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<   dZ ee         ed<   dZ!ee         ed<   dZ"ee         ed<   dZ#ee         ed<   defdZ$dS )PaddleOCRVLOptionsNr)   r*   use_layout_detectionrE   rB   rG   rH   rI   rJ   layout_shape_modeprompt_labelrepetition_penaltytemperaturetop_p
min_pixels
max_pixelsmax_new_tokensmerge_layout_blocksrQ   rR   restructure_pagesmerge_tablesrelevel_titlesr2   r   c                 >    t          |            t          |           S r   )_validate_vl_optionsr5   r6   s    r   r8   zPaddleOCRVLOptions.to_payload   s    T"""d###r   )%r   r   r   r)   r   r:   r;   r*   rW   rE   rB   rG   r   r>   r?   rH   rI   rT   rJ   r=   rX   rY   rZ   r[   r\   r]   r<   r^   r_   r`   rQ   rR   ra   rb   rc   r2   r8   r   r   r   rV   rV   x   s@        37 (4.777(,x~,,,+/(4.///,08D>000+/(4.///59huUD[12999!%J%%%>B%tT(9":;BBB;?huS$Y'78???'+x}+++"&L(3-&&&*....#'K%'''!E8E?!!! $J$$$ $J$$$$(NHSM(((*.$...(,x~,,,*.$...(,x~,,,#'L(4.'''%)NHTN))) $Ix~$$$$D $ $ $ $ $ $r   rV   r)   useDocOrientationClassifyr*   useDocUnwarpingr+   useTextlineOrientationr,   textDetLimitSideLenr-   textDetLimitTyper.   textDetThreshr/   textDetBoxThreshr0   textDetUnclipRatior1   textRecScoreThreshr2   rB   useSealRecognitionrC   useTableRecognitionrD   useFormulaRecognitionrE   useChartRecognitionrF   useRegionDetectionrW   useLayoutDetectionrG   layoutThresholdrH   	layoutNmsrI   layoutUnclipRatiorJ   layoutMergeBboxesModerX   layoutShapeModerY   promptLabelrZ   repetitionPenaltyr[   r\   topPr]   	minPixelsr^   	maxPixelsr_   maxNewTokensr`   mergeLayoutBlocksrQ   prettifyMarkdownrR   showFormulaNumberra   restructurePagesrb   mergeTablesrc   relevelTitlesuseWiredTableCellsTransToHtml useWirelessTableCellsTransToHtmluseTableOrientationClassifyuseOcrResultsWithTableCellsuseE2eWiredTableRecModeluseE2eWirelessTableRecModel)rK   rL   rM   rN   rO   rP   c                 x    i }t                                           D ]\  }}t          | |d           }||||<   |S r   )_FIELD_NAME_MAPitemsgetattr)optionspayload
field_nameapi_namevalues        r   r5   r5      sN    G / 5 5 7 7 & &
HT22 %GHNr   r   Nc                    | j         #d| j         cxk     rdk    sn t          d          | j        | j        dk     rt          d          | j        | j        dk    rt          d          | j        | j        dk    rt          d          | j        | j        dk    rt          d          | j        &| j        !| j        | j        k    rt          d          d S d S d S )	Nr   r   z9top_p must be greater than 0 and less than or equal to 1.z/temperature must be greater than or equal to 0.z*repetition_penalty must be greater than 0.z"min_pixels must be greater than 0.z"max_pixels must be greater than 0.z-min_pixels cannot be greater than max_pixels.)r\   r   r[   rZ   r]   r^   )r   s    r   re   re      s   } !gm*@*@*@*@q*@*@*@*@!G
 
 	
 &7+>+B+B!"STTT!-'2LPQ2Q2Q!"NOOO%'*<*A*A!"FGGG%'*<*A*A!"FGGG&*!333!"QRRR	 	'&**33r   )!dataclassesr   enumr   typingr   r   errorsr   r=   r
   	frozensetr   r   r   r   r   r   r"   r%   r   r:   r    r#   r&   r(   rA   rV   DocParsingOptionsr   r?   r5   re   r   r   r   <module>r      s   " ! ! ! ! !       " " " " " " " " ' ' ' ' ' '* * * * *C * * * i())$9	   Y 
ucz* x    /eSj) /d / / / /<U5#:%6 <4 < < < <.uUCZ( .T . . . . $ $ $ $ $ $ $ $  $ $ $ $ $ $ $ $B $ $ $ $ $ $ $ $> .0BBC )"$?)*)  8) 4	)
 -) ) -) 1) 1) ) 0) 2) 6) 2) 0)  0!)" )#) )$ +%)& .')(  7))* *+), M-). -/)0 =1)2 V3)4 +5)6 +7)8 n9): .;)< +=)> .?)@ +A)B MC)D oE) )F ,K.P&C(E%?(EQ) ) )Xt    S"4 S S S S S S Sr   