Created
May 5, 2023 08:34
-
-
Save rahulremanan/7f6c190efe19cf1ae0a15ba90fe63799 to your computer and use it in GitHub Desktop.
A simple inference API for the post-training dynamic range model quantization
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
class TfLiteModel(): | |
def __init__(self, model): | |
self.model = model | |
def predict(self, X, **kwargs): | |
_tflite_model = dynamic_range_quantize_model(self.model) | |
_x = np.asarray(X); assert len(X.shape)>=2 | |
_tflite_out_preds = list(map(lambda i : tflite_preds(np.expand_dims(_x[i,:],axis=0), _tflite_model), range(_x.shape[0]) )) | |
return np.asarray(_tflite_out_preds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment