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

OpenMV related project discussion.
uraibeef
Posts: 4
Joined: Sun Apr 28, 2019 5:56 am

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

Postby uraibeef » Sun Apr 28, 2019 6:04 am

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
User avatar
kwagyeman
Posts: 3132
Joined: Sun May 24, 2015 2:10 pm

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

Postby kwagyeman » 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.
Nyamekye,
uraibeef
Posts: 4
Joined: Sun Apr 28, 2019 5:56 am

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

Postby uraibeef » Mon Apr 29, 2019 12:22 pm

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.
uraibeef
Posts: 4
Joined: Sun Apr 28, 2019 5:56 am

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

Postby uraibeef » Thu May 02, 2019 1:44 am

@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?
User avatar
kwagyeman
Posts: 3132
Joined: Sun May 24, 2015 2:10 pm

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

Postby kwagyeman » Thu May 02, 2019 12:18 pm

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.
Nyamekye,
uraibeef
Posts: 4
Joined: Sun Apr 28, 2019 5:56 am

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

Postby uraibeef » Tue May 14, 2019 2:52 am

Do u have any update?
User avatar
kwagyeman
Posts: 3132
Joined: Sun May 24, 2015 2:10 pm

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

Postby kwagyeman » Wed May 15, 2019 12:41 am

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.
Nyamekye,
perdasilva
Posts: 2
Joined: Wed Jun 26, 2019 3:46 pm

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

Postby perdasilva » Wed Jun 26, 2019 4:09 pm

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 ^^
User avatar
kwagyeman
Posts: 3132
Joined: Sun May 24, 2015 2:10 pm

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

Postby kwagyeman » Thu Jun 27, 2019 1:58 am

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.
Nyamekye,
perdasilva
Posts: 2
Joined: Wed Jun 26, 2019 3:46 pm

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

Postby perdasilva » Thu Jun 27, 2019 2:22 am

No worries. Do your thing and chime back when you have any news. Thanks again for all your effort!

Return to “Project Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests