-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpredict.py
31 lines (25 loc) · 957 Bytes
/
predict.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# import the necessary packages
from keras.preprocessing import image as image_utils
from keras.applications.imagenet_utils import decode_predictions
from keras.applications.imagenet_utils import preprocess_input
from keras.applications import VGG16
import numpy as np
import argparse
from keras.preprocessing import image
import tensorflow as tf
from tensorflow import keras
from keras.models import load_model
if __name__ == '__main__':
# dimensions of our images
img_width, img_height = 150, 150
# load the model we saved
model = load_model('train_car_model_09_11.keras')
img = tf.keras.utils.load_img(
'image_test/car/1.jpeg', target_size=(img_height, img_width)
)
img_array = tf.keras.utils.img_to_array(img)
img_array = tf.expand_dims(img_array, 0) # Create a batch
predictions = model.predict(img_array)
print(predictions[0])
im_class = tf.argmax(predictions[0], axis=-1)
print(im_class)