import numpy as np
import tensorflow as tf
import os


#Import Data
PATH = os.path.join(os.getcwd(), "crop-data")

validation_data = os.path.join(PATH, "valid")
validation_data_32 = tf.keras.utils.image_dataset_from_directory(validation_data,
                                                                 shuffle=True,
                                                                 batch_size=32,
                                                                 image_size=(160,160))

validation_data_64 = tf.keras.utils.image_dataset_from_directory(validation_data,
                                                                 shuffle=True,
                                                                 batch_size=64,
                                                                 image_size=(160,160))

AUTOTUNE = tf.data.AUTOTUNE
validation_data_32 = validation_data_32.prefetch(buffer_size=AUTOTUNE)
validation_data_64 = validation_data_64.prefetch(buffer_size=AUTOTUNE)

validation_data_32 = validation_data_32.map(lambda x,y: (x, tf.one_hot(y,38)))
validation_data_64 = validation_data_64.map(lambda x,y: (x, tf.one_hot(y,38)))


model1 = tf.keras.models.load_model("crop-classifier.keras")
model2 = tf.keras.models.load_model("crop-classifier-64-batch.keras")
model3 = tf.keras.models.load_model("crop-classifier-callbacks.keras")

result = model1.evaluate(validation_data_32)
print(f"Validation Loss: {result[0]}")
print(f"Accuracy: {result[1]}")

result = model2.evaluate(validation_data_64)
print(f"Validation Loss: {result[0]}")
print(f"Accuracy: {result[1]}")

result = model3.evaluate(validation_data_64)
print(f"Validation Loss: {result[0]}")
print(f"Accuracy: {result[1]}")
