Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:edge2:npu: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
products:sbc:edge2:npu:demos:yolov8n [2023/09/19 22:42]
louis
products:sbc:edge2:npu:demos:yolov8n [2025/04/23 05:23] (current)
louis
Line 5: Line 5:
 {{indexmenu_n>2}} {{indexmenu_n>2}}
  
-===== Get Source Code =====+===== Introduction ===== 
 + 
 +YOLOv8n is an object detection model. It uses bounding boxes to precisely draw each object in image. 
 + 
 +Inference results on Edge2. 
 + 
 +{{:products:sbc:edge2:npu:demos:yolov8n-result.jpg?800|}} 
 + 
 +**Inference speed test**: USB camera about **52ms** per frame. MIPI camera about **40ms** per frame. 
 + 
 +===== Train Model =====
  
 Download YOLOv8 official code [[gh>ultralytics/ultralytics]] Download YOLOv8 official code [[gh>ultralytics/ultralytics]]
Line 13: Line 23:
 ``` ```
  
-Refer ''README.md'' to train a YOLOv8n model.+Refer ''README.md'' to train a YOLOv8n model. My version ''torch==1.10.1'' and ''ultralytics==8.0.86''.
  
 ===== Convert Model ===== ===== Convert Model =====
Line 61: Line 71:
 After training model, modify ''ultralytics/ultralytics/nn/modules/head.py'' as follows. After training 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 90: Line 100:
 + +
 ``` ```
 +
 +<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 98: Line 112:
 results = model.export(format="onnx") results = model.export(format="onnx")
 ``` ```
 +
 +<WRAP important>
 +Use [[https://netron.app/ | Netron]] to check your model output like this. If not, please check your ''head.py''.
 +
 +{{:products:sbc:edge2:npu:demos:yolov8n-edge2-output.png?600|}}
 +</WRAP>
  
 Enter ''rknn-toolkit2/examples/onnx/yolov5'' and modify ''test.py'' as follows. Enter ''rknn-toolkit2/examples/onnx/yolov5'' and modify ''test.py'' as follows.
Line 145: Line 165:
 ==== Get source code ==== ==== Get source code ====
  
-Clone the source code form our [[gh>khadas/edge2-npu]].+Clone the source code from our [[gh>khadas/edge2-npu]].
  
 ```shell ```shell
Line 181: Line 201:
 $ bash build.sh $ bash build.sh
  
-# Run+# Run USB camera 
 +$ cd install/yolov8n_cap 
 +$ ./yolov8n_cap data/model/yolov8n.rknn usb 60 
 + 
 +# Run MIPI camera
 $ cd install/yolov8n_cap $ cd install/yolov8n_cap
-$ ./yolov8n_cap data/model/yolov8n_cap.rknn 33+$ ./yolov8n_cap data/model/yolov8n.rknn mipi 42
 ``` ```
  
 <WRAP info > <WRAP info >
-''33'' is camera device index.+''60'' and ''42'' are camera device index.
 </WRAP> </WRAP>
  
Last modified: 2023/09/19 22:42 by louis