jordancaraballo commited on
Commit
bb7d5f6
1 Parent(s): 7398795

Adding model

Browse files
Files changed (1) hide show
  1. model.py +22 -0
model.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # from tensorflow.keras.models import load_model
2
+ # from tensorflow.keras.preprocessing.image import img_to_array, load_img
3
+ import numpy as np
4
+ import streamlit as st
5
+
6
+ @st.cache(allow_output_mutation=True)
7
+ def get_model():
8
+ model = load_model('Model/Traffic_Sign_Classifier_CNN.hdf5')
9
+ print('Model Loaded')
10
+ return model
11
+
12
+
13
+ def predict(image):
14
+ loaded_model = get_model()
15
+ image = load_img(image, target_size=(32, 32), color_mode = "grayscale")
16
+ image = img_to_array(image)
17
+ image = image/255.0
18
+ image = np.reshape(image,[1,32,32,1])
19
+
20
+ classes = loaded_model.predict_classes(image)
21
+
22
+ return classes