How to convert own yolov3 model through SDK

Hi I already trained my own custom yolov3 model so I got yolov3.cfg and yolov3.weights.
I’ve downloaded SDK 6.4.4.3 version and tried to convert my own model by following How to convert and call your own model through NPU | Khadas Documentation.
I’ve run 0_import_model.sh so that I got yolov3.json and yolov3.data
However when I tried next step (which is 1_quantize_model.sh) I got some errors like this.
W:tensorflow:From acuitylib/app/tensorzone/workspace.py:26: py_func (from tensorflow.python.ops.script_ops) is deprecated and will be removed in a future version.
Instructions for updating:
tf.py_func is deprecated in TF V2. Instead, there are two
options available in V2.
- tf.py_function takes a python function which manipulates tf eager
tensors instead of numpy arrays. It’s easy to convert a tf eager tensor to
an ndarray (just call tensor.numpy()) but having access to eager tensors
means tf.py_functions can use accelerators such as GPUs as well as
being differentiable using a gradient tape.
- tf.numpy_function maintains the semantics of the deprecated tf.py_func
(it is not differentiable, and manipulates numpy arrays). It drops the
stateful argument making all functions stateful.

I Fitting image with scale.
E Please set source and dataset into to workspace.
I ----------------Warning(0)----------------
Traceback (most recent call last):
File “tensorzonex.py”, line 450, in
File “tensorzonex.py”, line 387, in main
File “acuitylib/app/tensorzone/validator.py”, line 113, in run
File “acuitylib/app/tensorzone/workspace.py”, line 176, in _setup_provider
File “acuitylib/acuitylog.py”, line 251, in e
ValueError: Please set source and dataset into to workspace.
[3138] Failed to execute script tensorzonex

I’ve already done that you mentioned on that website like Modify 0_import_mode1.sh, 1_quantize_model.sh, Modify 2_export_case_code. But I guess I did something wrong while doing following things.

" Replace the image inside
1 $ cat ./data/validation_tf.txt
2 ./space_shuttle_224.jpg, 813

Modify to,
1 path/to/416x416.jpg
The picture resolution here is the same as the configuration in the yolo cfg file "

I don’t get it what that mean so I just put 416x416 single img in demo/data/
Can you explain that sentence and show me some examples?

Oh by the way I’m doing on Google Colaboratory since I don’t have proper GPU.

Thanks for reading :slight_smile:

@DarrenQ You don’t need to make any changes to the verification file of the picture, just convert it first

Thank you! I’ll give it a try :smile:

@Frank Hi me again Unfortunately I have another problem.
You told me that I don’t have to change verification file of the picture so I didn’t change validation_tf.text which is about spaceship.jpg.
Anyway everything work perfectly except 2_export_case_code.sh. When I run 2_export_case_code.sh by command “bash 2_export_case_code.sh” I got a message like this.

D Generate fake input /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo/input_0.tensor
gcc -Wall -std=c++0x -I. -I…/bin/vcmdtools/include/ -I…/bin/vcmdtools/include/CL -I…/bin/vcmdtools/include/VX -I…/bin/vcmdtools/include/ovxlib -D__linux__ -DLINUX -O3 -c vnn_pre_process.c
cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C
gcc -Wall -std=c++0x -I. -I…/bin/vcmdtools/include/ -I…/bin/vcmdtools/include/CL -I…/bin/vcmdtools/include/VX -I…/bin/vcmdtools/include/ovxlib -D__linux__ -DLINUX -O3 -c vnn_post_process.c
cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C
gcc -Wall -std=c++0x -I. -I…/bin/vcmdtools/include/ -I…/bin/vcmdtools/include/CL -I…/bin/vcmdtools/include/VX -I…/bin/vcmdtools/include/ovxlib -D__linux__ -DLINUX -O3 -c vnn_yolov3.c
cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C
gcc -Wall -std=c++0x -I. -I…/bin/vcmdtools/include/ -I…/bin/vcmdtools/include/CL -I…/bin/vcmdtools/include/VX -I…/bin/vcmdtools/include/ovxlib -D__linux__ -DLINUX -O3 -c main.c
cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C
gcc -Wall -std=c++0x -I. -I…/bin/vcmdtools/include/ -I…/bin/vcmdtools/include/CL -I…/bin/vcmdtools/include/VX -I…/bin/vcmdtools/include/ovxlib -D__linux__ -DLINUX -O3 -O3 vnn_pre_process.o vnn_post_process.o vnn_yolov3.o main.o -L…/bin/vcmdtools/lib -lOpenVX -lOpenVXU -lCLC -lVSC -lGAL -lovxlib -lEmulator -lvdtproxy -L…/bin/vcmdtools/lib/vsim -lOpenVX -lOpenVXU -lCLC -lVSC -lGAL -lovxlib -lEmulator -lvdtproxy -L…/bin/vcmdtools/lib/x64_linux -lOpenVX -lOpenVXU -lCLC -lVSC -lGAL -lovxlib -lEmulator -lvdtproxy -L…/bin/vcmdtools/lib/x64_linux/vsim -lOpenVX -lOpenVXU -lCLC -lVSC -lGAL -lovxlib -lEmulator -lvdtproxy …/bin/vcmdtools/lib/libjpeg.a -o gen_nbg
Create Neural Network: 197ms or 197494us
Verify…
Verify Graph: 23711ms or 23711181us
Start run graph [1] times…
Run the 1 time: 561.00ms or 561936.00us
vxProcessGraph execution time:
Total 562.00ms or 562020.00us
Average 562.02ms or 562020.00us
— Top5 —
0: 0.000000
1: 0.000000
2: 0.000000
3: 0.000000
4: 0.000000
mv: ‘/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo/network_binary.nb’ and ‘/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo/network_binary.nb’ are the same file
mv: ‘/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo/input_0.dat’ and ‘/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo/input_0.dat’ are the same file
mv: ‘/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo/output0_13_13_21_1.dat’ and ‘/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo/output0_13_13_21_1.dat’ are the same file
mv: ‘/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo/output1_26_26_21_1.dat’ and ‘/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo/output1_26_26_21_1.dat’ are the same file
mv: ‘/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo/output2_52_52_21_1.dat’ and ‘/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo/output2_52_52_21_1.dat’ are the same file
I Dump nbg input meta to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/nbg_meta.json
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/vnn_yolov3.c
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/vnn_yolov3.h
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/vnn_post_process.c
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/vnn_post_process.h
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/vnn_pre_process.c
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/vnn_pre_process.h
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/vnn_global.h
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/main.c
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/BUILD
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/yolov3.vcxproj
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/makefile.linux
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/.cproject
I Save vx network source file to /content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify/.project
/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify
customer:input,0,0:output,0,1:output,1,2:output,2,3:
/content/drive/MyDrive/Khadas/aml_npu_sdk_6.4.4.3/acuity-toolkit/demo_nbg_unify
I ----------------Warning(0)----------------
rm: cannot remove ‘*.lib’: No such file or directory

My yolov3 model is for detect fallen Person and normal Person. I think that’s because all of the Top 5 has 0 value(since image is for spaceship) or not. And why *.lib file doesn’t exist?

@Frank Oh and If I ignore that rm: cannot remove ‘*.lib’: No such file or directory and I keep doing what is written on How to convert and call your own model through NPU | Khadas Documentation.
when I d ./build_vx.sh I got an error message /bin/bash: ./build_vx.sh: /bin/bash: bad interpreter: Permission denied So I change command into bash build_vx.sh I got an another error message
COMPILE /content/drive/MyDrive/Khadas/aml_npu_app/DDK_6.3.3.4/detect_library/model_code/detect_yolo_v3/yolov3_process.c
make: aarch64-linux-gnu-gcc: Command not found
makefile.linux:50: recipe for target ‘bin_r/yolov3_process.o’ failed
make: *** [bin_r/yolov3_process.o] Error 127

What should I do?

@DarrenQ Just support compile on VIM3.

@Frank So you mean all of the conversion sequence have to be done on VIM3? I’m sorry I have too many questions…

NPU Demo and source code - #45 by Archangel1235 on this docs you said that the conversion should be done on PC. So All of the conversion have to be done on PC? I’m confused…

@DarrenQ You need to convert it with PC. But you case code need to compile on VIM3. So after you convert your case code, you need to move it to VIM3

1 Like

THANKS a lot. I’m gonna try.

@Frank
Finally…
I nailed it!!! What a long journey…
Thanks for your kindness.