Last active
May 5, 2023 08:36
-
-
Save rahulremanan/5a31d31f9d1c0e4382cc75889301cf59 to your computer and use it in GitHub Desktop.
Model inference using a post-training dynamic range quantized model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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