Add basic coreml and mlkit conversion scripts

This commit is contained in:
Piv
2021-03-29 18:58:16 +10:30
parent f3fc0f8fbb
commit f598005b73
2 changed files with 18 additions and 3 deletions

View File

@@ -1,9 +1,9 @@
import coremltools as ct
def convert_coreml(saved_model_path):
mlmodel = ct.convert(saved_model_path)
mlmodel.save('../mobilenet_nnconv.mlmodel')
def convert_coreml(model_path, save_path='../mobilenet_nnconv5.mlmodel'):
mlmodel = ct.convert(model_path)
mlmodel.save(save_path)
if __name__ == '__main__':

15
tensorflow_lite.py Normal file
View File

@@ -0,0 +1,15 @@
import tensorflow as tf
def convert_tensorflow_lite(model_path, save_path='../mobilenet_nnconv5.tflite'):
# Convert the model
converter = tf.lite.TFLiteConverter.from_saved_model(model_path) # path to the SavedModel directory
tflite_model = converter.convert()
# Save the model.
with open('model.tflite', 'wb') as f:
f.write(tflite_model)
if __name__ == '__main__':
convert_tensorflow_lite('../mobilenet-nnconv5-e12-experimental')