请教一个问题:量化训练后导出的模型如何部署?
您好!slim/quantization下的文档说到有以下两种预测方式:
预测
python预测
python slim/quantization/infer.py --not_quant_pattern yolo_output \
-c ./configs/yolov3_mobilenet_v1.yml \
--infer_dir ./demo \
-o weights=./output/mobilenetv1/yolov3_mobilenet_v1/best_model
PaddleLite预测
导出模型步骤中导出的FP32模型可使用PaddleLite进行加载预测,可参见教程Paddle-Lite如何加载运行量化模型
问题: 使用slim/quantization/export_model导出的模型如何使用deploy/python/infer.py进行部署? 我用tools/export_model.py对量化训练保存的best_model进行导出后,使用deploy/python/infer.py进行部署,速度和没有量化的一样?
@GZHUZhao
您是GPU部署、还是PaddleLite部署? 量化导出的模型还是模拟的FP32,直接使用deploy/python/infer.py是没有加速的。
如果您是PaddleLite:
- 导出模型后,先用PaddleLite的op工具, https://paddle-lite.readthedocs.io/zh/latest/user_guides/quant_aware.html#id4 准备PaddleLite模型。
- 其次再用PaddleLite预测。
如果您是GPU量化预测:
使用使用Paddle-TensorRT,develop分支有支持,需要设置precision_mode https://github.com/PaddlePaddle/PaddleDetection/blob/develop/deploy/python/trt_int8_calib.py#L239
我们后续的版本会提供完整的走通量化的示例。
Since this issue has not been updated for more than three months, it will be closed, if it is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up. It is recommended to pull and try the latest code first. 由于该问题超过三个月未更新,将会被关闭,若问题未解决或有后续问题,请随时重新打开(建议先拉取最新代码进行尝试),我们会继续跟进。