59 lines
1.6 KiB
Bash
Executable File
59 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
MODEL_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
REPO_DIR="$(cd "${MODEL_DIR}/.." && pwd)"
|
|
IMAGE="openexplorer/ai_toolchain_ubuntu_20_x5_cpu:v1.2.8"
|
|
|
|
docker run --rm --platform linux/amd64 \
|
|
-v "${REPO_DIR}:/workspace/smart_car_2026" \
|
|
"${IMAGE}" bash -lc '
|
|
set -euo pipefail
|
|
cd /workspace/smart_car_2026/model/x5_quantization
|
|
python3 extract_yolo26_bpu.py \
|
|
--input ../best.onnx \
|
|
--output best_bpu.onnx
|
|
python3 prepare_calibration.py \
|
|
--dataset /workspace/smart_car_2026/dataset \
|
|
--output calibration_data \
|
|
--samples 50
|
|
cat > best_bpu_int8.yaml <<"YAML"
|
|
model_parameters:
|
|
onnx_model: "./best_bpu.onnx"
|
|
march: "bayes-e"
|
|
layer_out_dump: false
|
|
working_dir: "mapper_output_bpu"
|
|
output_model_file_prefix: "best_bpu_bayese_640x640_nv12"
|
|
|
|
input_parameters:
|
|
input_name: "images"
|
|
input_type_rt: "nv12"
|
|
input_type_train: "rgb"
|
|
input_layout_train: "NCHW"
|
|
norm_type: "data_scale"
|
|
scale_value: 0.003921568627451
|
|
|
|
calibration_parameters:
|
|
cal_data_dir: "./calibration_data"
|
|
cal_data_type: "float32"
|
|
calibration_type: "default"
|
|
optimization: "set_Softmax_input_int8,set_Softmax_output_int8"
|
|
|
|
compiler_parameters:
|
|
jobs: 8
|
|
compile_mode: "latency"
|
|
debug: true
|
|
optimize_level: "O3"
|
|
YAML
|
|
hb_mapper checker \
|
|
--model best_bpu.onnx \
|
|
--model-type onnx \
|
|
--march bayes-e \
|
|
--input-shape images 1x3x640x640
|
|
hb_mapper makertbin \
|
|
--config best_bpu_int8.yaml \
|
|
--model-type onnx
|
|
ls -lh mapper_output_bpu/best_bpu_bayese_640x640_nv12.bin
|
|
'
|