I have a tensorflow trained .h5 model (size 27MB), and I found it's very slow in doing prediction (5s to predict whether the image is a dog or cat)
Below are my codes. May I know is it becuase of the model size caused it very slow or other factors?
import tensorflow as tf
import numpy as np
from keras.preprocessing import image
new_model=tf.keras.models.load_model('cat_dog.h5')
img = image.load_img('dog1.jpg', target_size=(150, 150))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
images = np.vstack([x])
classes = new_model.predict(images)
if classes[0]>0.8:
print("dog")
else:
print("cat")