diff --git a/TesterRandom.py b/TesterRandom.py new file mode 100644 index 0000000..63a97e9 --- /dev/null +++ b/TesterRandom.py @@ -0,0 +1,33 @@ +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'] + +# Path to the folder containing test images +test_images_folder = 'Testing/ + +# Iterate over the test images +for filename in os.listdir(test_images_folder): + if filename.endswith('.jpg') or filename.endswith('.jpeg') or filename.endswith('.png'): + # Load and preprocess the test image + image_path = os.path.join(test_images_folder, filename) + test_image = image.load_img(image_path, target_size=(224, 224)) + test_image = image.img_to_array(test_image) + test_image = np.expand_dims(test_image, axis=0) + test_image = test_image / 255.0 # Normalize the image + + # Make predictions + predictions = model.predict(test_image) + predicted_class_index = np.argmax(predictions[0]) + predicted_class = class_names[predicted_class_index] + + print('Image:', filename) + print('Predicted class:', predicted_class) + print() \ No newline at end of file diff --git a/mode2.h5 b/mode2.h5 deleted file mode 100644 index b462b21..0000000 Binary files a/mode2.h5 and /dev/null differ