Android,NPU] vsi_nn_verifyGraph fail at yolov3-tiny

Hello, I’m making android app for logo detection.
My first try is yolov3-416 but detection speed is too slow(vsi_nn_RunGraph consumes 150ms at 608x608, 90ms at 416x416 ), so I tried yolov3-tiny but problem occured. vnn_CreateYoloTiny() successed, but vsi_nn_verifyGraph fail.

Is this DDK version problem? I saw your updated aml_npu_app(yolov3-tiny demo added) and DDK version of that is 6.3.3.4. Khadas Android repo’s NPU DDK version is 6.3.2.5(/vendor/amlogic/common/npu). If cause is that, Can I get updated version of NPU DDK so files or repo of Android? Or another cause?

ADD : This error caused by different output tensor size. I fixed and RunGraph time is 10ms.

@khs971 all is v6.3.3.4, v6.3.2.5 is a old version .Where did you get the DDK ?

See Khadas android git repo’s /vendor/amlogic/common/npu version file.

@khs971 You should follow this link to get the DDK .

how to run yolov3 at android?

My english is awful sorry I’ll make it clear.

  1. I have 6.3.3.4 SDK(including acuity toolkit) and already made my .nb file by this sdk.
  2. In Khadas android AOSP source tree, there is 6.3.2.5 version NPU library. (like libGAL.so, galcore.ko…)

I made some jni code using NPU so library and build it by ndk-build, and load library in android app.
But I think there is a way porting Android.Neuralnetworks api, not using jni.

@khs971 update you firmware . https://dl.khadas.com/Firmware/VIM3/Android/VIM3_Pie_V200319.7z

感谢,可以中文交流的哈:grinning:

@bingbingo
I’m korean and I have no chinese language skill sorry.
Running NPU in Android is very annoying job. You have to fixed some selinux permission for using galcore char device and libovxlib. NPU App needs permission for using this resource. So, you have to build android AOSP. selinux permission file located this directory.
(AOSP source directory)/common/sepolicy/
I decided make my app to system app and give permission to system apps.

+++ b/common/public.libraries.txt
@@ -1,3 +1,14 @@
libsystemcontrol_jni.so
libtv_jni.so
libscreencontrol_jni.so
+libc++.so
+libCLC.so
+libcutils.so
+libjpeg.so
+libGAL.so
+libLLVM_viv.so
+libOpenCL.so
+libOpenVX.so
+libOpenVXU.so
+libovxlib.so
+libVSC.so

+++ b/common/sepolicy/file_contexts
@@ -332,6 +332,14 @@
/vendor/lib(64)?/libjnifont_tv.so u:object_r:vendor_app_file:s0
/vendor/lib(64)?/libscreencontrolclient.so u:object_r:vendor_app_file:s0
/vendor/lib(64)?/libsystemcontrolclient.so u:object_r:vendor_app_file:s0
+/vendor/lib(64)?/libVSC.so u:object_r:vendor_app_file:s0
+/vendor/lib(64)?/libCLC.so u:object_r:vendor_app_file:s0
+/vendor/lib(64)?/libGAL.so u:object_r:vendor_app_file:s0
+/vendor/lib(64)?/libLLVM_viv.so u:object_r:vendor_app_file:s0
+/vendor/lib(64)?/libOpenCL.so u:object_r:vendor_app_file:s0
+/vendor/lib(64)?/libOpenVX.so u:object_r:vendor_app_file:s0
+/vendor/lib(64)?/libOpenVXU.so u:object_r:vendor_app_file:s0
+/vendor/lib(64)?/libovxlib.so u:object_r:vendor_app_file:s0

+++ b/common/sepolicy/system_app.te
@@ -87,3 +87,4 @@ allow system_app param_tv_file:file { create open read write setattr getattr loc
allow system_app vendor_video_device:chr_file {open ioctl read write};
allow system_app debugfs_mali:dir search;
+allow system_app galcore_device:chr_file { open ioctl read write };