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/08/25 06:21]
louis
products:sbc:edge2:npu:demos:yolov8n [2025/04/23 05:23] (current)
louis
Line 1: Line 1:
-====== Demo2 - Yolov8n ======+~~tag> YOLO NPU Edge2 RK3588~~
  
-===== Get Source Code =====+====== YOLOv8n OpenCV Edge2 Demo - 2 ======
  
-Download yolov8 official codesRefer README.md to train a yolov8n model.+{{indexmenu_n>2}} 
 + 
 +===== Introduction ===== 
 + 
 +YOLOv8n is an object detection modelIt 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]]
  
 ```shell ```shell
 $ git clone https://github.com/ultralytics/ultralytics.git $ git clone https://github.com/ultralytics/ultralytics.git
 ``` ```
 +
 +Refer ''README.md'' to train a YOLOv8n model. My version ''torch==1.10.1'' and ''ultralytics==8.0.86''.
  
 ===== Convert Model ===== ===== Convert Model =====
Line 55: 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 85: Line 101:
 ``` ```
  
-Create a python file written as follows to export onnx model.+<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.
  
 ```python export.py ```python export.py
Line 92: 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 139: 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 175: 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>
  
 <WRAP tip > <WRAP tip >
-If your yolov8n model classes is not the same as coco, please change ''data/coco_80_labels_list.txt'' and the ''OBJ_CLASS_NUM'' in ''include/postprocess.h''.+If your **YOLOv8n** model classes is not the same as **coco**, please change ''data/coco_80_labels_list.txt'' and the ''OBJ_CLASS_NUM'' in ''include/postprocess.h''.
 </WRAP> </WRAP>
  
Last modified: 2023/08/25 06:21 by louis