Page 1 of 1

How to convert model.h5 to model.network for OpenMV

Posted: Sun Apr 28, 2019 6:04 am
by uraibeef
I want to convert my images classification model (model.h5) from keras to .network type and deploy it to the OpenMV M7

(My model is used to classify A-Z, 0-9 on OpenMV)

What should I do?

thank you very much

Re: How to convert model.h5 to model.network for OpenMV

Posted: Sun Apr 28, 2019 12:43 pm
by kwagyeman
Hi, I'm about to get tensorflow lite running on the OpenMV Cam. I'm aiming to get the PR done for this in the next 3 days or so. Once I do that you can take any tensor flow model and run it on the M7/H7. Tensorflow will only support depthwise convolutions and fully connected however. So, you want to use transfer learning from mobilenet.

Re: How to convert model.h5 to model.network for OpenMV

Posted: Mon Apr 29, 2019 12:22 pm
by uraibeef
kwagyeman wrote:
Sun Apr 28, 2019 12:43 pm
Hi, I'm about to get tensorflow lite running on the OpenMV Cam. I'm aiming to get the PR done for this in the next 3 days or so. Once I do that you can take any tensor flow model and run it on the M7/H7. Tensorflow will only support depthwise convolutions and fully connected however. So, you want to use transfer learning from mobilenet.
thank you for your answer, I'm very excited to use it.

Re: How to convert model.h5 to model.network for OpenMV

Posted: Thu May 02, 2019 1:44 am
by uraibeef
@kwagyeman, Is this the git you mean?
https://github.com/openmv/tensorflow-lib

And if it's yes, How can I use it? Do you have a example to use?

Re: How to convert model.h5 to model.network for OpenMV

Posted: Thu May 02, 2019 12:18 pm
by kwagyeman
I'm almost done getting tensor flow working on the camera. The library is just for other folks wanting to use the code on their custom MCUs.

Anyway, I'm actively working on the library. I've gotten past most compile issues and should be getting it integrated into our firmware soon. I'll have as a first demo mobilenet running on the OpenMV Cam.

Re: How to convert model.h5 to model.network for OpenMV

Posted: Tue May 14, 2019 2:52 am
by uraibeef
Do u have any update?

Re: How to convert model.h5 to model.network for OpenMV

Posted: Wed May 15, 2019 12:41 am
by kwagyeman
Sorry, this has gotten bogged down.

The code has been pushed to a branch on my github fork here:

https://github.com/kwagyeman/openmv/tree/kwabena/add_tf

I was about to have mobilnet working. However, google's default memory allocator uses up all of our RAM and is not efficient. It allocates very layer for the net in RAM instead of just the two layers its actually working on. As such, I don't have a network to demo. So, I have to write a guide for how to train a tensor flow model. Anyway, I have not found time for this because the email load is quite every right now.

If you have a tflite network that's been trained and quantizied I may be able to run it and debug my code however. That would help me. Since I'm just a wrapper around tensor flow and tensor flow is already verified I could get this released to everyone more quickly then. I'd need a network that does something obvious however.

Re: How to convert model.h5 to model.network for OpenMV

Posted: Wed Jun 26, 2019 4:09 pm
by perdasilva
Hi,

I've tried to put together a tflite model for recognizing american sign language.
I've used the data from kagle here: https://www.kaggle.com/grassknoted/asl-alphabet

I've tried to do some transfer learning from mobilenet from imagenet weights. I just attached a few simple layers at the end and changed the number of categories.

My jupyter notebook: https://www.dropbox.com/s/q1t9u99d2mhtp ... ipynb?dl=0
The resulting tflite file: https://www.dropbox.com/s/8wu7qgxm8k8ea ... flite?dl=0

It's not particularly small, and when I xdd -i against it, the size grew considerably. I don't know if that is normal.

I'm fairly new to all this. It would be great to get some hints on how to get the model on the cam =)

thanks for all your work ^^

Re: How to convert model.h5 to model.network for OpenMV

Posted: Thu Jun 27, 2019 1:58 am
by kwagyeman
Honestly, I really haven't had time to deal with this. Me an Ibrahim are being hit by a bunch of stuff in the background. I was hoping Google would provide some more support but like normal we aren't big enough to warrant when we email folks for action to quickly happen.

The next firmware release will have TF support however. We just finished shipping all the Kickstarter orders and getting the store stable so I can focus on development work again.

Re: How to convert model.h5 to model.network for OpenMV

Posted: Thu Jun 27, 2019 2:22 am
by perdasilva
No worries. Do your thing and chime back when you have any news. Thanks again for all your effort!