sunjunlishi / PaddleOCR-rec-ONNX-demo

Simple demo for converting PaddleOCR text recognizer model to ONNX and ONNX inference

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PaddleOCR-rec-ONNX-demo

Simple demo for converting PaddleOCR text recognizer model to ONNX and ONNX inference

This simple demo shows how to export trained PaddleOCR recognizer model to ONNX and make inference

To export ONNX model add following lines after model.eval() in the tools\export_model.py in PaddleOCR repo

    model.eval()
###
    if config['Architecture']['model_type'] == "rec":
        input_spec = paddle.static.InputSpec(shape=[1, 3, 48, 96], dtype='float32', name='image')
        paddle.onnx.export(model, os.path.join(config['Global']['save_inference_dir'],'rec_db'), input_spec=[input_spec], opset_version=10, enable_onnx_checker=True)
###

NB Not all of the recognition models can be converted to ONNX (e.g. STARNet), because of the specific ops in Paddle which are missing from ONNX.

and run

python3 tools/export_model.py -c configs/rec/your_rec_config.yml -o Global.pretrained_model=output/rec_mv3/best_accuracy  Global.save_inference_dir=output/rec_db/ Global.load_static_weights=false 

To test ONNX inference

python3 demo_razmetka.py

Examples

1

2

About

Simple demo for converting PaddleOCR text recognizer model to ONNX and ONNX inference

License:Apache License 2.0


Languages

Language:Python 100.0%