[Bug Fix] Fix bugs when deploy quantized YOLOv5/v6/v7 model. (#729)

* Improve the usage of fastdeploy tools

* Fix quantized YOLOv5,v6 and v7 model deployment
This commit is contained in:
yunyaoXYY
2022-11-28 19:19:37 +08:00
committed by GitHub
parent 941057888a
commit dc2dad62a4
14 changed files with 12 additions and 32 deletions

View File

@@ -28,7 +28,7 @@ tar -xvf yolov5s_quant.tar
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
# 在CPU上使用Paddle-Inference推理量化模型 # 在CPU上使用ONNX Runtime推理量化模型
./infer_demo yolov5s_quant 000000014439.jpg 0 ./infer_demo yolov5s_quant 000000014439.jpg 0
# 在GPU上使用TensorRT推理量化模型 # 在GPU上使用TensorRT推理量化模型
./infer_demo yolov5s_quant 000000014439.jpg 1 ./infer_demo yolov5s_quant 000000014439.jpg 1

View File

@@ -64,7 +64,7 @@ int main(int argc, char* argv[]) {
if (flag == 0) { if (flag == 0) {
option.UseCpu(); option.UseCpu();
option.UsePaddleBackend(); option.UseOrtBackend();
} else if (flag == 1) { } else if (flag == 1) {
option.UseGpu(); option.UseGpu();
option.UseTrtBackend(); option.UseTrtBackend();

View File

@@ -22,8 +22,8 @@ wget https://bj.bcebos.com/paddlehub/fastdeploy/yolov5s_quant.tar
tar -xvf yolov5s_quant.tar tar -xvf yolov5s_quant.tar
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
# 在CPU上使用Paddle-Inference推理量化模型 # 在CPU上使用ONNX Runtime推理量化模型
python infer.py --model yolov5s_quant --image 000000014439.jpg --device cpu --backend paddle python infer.py --model yolov5s_quant --image 000000014439.jpg --device cpu --backend ort
# 在GPU上使用TensorRT推理量化模型 # 在GPU上使用TensorRT推理量化模型
python infer.py --model yolov5s_quant --image 000000014439.jpg --device gpu --backend trt python infer.py --model yolov5s_quant --image 000000014439.jpg --device gpu --backend trt
# 在GPU上使用Paddle-TensorRT推理量化模型 # 在GPU上使用Paddle-TensorRT推理量化模型

View File

@@ -54,12 +54,6 @@ def build_option(args):
option.enable_paddle_to_trt() option.enable_paddle_to_trt()
elif args.backend.lower() == "ort": elif args.backend.lower() == "ort":
option.use_ort_backend() option.use_ort_backend()
elif args.backend.lower() == "paddle":
option.use_paddle_backend()
elif args.backend.lower() == "openvino":
assert args.device.lower(
) == "cpu", "OpenVINO backend require inference on device CPU."
option.use_openvino_backend()
return option return option

View File

@@ -28,7 +28,7 @@ tar -xvf yolov6s_qat_model.tar
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
# 在CPU上使用Paddle-Inference推理量化模型 # 在CPU上使用ONNX Runtime推理量化模型
./infer_demo yolov6s_qat_model 000000014439.jpg 0 ./infer_demo yolov6s_qat_model 000000014439.jpg 0
# 在GPU上使用TensorRT推理量化模型 # 在GPU上使用TensorRT推理量化模型
./infer_demo yolov6s_qat_model 000000014439.jpg 1 ./infer_demo yolov6s_qat_model 000000014439.jpg 1

View File

@@ -64,7 +64,7 @@ int main(int argc, char* argv[]) {
if (flag == 0) { if (flag == 0) {
option.UseCpu(); option.UseCpu();
option.UsePaddleBackend(); option.UseOrtBackend();
} else if (flag == 1) { } else if (flag == 1) {
option.UseGpu(); option.UseGpu();
option.UseTrtBackend(); option.UseTrtBackend();

View File

@@ -21,8 +21,8 @@ wget https://bj.bcebos.com/paddlehub/fastdeploy/yolov6s_qat_model.tar
tar -xvf yolov6s_qat_model.tar tar -xvf yolov6s_qat_model.tar
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
# 在CPU上使用Paddle-Inference推理量化模型 # 在CPU上使用ONNX Runtime推理量化模型
python infer.py --model yolov6s_qat_model --image 000000014439.jpg --device cpu --backend paddle python infer.py --model yolov6s_qat_model --image 000000014439.jpg --device cpu --backend ort
# 在GPU上使用TensorRT推理量化模型 # 在GPU上使用TensorRT推理量化模型
python infer.py --model yolov6s_qat_model --image 000000014439.jpg --device gpu --backend trt python infer.py --model yolov6s_qat_model --image 000000014439.jpg --device gpu --backend trt
# 在GPU上使用Paddle-TensorRT推理量化模型 # 在GPU上使用Paddle-TensorRT推理量化模型

View File

@@ -54,12 +54,6 @@ def build_option(args):
option.enable_paddle_to_trt() option.enable_paddle_to_trt()
elif args.backend.lower() == "ort": elif args.backend.lower() == "ort":
option.use_ort_backend() option.use_ort_backend()
elif args.backend.lower() == "paddle":
option.use_paddle_backend()
elif args.backend.lower() == "openvino":
assert args.device.lower(
) == "cpu", "OpenVINO backend require inference on device CPU."
option.use_openvino_backend()
return option return option

View File

@@ -28,7 +28,7 @@ tar -xvf yolov7_quant.tar
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
# 在CPU上使用Paddle-Inference推理量化模型 # 在CPU上使用ONNX Runtime推理量化模型
./infer_demo yolov7_quant 000000014439.jpg 0 ./infer_demo yolov7_quant 000000014439.jpg 0
# 在GPU上使用TensorRT推理量化模型 # 在GPU上使用TensorRT推理量化模型
./infer_demo yolov7_quant 000000014439.jpg 1 ./infer_demo yolov7_quant 000000014439.jpg 1

View File

@@ -64,7 +64,7 @@ int main(int argc, char* argv[]) {
if (flag == 0) { if (flag == 0) {
option.UseCpu(); option.UseCpu();
option.UsePaddleBackend(); option.UseOrtBackend();
} else if (flag == 1) { } else if (flag == 1) {
option.UseGpu(); option.UseGpu();
option.UseTrtBackend(); option.UseTrtBackend();

View File

@@ -21,8 +21,8 @@ wget https://bj.bcebos.com/paddlehub/fastdeploy/yolov7_quant.tar
tar -xvf yolov7_quant.tar tar -xvf yolov7_quant.tar
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
# 在CPU上使用Paddle-Inference推理量化模型 # 在CPU上使用ONNX Runtime推理量化模型
python infer.py --model yolov7_quant --image 000000014439.jpg --device cpu --backend paddle python infer.py --model yolov7_quant --image 000000014439.jpg --device cpu --backend ort
# 在GPU上使用TensorRT推理量化模型 # 在GPU上使用TensorRT推理量化模型
python infer.py --model yolov7_quant --image 000000014439.jpg --device gpu --backend trt python infer.py --model yolov7_quant --image 000000014439.jpg --device gpu --backend trt
# 在GPU上使用Paddle-TensorRT推理量化模型 # 在GPU上使用Paddle-TensorRT推理量化模型

View File

@@ -54,12 +54,6 @@ def build_option(args):
option.enable_paddle_to_trt() option.enable_paddle_to_trt()
elif args.backend.lower() == "ort": elif args.backend.lower() == "ort":
option.use_ort_backend() option.use_ort_backend()
elif args.backend.lower() == "paddle":
option.use_paddle_backend()
elif args.backend.lower() == "openvino":
assert args.device.lower(
) == "cpu", "OpenVINO backend require inference on device CPU."
option.use_openvino_backend()
return option return option

View File

@@ -151,7 +151,6 @@ class YOLOv5(FastDeployModel):
# 初始化后的option保存在self._runtime_option # 初始化后的option保存在self._runtime_option
super(YOLOv5, self).__init__(runtime_option) super(YOLOv5, self).__init__(runtime_option)
assert model_format == ModelFormat.ONNX, "YOLOv5 only support model format of ModelFormat.ONNX now."
self._model = C.vision.detection.YOLOv5( self._model = C.vision.detection.YOLOv5(
model_file, params_file, self._runtime_option, model_format) model_file, params_file, self._runtime_option, model_format)
# 通过self.initialized判断整个模型的初始化是否成功 # 通过self.initialized判断整个模型的初始化是否成功

View File

@@ -137,7 +137,6 @@ class YOLOv7(FastDeployModel):
# 初始化后的option保存在self._runtime_option # 初始化后的option保存在self._runtime_option
super(YOLOv7, self).__init__(runtime_option) super(YOLOv7, self).__init__(runtime_option)
assert model_format == ModelFormat.ONNX, "YOLOv7 only support model format of ModelFormat.ONNX now."
self._model = C.vision.detection.YOLOv7( self._model = C.vision.detection.YOLOv7(
model_file, params_file, self._runtime_option, model_format) model_file, params_file, self._runtime_option, model_format)
# 通过self.initialized判断整个模型的初始化是否成功 # 通过self.initialized判断整个模型的初始化是否成功