PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
Apache License 2.0
39.74k stars 7.38k forks source link

用导出的微调量化模型(车牌检测和识别都一样)对测试集进行预测出现报错input_data_type:5 != filter_data_type:21. #12073

Closed stringency closed 3 weeks ago

stringency commented 1 month ago

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

stringency commented 1 month ago

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

Sunting78 commented 1 month ago

看起来是ValueError: (InvalidArgument) input and filter data type should be consistent, but received input data type is float and filter type is int8_t 显示的转下数据类型看看

stringency commented 1 month ago

看起来是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,我加入后依然一样的报错。

hellohahaw commented 1 month ago

看起来是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,我加入后依然一样的报错。

请问您是怎么处理双行车牌的识别的呢?

stringency commented 1 month ago

看起来是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,我加入后依然一样的报错。

请问您是怎么处理双行车牌的识别的呢?

我的是单行的识别

Sunting78 commented 1 month ago

显示的转下数据类型尝试一下 把输入的图像转int8

stringency commented 3 weeks ago

使用cpu版本,解决全部问题!!