self.ocr = PaddleOCR(
use_angle_cls=True,
use_space_char=True,
use_gpu=True,
use_tensorrt=True,
precision='fp32', #根据需要改fp16或fp32
det_model_dir='models/ocr/ch_PP-OCRv4_det_infer/',
rec_model_dir='models/ocr/ch_PP-OCRv4_rec_infer/',
cls_model_dir='models/ocr/ch_ppocr_mobile_v2.0_cls_infer/',
shape_info_filename="shape.txt",
thread_num=8#线程数
)
注意事项:
报错:ppocr INFO: when using tensorrt, dynamic shape is a suggested option, you can use ‘–shape_info_filename=shape.txt’ for offline dygnamic shape tuning,
–shape_info_filename=“shape.txt”,首次运行:程序会分析输入图像的尺寸范围,并生成shape.txt文件。后续运行:直接复用该文件,避免重复优化。但是,在执行新的进程时一定要删除shape.txt文件再运行否则会报错。
误区:使用tensorrt就一定要用到engine文件×,这里的文件地址输入是’models/ocr/ch_PP-OCRv4_det_infer/',不需要我们自己转换。