Mr00Magician
commited on
Commit
•
45df5ba
1
Parent(s):
0eae1ca
added initial files
Browse files- CNN_extended_dataset.h5 +3 -0
- app.py +22 -0
- requirements.txt +5 -0
CNN_extended_dataset.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fe735ef417f2787dc34933069aa19843b4ed6d6c930da3441ea95a32d20af8b4
|
3 |
+
size 2972272
|
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request
|
2 |
+
import numpy as np
|
3 |
+
import tensorflow as tf
|
4 |
+
import cv2
|
5 |
+
|
6 |
+
app = Flask(__name__)
|
7 |
+
|
8 |
+
loaded_CNN = tf.keras.models.load_model('CNN_extended_dataset.h5')
|
9 |
+
|
10 |
+
@app.route('/get-prediction', methods = ['POST'])
|
11 |
+
def get_prediction():
|
12 |
+
img_array = request.json.get('data')
|
13 |
+
img_array = np.array(img_array, dtype=np.uint8).reshape(400, 400)
|
14 |
+
img_array = cv2.resize(img_array, (28, 28))
|
15 |
+
img_array = img_array.reshape(1, 28, 28)
|
16 |
+
|
17 |
+
pred = loaded_CNN.predict([img_array])
|
18 |
+
final_pred = np.argmax(pred)
|
19 |
+
return str(final_pred)
|
20 |
+
|
21 |
+
if __name__ == '__main__':
|
22 |
+
app.run()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Flask
|
2 |
+
Jinja2==3.1.2
|
3 |
+
numpy
|
4 |
+
opencv-python
|
5 |
+
tensorflow
|