OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.63k stars 2.19k forks source link

How to use trained .h5 model in tflite format for Android #535

Open codebugged opened 4 years ago

codebugged commented 4 years ago

Dear Sir @OlafenwaMoses

Thank you so much for this awesome library.

I have trained the model for custom object detection and now wish to use in an android app. How can I convert it into tfLite Model and embed it into an Android APP?

Thanks in advance

Overdoze47 commented 3 years ago

You can convert your model with: `import tensorflow as tf

Convert the model

converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir) # path to the SavedModel directory tflite_model = converter.convert()

Save the model.

with open('model.tflite', 'wb') as f: f.write(tflite_model)`

https://www.tensorflow.org/lite/convert