Skip to main content

A cross platform OCR Library based on OnnxRuntime.

Project description

rapidocr-onnxruntime Package

1. Install package by pypi.

$ pip install rapidocr-onnxruntime

2. Use.

  • Run by script.

    import cv2
    from rapidocr_onnxruntime import RapidOCR
    
    rapid_ocr = RapidOCR()
    
    img_path = 'tests/test_files/ch_en_num.jpg'
    
    # Support:Union[str, np.ndarray, bytes, Path]
    # str
    result, elapse = rapid_ocr(img_path)
    
    # np.ndarray
    img = cv2.imread('tests/test_files/ch_en_num.jpg')
    result, elapse = rapid_ocr(img)
    
    # bytes
    with open(img_path, 'rb') as f:
        result, elapse = rapid_ocr(f.read())
    
    # Path
    result, elapse = rapid_ocr(Path(img_path))
    print(result)
    
    # result: [[dt_boxes], txt, score]
    # e.g.:[[left-top, right-top, right-down, left-top], '小明', '0.99']
    
    # elapse: [det_elapse, cls_elapse, rec_elapse]
    # all_elapse = det_elapse + cls_elapse + rec_elapse
    
    # If without valid texts, result: (None, None )
    
  • Run by command line.

    $ rapidocr_onnxruntime -h
      usage: rapidocr_onnxruntime [-h] -img IMG_PATH [-p] [--text_score TEXT_SCORE]
                                  [--use_angle_cls USE_ANGLE_CLS]
                                  [--use_text_det USE_TEXT_DET]
                                  [--print_verbose PRINT_VERBOSE]
                                  [--min_height MIN_HEIGHT]
                                  [--width_height_ratio WIDTH_HEIGHT_RATIO]
                                  [--det_model_path DET_MODEL_PATH]
                                  [--det_limit_side_len DET_LIMIT_SIDE_LEN]
                                  [--det_limit_type {max,min}]
                                  [--det_thresh DET_THRESH]
                                  [--det_box_thresh DET_BOX_THRESH]
                                  [--det_unclip_ratio DET_UNCLIP_RATIO]
                                  [--det_use_dilation DET_USE_DILATION]
                                  [--det_score_mode {slow,fast}]
                                  [--cls_model_path CLS_MODEL_PATH]
                                  [--cls_image_shape CLS_IMAGE_SHAPE]
                                  [--cls_label_list CLS_LABEL_LIST]
                                  [--cls_batch_num CLS_BATCH_NUM]
                                  [--cls_thresh CLS_THRESH]
                                  [--rec_model_path REC_MODEL_PATH]
                                  [--rec_image_shape REC_IMAGE_SHAPE]
                                  [--rec_batch_num REC_BATCH_NUM]
    
      optional arguments:
      -h, --help            show this help message and exit
      -img IMG_PATH, --img_path IMG_PATH MUST
      -p, --print_cost
    
      Global:
      --text_score TEXT_SCORE
      --use_angle_cls USE_ANGLE_CLS
      --use_text_det USE_TEXT_DET
      --print_verbose PRINT_VERBOSE
      --min_height MIN_HEIGHT
      --width_height_ratio WIDTH_HEIGHT_RATIO
    
      Det:
      --det_model_path DET_MODEL_PATH
      --det_limit_side_len DET_LIMIT_SIDE_LEN
      --det_limit_type {max,min}
      --det_thresh DET_THRESH
      --det_box_thresh DET_BOX_THRESH
      --det_unclip_ratio DET_UNCLIP_RATIO
      --det_use_dilation DET_USE_DILATION
      --det_score_mode {slow,fast}
    
      Cls:
      --cls_model_path CLS_MODEL_PATH
      --cls_image_shape CLS_IMAGE_SHAPE
      --cls_label_list CLS_LABEL_LIST
      --cls_batch_num CLS_BATCH_NUM
      --cls_thresh CLS_THRESH
    
      Rec:
      --rec_model_path REC_MODEL_PATH
      --rec_image_shape REC_IMAGE_SHAPE
      --rec_batch_num REC_BATCH_NUM
    
    $ rapidocr_onnxruntime -img tests/test_files/ch_en_num.jpg
    

Project details


Release history Release notifications | RSS feed

This version

1.2.5

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rapidocr_onnxruntime-1.2.5-py3-none-any.whl (12.3 MB view details)

Uploaded Python 3

File details

Details for the file rapidocr_onnxruntime-1.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for rapidocr_onnxruntime-1.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 769cf3188b53f9db6b98074995fe209d622cec258b924f4981610e11e75f358e
MD5 929b5399d4fe0d1e601b4d6b310661cc
BLAKE2b-256 2c49b03f34323f0706adb812f12ad1b5a5524ef8cd5a9a33f42f5e26071663b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page