Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulremanan/5a31d31f9d1c0e4382cc75889301cf59 to your computer and use it in GitHub Desktop.
Save rahulremanan/5a31d31f9d1c0e4382cc75889301cf59 to your computer and use it in GitHub Desktop.
Model inference using a post-training dynamic range quantized model
def tflite_preds(X, tflite_model):
_interpreter = tf.lite.Interpreter(model_content=tflite_model)
_interpreter.allocate_tensors()
_input_details = _interpreter.get_input_details()
_output_details = _interpreter.get_output_details()
_interpreter.set_tensor(_input_details[0]['index'], tf.cast(X, dtype=tf.float32))
del X; _interpreter.invoke()
_out_pred = _interpreter.get_tensor(_output_details[0]['index'])
return np.squeeze(np.asarray(_out_pred), axis=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment