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 [2024/01/04 04:46]
louis
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 ~~
 +
 +**Doc for version ddk-3.4.7.7**
  
 ====== YOLOv7-tiny VIM4 Demo - 1 ====== ====== YOLOv7-tiny VIM4 Demo - 1 ======
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 ====
Line 56: Line 66:
                  if self.grid[i].shape[2:4] != x[i].shape[2:4]:                  if self.grid[i].shape[2:4] != x[i].shape[2:4]:
 ``` ```
 +
 +<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. Then, run ''export.py'' to convert the model to ONNX.
Line 81: Line 95:
         --inputs "images" \         --inputs "images" \
         --input-shapes  "3,640,640"  \         --input-shapes  "3,640,640"  \
-        --inference-input-type float32 \ 
- --inference-output-type float32 \ 
         --dtypes "float32" \         --dtypes "float32" \
         --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  \
-        --iterations 500 \ 
-        --disable-per-channel False \ 
         --batch-size 1 --target-platform PRODUCT_PID0XA003         --batch-size 1 --target-platform PRODUCT_PID0XA003
 ``` ```
- 
-<WRAP important > 
-Please prepare about 500 pictures for quantification. If the pictures size is smaller than model input size, please resize pictures to input size before quantification. 
-</WRAP> 
  
 Run ''convert_adla.sh'' to generate the 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''.
Line 110: Line 118:
 ```shell ```shell
 $ git clone https://github.com/khadas/vim4_npu_applications $ git clone https://github.com/khadas/vim4_npu_applications
 +
 ``` ```
  
-<WRAP important > +<WRAP important> 
-If your kernel version is 5.4 or earlier, please use tag ''ddk-1.7.5.5''. Tag ''ddk-2.3.6.7'' is for 5.15.+If your kernel is older than 241129, please use version before tag ddk-3.4.7.7.
 </WRAP> </WRAP>
  
Line 138: 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 154: 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
 ``` ```
  
Last modified: 2024/01/04 04:46 by louis