YOLO Model Conversion Workflow (.pt → ONNX → BIE → NEF)

Model Information:

* Dataset: Without Roboflow dataset
* Model: best.pt
* Performance: mAP@50 = 0.89
* Classes: 10

Step 1: Convert .pt to ONNX

Run on local PC:

/model_convertsion_scripts/model_conversion/pt_to_onnx.py

If there are library/toolchain conflicts, install:

pip install "numpy==1.26.4" "typing-extensions>=4.10.0"
pip install "opencv-python-headless==4.8.1.78"

This will generate the ONNX model.

---

Step 2: Optimize ONNX

Run inside kneron/toolchain:latest:

onnx_utils/optimize_onnx.py

This will create an optimized ONNX model.

---

Step 3: Remove Final Sigmoid Layer

Run inside kneron/toolchain:latest:

onnx_utils/remove_sigmoid.py

Output:
optimized_best_no_sigmoid.onnx

---

Step 4: Validate the No-Sigmoid ONNX Model

Run:

python test.py 
--onnx-path /workspace/milan/models/optimized_best_no_sigmoid.onnx 
--img-dir /workspace/milan/20_crop/train/images 
--lbl-dir /workspace/milan/20_crop/train/labels 
--iou-sweep 
--apply-sigmoid

Notes:

* The model output no longer contains the final sigmoid layer.
* --apply-sigmoid applies sigmoid during post-processing.
* Verify that the accuracy and detection results match the original model before proceeding.

---

Step 5: Convert ONNX to BIE and NEF

Run inside kneron/toolchain:latest:

/model_convertsion_scripts/model_conversion/onnx_to_bie2.py

This converts:

ONNX → BIE → NEF

The generated NEF file is ready for deployment on the Kneron device.

---

Pipeline Summary

best.pt
↓
pt_to_onnx.py
↓
best.onnx
↓
optimize_onnx.py
↓
optimized_best.onnx
↓
remove_sigmoid.py
↓
optimized_best_no_sigmoid.onnx
↓
test.py (--apply-sigmoid)
↓
onnx_to_bie2.py
↓
best.bie
↓
best.nef

