paddleocr 量化模型进行进行转换不支持fake_quantize_dequantize_moving_average_abs_max

你好,请问你转换量化模型后部署的推理引擎是?在量化时请开启onnx_format=True
量化的模型是用官方给的en_PP-OCRv3_det_slim这个模型进行导出onnx模型
请问使用什么推理引擎进行部署呢?
目前是转成onnx,打算使用ncnn推理框架进行部署
模型量化的时候需要开启onnx_format=True,然后再进行转换
模型量化的时候需要开启onnx_format=True,然后再进行转换
设置onnx_format=True,是在exprt_model.py的时候,而不是模型量化的时候设置的。设置后,出现了其他问题[ERROR] Cannot read scale file: calibration_table.txt, please check if the file exist. 这个文件calibration_table.txt应该在exprt_model.py的时候产生的,但是没有生成。。
目前是不是还不支持 paddleslim的量化模型转onnx
支持转换的,请先升级到paddle==2.3.2,最新的paddleslim,然后再试一下
QAT是不支持的,PTQ Static支持的,PTQ Static可以得到onnx_format=True的量化模型和calibration_table.txt
[2022/09/21 15:17:13] ppocr INFO: train with paddle 2.3.2 and device Place(cpu)
[2022/09/21 15:17:13] ppocr INFO: Initialize indexs of datasets:['./train_data/train_list.txt']
[2022/09/21 15:17:13] ppocr INFO: Initialize indexs of datasets:['./train_data/val_list.txt']
Wed Sep 21 15:17:13-INFO: Load model and set data loader ...
Wed Sep 21 15:17:13-INFO: Collect quantized variable names ...
Preparation stage, Run batch:| | 250/?
Sampling stage, Run batch:| | 250/?
Wed Sep 21 15:20:34-INFO: Calculate hist threshold ...
Wed Sep 21 15:20:34-INFO: Update the program ...
Adding quant op with weight:|██████████████████████████████████████████| 185/185
Adding quant activation op:|███████████████████████████████████████████| 329/329
Wed Sep 21 15:20:35-INFO: The quantized model is saved in ./quant_inference_model
2022-09-21 15:20:35,046-INFO: Quantization clip ranges of tensors is save in: ./quant_inference_model/calibration_table.txt
,,但是在paddle2onnx的时候会报错:
(paddleseg_env) :~/paddleOCR/PaddleOCR$ paddle2onnx --model_dir paddleOCR/PaddleOCR/quant_inference_model/ --model_filename inference.pdmodel --params_filename inference.pdiparams --save_file ./inference_results/model.onnx --opset_version 13 --enable_onnx_checker True
[Paddle2ONNX] Start to parse PaddlePaddle model...
[Paddle2ONNX] Model file path: paddleOCR/PaddleOCR/quant_inference_model/inference.pdmodel
[Paddle2ONNX] Paramters file path: /paddleOCR/PaddleOCR/quant_inference_model/inference.pdiparams
[Paddle2ONNX] Start to parsing Paddle model...
[Paddle2ONNX] [Info] The Paddle model is a quantized model.
[Paddle2ONNX] Use opset_version = 13 for ONNX export.
[Paddle2ONNX] [Info] Quantize model deploy backend is: onnxruntime
[Paddle2ONNX] [Info] Load scale info from: paddleOCR/PaddleOCR/quant_inference_model/calibration_table.txt
[ERROR] [GetChannelWiseQuantizeInfo] Require the scale > 0, but now it's 0.000000.
Aborted (core dumped)
我用了250张图片
你的模型中有很多权重值为0的吗?是不是模型量化过程中有错呢?是不是matmul的权重都为0了
你可以先看看量化后的模型精度吗?确认一下是不是量化有问题
应该是在用PTQ Static量化时用了ch_pp-ocrv3动态图导致量化结果有问题。用ch_pp-ocrv2是可以得到onnx模型,但是inference的结果是有问题的。