Skip to content

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

License

Notifications You must be signed in to change notification settings

nazarovsky/PaddleOCR-rec-ONNX-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages