nnabla_cli converstion to output.nnb cannot be loaded on Spresense board
I am trying to use a trained model on a Sony Spresense board, however after training and converting my nnp file to nnb, the Spresense board cannot load the file. Following this example:
https://github.com/sony/nnabla-examples/tree/master/mnist-collection
The command I used to convert the nnp to nnb file:
nnabla_cli convert input.nnp output.nnb
Using the Arduino IDE, I loaded this example https://github.com/sonydevworld/spresense-arduino-compatible/blob/master/Arduino15/packages/SPRESENSE/hardware/spresense/1.0.0/libraries/DNNRT/examples/number_recognition/number_recognition.ino
Using the following library:
#include <DNNRT.h>
But the program gets stuck in this line
int ret = dnnrt.begin(nnbfile);
If I train using the Sony cloud https://dl.sony.com, the nnb file works fine with the Spresense board. Is there something I'm doing wrong? Thanks!
I have no SPRESENSE on hand, so I cannot now make sure
my idea is the direct solution against your issue.
I imagine your issue is because NNB supports minibatch inference.
What is confusing is, probably, the default bath size is not 1 in nnabla_cli.
Thus, could you try the following command?
nnabla_cli convert -b 1 input.nnp output.nnb
I'm sorry if my idea is not enough to help you :(
Thank you for your reply. Unfortunately it didn't work.
I also tried the following but didn't work as well.
nnabla_cli convert -I NNP -O NNB -b 1 resnet_result.nnp output.nnb
If you are able to access the build process of https://dl.sony.com/, then taking a look at how the nnb file is created could give me a clue since exporting an nnb file from there works on the Spresense board. Thanks!
instead of nnabla_cli convert -b 1 input.nnp output.nnb, do nnabla_cli convert -b 1 --api 1 input.nnp output.nnb
This output.nnb will work in spresense
Thank you for providing valuable information!
When spresense was introduced, nnabla's api level was 1, so it only -b 1 option worked fine.
But we updated api level to add more functions, so we have needed to add --api option when converting.
Sorry for missing information.