Skip to main content

A cross platform OCR Library based on OnnxRuntime.

Project description

rapidocr-web

PyPI

1. Install package by pypi.

$ pip install rapidocr-web

2. Run by command line.

  • Usage:
    $ rapidocr_web -h
    usage: rapidocr_web [-h] [-ip IP] [-p PORT] [-api]
    
    optional arguments:
    -h, --help            show this help message and exit
    -ip IP, --ip IP       IP Address
    -p PORT, --port PORT  IP port
    -api, --is_api        Whether to use the api format.
    
  • Example:
    # Web mode
    $ rapidocr_web -ip "0.0.0.0" -p 9003
    
    # API mode
    $ rapidocr_web -ip "0.0.0.0" -p 9003 -api
    

3. Use.

  • Web mode: Open http://localhost:9003/ to view, enjoy it.
  • API mode:
    import ast
    import base64
    import json
    
    import requests
    
    
    def get_json_format(img_path):
        with open(img_path, 'rb') as f:
            img_byte = base64.b64encode(f.read())
        img_json = json.dumps({'file': img_byte.decode('ascii')})
        return img_json
    
    
    if __name__ == '__main__':
        url = 'http://localhost:9003/ocr'
        header = {'Content-Type': 'application/json; charset=UTF-8'}
    
        img_path = '1.jpg'
        img_json = get_json_format(img_path)
    
        response = requests.post(url, data=img_json, headers=header)
        if response.status_code == 200:
            rec_res = ast.literal_eval(response.text)
            print(rec_res)
        else:
            print(response.status_code)
    

See details for RapidOCR.

Project details


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

rapidocr_web-0.0.1-py3-none-any.whl (41.4 kB view hashes)

Uploaded Python 3

Supported by

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