Skip to content

Instantly share code, notes, and snippets.

@hayunjong83
Created November 9, 2021 09:27
Show Gist options
  • Save hayunjong83/8637cdde4366c9908f394e39c5ce7d06 to your computer and use it in GitHub Desktop.
Save hayunjong83/8637cdde4366c9908f394e39c5ce7d06 to your computer and use it in GitHub Desktop.
udacity TensorFlow Lite Chap.2-3 example code
import tensorflow as tf
import pathlib
# Load the MobileNet tf.keras model
model = tf.keras.applications.MobileNetV2(weights="imagenet", input_shape=(224,224,3))
# Convert the model
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
# Save the model
tflite_model_file = pathlib.Path('/tmp/foo.tflite')
tflite_model_file.write_bytes(tflite_model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment