def calculateTestEmbeddings():
    graph = load_graph('src/20180402-114759/20180402-114759.pb')

    faceList = []
    for imagePath in glob.glob('data/library/test2/*'):
        # loading cropped,RGBscale,aligned (160,160)sized faces as reqd by FaceNet
        faceList.append(
            np.expand_dims(cv2.resize(pre.getFaceColor(imagePath), (160, 160)),
                           axis=0))

    with tf.Session(graph=graph) as sess:
        images_placeholder = graph.get_tensor_by_name("import/input:0")
        embeddings = graph.get_tensor_by_name("import/embeddings:0")
        phase_train_placeholder = graph.get_tensor_by_name(
            "import/phase_train:0")

        faceListInput = np.concatenate(faceList, axis=0)
        #normalizing the input
        faceListInput = np.float32(faceListInput) / 255.0

        feedDict = {
            phase_train_placeholder: False,
            images_placeholder: faceListInput
        }
        values = sess.run(embeddings, feedDict)

        # save embedding values
        np.save('src/cstmrEmbeddings', values)

    tf.reset_default_graph()
import matplotlib.pyplot as plt
import pre_processing2 as pre

# load trained images embeddings
empEmbeddings = np.load('src/empEmbeddings.npy')
print empEmbeddings.shape

# load test image embeddings
cstmrEmbeddings = np.load('src/cstmrEmbeddings.npy')
print cstmrEmbeddings.shape

faceListTrain = []
faceListTest = []

for imagePath in glob.glob('data/library/train2/*'):
	faceListTrain.append(cv2.resize(pre.getFaceColor(imagePath),(160,160)))

for imagePath in glob.glob('data/library/test2/*'):
	faceListTest.append(cv2.resize(pre.getFaceColor(imagePath),(160,160)))

plt.subplot2grid((1,4),(0,0))
plt.imshow(faceListTrain[0])

# calculate L2 norm of test image versusal of the training images
for i in range(0,len(empEmbeddings)):
	for j in range(0,len(cstmrEmbeddings)):
		plt.subplot2grid((1,4),(0,j+1))
		plt.imshow(faceListTest[j])
		plt.title(np.linalg.norm(empEmbeddings[i] - cstmrEmbeddings[j]))

        values = sess.run(embeddings, feedDict)

        # save embedding values
        np.save('src/cstmrEmbeddings', values)

    tf.reset_default_graph()


if __name__ == '__main__':

    graph = load_graph('src/20180402-114759/20180402-114759.pb')
    faceList = []
    for imagePath in glob.glob('data/library/test2/*'):
        # loading cropped,RGBscale,aligned (160,160)sized faces as reqd by FaceNet
        faceList.append(
            np.expand_dims(cv2.resize(pre.getFaceColor(imagePath), (160, 160)),
                           axis=0))

    with tf.Session(graph=graph) as sess:
        images_placeholder = graph.get_tensor_by_name("import/input:0")
        embeddings = graph.get_tensor_by_name("import/embeddings:0")
        phase_train_placeholder = graph.get_tensor_by_name(
            "import/phase_train:0")

        faceListInput = np.concatenate(faceList, axis=0)
        #normalizing the input
        faceListInput = np.float32(faceListInput) / 255.0
        print(faceListInput.shape)

        feedDict = {
            phase_train_placeholder: False,