PaddleDetection icon indicating copy to clipboard operation
PaddleDetection copied to clipboard

请教一个问题:量化训练后导出的模型如何部署?

Open GZHUZhao opened this issue 5 years ago • 2 comments

您好!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 avatar Apr 07 '21 12:04 GZHUZhao

@GZHUZhao

您是GPU部署、还是PaddleLite部署? 量化导出的模型还是模拟的FP32,直接使用deploy/python/infer.py是没有加速的。

如果您是PaddleLite:

  1. 导出模型后,先用PaddleLite的op工具, https://paddle-lite.readthedocs.io/zh/latest/user_guides/quant_aware.html#id4 准备PaddleLite模型。
  2. 其次再用PaddleLite预测。

如果您是GPU量化预测:

使用使用Paddle-TensorRT,develop分支有支持,需要设置precision_mode https://github.com/PaddlePaddle/PaddleDetection/blob/develop/deploy/python/trt_int8_calib.py#L239

我们后续的版本会提供完整的走通量化的示例。

qingqing01 avatar Apr 08 '21 05:04 qingqing01

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. 由于该问题超过三个月未更新,将会被关闭,若问题未解决或有后续问题,请随时重新打开(建议先拉取最新代码进行尝试),我们会继续跟进。

paddle-bot-old avatar Mar 16 '22 06:03 paddle-bot-old