PP-OCR系列模型对比
PaddleOCR/ppocr_introduction.md at release/2.6 · PaddlePaddle/PaddleOCR · GitHub
(1)PP-OCR:两阶段的OCR系统,其中文本检测算法选用DB,文本识别算法选用CRNN,并在检测和识别模块之间添加文本方向分类器.
(2)PP-OCRv2:基于PP-OCR在5个方面重点优化,检测模型采用CML协同互学习知识蒸馏策略和CopyPaste数据增广策略;识别模型采用LCNet轻量级骨干网络、UDML 改进知识蒸馏策略和Enhanced CTC loss损失函数改进(如上图红框所示),进一步在推理速度和预测效果上取得明显提升。
(3)PP-OCRv3:基于PP-OCRv2在9个方面进行升级。
各版本模型下载地址与配置文件
PaddleOCR/models_list.md at release/2.6 · PaddlePaddle/PaddleOCR · GitHub
ch_ppocr_server_v2.0_det:
训练模型:https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_train.tar
推理模型:https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_infer.tar
ch_ppocr_mobile_v2.0_det:
训练模型:https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_train.tar
推理模型:https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar
ch_ppocr_server_v2.0_rec:
训练模型:https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_train.tar
推理模型:https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_infer.tar
ch_ppocr_mobile_v2.0_rec:
训练模型:https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_train.tar
推理模型:https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar
ch_ppocr_mobile_v2.0_cls:
https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_train.tar预训练模型:https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_train.tar
推理模型:https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar
PP-OCR推理模型使用
详见:PaddleOCR/quickstart.md at static · PaddlePaddle/PaddleOCR · GitHub
git clone https://github.com/PaddlePaddle/PaddleOCR.git
新建inference文件夹,将下载的推理模型放进来并解压:
(1)测试下det推理模型的效果:
python tools/infer/predict_det.py --image_dir doc/imgs/00111002.jpg --det_model_dir inference/ch_ppocr_server_v2.0_det_infer
结果存储在inference_results下:det_res_00111002.jpg和det_results.txt
(2)测试下cls推理模型的效果:
python tools/infer/predict_cls.py --image_dir doc/imgs_words/ch/word_4.jpg --cls_model_dir inference/ch_ppocr_mobile_v2.0_cls_infer
结果:Predicts of doc/imgs_words/ch/word_4.jpg:['0', 0.9999982]
第一个是角度,第二个是置信度
(3)测试下rec推理模型的效果:
python tools/infer/predict_rec.py --image_dir doc/imgs_words/ch/word_4.jpg --rec_model_dir inference/ch_ppocr_server_v2.0_rec_infer
ppocr INFO: Predicts of doc/imgs_words/ch/word_4.jpg:('交自活具', 0.2635100483894348)
第一个是文字结果,第二个是置信度
(4)综合起来
python tools/infer/predict_system.py --image_dir doc/imgs/00111002.jpg \
--det_model_dir inference/ch_ppocr_server_v2.0_det_infer/ \
--rec_model_dir inference/ch_ppocr_server_v2.0_rec_infer/ \
--cls_model_dir inference/ch_ppocr_mobile_v2.0_cls_infer/ \
--use_angle_cls True \
--use_space_char True
结果存储在inference_results下:00111002.jpg和system_results.txt
PP-OCRv3改进点:
PaddleOCR/PP-OCRv3_introduction.md at release/2.6 · PaddlePaddle/PaddleOCR · GitHub
PP-OCRv3检测模型训练步骤参考:
PaddleOCR/PP-OCRv3_det_train.md at release/2.6 · PaddlePaddle/PaddleOCR · GitHub