Skip to content

Instantly share code, notes, and snippets.

@nbortolotti
Created December 9, 2019 21:23
Show Gist options
  • Save nbortolotti/2b799f6d9879120b28a62ec85c1b9249 to your computer and use it in GitHub Desktop.
Save nbortolotti/2b799f6d9879120b28a62ec85c1b9249 to your computer and use it in GitHub Desktop.
import numpy as np
import tflite_runtime.interpreter as tflite
interpreter = tflite.Interpreter(model_path="converted_model.tflite") # change the tflite model
interpreter.allocate_tensors()
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
# Test model
new_specie = np.array([7.9,3.8,6.4,2.0]) # general example to predict
input_data = np.array(np.expand_dims(new_specie, axis=0), dtype=np.float32)
interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()
output_data = interpreter.get_tensor(output_details[0]['index'])
print(output_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment