Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:vim4: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:vim4:npu:demos:yolov8n [2023/09/17 23:05]
sravan [Get Source Code]
products:sbc:vim4:npu:demos:yolov8n [2024/02/17 22:43] (current)
louis
Line 12: Line 12:
 ``` ```
  
-Refer ''README.md'' to train a yolov8n model.+Refer ''README.md'' to train a YOLOv8n model.
  
 ===== Convert Model ===== ===== Convert Model =====
Line 18: Line 18:
 ==== Build virtual environment ==== ==== Build virtual environment ====
  
-Follow Docker official docs to install Docker: [[https://docs.docker.com/engine/install/ubuntu/|Install Docker Engine on Ubuntu]].+Follow Docker official documentation to install Docker: [[https://docs.docker.com/engine/install/ubuntu/|Install Docker Engine on Ubuntu]].
  
-Get Docker.+Then fetch the prebuilt NPU Docker container and run it.
  
 ```shell ```shell
Line 42: Line 42:
 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 ultralytics/nn/modules/head.py.patch+```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 66: Line 66:
 +            dfl = self.cv2[i](x[i]).contiguous() +            dfl = self.cv2[i](x[i]).contiguous()
 +            cls = self.cv3[i](x[i]).contiguous() +            cls = self.cv3[i](x[i]).contiguous()
-+            results.append(torch.cat([cls, dfl], 1).permute(0, 2, 3, 1).unsqueeze(1))++            results.append(torch.cat([cls, dfl], 1).permute(0, 2, 3, 1))
 +            # results.append(torch.cat([cls, dfl], 1)) +            # results.append(torch.cat([cls, dfl], 1))
 +        return tuple(results) +        return tuple(results)
 + +
 ``` ```
 +
 +<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 83: Line 87:
 $ 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:vim4:npu:demos:yolov8n-vim4-output.png?600|}}
 +</WRAP>
  
 Enter ''vim4_npu_sdk/demo'' and modify ''convert_adla.sh'' as follows. Enter ''vim4_npu_sdk/demo'' and modify ''convert_adla.sh'' as follows.
Line 169: Line 179:
  
 <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 are 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/09/17 23:05 by sravan