From 132e3b4757b621f7132d5a666d3139adad3bdcdb Mon Sep 17 00:00:00 2001 From: "hongliang.yuan" Date: Mon, 12 Jan 2026 13:09:57 +0800 Subject: [PATCH] support yolov8n ixrt bsz --- .../object_detection/yolov8n/ixrt/ci/prepare.sh | 2 +- .../ixrt/scripts/infer_yolov8n_fp16_accuracy.sh | 15 +++++++++++++-- .../scripts/infer_yolov8n_fp16_performance.sh | 15 +++++++++++++-- .../ixrt/scripts/infer_yolov8n_int8_accuracy.sh | 15 +++++++++++++-- .../scripts/infer_yolov8n_int8_performance.sh | 15 +++++++++++++-- tests/run_ixrt.py | 7 +++++++ 6 files changed, 60 insertions(+), 9 deletions(-) diff --git a/models/cv/object_detection/yolov8n/ixrt/ci/prepare.sh b/models/cv/object_detection/yolov8n/ixrt/ci/prepare.sh index 63103ee9..b528cd18 100644 --- a/models/cv/object_detection/yolov8n/ixrt/ci/prepare.sh +++ b/models/cv/object_detection/yolov8n/ixrt/ci/prepare.sh @@ -18,6 +18,6 @@ set -x pip install -r requirements.txt mkdir -p checkpoints -ln -s /root/data/checkpoints/yolov8.pt yolov8.pt +ln -s /root/data/checkpoints/yolov8n.pt yolov8.pt python3 export.py --weight yolov8.pt --batch 32 onnxsim ./yolov8.onnx ./checkpoints/yolov8.onnx \ No newline at end of file diff --git a/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_fp16_accuracy.sh b/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_fp16_accuracy.sh index 65434fec..01ecb742 100644 --- a/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_fp16_accuracy.sh +++ b/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_fp16_accuracy.sh @@ -40,6 +40,18 @@ echo Onnx Path : ${ORIGINE_MODEL} BATCH_SIZE=32 CURRENT_MODEL=${CHECKPOINTS_DIR}/yolov8.onnx +# Update arguments +index=0 +options=$@ +arguments=($options) +for argument in $options +do + index=`expr $index + 1` + case $argument in + --bs) BATCH_SIZE=${arguments[index]};; + esac +done + # Build Engine echo Build Engine ENGINE_FILE=${CHECKPOINTS_DIR}/yolov8_fp16.engine @@ -55,11 +67,10 @@ fi # Inference echo Inference -RUN_BATCH_SIZE=32 python3 ${RUN_DIR}/inference.py \ --model_engine ${ENGINE_FILE} \ --warm_up 2 \ - --bsz ${RUN_BATCH_SIZE} \ + --bsz ${BATCH_SIZE} \ --imgsz 640 \ --datasets ${DATASETS_DIR} \ --acc_target 0.3 diff --git a/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_fp16_performance.sh b/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_fp16_performance.sh index 355b27bc..0801e62b 100644 --- a/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_fp16_performance.sh +++ b/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_fp16_performance.sh @@ -40,6 +40,18 @@ echo Onnx Path : ${ORIGINE_MODEL} BATCH_SIZE=32 CURRENT_MODEL=${CHECKPOINTS_DIR}/yolov8.onnx +# Update arguments +index=0 +options=$@ +arguments=($options) +for argument in $options +do + index=`expr $index + 1` + case $argument in + --bs) BATCH_SIZE=${arguments[index]};; + esac +done + # Build Engine echo Build Engine ENGINE_FILE=${CHECKPOINTS_DIR}/yolov8_fp16.engine @@ -55,11 +67,10 @@ fi # Inference echo Inference -RUN_BATCH_SIZE=32 python3 ${RUN_DIR}/inference.py \ --model_engine ${ENGINE_FILE} \ --warm_up 2 \ - --bsz ${RUN_BATCH_SIZE} \ + --bsz ${BATCH_SIZE} \ --imgsz 640 \ --datasets ${DATASETS_DIR} \ --perf_only true \ diff --git a/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_int8_accuracy.sh b/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_int8_accuracy.sh index bf1ecf25..034427e4 100644 --- a/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_int8_accuracy.sh +++ b/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_int8_accuracy.sh @@ -41,6 +41,18 @@ echo Onnx Path : ${ORIGINE_MODEL} BATCH_SIZE=32 CURRENT_MODEL=${CHECKPOINTS_DIR}/yolov8.onnx +# Update arguments +index=0 +options=$@ +arguments=($options) +for argument in $options +do + index=`expr $index + 1` + case $argument in + --bs) BATCH_SIZE=${arguments[index]};; + esac +done + # quant FINAL_MODEL=${CHECKPOINTS_DIR}/quantized_yolov8_bs${BATCH_SIZE}.onnx if [ -f $FINAL_MODEL ];then @@ -75,11 +87,10 @@ fi # Inference echo Inference -RUN_BATCH_SIZE=32 python3 ${RUN_DIR}/inference.py \ --model_engine ${ENGINE_FILE} \ --warm_up 2 \ - --bsz ${RUN_BATCH_SIZE} \ + --bsz ${BATCH_SIZE} \ --imgsz 640 \ --datasets ${DATASETS_DIR} \ --acc_target 0.3 diff --git a/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_int8_performance.sh b/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_int8_performance.sh index f4c31b68..d36b9d4a 100644 --- a/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_int8_performance.sh +++ b/models/cv/object_detection/yolov8n/ixrt/scripts/infer_yolov8n_int8_performance.sh @@ -40,6 +40,18 @@ echo Onnx Path : ${ORIGINE_MODEL} BATCH_SIZE=32 CURRENT_MODEL=${CHECKPOINTS_DIR}/yolov8.onnx +# Update arguments +index=0 +options=$@ +arguments=($options) +for argument in $options +do + index=`expr $index + 1` + case $argument in + --bs) BATCH_SIZE=${arguments[index]};; + esac +done + # quant FINAL_MODEL=${CHECKPOINTS_DIR}/quantized_yolov8_bs${BATCH_SIZE}.onnx if [ -f $FINAL_MODEL ];then @@ -74,11 +86,10 @@ fi # Inference echo Inference -RUN_BATCH_SIZE=32 python3 ${RUN_DIR}/inference.py \ --model_engine ${ENGINE_FILE} \ --warm_up 2 \ - --bsz ${RUN_BATCH_SIZE} \ + --bsz ${BATCH_SIZE} \ --imgsz 640 \ --datasets ${DATASETS_DIR} \ --perf_only true \ diff --git a/tests/run_ixrt.py b/tests/run_ixrt.py index 68f3fe35..479a02a3 100644 --- a/tests/run_ixrt.py +++ b/tests/run_ixrt.py @@ -370,6 +370,13 @@ def run_detec_testcase(model, batch_size, whl_url): rm -rf ../checkpoints/tmp cd - """ + elif model_name == "yolov8n": + export_onnx_script = f""" + cd ../{model['model_path']} + python3 export.py --weight yolov8.pt --batch {bs} + rm -rf checkpoints/* + onnxsim yolov8.onnx ./checkpoints/yolov8.onnx + """ script = export_onnx_script + base_script + f""" bash scripts/infer_{model_name}_{prec}_accuracy.sh --bs {bs} bash scripts/infer_{model_name}_{prec}_performance.sh --bs {bs} -- Gitee