Closed xhsonny closed 5 years ago
What's the bin
file you mean?
Thanks for the quick reply.
https://github.com/kendryte/kendryte-standalone-sdk/blob/develop/README.md like hello_world.bin
that is built by sdk.
Another example is https://github.com/kendryte/tensorflow-workspace/tree/master/K210code. It has a mobilenetv1.c
which is k210code format and sdk will build a .bin
file from it.
You can write the .kmodel
to the flash and read it to memory in your program. Or you can use INCBIN
to embed the .kmodel
in your code.
Could you point me to an example how to load .kmodel
in C code? And an example for INCBIN
as well. Thanks!
For loading from flash: https://github.com/kendryte/kendryte-standalone-demo/blob/develop/face_detect_kmodel_flash/main.c
incbin.h
: https://github.com/kendryte/kendryte-standalone-demo/blob/develop/face_detect_kmodel_flash/incbin.h
Usage:
#define INCBIN_STYLE INCBIN_STYLE_SNAKE
#define INCBIN_PREFIX
#include "incbin.h"
INCBIN(model, "../src/yourproject/model.kmodel");
kpu_model_load_from_buffer(&task, model_data, NULL);
After kpu_model_load_from_buffer(&task, model_data, NULL);
, task
is initialized the same as kpu_task_mobilenetv1_init(&task);
(https://github.com/kendryte/tensorflow-workspace/blob/master/K210code/main.c#L84), right?
Hmm, another question. I am using the mobilenet_v1 model you guys released and the last layer is computed by manually calling kpu_global_average_pool
(https://github.com/kendryte/tensorflow-workspace/blob/master/K210code/main.c#L59) because of unsupported 7x7 pooling. In this case, the code needs scale and bias like https://github.com/kendryte/tensorflow-workspace/blob/master/K210code/main.c#L58. How can I get these numbers from .kmodel
?
If you are using preview5, you can convert model to .c
and find scale and bias in the comments in that .c
.
If you are using RC1, you don't need to do this manually, but the SDK compatible with RC1 isn't released yet.
Got it. Thanks a lot!
Hi,
I am reopening this issue because I want to check in if tensorflow-workspace
will be updated soon to use .kmodel
. It is using a .c
file now. Thanks.
Hi,
I would suggest you raise an issue at https://github.com/kendryte/tensorflow-workspace.
Also you can check https://github.com/kendryte/kendryte-standalone-demo/tree/develop/face_detect for kmodel
usage.
OK
With previous nncase, I had a workflow to use it to convert model to k210code and compile kendryte-standalone-sdk. Now nncase only ouputs k210modeo. What is the workflow to build a bin file?