NPU toolkit (aml_npu_sdk.tgz) does not include model conversion scripts for Yolo model

Dear a technical team,

Hello, I recently bought the Khadas/VIM Pro board to run the various up-to-date network models.
I checked how to transform Yolo model at https://docs.khadas.com/vim3/HowToTransformYolo.html.
Then, I downloaded the “aml_npu_sdk.tgz (478MB)” file by submitting the contents at https://www.khadas.com/npu-toolkit-vim3.
When I decompressed the “aml_npu_sdk.tgz” file, I could not find the below files to use the transform tool for Yolov3.
The “aml_npu_sdk.tgz” file only includes the three scripts for Inceptionv3 in the "./aml_npu_sdk/acuity-toolkit/conversion_scripts/" folder.

  • 0_import_model.sh
  • 1_quantize_model.sh
  • 2_export_case_code.sh

The below messages show the folder structure of the "conversion_scripts” directory.

$ tar xvzf ./aml_npu_sdk.tgz
$ cd aml_npu_sdk
$ find . -name 0_import_model.sh
./acuity-toolkit/conversion_scripts/0_import_model.sh
$ tree ./acuity-toolkit/conversion_scripts/
./acuity-toolkit/conversion_scripts/
|-- 0_import_model.sh <============= It is example scripts for Inceptionv3 (w/o Yolov3).
|-- 1_quantize_model.sh
|-- 2_export_case_code.sh
|-- data
|   |-- 0.jpg
|   |-- dog_299.jpg
|   |-- goldfish_224.jpg
|   |-- space_shuttle_224.jpg
|   `-- validation_tf.txt
|-- extractoutput.py
`-- model
    |-- imagenet_slim_labels.txt
    `-- inception_v3_2016_08_28_frozen.pb

2 directories, 11 files

I wonder where the files to transform Yolo model on VIM3 pro board such as Inceptionv3 model. Welcome to any comments.

1 Like

@leemgs The conversion script is general, and this script can also convert Yolo model.
Follow up those pages:

@leemgs The conversion script is general, and this script can also convert Yolo model.
Thanks. got it. :slight_smile:

https://docs.khadas.com/vim3/HowToTransformYolo.html#0-import-model-sh
… Omission …
--net-input /home/khadas/Pictures/VOCdevkit/yolov3-train/yolov3-voc.cfg \
--weight-input /home/khadas/Pictures/VOCdevkit/yolov3-train/backup/yolov3-voc_final.weights \

@Frank, BTW, Where can I download the yolov3-voc.cfg and the yolov3-voc_final.weights file?

@leemgs You can find those in darnknet website ,or you can train it by yourself .

@Frank Thanks. :slight_smile:

How to transform Yolo Model - https://docs.khadas.com/vim3/HowToTransformYolo.html
You can find those in darnknet website ,or you can train it by yourself .

@Frank, @numbqq , It’s weird. It seems that the tool does not generate a case code correctly.
After modifying the below three script files for Yolov3, I tried to run the scripts files.

  • 0_import_model.sh
  • 1_quantize_model.sh
  • 2_export_case_code.sh

Then, I could get the below case code files in the “nbg_unify_yolov3” folder as follows.
However, the post-process files (e.g., vnn_post_process.c and vnn_post_process.h) for Yolov3 model are incorrect. Can I get the latest “aml_npu_sdk.tgz” file that solve this issue? How can I fix this issue? Welcome to an hints and similar experience.

drwxrwxr-x 2 invain invain 4096 3월 16 09:15 .
drwxr-xr-x 6 invain invain 4096 3월 16 09:13 …
-rw-rw-r-- 1 invain invain 37763 3월 16 09:08 .cproject
-rw-rw-r-- 1 invain invain 2189 3월 16 09:08 .project
-rw-rw-r-- 1 invain invain 567 3월 16 09:08 BUILD
-rw-rw-r-- 1 invain invain 5839 3월 16 09:08 main.c
-rw-rw-r-- 1 invain invain 1995 3월 16 09:08 makefile.linux
-rw-rw-r-- 1 invain invain 358 3월 16 09:08 vnn_global.h
-rw-rw-r-- 1 invain invain 3561 3월 16 09:08 vnn_post_process.c
-rw-rw-r-- 1 invain invain 459 3월 16 09:08 vnn_post_process.h
-rw-rw-r-- 1 invain invain 20326 3월 16 09:08 vnn_pre_process.c
-rw-rw-r-- 1 invain invain 1284 3월 16 09:08 vnn_pre_process.h
-rw-rw-r-- 1 invain invain 7934 3월 16 09:08 vnn_yolov3.c
-rw-rw-r-- 1 invain invain 965 3월 16 09:08 vnn_yolov3.h
-rw-rw-r-- 1 invain invain 62057472 3월 16 09:08 yolov3.nb
-rw-rw-r-- 1 invain invain 12676 3월 16 09:08 yolov3.vcxproj

  1. khadas / aml_npu_app · GitLab (source files): (./DDK_6.3.3.4/detect_library/model_code/detect_yolo_v3/ )
  2. khadas / aml_npu_demo_binaries · GitLab (Only ELF binaries)
    2.1. detect_demo_uvc (source code): Files · master · khadas / aml_npu_app · GitLab
    2.2. detect_demo_mipi (source code): Files · master · khadas / aml_npu_app · GitLab

At that time, I exepcted that the output message would be displayed as follows.

. . . Omission . . .
Loading weights from yolov3.weights…Done!
data/dog.jpg: Predicted in 0.029329 seconds.
dog: 99%
truck: 93%
bicycle: 99%

However, when I checked the Line 116,126 at the vnn_post_process.c file,
The output template is not correct.

116 printf(" — Top5 —\n");
117 for(i=0; i<5; i++)
118 {
119 printf(“%3d: %8.6f\n”, MaxClass[i], fMaxProb[i]);
120 }
121 status = VSI_SUCCESS;
122
123 final:
124 if(tensor_data)vsi_nn_Free(tensor_data);
125 if(buffer)free(buffer);
126 return status;

After generating the case code files, do I have to always combine files between case code (yolov3.nb, vnn_yolov3.c, and vnn_yolov3.h) and ./aml_npu_app/DDK_6.3.3.4/detect_library/model_code/detect_yolo_v3/* manually?
When can I use automatically geneated case code such as the existing Inceptionv3’s case code instead of the manual combination?

BRs,
Geunsik Lim

@leemgs It’s right . You need to combile files to detect_library . The automatically compiled Python program has been included in this year’s plan. We have tried some recently, but we still can’t give the specific time of going online. It’s certain that we will make a version of Python

3 Likes