# USAGE
# python test_network.py --model santa_not_santa.model --image images/examples/santa_01.png

# import the necessary packages
from keras.preprocessing.image import img_to_array
from keras.models import load_model
import numpy as np
import argparse
import imutils
import cv2
import time

# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-m", "--model", required=True,
	help="path to trained model model")
ap.add_argument("-i", "--image", required=True,
	help="path to input image")
args = vars(ap.parse_args())
model = load_model(args["model"])

import os
path = '<path to test image folder>'
image_list = os.listdir(path)
# load the image
for img in image_list:
	image = cv2.imread(path + img)
	orig = image.copy()

	# pre-process the image for classification
	image = cv2.resize(image, (299, 299))
	image = image.astype("float") / 255.0
	image = img_to_array(image)
	image = np.expand_dims(image, axis=0)

	# load the trained convolutional neural network
	print("[INFO] loading network...")

	# classify the input image
	pred = model.predict(image)[0]
	label = ['low', 'medium', 'severe'][np.argmax(pred)]

	# draw the label on the image
	output = imutils.resize(orig, width=400)
	cv2.putText(output, label, (10, 25),  cv2.FONT_HERSHEY_SIMPLEX,
		0.7, (0, 255, 0), 2)

	# show the output image
	cv2.imwrite(str(time.time()) + '.jpg', output)