# importing required libraries

from tensorflow import keras
import os 
from pathlib import Path

modelPath = os.path.join(Path(os.path.realpath("__file__")).parent.parent, "assets/model/hand_gesture_classify_model.h5")

model = keras.models.load_model(modelPath)

model.summary()

# TESTING the model

# Augment the Data 
datagen = keras.preprocessing.image.ImageDataGenerator(
        samplewise_center = True,  # set each sample mean to 0
        rotation_range = 10,  # randomly rotate images in the range (degrees, 0 to 180)
        zoom_range = 0.1, # Randomly zoom image 
        width_shift_range = 0.1,  # randomly shift images horizontally (fraction of total width)
        height_shift_range = 0.1,  # randomly shift images vertically (fraction of total height)
        horizontal_flip = True,  # randomly flip images
        vertical_flip = True)

# load and iterate testing dataset
dirPath = os.path.join(Path(os.path.realpath("__file__")).parent.parent, "assets/data")
test_it = datagen.flow_from_directory(dirPath + "/test", 
                                      target_size = (224, 224), 
                                      color_mode = 'rgb', 
                                      class_mode = "categorical",
                                      batch_size = 1)

model.evaluate(test_it, steps = test_it.samples/test_it.batch_size)