Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:vim4:npu:demos:yolov7-tiny

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:yolov7-tiny [2023/09/18 00:32]
sravan [Compile and run]
products:sbc:vim4:npu:demos:yolov7-tiny [2025/01/08 22:22] (current)
louis
Line 1: Line 1:
 ~~tag> NPU YOLO OpenCV VIM4 ~~ ~~tag> NPU YOLO OpenCV VIM4 ~~
  
-====== YOLOv7 Tiny VIM4 Demo - 1 ======+**Doc for version ddk-3.4.7.7** 
 + 
 +====== YOLOv7-tiny VIM4 Demo - 1 ======
  
 {{indexmenu_n>1}} {{indexmenu_n>1}}
Line 13: Line 15:
 ``` ```
  
-Refer ''README.md'' to create and train a yolov7_tiny model.+Refer ''README.md'' to create and train a YOLOv7 tiny model.
 ===== Convert the model ===== ===== Convert the model =====
  
Line 20: Line 22:
 Follow Docker official documentation 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]].
  
-Then fetch the prebuilt NPU Docker Container and run it.+Follow the script below to get Docker image:
  
 ```shell ```shell
-docker pull yanwyb/npu:v1 +docker pull numbqq/npu-vim4
-$ docker run -it --name vim4-npu1 -v $(pwd):/home/khadas/npu \ +
- -v /etc/localtime:/etc/localtime:ro \ +
- -v /etc/timezone:/etc/timezone:ro \ +
- yanwyb/npu:v1+
 ``` ```
  
 ==== Get the conversion tool ==== ==== Get the conversion tool ====
  
-Download The conversion tool from [[gl>khadas/vim4_npu_sdk]].+Download The conversion tool from [[gh>khadas/vim4_npu_sdk]].
  
 ```shell ```shell
-$ git clone https://gitlab.com/khadas/vim4_npu_sdk+$ git lfs install 
 +$ git lfs clone https://github.com/khadas/vim4_npu_sdk 
 +$ cd vim4_npu_sdk 
 +$ ls 
 +adla-toolkit-binary  adla-toolkit-binary-3.1.7.4  convert-in-docker.sh  Dockerfile  docs  README.md
 ``` ```
 +
 +  * ''adla-toolkit-binary/docs'' - SDK documentations
 +  * ''adla-toolkit-binary/bin'' - SDK tools required for model conversion
 +  * ''adla-toolkit-binary/demo'' - Conversion examples
 +
 +<WRAP important>
 +If your kernel is older than 241129, please use branch npu-ddk-1.7.5.5.
 +</WRAP>
  
 ==== Convert ==== ==== Convert ====
  
-After training model, modify ''yolov7/models/yolo.py'' as follows.+After training the model, modify ''yolov7/models/yolo.py'' as follows.
  
 ```diff ```diff
Line 57: Line 67:
 ``` ```
  
-Then, run ''export.py'' to convert model to ONNX.+<WRAP important> 
 +yolo.py has many forward. Right place is class **IDetect** function **fuseforward**. 
 +</WRAP> 
 + 
 +Then, run ''export.py'' to convert the model to ONNX.
  
 ```shell ```shell
Line 84: Line 98:
         --quantize-dtype int8 --outdir onnx_output  \         --quantize-dtype int8 --outdir onnx_output  \
         --channel-mean-value "0,0,0,255"  \         --channel-mean-value "0,0,0,255"  \
 +        --inference-input-type "float32" \
 +        --inference-output-type "float32" \
         --source-file dataset.txt  \         --source-file dataset.txt  \
         --batch-size 1 --target-platform PRODUCT_PID0XA003         --batch-size 1 --target-platform PRODUCT_PID0XA003
 ``` ```
  
-Run ''convert_adla.sh'' to generate VIM4 model. The converted model is ''xxx.adla'' in ''onnx_output''.+Run ''convert_adla.sh'' to generate the VIM4 model. The converted model is ''xxx.adla'' in ''onnx_output''.
  
 ```shell ```shell
Line 104: Line 120:
  
 ``` ```
 +
 +<WRAP important>
 +If your kernel is older than 241129, please use version before tag ddk-3.4.7.7.
 +</WRAP>
  
 ==== Install dependencies ==== ==== Install dependencies ====
Line 127: Line 147:
  
 # Run # Run
-sudo ./yolov7_tiny -m ../data/yolov7_tiny_int8.adla -p ../data/horses.jpg+$ ./yolov7_tiny -m ../data/yolov7_tiny_int8.adla -p ../data/horses.jpg
 ``` ```
 +
 +{{:products:sbc:vim4:npu:demos:yolov7-tiny-demo-output.webp?800|}}
  
 === Camera input demo === === Camera input demo ===
Line 143: Line 165:
  
 # Run # Run
-sudo ./yolov7_tiny_cap -m ../data/yolov7_tiny_int8.adla -d 0 -w 1920 -h 1080+$ ./yolov7_tiny_cap -m ../data/yolov7_tiny_int8.adla -d 0
 ``` ```
  
-''0'' is camera device index.+''0'' is the camera device index.
  
 <WRAP tip > <WRAP tip >
-If your **YOLOv7_tiny** 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''.+If your **YOLOv7-tiny** 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/18 00:32 by sravan