| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
English | 简体中文
Though PaddleOCR provides support for TensorRT, it is difficult to decouple. This project provides simple code and demonstrates how to use the TensorRT C++ API and ONNX to deploy PaddleOCR text recognition model.
Details can be found in the PaddleOCR official document.
Doc-Text Recognition Model Inference
The model used in this tutorial are ch_PP-OCRv2_rec and ch_PP-OCRv3_rec from PaddleOCR model list. Download the corresponding inference model and convert it to ONNX model.
# TODO: Specify the path to TensorRT root dir
set(TensorRT_DIR "/usr/yyx/tensorrt/TensorRT/")// TODO: Specify your precision here.
options.FP16 = false;
// TODO: Specify your input dimension here.
options.inputDimension = {3,48,320}; // Modify to {3,32,320} when using ppocrv2
// TODO: Specify your character_dict here.
std::string label_path = "../data/ppocr_keys_v1.txt";
// TODO: Specify your test image here.
const std::string inputImage = "../data/word_2.png";
// TODO: Specify your model here.
const std::string onnxModelpath = "../data/modelv3.onnx"; // Modify to "../data/modelv2.onnx" when using ppocrv2mkdir build
cd build
cmake ..
make
./demoThe result of ch_PP-OCRv2_rec ONNX model on data/word_2.png:
yourself score: 0.95626300573349
The result of ch_PP-OCRv2_rec using tools/infer_rec.py in PaddleOCR on data/word_2.png:
{"Student": {"label": "yourself", "score": 0.9562630653381348}
"Teacher": {"label": "yourself", "score": 0.9850824475288391}}
The result of ch_PP-OCRv3_rec ONNX model on data/word_2.png:
yourself score: 0.9922693371772766
The result of ch_PP-OCRv3_rec using tools/infer_rec.py in PaddleOCR on data/word_2.png:
{"Student": {"label": "yourself", "score": 0.9922693371772766}
"Teacher": {"label": "yourself", "score": 0.9903509020805359}}
tensorrt-cpp-api for creating a easy-to-use TensorRT C++ API Tutorial.
PaddleOCRv2_TensorRT for creating some C++ implemention of PaddleOCR preprocess and postprocess method.
PaddleOCR for creating awesome and practical OCR tools that help users train better models and apply them into practice.
| Back | FazBrowse Home | New Git URL |