-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel_Test.py
More file actions
27 lines (19 loc) · 837 Bytes
/
Model_Test.py
File metadata and controls
27 lines (19 loc) · 837 Bytes
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
from keras.datasets import cifar10
import keras.utils as utils
from keras.models import load_model
import numpy as np
import os
(_, _), (test_images, test_labels) = cifar10.load_data()
test_images = test_images.astype('float32') / 255.0
test_labels = utils.to_categorical(test_labels)
labels_array = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + '/Image_Classifier.h5'
model = load_model(path)
# results = model.evaluate(x=test_images, y=test_labels)
#
# print("Test loss: ", results[0])
# print("Test accuracy: ", results[1])
test_image_data = np.asarray([test_images[0]])
prediction = model.predict(x=test_image_data)
max_prediction = np.argmax(prediction[0])
print("Prediction: " + labels_array[max_prediction])