alessandrocapotondi / mobilenet_v1_stmcube_ai

Mobilenet v1 (3,128,128, alpha=0.25) on STMH7 using STMCube AI
Apache License 2.0
10 stars 2 forks source link

MobileNetV2 #1

Open EduardShaid opened 5 years ago

EduardShaid commented 5 years ago

Thanks for the example, but a number of questions arise:

  1. Will such a method work correctly on an already trained MobileNet model ? After all, we violated the internal architecture of the model. Or do I need to train this model again ?

  2. You have an example on the MobileNet model. Will your method work for MobileNetV2 ?

alessandrocapotondi commented 5 years ago

Ciao @EduardShaid,

This project starts from a pre-trained Mobilenet model downloaded by the module keras.applications. You can find the script here: https://github.com/alessandrocapotondi/mobilenet_stmcube_ai/blob/master/keras_model/keras_mobilenet_stm_cubemx_ai.ipynb

The main problem is that not all the layers are supported by STMCubeMX.AI. For example it do not support ReLU directly. Such layers require to be converted to Activation('relu'). This operation is done as well by the script above.

By the way, at the moment I am not able to link the generated code because contrary to what STMCubeMX.AI the activations do not inside the SRAM...I am posting an issue right now on the STM Community Forum.

About the MobileNetV2, I did test it, so I do not have so much feedbacks. Sorry.

Alessandro

EduardShaid commented 5 years ago

The launch of the test_and_compare_models(...) function shows that the old model and the new one work differently ! It turns out that after the transformation of the model, it stops working correctly. Is it so ? and is it necessary to retrain the model ?

alessandrocapotondi commented 5 years ago

Ciao @EduardShaid,

You don't need to retrain the model. There was an issue on the conversion. I was using unbounded relu activations while the pretrained model was based on relu6.

I fixed the model and the script on the last commit 1adeb45.

Thanks, Alessandro

EduardShaid commented 5 years ago

Yes, thank you, the example works. I have another question about MobilenetV2: can I use the already trained MobilenetV2 model, but converted by your method, to recognize faces on the STM32 platform ?

EduardShaid commented 5 years ago

Can you give an example of your approach for MobileNetV2 ? It does not work out for me.