Update inference.py
Browse files- inference.py +11 -0
inference.py
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import joblib
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
class Model:
|
| 5 |
+
def __init__(self):
|
| 6 |
+
self.model = joblib.load("mnist_svm.pkl") # Change for logistic and RF
|
| 7 |
+
|
| 8 |
+
def predict(self, inputs):
|
| 9 |
+
inputs = np.array(inputs).reshape(1, -1)
|
| 10 |
+
digit = self.model.predict(inputs)[0]
|
| 11 |
+
return {"digit": int(digit)}
|