Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:vim3:npu:ksnn:demos:yolov8n

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
products:sbc:vim3:npu:ksnn:demos:yolov8n [2023/12/22 04:01]
louis
products:sbc:vim3:npu:ksnn:demos:yolov8n [2024/02/22 05:19]
louis
Line 13: Line 13:
 ``` ```
  
-Refer ''README.md'' to create and train a YOLOv8n model.+Refer ''README.md'' to create and train a YOLOv8n model. My version ''torch==1.10.1'' and ''ultralytics==8.0.86''.
  
 ===== Convert the model ===== ===== Convert the model =====
Line 34: Line 34:
 After training the model, modify ''ultralytics/ultralytics/nn/modules/head.py'' as follows. After training the model, modify ''ultralytics/ultralytics/nn/modules/head.py'' as follows.
  
-```diff+```diff head.py
 diff --git a/ultralytics/nn/modules/head.py b/ultralytics/nn/modules/head.py diff --git a/ultralytics/nn/modules/head.py b/ultralytics/nn/modules/head.py
 index 0b02eb3..0a6e43a 100644 index 0b02eb3..0a6e43a 100644
Line 62: Line 62:
 + +
 ``` ```
 +
 +<WRAP important>
 +If you pip-installed ultralytics package, you should modify in package.
 +</WRAP>
  
 Create a python file written as follows to export ONNX model. Create a python file written as follows to export ONNX model.
Line 74: Line 78:
 $ python export.py $ python export.py
 ``` ```
 +
 +<WRAP important>
 +Use [[https://netron.app/ | Netron]] to check your model output like this. If not, please check your ''head.py''.
 +
 +{{:products:sbc:vim3:npu:ksnn:yolov8n-vim3-ksnn-output.png?600|}}
 +</WRAP>
  
 Enter ''aml_npu_sdk/acuity-toolkit/python'' and run command as follows. Enter ''aml_npu_sdk/acuity-toolkit/python'' and run command as follows.
Line 84: Line 94:
             --quantized-dtype asymmetric_affine \             --quantized-dtype asymmetric_affine \
             --source-files ./data/dataset/dataset0.txt \             --source-files ./data/dataset/dataset0.txt \
 +            --batch-size 1 \
 +            --iterations 1 \
             --kboard VIM3 --print-level 0              --kboard VIM3 --print-level 0 
 ``` ```
  
-If you use ''VIM3L'' , please use ''VIM3L'' to replace ''VIM3''+If you want to use more quantified images, please modify ''batch-size'' and ''iterations''. ''batch-size''×''iterations''=number of quantified images. 
 + 
 +If you use ''VIM3L'' , please use ''VIM3L'' to replace ''VIM3''.
  
 If run succeed, converted model and library will generate in ''outputs/yolov8n''. If run succeed, converted model and library will generate in ''outputs/yolov8n''.
Line 112: Line 126:
  
 Put ''yolov8n.nb'' and ''libnn_yolov8n.so'' into ''ksnn/examples/yolov8n/models/VIM3'' and ''ksnn/examples/yolov8n/libs'' Put ''yolov8n.nb'' and ''libnn_yolov8n.so'' into ''ksnn/examples/yolov8n/models/VIM3'' and ''ksnn/examples/yolov8n/libs''
 +
 +If your model's classes is not 80, please remember to modify the parameter, ''LISTSIZE''
 +
 +```shell
 +LISTSIZE = classes number + 64
 +```
  
 ==== Picture input demo ==== ==== Picture input demo ====
Last modified: 2024/05/27 22:16 by louis