§
    ³Æj<$  ã                   ó’  — d dl mZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddgZ
	 	 	 	 	 	 	 	 	 d#dededededededededededededefd„Z	 	 	 	 	 	 	 	 	 	 	 d$dededededededededededededefd„Z	 	 	 	 	 	 	 	 	 d#dededededededededededededefd „Z	 	 	 	 	 	 	 	 	 	 	 d$dededededededededededededefd!„Zd"S )%é    )ÚAnyé   )Údetection_predictor)ÚKIEPredictor)ÚOCRPredictor)Úrecognition_predictorÚocr_predictorÚkie_predictorTé   é€   FÚdet_archÚ	reco_archÚ
pretrainedÚpretrained_backboneÚassume_straight_pagesÚpreserve_aspect_ratioÚsymmetric_padÚdet_bsÚreco_bsÚdetect_orientationÚstraighten_pagesÚdetect_languageÚreturnc           
      ó~   — t          | ||||||¬¦  «        }t          ||||¬¦  «        }t          ||f||||	|
|dœ|¤ŽS ©N)r   r   Ú
batch_sizer   r   r   )r   r   r   )r   r   r   r   r   r   )r   r   r   ©r   r   r   r   r   r   r   r   r   r   r   r   ÚkwargsÚdet_predictorÚreco_predictors                  úS/var/www/html/Carbon-Document/venv/lib/python3.11/site-packages/doctr/models/zoo.pyÚ
_predictorr"      ó‘   € õ  (ØØØ/ØØ3Ø3Ø#ðñ ô €Mõ +ØØØ/Øð	ñ ô €Nõ ØØð
ð 4Ø3Ø#Ø-Ø)Ø'ð
ð 
ð ð
ð 
ð 
ó    Ú	fast_baseÚcrnn_vgg16_bnÚexport_as_straight_boxesr   c                 ó2   — t          | ||f|||||||	|
dœ|¤ŽS )a`  End-to-end OCR architecture using one model for localization, and another for text recognition.

    >>> import numpy as np
    >>> from doctr.models import ocr_predictor
    >>> model = ocr_predictor('db_resnet50', 'crnn_vgg16_bn', pretrained=True)
    >>> input_page = (255 * np.random.rand(600, 800, 3)).astype(np.uint8)
    >>> out = model([input_page])

    Args:
        det_arch: name of the detection architecture or the model itself to use
            (e.g. 'db_resnet50', 'db_mobilenet_v3_large')
        reco_arch: name of the recognition architecture or the model itself to use
            (e.g. 'crnn_vgg16_bn', 'sar_resnet31')
        pretrained: If True, returns a model pre-trained on our OCR dataset
        pretrained_backbone: If True, returns a model with a pretrained backbone
        assume_straight_pages: if True, speeds up the inference by assuming you only pass straight pages
            without rotated textual elements.
        preserve_aspect_ratio: If True, pad the input document image to preserve the aspect ratio before
            running the detection model on it.
        symmetric_pad: if True, pad the image symmetrically instead of padding at the bottom-right.
        export_as_straight_boxes: when assume_straight_pages is set to False, export final predictions
            (potentially rotated) as straight bounding boxes.
        detect_orientation: if True, the estimated general page orientation will be added to the predictions for each
            page. Doing so will slightly deteriorate the overall latency.
        straighten_pages: if True, estimates the page general orientation
            based on the segmentation map median line orientation.
            Then, rotates page before passing it again to the deep learning detection module.
            Doing so will improve performances for documents with page-uniform rotations.
        detect_language: if True, the language prediction will be added to the predictions for each
            page. Doing so will slightly deteriorate the overall latency.
        kwargs: keyword args of `OCRPredictor`

    Returns:
        OCR predictor
    ©r   r   r   r   r'   r   r   r   )r"   ©r   r   r   r   r   r   r   r'   r   r   r   r   s               r!   r	   r	   ?   sN   € õb ØØØðð 0Ø3Ø3Ø#Ø!9Ø-Ø)Ø'ðð ð ðð ð r$   c           
      ó~   — t          | ||||||¬¦  «        }t          ||||¬¦  «        }t          ||f||||	|
|dœ|¤ŽS r   )r   r   r   r   s                  r!   Ú_kie_predictorr,   €   r#   r$   c                 ó2   — t          | ||f|||||||	|
dœ|¤ŽS )a`  End-to-end KIE architecture using one model for localization, and another for text recognition.

    >>> import numpy as np
    >>> from doctr.models import ocr_predictor
    >>> model = ocr_predictor('db_resnet50', 'crnn_vgg16_bn', pretrained=True)
    >>> input_page = (255 * np.random.rand(600, 800, 3)).astype(np.uint8)
    >>> out = model([input_page])

    Args:
        det_arch: name of the detection architecture or the model itself to use
            (e.g. 'db_resnet50', 'db_mobilenet_v3_large')
        reco_arch: name of the recognition architecture or the model itself to use
            (e.g. 'crnn_vgg16_bn', 'sar_resnet31')
        pretrained: If True, returns a model pre-trained on our OCR dataset
        pretrained_backbone: If True, returns a model with a pretrained backbone
        assume_straight_pages: if True, speeds up the inference by assuming you only pass straight pages
            without rotated textual elements.
        preserve_aspect_ratio: If True, pad the input document image to preserve the aspect ratio before
            running the detection model on it.
        symmetric_pad: if True, pad the image symmetrically instead of padding at the bottom-right.
        export_as_straight_boxes: when assume_straight_pages is set to False, export final predictions
            (potentially rotated) as straight bounding boxes.
        detect_orientation: if True, the estimated general page orientation will be added to the predictions for each
            page. Doing so will slightly deteriorate the overall latency.
        straighten_pages: if True, estimates the page general orientation
            based on the segmentation map median line orientation.
            Then, rotates page before passing it again to the deep learning detection module.
            Doing so will improve performances for documents with page-uniform rotations.
        detect_language: if True, the language prediction will be added to the predictions for each
            page. Doing so will slightly deteriorate the overall latency.
        kwargs: keyword args of `OCRPredictor`

    Returns:
        KIE predictor
    r)   )r,   r*   s               r!   r
   r
   ¯   sN   € õb ØØØðð 0Ø3Ø3Ø#Ø!9Ø-Ø)Ø'ðð ð ðð ð r$   N)	TTTTr   r   FFF)r%   r&   FTTTTFFFF)Útypingr   Údetection.zoor   r
   r   Ú	predictorr   Úrecognition.zoor   Ú__all__ÚboolÚintr"   r	   r,   © r$   r!   ú<module>r6      sT  ðð Ð Ð Ð Ð Ð à .Ð .Ð .Ð .Ð .Ð .Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø #Ð #Ð #Ð #Ð #Ð #Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2à˜OÐ
,€ð !%Ø"&Ø"&ØØØØ$Ø"Ø!ð,ð ,Øð,àð,ð ð,ð ð	,ð
  ð,ð  ð,ð ð,ð ð,ð ð,ð ð,ð ð,ð ð,ð ð,ð ,ð ,ð ,ð`  Ø$ØØ $Ø"&Ø"&ØØ%*Ø$Ø"Ø!ð>ð >Øð>àð>ð ð>ð ð	>ð
  ð>ð  ð>ð ð>ð #ð>ð ð>ð ð>ð ð>ð ð>ð ð>ð >ð >ð >ðJ !%Ø"&Ø"&ØØØØ$Ø"Ø!ð,ð ,Øð,àð,ð ð,ð ð	,ð
  ð,ð  ð,ð ð,ð ð,ð ð,ð ð,ð ð,ð ð,ð ð,ð ,ð ,ð ,ð`  Ø$ØØ $Ø"&Ø"&ØØ%*Ø$Ø"Ø!ð>ð >Øð>àð>ð ð>ð ð	>ð
  ð>ð  ð>ð ð>ð #ð>ð ð>ð ð>ð ð>ð ð>ð ð>ð >ð >ð >ð >ð >r$   