Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:vim4:npu:demos:densenet

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:densenet [2023/09/18 02:09]
sravan
products:sbc:vim4:npu:demos:densenet [2025/01/08 22:22] (current)
louis
Line 1: Line 1:
 ~~tag> NPU Densenet VIM4 ONNX~~ ~~tag> NPU Densenet VIM4 ONNX~~
-====== DenseNet CTC ONNX Keras VIM4 Demo - 3======+ 
 +**Doc for version ddk-3.4.7.7** 
 + 
 +====== DenseNet CTC ONNX Keras VIM4 Demo - 3 ======
  
 {{indexmenu_n>3}} {{indexmenu_n>3}}
Line 17: Line 20:
 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 clone https://github.com/khadas/vim4_npu_sdk 
 +$ cd vim4_npu_sdk 
 +$ git lfs pull 
 +$ 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 ====
  
 After training the model, run the scripts as follows to modify net input and output and convert the model to ONNX. After training the model, run the scripts as follows to modify net input and output and convert the model to ONNX.
Line 62: Line 75:
 ``` ```
  
-Enter ''vim4_npu_sdk/demo'' and modify ''convert_adla.sh'' as follows. We should quantize the model to **int16** because it is very inaccurate with **int8**.+Enter ''vim4_npu_sdk/demo'' and modify ''convert_adla.sh'' as follows.
  
 ```bash convert_adla.sh ```bash convert_adla.sh
Line 82: Line 95:
         --dtypes "float32" \         --dtypes "float32" \
         --inference-input-type float32 \         --inference-input-type float32 \
- --inference-output-type float32 \ + --inference-output-type float32 \ 
-        --quantize-dtype int16 --outdir onnx_output  \+        --quantize-dtype int8 --outdir onnx_output  \
         --channel-mean-value "0,0,0,255"  \         --channel-mean-value "0,0,0,255"  \
         --source-file ./densenet_ctc_dataset.txt  \         --source-file ./densenet_ctc_dataset.txt  \
Line 106: Line 119:
 $ git clone https://github.com/khadas/vim4_npu_applications $ git clone https://github.com/khadas/vim4_npu_applications
 ``` ```
 +
 +<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 118: Line 135:
 === Picture input demo === === Picture input demo ===
  
-Put ''densenet_ctc_int16.adla'' in ''vim4_npu_applications/densenet_ctc/data/''.+Put ''densenet_ctc_int8.adla'' in ''vim4_npu_applications/densenet_ctc/data/''.
  
 ```shell ```shell
Line 129: Line 146:
  
 # Run # Run
-sudo ./densenet_ctc -m ../data/densenet_ctc_int16.adla -p ../data/KhadasTeam.png+$ ./densenet_ctc -m ../data/densenet_ctc_int8.adla -p ../data/KhadasTeam.png
 ``` ```
  
-<WRAP tip >+{{:products:sbc:vim4:npu:demos:khadasteam.webp?400|}} 
 + 
 +{{:products:sbc:vim4:npu:demos:densenet-demo-output.webp?400|}} 
 + 
 +<WRAP tip>
 If your ''densenet_ctc'' - **DenseNet-CTC** model classes are not the same, please change ''data/class_str.txt'' and the ''OBJ_CLASS_NUM'' in ''include/postprocess.h''. If your ''densenet_ctc'' - **DenseNet-CTC** model classes are not the same, please change ''data/class_str.txt'' and the ''OBJ_CLASS_NUM'' in ''include/postprocess.h''.
 </WRAP> </WRAP>
  
Last modified: 2023/09/18 02:09 by sravan