Skip to content

Commit

Permalink
new script for ep05
Browse files Browse the repository at this point in the history
  • Loading branch information
erinmgraham committed Oct 5, 2023
1 parent 9c06fd0 commit f3aeacc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions episodes/scripts/predict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 15 16:27:34 2023
@author: jc140298
"""

from tensorflow.keras.utils import load_img
from tensorflow.keras.utils import img_to_array

# load a new image and prepare it to match cifar10 dataset
new_img_pil = load_img("01_Jabiru_TGS.JPG", target_size=(32,32)) # Image format
new_img_arr = img_to_array(new_img_pil) # convert to array for analysis
new_img_reshape = new_img_arr.reshape(1, 32, 32, 3) # reshape into single sample
new_img_float = new_img_reshape.astype('float64') / 255.0 # normalize

# predict the classname
result = model.predict(new_img_float) # make prediction
print(result) # probability for each class
print(class_names[result.argmax()]) # class with highest probability


# test set
y_pred = model.predict(test_images)

0 comments on commit f3aeacc

Please sign in to comment.