Neural Network - Testers (edit)
This commit is contained in:
parent
c006fc128e
commit
b1880d61cb
@ -1,14 +1,13 @@
|
||||
import os
|
||||
import numpy as np
|
||||
import tensorflow as tf
|
||||
from tensorflow import keras
|
||||
from tensorflow.keras.preprocessing import image
|
||||
import numpy as np
|
||||
import os
|
||||
|
||||
# Load the trained model
|
||||
model = keras.models.load_model('trained_model.h5')
|
||||
|
||||
# Load the class names
|
||||
class_names = ['Empty', 'Food','People']
|
||||
class_names = ['Table', 'Done','Order']
|
||||
|
||||
# Path to the folder containing test images
|
||||
test_images_folder = 'Testing/'
|
||||
@ -23,11 +22,11 @@ for folder_name in os.listdir(test_images_folder):
|
||||
|
||||
# True class based on folder name
|
||||
if folder_name == 'Empty':
|
||||
true_class = 'Empty'
|
||||
true_class = 'Table'
|
||||
elif folder_name == 'Food':
|
||||
true_class = 'Food'
|
||||
true_class = 'Done'
|
||||
elif folder_name == 'People':
|
||||
true_class = 'People'
|
||||
true_class = 'Order'
|
||||
true_class = folder_name
|
||||
|
||||
# Iterate over the files in the subfolder
|
||||
@ -36,8 +35,8 @@ for folder_name in os.listdir(test_images_folder):
|
||||
i+=1
|
||||
# Load and preprocess the test image
|
||||
image_path = os.path.join(folder_path, filename)
|
||||
test_image = image.load_img(image_path, target_size=(100, 100))
|
||||
test_image = image.img_to_array(test_image)
|
||||
test_image = keras.preprocessingimage.load_img(image_path, target_size=(100, 100))
|
||||
test_image = keras.preprocessingimage.img_to_array(test_image)
|
||||
test_image = np.expand_dims(test_image, axis=0)
|
||||
test_image = test_image / 255.0 # Normalize the image
|
||||
|
||||
|
@ -7,7 +7,7 @@ from tensorflow import keras
|
||||
model = keras.models.load_model('trained_model.h5')
|
||||
|
||||
# Load the class names
|
||||
class_names = ['Empty', 'Food','People']
|
||||
class_names = ['Table', 'Done','Order']
|
||||
|
||||
# Load and preprocess the validation dataset
|
||||
data_dir = "Training/"
|
||||
|
Loading…
Reference in New Issue
Block a user