I tried to follow the instruction, but I have difficulty with the path of the NCPU Project Main Folder in KL630 board.
4. Pre-process and Post-process Development
If the customized models need a customized pre-process or post-process on Kneron AI device, you can add the pre-process and post-process in the following files.
Go to NCPU Project Main Folder {KL630_SDK_FOLDER_PATH}/apps/vmf_nnm/solution/app_flow/pre_post_proc
Add your customized pre-process/post-process header file into include folder.
When I connect with KL630 using the putty, I don't know where the path of the NCPU Project Main Folder.
I think what you need to do now is modify the pre/post process and host_stream.ini.
For the pre/post process part, please refer to demo_customize_inf_single_model.c. (sdk_v2.5.5\sdk\apps\vmf_nnm\solution\app_flow\)
For the host_stream.ini part, you need to modify the "ModelId", "JobId" and "ModelPath" according to the setting of the model you converted at the beginning.
[nnm]
ModelPath = "nef/XXX"
ModelId = XXX # for yolo only - switch model(If there are multiple yolo models in one nef file)
Comments
Hi YOUNGJUN,
For instructions on Job ID, please see the following link:
Thanks.
Dear nick,
I tried to follow the instruction, but I have difficulty with the path of the NCPU Project Main Folder in KL630 board.
4. Pre-process and Post-process Development
If the customized models need a customized pre-process or post-process on Kneron AI device, you can add the pre-process and post-process in the following files.
When I connect with KL630 using the putty, I don't know where the path of the NCPU Project Main Folder.
Could you give me advice for me?
Could you give me advice for me?
Thank you.
Hi YOUNGJUN,
The folder path "{KL630_SDK_FOLDER_PATH}/apps/vmf_nnm/solution/app_flow/pre_post_proc" refers to a directory in the SDK package.
If you do not have permission to download the SDK, please contact the sales to obtain the necessary permissions. Thank you.
Thank you Ellis Yang,
I found it the folder.
I also have few questions,
When I review the manual ( 4.2 Develop Customized Data Input and Result Output in Vienna_NNM_Programming_Guide.pdf)
My model should be modifiled the Customized Data Input and Result Outut in KL630.
I think that my model (3D-CNN) shoulde be using solution_host_stream model.
Because I have to convert to images from Image sensor of KL630 with 15fps
to np array as follow.
I found the solution under following path:
KLM5S3-V2.5.5\SDK\Software_Toolkit\sdk_v2.5.5\sdk\apps\vmf_nnm\solution\solution_host_stream
but I'don know how to Input images from Image sensor of KL630 to NP array to make an input of the converted customized model
The conversion model is sucessful as you can see following figure.
Please, Guide how to Input images from Image sensor of KL630 to NP array to make an input of the converted customized model. Thank you.
Hi YOUNGJUN,
I think what you need to do now is modify the pre/post process and host_stream.ini.
For the pre/post process part, please refer to demo_customize_inf_single_model.c. (sdk_v2.5.5\sdk\apps\vmf_nnm\solution\app_flow\)
For the host_stream.ini part, you need to modify the "ModelId", "JobId" and "ModelPath" according to the setting of the model you converted at the beginning.
[nnm]
ModelPath = "nef/XXX"
ModelId = XXX # for yolo only - switch model(If there are multiple yolo models in one nef file)
JobId = XXX
Thank you, Nick Wang
As you guided, I review the demo_customize_inf_single_model.c of KL630 which is almost same
in 3.Add my_kl630_sin_example_inf.c
But, when I saw the code, this code is suitable for yolo model like this picture
For implentation of my model (3D CNN for video classification), not yolo,
Where can I change the pre-process in the code?
For example, I have to change the inf_config.num_image = 15 for 15fps input images.
Is there a another reference example for multiple input images as one input for inference model?
Thank you for your cooperation.
Hi YOUNGJUN,
"inf_config.model_id" This model ID is the value you set when you converted the model, please refer to the following link:
https://doc.kneron.com/docs/#toolchain/appendix/toolchain_webgui/#3-web-gui-introduction
And the FPS setting can be modified in the host_stream.ini.
[nnm]
...
Fps = 15 # Image input fps for NPU inference
Thank you for your support.
I changed the JobID and Model id, Fps in host_stream.ini and run it in KL 630.
But I have following errors
=============================================================================================
[app_header_send_inference] Error: Job ID 3002
[kdp2_host_stream_image_thread] Error: callback function error (100)
D/[VMF_VENC] venc_mgr_remove_venc() Venc removed, venc num(2)
D/[VBIND] VMF_BIND_Request() src status:3, is_request_resize:0, src_width:1920, src_height: 1080, src_stride: 1920, dwWidth: 1920, dwHeight: 1080, dwOldResolutionWidth(0), dwOldResolutionHeight(0)
D/[VMF_VENC] venc_mgr_remove_venc() Venc removed, venc num(1)
D/[VBIND] VMF_BIND_Request() src status:3, is_request_resize:1, src_width:1920, src_height: 1080, src_stride: 1920, dwWidth: 2560, dwHeight: 1920, dwOldResolutionWidth(0), dwOldResolutionHeight(0)
D/[VBIND] setup_resize_info()::76, found ptRsInfo->adwWidth[0] = 2560, ptRsInfo->adwHeight[0] = 1920, KeepRati o: 0
D/[VMF_VENC] venc_mgr_deref_vsrc() Vsrc removed, vsrc num(0)
D/[VMF_VENC] venc_mgr_remove_venc() Venc removed, venc num(0)
D/[VBIND] VMF_BIND_Request() src status:3, is_request_resize:1, src_width:1920, src_height: 1080, src_stride: 1920, dwWidth: 2560, dwHeight: 1920, dwOldResolutionWidth(0), dwOldResolutionHeight(0)
D/[VBIND] setup_resize_info()::76, found ptRsInfo->adwWidth[0] = 2560, ptRsInfo->adwHeight[0] = 1920, KeepRati o: 0
D/[VBIND] setup_resize_info()::216, unregistering 0 - ptRsInfo->adwWidth[0] = 2560, ptRsInfo->adwHeight[0] = 1 920, ptRsInfo->dwChannelNum = 1
I/[VMTK_VI] VMTK_VI_Stop
W/[VMF_ISP_MD] VSRC_ISP_MD_Release() invalid input: VMF_VSRC_STREAM_OUTPUT_T is NULL.
W/[VMF_ISP_MD] VSRC_ISP_MD_Release() invalid input: VMF_VSRC_STREAM_OUTPUT_T is NULL.
W/[VMF_ISP_MD] VSRC_ISP_MD_Release() invalid input: VMF_VSRC_STREAM_OUTPUT_T is NULL.
I/[VMTK_VI] VMTK_VI_Release
VideoCap release done !!
# [MemMgr][Info]: Start to use memory manager library version 4.2.0.0 !!
[MemMgr][Info]: Open EDMC device driver version 6.3.0.2 successful !!
Failed to locate configfs mount point, using default
uvc device is b8300000.dwc2 on bus gadget
uvc open succeeded, file descriptor = 4
dwc2 b8300000.dwc2: new device is high-speed
dwc2 b8300000.dwc2: new address 5
g_webcam gadget: high-speed config #1: Video
g_webcam gadget: uvc_function_set_alt(0, 0)
g_webcam gadget: reset UVC Control
g_webcam gadget: uvc_function_set_alt(1, 0)
g_webcam gadget: uvc_function_set_alt(1, 0)
g_webcam gadget: uvc_function_set_alt(1, 0)
UVC_EVENT_SETUPdwc2 b8300000.dwc2: dwc2_hsotg_ep_sethalt(ep c2e3f410 ep0, 1)
=============================================================================================
I think the JobID error is caused by image size of the My model input (3D-CNN: (32,32,15)),
But I just build kp_firmware_host_stream in PLUS and copy it to the KL630 Board.
Do I have to resize Input images before re-building kp_firmware_host_stream??
I modified c file and its header
in KLM5S3-V2.5.5/SDK/Software_Toolkit/sdk_v2.5.5/sdk/apps/vmf_nnm/solution/app_flow/my_kl630_sin_example_inf.c
===================================================================================================
static int inference_video_classification(my_kl630_sin_example_header_t *_input_header,
struct classifier_result_s * _3DCNN_result/* output */)
{
// config image preprocessing and model settings
VMF_NNM_INFERENCE_APP_CONFIG_T inf_config;
memset(&inf_config, 0, sizeof(VMF_NNM_INFERENCE_APP_CONFIG_T)); // for safety let default 'bool' to 'false'
// image buffer address should be just after the header
inf_config.num_image = 15; // for 15fps
inf_config.image_list[0].image_buf = (void *)((uint32_t)_input_header + sizeof(my_kl630_sin_example_header_t));
inf_config.image_list[0].image_width = _input_header->width;
inf_config.image_list[0].image_height = _input_header->height;
inf_config.image_list[0].image_channel = 3; // assume RGB565
inf_config.image_list[0].image_format = KP_IMAGE_FORMAT_RGB565; // assume RGB565
inf_config.image_list[0].image_norm = KP_NORMALIZE_KNERON; // this depends on model
inf_config.image_list[0].image_resize = KP_RESIZE_ENABLE; // default: enable resize
inf_config.image_list[0].image_padding = KP_PADDING_DISABLE; // default: disable padding
inf_config.model_id = MY_KL630_MODEL_ID; // this depends on model
//inf_config.post_proc_func = classifier_post_process;
// set up fd result output buffer for ncpu/npu
inf_config.ncpu_result_buf = (void *)_classifier_result;
return VMF_NNM_Inference_App_Execute(&inf_config);
}
Hi YOUNGJUN,
I see that you have posted another question. https://www.kneron.com/forum/discussion/466/kp-firmware-host-stream-build-file-problems#latest
If there are no more questions here, we will reply in that one.
Thanks !
Hi Nick Wang,
It's better to move: https://www.kneron.com/forum/discussion/466/kp-firmware-host-stream-build-file-problems#latest
Thank you.