fzhiheng / paddleOCR_cpp_tensorrt

The version of cpp tensorrt for paddleOCR.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

paddOCR_cpp_tensorrt

environment

cuda 10.2
cudnn 8.2.1
tentorrt 8.2.1

build

mkdir build && cd build
cmake .. -DTensorRT_DIR=/usr/local/tensorrt -DOpenCV_DIR=/usr/local -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda 

run

build engine from onnx and inference (you only have onnx files)

./build/ocr --build_precision="fp16" 
--det_onnx_dir="../myModels/det.onnx" 
--rec_onnx_ dir="../myModels/ch_rec_v3.onnx"
--save_engine_dir="../myEngines/"
--rec_char_dict_path="../myModels/dict_txt/ppocr_keys_v1.txt"
--rec_batch_num=1
--det=true --cls=false --rec=true  
--image_dir="../testImgs/11.jpg" --output="./output/"

It will build a engine from your onnx file. In this example above, you will get a engine named det_fp16.engine in ../myEngines/. The detection and recognize results are in ./output/. The rec_batch_num should be $\leq$ 8. If you want bigger batch size, please modify the MAX_DIMS_ in ./src/rec.h.

load engine and inference (you already have engines)

./build/ocr 
--det_engine_dir="../myEngines/det_fp16.engine"
--rec_engine_dir="../myEngines/ch_rec_v3_fp16.engine"
--rec_char_dict_path="../myModels/dict_txt/ppocr_keys_v1.txt"
--rec_batch_num=1
--det=true --cls=false --rec=true 
--image_dir="../testImgs/11.jpg" --output="./output/"

About

The version of cpp tensorrt for paddleOCR.

License:Apache License 2.0


Languages

Language:C++ 97.9%Language:CMake 1.8%Language:C 0.4%