PaddleOCR
PaddleOCR copied to clipboard
用导出的微调量化模型(车牌检测和识别都一样)对测试集进行预测出现报错input_data_type:5 != filter_data_type:21.
请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem
-
系统环境/System Environment:3.10.4
-
版本号/Version:Paddle:2.6.1 PaddleOCR: 问题相关组件/Related components:tools/infer/predict_system.py
-
运行指令/Command Code:python tools/infer/predict_system.py --det_model_dir=output/CCPD/det_quant/infer --rec_model_dir=output/CCPD/rec_quant/infer --det_limit_side_len=736 --det_limit_type=min --image_dir=F:/DataSet/CCPD2020/ccpd_green/test/ --draw_img_save_dir=infer/quant --use_dilation=true
-
完整报错/Complete Error Message:
-
(base) (venv) PS F:\GithubProject\PaddleOCR> python tools/infer/predict_system.py --det_model_dir=output/CCPD/det_quant/infer --rec_model_dir=output/CCPD/rec_quant/infer --det_limit_side_len=736 --det_limit_type=min --image_dir=F:/DataSet/CCPD2020/ccpd_green/test/ --draw_img_save_dir=infer/quant --use_dilation=true [2024/05/08 10:27:31] ppocr INFO: In PP-OCRv3, rec_image_shape parameter defaults to '3, 48, 320', if you are using recognition model with PP-OCRv2 or an older version, please set --rec_image_shape='3,32,320 Traceback (most recent call last): File "F:\GithubProject\PaddleOCR\tools\infer\predict_system.py", line 295, in
main(args) File "F:\GithubProject\PaddleOCR\tools\infer\predict_system.py", line 196, in main dt_boxes, rec_res, time_dict = text_sys(img) File "F:\GithubProject\PaddleOCR\tools\infer\predict_system.py", line 83, in call dt_boxes, elapse = self.text_detector(img) File "F:\GithubProject\PaddleOCR\tools\infer\predict_det.py", line 379, in call dt_boxes, elapse = self.predict(img) File "F:\GithubProject\PaddleOCR\tools\infer\predict_det.py", line 240, in predict self.predictor.run() ValueError: (InvalidArgument) input and filter data type should be consistent, but received input data type is float and filter type is int8_t [Hint: Expected input_data_type == filter_data_type, but received input_data_type:5 != filter_data_type:21.] (at ..\paddle\fluid\operators\generator\get_expected_kernel_func.cc:431) [operator < conv2d > error]
CCPD车牌检测数据集fine-tune+量化训练: python deploy/slim/quantization/quant.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml -o Global.pretrained_model=output/CCPD/det/best_accuracy.pdparams Global.save_model_dir=output/CCPD/det_quant Global.eval_batch_step="[0, 772]" Optimizer.lr.name=Const Optimizer.lr.learning_rate=0.0005 Optimizer.lr.warmup_epoch=0 Train.dataset.data_dir=F:/DataSet/CCPD2020/ccpd_green Train.dataset.label_file_list=[F:/DataSet/CCPD2020/PPOCR/train/det.txt] Eval.dataset.data_dir=F:/DataSet/CCPD2020/ccpd_green Eval.dataset.label_file_list=[F:/DataSet/CCPD2020/PPOCR/test/det.txt]
检测量化模型导出: python deploy/slim/quantization/export_model.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml -o Global.pretrained_model=output/CCPD/det_quant/best_accuracy.pdparams Global.save_inference_dir=output/CCPD/det_quant/infer Eval.dataset.data_dir=F:/DataSet/CCPD2020/ccpd_green Eval.dataset.label_file_list=[F:/DataSet/CCPD2020/PPOCR/test/det.txt] Eval.loader.num_workers=0
CCPD车牌识别数据集fine-tune+量化训练: python deploy/slim/quantization/quant.py -c configs/rec/PP-OCRv3/ch_PP-OCRv3_rec.yml -o Global.pretrained_model=output/CCPD/rec/best_accuracy.pdparams Global.save_model_dir=output/CCPD/rec_quant/ Global.eval_batch_step="[0, 90]" Optimizer.lr.name=Const Optimizer.lr.learning_rate=0.0005 Optimizer.lr.warmup_epoch=0 Train.dataset.data_dir=F:/DataSet/CCPD2020/PPOCR Train.dataset.label_file_list=[F:/DataSet/CCPD2020/PPOCR/train/rec.txt] Eval.dataset.data_dir=F:/DataSet/CCPD2020/PPOCR Eval.dataset.label_file_list=[F:/DataSet/CCPD2020/PPOCR/test/rec.txt] Train.loader.batch_size_per_card=64
识别量化模型导出: python deploy/slim/quantization/export_model.py -c configs/rec/PP-OCRv3/ch_PP-OCRv3_rec.yml -o Global.pretrained_model=output/CCPD/rec_quant/best_accuracy.pdparams Global.save_inference_dir=output/CCPD/rec_quant/infer Eval.dataset.data_dir=F:/DataSet/CCPD2020/PPOCR Eval.dataset.label_file_list=[F:/DataSet/CCPD2020/PPOCR/test/rec.txt]
用导出的量化模型对测试集进行预测: python tools/infer/predict_system.py --det_model_dir=output/CCPD/det_quant/infer --rec_model_dir=output/CCPD/rec_quant/infer --det_limit_side_len=736 --det_limit_type=min --image_dir=F:/DataSet/CCPD2020/ccpd_green/test/ --draw_img_save_dir=infer/quant --use_dilation=true
看起来是ValueError: (InvalidArgument) input and filter data type should be consistent, but received input data type is float and filter type is int8_t 显示的转下数据类型看看
看起来是ValueError: (InvalidArgument) input and filter data type should be consistent, but received input data type is float and filter type is int8_t 显示的转下数据类型看看
请问:deploy/slim/quantization/README.md 里面说:“备注:量化训练后的模型参数是float32类型,转inference model预测时相对不量化无加速效果,原因是量化后模型结构之间存在量化和反量化算子,如果要使用量化模型部署,建议使用TensorRT并设置precision为INT8加速量化模型的预测时间。”那我应该在命令后面加入参数--use_tensorrt=USE_TENSORRT --precision=INT8,我加入后依然一样的报错。
看起来是ValueError: (InvalidArgument) input and filter data type should be consistent, but received input data type is float and filter type is int8_t 显示的转下数据类型看看
请问:deploy/slim/quantization/README.md 里面说:“备注:量化训练后的模型参数是float32类型,转inference model预测时相对不量化无加速效果,原因是量化后模型结构之间存在量化和反量化算子,如果要使用量化模型部署,建议使用TensorRT并设置precision为INT8加速量化模型的预测时间。”那我应该在命令后面加入参数--use_tensorrt=USE_TENSORRT --precision=INT8,我加入后依然一样的报错。
请问您是怎么处理双行车牌的识别的呢?
看起来是ValueError: (InvalidArgument) input and filter data type should be consistent, but received input data type is float and filter type is int8_t 显示的转下数据类型看看
请问:deploy/slim/quantization/README.md 里面说:“备注:量化训练后的模型参数是float32类型,转inference model预测时相对不量化无加速效果,原因是量化后模型结构之间存在量化和反量化算子,如果要使用量化模型部署,建议使用TensorRT并设置precision为INT8加速量化模型的预测时间。”那我应该在命令后面加入参数--use_tensorrt=USE_TENSORRT --precision=INT8,我加入后依然一样的报错。
请问您是怎么处理双行车牌的识别的呢?
我的是单行的识别
显示的转下数据类型尝试一下 把输入的图像转int8
使用cpu版本,解决全部问题!!