VIM3 NPU max detect target num is capped to 10

Hi,
when using the default NPU Detect library (libnn_detect.so) with YoloV3 I would like to get more than 10 targets returned by the Npu, especially when elaborating crowed scenes.
I tried to increment MAX_DETECT_NUM to 20 but I always got:
resultData.detect_num=10
I tried to rebuild the lib with the modified
#define MAX_DETECT_NUM 20
in the nn_detect_utils.h
without any remarkable results.

Please, where’s the config to touch?
BR
F

I’ve also found that when setting MAX_DETECT_NUM to 20 results are not consistent related to positions values. Below the results I get from the same frame just changing the MAX_DETECT_NUM

--- #define MAX_DETECT_NUM 20 ---
resultData.detect_num=10
0:7, truck: 71% , left:0 right:0 top:0 bottom:0
1:7, truck: 87% , left:0 right:0 top:0 bottom:0
2:7, truck: 95% , left:-9.85562e-32 right:-4.51638e-38 top:1.77965e-43 bottom:1.1911e-43
3:0, person: 68% , left:4.2039e-45 right:-9.85575e-32 top:0 bottom:1.77965e-43
4:0, person: 56% , left:-5.67175e-09 right:-9.85659e-32 top:1.1911e-43 bottom:1.77965e-43
5:0, person: 90% , left:7.64554e-28 right:3.46415e-41 top:1.01212e-25 bottom:0
6:0, person: 85% , left:1.21023e+25 right:4.98979e-08 top:3.64448e+09 bottom:0
7:0, person: 94% , left:-9.85592e-32 right:-4.14189e-26 top:1.77965e-43 bottom:1.77965e-43
8:0, person: 88% , left:0 right:0 top:0 bottom:0
9:0, person: 98% , left:-4.37205e-42 right:1.4013e-45 top:1.77965e-43 bottom:0

--- #define MAX_DETECT_NUM 10 ---
resultData.detect_num=10
0:7, truck: 54% , left:0.299752 right:0.371868 top:0.0897302 bottom:0.203929
1:7, truck: 85% , left:0.217238 right:0.309836 top:0.212753 bottom:0.359387
2:7, truck: 91% , left:0.0743673 right:0.216194 top:0.288613 bottom:0.574671
3:0, person: 56% , left:0.217465 right:0.261205 top:0.412162 bottom:0.558797
4:0, person: 82% , left:0.334628 right:0.378368 top:0.422098 bottom:0.568733
5:0, person: 56% , left:0.63767 right:0.68141 top:0.606651 bottom:0.753286
6:0, person: 94% , left:0.375085 right:0.418825 top:0.667796 bottom:0.81443
7:0, person: 95% , left:0.959027 right:0.993092 top:0.648967 bottom:0.83725
8:0, person: 85% , left:0.627391 right:0.671131 top:0.724031 bottom:0.870666
9:0, person: 88% , left:0.72342 right:0.76716 top:0.715144 bottom:0.861779

@fguerzoni Maybe you need to view the source code of demo . The source code after conversion still needs to be modified in many places.

Thank you for quick reply.
Replacing libnn_yolo_v3.so with the new one I get the following errors:

E Detect_api:[check_and_set_function:176]dlopen libnn_yolo_v3.so failed!
E Detect_api:[det_set_model:217]ModelType so open failed or Not support now!!

I’ll check them next days.
BR

@fguerzoni Did you execute that command to generate this error? Can you provide a complete log ?

The issue auto-solved when I rebuilt the application binary to integrate the code line to set the log level.
Now it works.

Here’s the log:

W Detect_api:[det_set_log_level:19]Set log level=4
W Detect_api:[det_set_log_level:21]output_format not support Imperfect, default to DET_LOG_TERMINAL
W Detect_api:[det_set_log_level:26]Not exist VSI_NN_LOG_LEVEL, Setenv set_vsi_log_error_level
D Detect_api:[det_set_log_config:335]Leave, level:4
D Detect_api:[det_set_model:203]Enter, modeltype:2
Detaching from process 4240
D Detect_api:[check_and_set_dev_type:145]Read Cpuinfo:
processor	: 0
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4
...
Serial		: 290b100001190b00000437304e424e50
Hardware	: Khadas VIM3
D Detect_api:[check_and_set_dev_type:146]290 index=1096
I Detect_api:[check_and_set_dev_type:154]set_dev_type REVB and setenv 1
D Detect_api:[check_and_set_function:169]Enter, dlopen so:libnn_yolo_v3.so
D Detect_api:[check_and_set_function:197]Leave, dlopen so:libnn_yolo_v3.so, ret=0
I Detect_api:[det_set_model:221]Start create Model, data_file_path=nn_data
D Detect_api:[det_get_model_size:245]Enter, modeltype:2
D Detect_api:[det_get_model_size:256]Leave, modeltype:2
I Detect_api:[det_set_model:237]input_ptr size=519168, addr=b01c3010
D Detect_api:[det_set_model:239]Leave, modeltype:2
D Detect_api:[det_get_model_size:245]Enter, modeltype:2
D Detect_api:[det_get_model_size:256]Leave, modeltype:2
D Detect_api:[det_set_input:262]Enter, modeltype:2
D Detect_api:[det_get_model_size:245]Enter, modeltype:2
D Detect_api:[det_get_model_size:256]Leave, modeltype:2
D Detect_api:[det_set_input:280]Leave, modeltype:2
D Detect_api:[det_get_result:286]Enter, modeltype:2
D Detect_api:[det_get_result:303]Leave, modeltype:2

To recap: I just had to rebuild both

  • libnn_detect.so
  • libnn_yolo_v3.so

with modified
#define MAX_DETECT_NUM 20
in the nn_detect_utils.h

thanks and regards
F

@fguerzoni Hello, I was also trying to do object detection using Yolov3. I have trained my model with 3 classes, and I used SDK to convert it for NPU compatability. Now, when I try to detect objects, I am not getting any error, and there is no predicition happening.
I did the inference on PC and there my model is able to predict the objects. Do you have any suggestions for me to fix the problem?

Please find the attached screenshot of the output.