1.
ONNX Model - Now Works on CPU
After re-export with correct settings:
PyTorch: Class 0 (drone), conf=0.766, box=[1397,834,1983,1098]
ONNX: Class 0 (drone), conf=0.771, box=[1398,837,1982,1095]
ONNX gives correct detections on CPU.
2. Preprocessing Details
| Stage |
Normalization |
Color |
Format |
Range |
| Training |
÷255 (0-1) |
RGB |
CHW |
float32 |
| Calibration |
0-255 |
RGB |
HWC |
float32 |
| Hailo Inference |
0-255 |
RGB |
HWC |
UINT8 |
| ALLS normalization |
[0,0,0]/[255,255,255] |
- |
- |
internal |
Calibration data:
-
Shape: (17, 640, 640, 3)
-
Dtype: float32
-
Range: [0.0, 255.0]
3.
NOT Using Official yolov8n.alls
I used yolov8m.alls which has wrong layer names for my custom model:
yolov8m.alls references:
conv58, conv71, conv83
My model’s actual output conv layers:
/model.22/cv2.0/cv2.0.2/Conv (bbox scale 1)
/model.22/cv2.1/cv2.1.2/Conv (bbox scale 2)
/model.22/cv2.2/cv2.2.2/Conv (bbox scale 3)
/model.22/cv3.0/cv3.0.2/Conv (class scale 1) ← need sigmoid
/model.22/cv3.1/cv3.1.2/Conv (class scale 2) ← need sigmoid
/model.22/cv3.2/cv3.2.2/Conv (class scale 3) ← need sigmoid
This mismatch is likely causing the issue!
4.
NMS is in ALLS
nms_postprocess("yolov8m_nms_config.json", meta_arch=yolov8, engine=cpu)
5. Current ALLS File
normalization1 = normalization([0.0, 0.0, 0.0], [255.0, 255.0, 255.0])
model_optimization_config(calibration, batch_size=2)
change_output_activation(conv58, sigmoid)
change_output_activation(conv71, sigmoid)
change_output_activation(conv83, sigmoid)
post_quantization_optimization(finetune, policy=enabled, learning_rate=0.000025)
nms_postprocess("../../postprocess_config/yolov8m_nms_config.json", meta_arch=yolov8, engine=cpu)
6. Proposed Fix - Custom ALLS
Should I create a new ALLS like this?
normalization1 = normalization([0.0, 0.0, 0.0], [255.0, 255.0, 255.0])
model_optimization_config(calibration, batch_size=2)
# Correct layer names for custom YOLOv8m
change_output_activation(model_22_cv3_0_cv3_0_2_Conv, sigmoid)
change_output_activation(model_22_cv3_1_cv3_1_2_Conv, sigmoid)
change_output_activation(model_22_cv3_2_cv3_2_2_Conv, sigmoid)
# Force range for class outputs (4 classes)
quantization_param([model_22_cv3_0_cv3_0_2_Conv, model_22_cv3_1_cv3_1_2_Conv, model_22_cv3_2_cv3_2_2_Conv], force_range_out=[0.0, 1.0])
post_quantization_optimization(finetune, policy=enabled, learning_rate=0.000025)
nms_postprocess("custom_nms_config.json", meta_arch=yolov8, engine=cpu)