Train, Convert, Run MobileNet on Sipeed MaixPy and MaixDuino !


can you post the pb to check?



please do not use PAD method, use SpaceToBatchND instead, here is the example:


Since I’m using Keras I don’t see where the PAD method come from and I’m using your modified that has ZeroPadding2D((1,1),(1,1))
Can you tell me how to replace PAD with SpaceToBatchND?


You may need to update keras to the latest version.


2.2.4 is already installed.


I reinstalled the entire conda environment to isolate and it seems that PAD comes from layers.ZeroPadding2D :confused:
So how did you get it working @Zepan? What version of … everything are you using? Is there another way to do ZeroPadding which is K210 compatible?


strange, did you follow the step and use the tools in my github?
in my workspace, there have no problem
should I upload docker image?


Yes I followed every step and used all your tools.
A docker could help yes but only a temporarily fix as it’s ultimately better to know the root cause so I attached the keras .h5 file as well as the .py that does the training. Could you have a look? Maybe the reason lies somewhere there.


Could you include the proper version of NCC with your Maix_Toolbox?
For linux and windows.
The ncc.dll properties show version 1.0.0 but shows v 0.1.0rc5 and above in the thread, you talk about a version 0.4 … which is confusing


Wu corrected the get nnc to the latest and now it’s converting a kmodel no problem :fist:

But the kmodel is about 4MB, not 2.7MB, is there a way to know what is eating up so much space?

Also loading never ends and boxing the task = kpu.load(0x200000) with

	task = kpu.load(0x200000)
	lcd.draw_string(100,112,"ERROR: "%e)

Doesn’t show any error so:

  1. how do we detect kpu.loading progress?
  2. how do we catch errors?


Hi, I use 0.75x version, but you use 1.0x version, so mine is 2.7MB, and yours is 4MB
not implement catch for kpu load yet, but you can check it by your self.
It will output error mag if load failed.


I use mobilenet_7_5_224_tf_no_top as well. I think that’s because the new top is 2x dense 1024 and a 512, that’s 1.5MB additional I think. I’ll simplify :sweat_smile: … and done, I replaced with dense 512+128+32 and now all is good, it fits and it’s quite accurate for obstacles.

Regarding error catch, I don’t understand what you suggest, can you give an example?
Also what happens if the model is too large to fit in?
Ideally we’d prefer the system rebooth rather than a freeze.


too big model will case malloc failed, and return error.


try/catch doesn’t catch the error, I guess you’ll add error handling in the next firmware.



How did you fix the PAD problem? I tried updating ncc using the following script, but I still get the error.

mkdir -p ncc
mkdir -p workspace
mkdir -p images
mkdir -p log
cd ncc
tar xJvf ncc-linux-x86_64.tar.xz
rm ncc-linux-x86_64.tar.xz
echo "download nncase ok!"


With this version of NCC the likely cause is that you aren’t using the modified version of so it’ll complain that you have a non uniform padding.


Thanks for your reply.
The code is still not working as intended, it keeps saying layer not supported.
Even when using the keras model supplied on the sipeed github (mbnet75.h5) I get the following error when trying to convert to .kmodel:
Fatal: Layer Conv2d is not supported
I am running tensorflow 1.13.1 and keras 2.2.4.
I also use the as provided on the sipeed github.
What am I doing wrong?


did you update newest nncase?


Yes, I am using v0.1.0-rc5