Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can it run on ESP-CAM with tensorflow lite? #67

Open
manjrekarom opened this issue Jun 29, 2020 · 5 comments
Open

Can it run on ESP-CAM with tensorflow lite? #67

manjrekarom opened this issue Jun 29, 2020 · 5 comments

Comments

@manjrekarom
Copy link

This may be a bit off-topic not sure though. So I am trying to do face recognition on ESP-CAM with 4MB flash.

At the moment the size of weights file for this model is 8MB so I am not able to put it on the device's flash which is only 4MB.
I am thinking about pruning/distilling the model further to reduce its size but I have not done it prior to this.

If possible can you share your ideas how can that be done and if it'll work? My last option is to make a custom network and training it myself. Welcoming other ideas.

Thanks!

@mvhsin
Copy link

mvhsin commented Jul 8, 2020

Hi @manjrekarom ,

You can try with MobileFacenet-S, which model size will be around 1.4MB when quantized with TFlite with the following cmd:

tflite_convert --output_file tf-lite/MobileFacenet_uint8_128.tflite
--graph_def_file tf-lite/MobileFacenet.pb
--input_arrays "input"
--input_shapes "1,112,112,3"
--output_arrays output
--output_format TFLITE
--mean_values 128
--std_dev_values 127.5
--default_ranges_min 0
--default_ranges_max 255
--inference_type QUANTIZED_UINT8
--inference_input_type QUANTIZED_UINT8

But I met the other issue related to accuracy.
The result seems not correct with the quantized model, please kindly share the information if you have the idea. Many thanks!

@manjrekarom
Copy link
Author

manjrekarom commented Jul 9, 2020

Hi @mvhsin ! Thanks for your reply.

Can I get a link to pretrained MobileFacenet-S?
The model that we had quantized was also about 1.5MB in size after quantization but after converting it back to .cc file it grew to about 6x - 8x (~8MB).

Sure. I will share if I find something relevant.

@mvhsin
Copy link

mvhsin commented Jul 9, 2020

Hi @manjrekarom ,

The author of MobileFacenet mentioned in the paper.

remove the linear 1 × 1 convolution layer afterthe linear GDConv layer from MobileFaceNet, the resulting network of which is called MobileFaceNet-M. From MobileFaceNet-M, removing the 1 × 1 convolution layer before the linear GDConv layer produces the smallest network called MobileFaceNet-S.
Sorry I am not sure about *.cc file.
Is that done by TF-lite microcontroller?

@manjrekarom
Copy link
Author

Oh thanks I'll take a look.

Yes it is for TF-Lite microcontrollers. The FlatBuffer obtained from an initial tf model, is converted to a C byte array.

This C file is taking up ~7x space (1.5 -> ~8MB). So we need an even smaller model. The options I feel I am left with are network pruning, knowledge distillation and training an even smaller custom architecture similar to MobileFaceNet.

@mvhsin
Copy link

mvhsin commented Jul 10, 2020

Same here! Thanks for the info of TF-lite microcontroller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants