imgocr

6.7K downloads 9 likes on ModelScope updated

Model card

这里用来托管从PaddleOCR项目转换而来的ONNX模型,涵盖PPOCR-v4/PPOCR-v5的mobile和serve版本的模型。

建议pip install imgocr -U 来加载PPOCR-v4-onnx/ppocr-v5-onnx模型.

Usage

import time
import sys

sys.path.append('..')
from imgocr import ImgOcr
from imgocr import drwa_ocr_boxes

if __name__ == "__main__":
    m = ImgOcr(use_gpu=False, is_efficiency_mode=True)
    img_path = "sample_img.jpg"
    s = time.time()
    result = m.ocr(img_path)
    e = time.time()
    print("total time: {:.4f} s".format(e - s))
    print("result:", result)
    for line in result:
        print(line.get('text'))

    # draw boxes
    drwa_ocr_boxes(img_path, result, '11_box.jpg')
    print('Save result to 11_box.jpg')

is_efficiency_mode: 是否使用高效率模型,默认True,使用高效率模型(mobile,14MB),速度更快,精度稍低。如果需要更高精度,设置为False,使用高精度模型(server,207MB)。

sample_img:

output: