<jupyter_start><jupyter_text>Face Verification   Uploading Face Dataset<jupyter_code>#open files from your local file system
from google.colab import files

uploaded_train = files.upload()

for fn in uploaded_train.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded_train[fn])))<jupyter_output><empty_output><jupyter_text>Preparing inputs for the train_test_split function<jupyter_code>face_X = []
for key, value in uploaded_train.items():
          img_path = key
          img = image.load_img(img_path, target_size=(128, 128))#loads as image in the PIL format
          x = image.img_to_array(img)#equal to cv2
          x = np.expand_dims(x, axis=0)#to respond to the input dimensions of the model
          x = preprocess_input(x)#normalizing pixel values to caffe style
          face_X.append(x)
face_X = np.array(face_X)
face_X = face_X.reshape(face_X.shape[0],128, 128, 3)
face_X.shape<jupyter_output><empty_output><jupyter_text>labels<jupyter_code>keys=[]
for key, value in uploaded_train.items():
  keys.append(key[1:3])
keys = [key.replace('_', '') for key in keys]
face_Y = np.array([int(i) for i in keys])
len(face_Y)<jupyter_output><empty_output><jupyter_text>train/test split<jupyter_code>from sklearn.model_selection import train_test_split
X_train_face, X_test_face, y_train_face, y_test_face = train_test_split(face_X, face_Y, test_size=0.33, random_state=42)
len(y_test_face)<jupyter_output><empty_output><jupyter_text>one-hot-encoding the labels<jupyter_code>def convert_to_one_hot(Y, C):
    Y = np.eye(C)[Y.reshape(-1)].T
    return Y
  
Y_train_face = convert_to_one_hot(y_train_face,32).T
Y_test_face = convert_to_one_hot(y_test_face,32).T
print ("number of training examples = " + str(X_train_face.shape[0]))
print ("number of test examples = " + str(X_test_face.shape[0]))
print ("X_train shape: " + str(X_train_face.shape))
print ("Y_train shape: " + str(Y_train_face.shape))
print ("X_test shape: " + str(X_test_face.shape))
print ("Y_test shape: " + str(Y_test_face.shape))<jupyter_output>number of training examples = 643
number of test examples = 317
X_train shape: (643, 128, 128, 3)
Y_train shape: (643, 32)
X_test shape: (317, 128, 128, 3)
Y_test shape: (317, 32)<jupyter_text>Model  Creating the base_model using TRANSFER LEARNING<jupyter_code>img_height,img_width = 128,128
num_classes = 32
#imagenet weights are being loaded
base_model = applications.resnet50.ResNet50(weights= 'imagenet', include_top=False, input_shape= (img_height,img_width,3))
#freezing the NN layers
#for layer in base_model.layers:
#	layer.trainable = False
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dropout(0.7)(x)
predictions = Dense(num_classes, activation= 'softmax')(x)
model = Model(inputs = base_model.input, outputs = predictions)
from keras.optimizers import SGD, Adam
adam = Adam(lr=0.0001)
model.compile(optimizer= adam, loss='categorical_crossentropy', metrics=['accuracy'])<jupyter_output><empty_output><jupyter_text>Training the model<jupyter_code>model.fit(X_train_face, Y_train_face, epochs = 50, batch_size = 32)<jupyter_output>W0701 12:43:34.851056 140685096044416 deprecation.py:323] From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_grad.py:1250: add_dispatch_support.<locals>.wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where<jupyter_text>Evaluating the model on the test set - ACCURACY<jupyter_code>preds = model.evaluate(X_test_face, Y_test_face)
print ("Loss = " + str(preds[0]))
print ("Test Accuracy = " + str(preds[1]))
# mp=model predict
#np.amax(mp)  this is the maximum probability returned and then we find the label of the class which is the value returned by mp.argmax()
#mp.argmax()   returns the position of the largest value in a numpy array|<jupyter_output><empty_output><jupyter_text>Evaluation   Different thresholds<jupyter_code>threshold = np.arange(0, 1.005, 0.005)
len(threshold)<jupyter_output><empty_output><jupyter_text>False Rejection Rate<jupyter_code>TP_face = 0
FN_face = 0 #False Negative(False Rejection)/typeI error
FRR_face = [] # a list of false rejection rate values for 201 different threshold between 0 and 1
for T in threshold: 
  for i in range(0,317):
            x = np.expand_dims(X_test_face[i], axis=0)#to respond to the input dimensions of the model
            label = y_test_face[i]

            p = model.predict(x)
            if np.amax(p)>=T and label == p.argmax(): # Top matched value's label is equal to the probe's label and the probabiliy surpasses the T
              TP_face+=1

            if np.amax(p)<T and  label == p.argmax(): # Top matched value's label is the same as the probe's class but this value is lower than the threshold set so, the genuine probe won't be allowed in the system and this is a false reject
              FN_face+=1
  FRR_face.append(FN_face/(FN_face+TP_face))    
  TP_face=0
  FN_face=0

len(FRR_face)<jupyter_output><empty_output><jupyter_text>False Acceptance Rate<jupyter_code>#open files from your local file system
from google.colab import files

uploaded_imposter_face = files.upload()

for fn in uploaded_imposter_face.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded_imposter_face[fn])))
len(uploaded_imposter_face)
imposter_keys=[]
for key in uploaded_imposter_face.keys():
  imposter_keys.append(key[1:3])

TN_face = 0
FP_face = 0 #False Positive(False Acceptance)/typeII error
predicts = []
FAR_face = []
for T in threshold:
  key_index=0
  for key, value in uploaded_imposter_face.items():
            img_path = key
            img = image.load_img(img_path, target_size=(128, 128))#loads as image in the PIL format
            x = image.img_to_array(img)#equal to cv2
            x = np.expand_dims(x, axis=0)#to respond to the input dimensions of the model
            x = preprocess_input(x)#normalizing pixel values to caffe style
            label = int(imposter_keys[key_index])
            key_index+=1

            p = model.predict(x)
            predicts.append(p)
            if np.amax(p)>=T and label == p.argmax(): # An imposter pretending to be one of genuine probes, top matches and this probabbility surpasses the T value
              FP_face+=1

            if np.amax(p)<T: # An imposter pretening to be a genuine probe, matches the highest but this probability does not surpass the T value
              TN_face+=1

            if np.amax(p)>T and label != p.argmax():
              TN_face+=1

            #if np.amax(p) >=T and label != p.argmax(): # Top matched value's label is not equal to the label (wrong match) and this probability surpasses the T value so we get a False Acceptance error
            #  FP+=1

            #L.append([p, label, (np.amax(p), p.argmax())])

  FAR_face.append(FP_face/(TN_face+FP_face))    
  FP_face=0
  TN_face=0<jupyter_output><empty_output><jupyter_text>Plotting<jupyter_code>t=threshold.tolist()
# importing the required module 
import matplotlib.pyplot as plt 

# x axis values 
# FRR 
# corresponding y axis values 
# t

# plotting the points 
plt.plot(t, FRR_face) 

# naming the x axis 
plt.xlabel('threshold') 
# naming the y axis 
plt.ylabel('Error_rate') 

# giving a title to my graph 
plt.title('FRR') 

# function to show the plot 
plt.show() 

# plotting the points 
plt.plot(t, FAR_face) 

# naming the x axis 
plt.xlabel('threshold') 
# naming the y axis 
plt.ylabel('FAR') 

# giving a title to my graph 
plt.title('FAR') 

# function to show the plot 
plt.show() 
#plt.axis([0, 1, 0, 0.03])
# line 1 points 
# plotting the line 1 points 
plt.plot(t, FRR_face, label = "FRR") 

# line 2 points 
# plotting the line 2 points 
plt.plot(t, FAR_face, label = "FAR") 

# naming the x axis 
plt.xlabel('threshold') 
# naming the y axis 
plt.ylabel('Error_Rate') 
# giving a title to my graph 
plt.title('FAR and FRR with different thresholds!') 


# show a legend on the plot 
plt.legend() 

# function to show the plot 
plt.show()<jupyter_output><empty_output><jupyter_text>Eye1 Verification  X_train, X_test<jupyter_code>#open files from your local file system
from google.colab import files

uploaded_eye1_train = files.upload()

for fn in uploaded_eye_train.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded_eye_train[fn])))
eye1_X = []
for key, value in uploaded_eye1_train.items():
          img_path = key
          img = image.load_img(img_path, target_size=(128, 128))#loads as image in the PIL format
          x = image.img_to_array(img)#equal to cv2
          x = np.expand_dims(x, axis=0)#to respond to the input dimensions of the model
          x = preprocess_input(x)#normalizing pixel values to caffe style
          eye1_X.append(x)
eye1_X = np.array(eye1_X)
eye1_X = eye1_X.reshape(eye1_X.shape[0],128, 128, 3)
eye1_X.shape<jupyter_output><empty_output><jupyter_text>Y_Train, Y_test<jupyter_code>keys=[]
for key, value in uploaded_eye1_train.items():
  keys.append(key[1:3])
keys = [key.replace('_', '') for key in keys]
eye1_Y= np.array([int(i) for i in keys])<jupyter_output><empty_output><jupyter_text>train/test split<jupyter_code>X_train_eye1, X_test_eye1, y_train_eye1, y_test_eye1 = train_test_split(eye1_X, eye1_Y, test_size=0.33, random_state=42)<jupyter_output><empty_output><jupyter_text>one-hot encode the labels to feed the keras model<jupyter_code>Y_train_eye1 = convert_to_one_hot(y_train_eye1,32).T
Y_test_eye1 = convert_to_one_hot(y_test_eye1,32).T<jupyter_output><empty_output><jupyter_text>Model  Creating the base model using transfer learning<jupyter_code>img_height,img_width = 128,128
num_classes = 32
#If imagenet weights are being loaded, 
#input must have a static square shape (one of (128, 128), (160, 160), (192, 192), or (224, 224))
base_model = applications.resnet50.ResNet50(weights= 'imagenet', include_top=False, input_shape= (img_height,img_width,3))
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dropout(0.7)(x)
predictions = Dense(num_classes, activation= 'softmax')(x)
model_eye1 = Model(inputs = base_model.input, outputs = predictions)
from keras.optimizers import SGD, Adam
# sgd = SGD(lr=lrate, momentum=0.9, decay=decay, nesterov=False)
adam = Adam(lr=0.0001)
model_eye1.compile(optimizer= adam, loss='categorical_crossentropy', metrics=['accuracy'])<jupyter_output><empty_output><jupyter_text>Training the model<jupyter_code>model_eye1.fit(X_train_eye1, Y_train_eye1, epochs = 50, batch_size = 32)<jupyter_output>Epoch 1/50
641/641 [==============================] - 13s 21ms/step - loss: 3.7092 - acc: 0.1654
Epoch 2/50
641/641 [==============================] - 3s 5ms/step - loss: 1.5366 - acc: 0.6006
Epoch 3/50
641/641 [==============================] - 3s 5ms/step - loss: 0.7988 - acc: 0.8081
Epoch 4/50
641/641 [==============================] - 3s 5ms/step - loss: 0.4314 - acc: 0.9095
Epoch 5/50
641/641 [==============================] - 3s 5ms/step - loss: 0.2733 - acc: 0.9594
Epoch 6/50
641/641 [==============================] - 3s 5ms/step - loss: 0.1787 - acc: 0.9688
Epoch 7/50
641/641 [==============================] - 3s 5ms/step - loss: 0.1326 - acc: 0.9766
Epoch 8/50
641/641 [==============================] - 3s 5ms/step - loss: 0.1004 - acc: 0.9875
Epoch 9/50
641/641 [==============================] - 3s 5ms/step - loss: 0.0726 - acc: 0.9891
Epoch 10/50
641/641 [==============================] - 3s 5ms/step - loss: 0.0575 - acc: 0.9922
Epoch 11/50
641/641 [==========================[...]<jupyter_text>Evaluating the model on the test set<jupyter_code>preds = model_eye1.evaluate(X_test_eye1, Y_test_eye1)
print ("Loss = " + str(preds[0]))
print ("Test Accuracy = " + str(preds[1]))
len(y_test_eye1)<jupyter_output><empty_output><jupyter_text>False Rejection Rate<jupyter_code>TP_eye1 = 0
tp_eye1=[]
fn_eye1=[]
predicts=[]
FN_eye1 = 0 #False Negative(False Rejection)/typeI error
FRR_eye1 = []
for T in threshold: 
  #for key, value in uploaded_eye_test.items():
  for i in range(0, 316):
    
            x = np.expand_dims(X_test_eye1[i], axis=0)#to respond to the input dimensions of the model
      
            label = y_test_eye1[i]
        
            p = model_eye1.predict(x)
            predicts.append(p)
          
            if np.amax(p)>=T and label == p.argmax(): # Top matched value's label is equal to the probe's label and the probabiliy surpasses the T
              TP_eye1+=1
              

            if np.amax(p)<T and  label == p.argmax(): # Top matched value's label is the same as the probe's class but this value is lower than the threshold set so, the genuine probe won't be allowed in the system and this is a false reject
              FN_eye1+=1

            #if np.amax(p) >=T and label != p.argmax(): # Top matched value's label is not equal to the label (wrong match) and this probability surpasses the T value so we get a False Acceptance error
            #  FP+=1
  FRR_eye1.append(FN_eye1/(FN_eye1+TP_eye1))
  
  tp_eye1.append(TP_eye1)
  fn_eye1.append(FN_eye1)
  
  TP_eye1=0
  FN_eye1=0<jupyter_output><empty_output><jupyter_text>False Acceptance Rate<jupyter_code>#open files from your local file system
from google.colab import files

uploaded_imposter_eye1 = files.upload()

for fn in uploaded_imposter_eye1.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded_imposter_eye1[fn])))
imposter_keys_eye1=[]
for key in uploaded_imposter_eye1.keys():
  imposter_keys_eye1.append(key[1:3])
TN_eye1 = 0
FP_eye1 = 0 #False Positive(False Acceptance)/typeII error
FAR_eye1 = []
for T in threshold:
  key_index = 0
  for key, value in uploaded_imposter_eye1.items():
          img_path = key
          img = image.load_img(img_path, target_size=(128, 128))#loads as image in the PIL format
          x = image.img_to_array(img)#equal to cv2
          x = np.expand_dims(x, axis=0)#to respond to the input dimensions of the model
          x = preprocess_input(x)#normalizing pixel values to caffe style
          label = int(imposter_keys_eye1[key_index])
          key_index+=1

          p = model_eye1.predict(x)
          if np.amax(p)>=T and label == p.argmax(): # An imposter pretending to be one of genuine probes, top matches and this probabbility surpasses the T value
            FP_eye1 +=1

          if np.amax(p)<T: # An imposter pretening to be a genuine probe, matches the highest but this probability does not surpass the T value
            TN_eye1 +=1

          if np.amax(p)>T and label != p.argmax():
            TN_eye1 +=1

          #if np.amax(p) >=T and label != p.argmax(): # Top matched value's label is not equal to the label (wrong match) and this probability surpasses the T value so we get a False Acceptance error
          #  FP+=1

          #L.append([p, label, (np.amax(p), p.argmax())])

  FAR_eye1.append(FP_eye1/(TN_eye1+FP_eye1))    
  FP_eye1=0
  TN_eye1=0<jupyter_output><empty_output><jupyter_text>Plotting<jupyter_code># importing the required module 
import matplotlib.pyplot as plt 

# x axis values 
# FRR 
# corresponding y axis values 
# t

# plotting the points 
plt.plot(t, FRR_eye1) 

# naming the x axis 
plt.xlabel('threshold') 
# naming the y axis 
plt.ylabel('Error_rate') 

# giving a title to my graph 
plt.title('FRR') 

# function to show the plot 
plt.show() 
# plotting the points 
plt.plot(t, FAR_eye1) 

# naming the x axis 
plt.xlabel('threshold') 
# naming the y axis 
plt.ylabel('FAR') 

# giving a title to my graph 
plt.title('FAR') 

# function to show the plot 
plt.show()
plt.axis([0, 1, -0, 0.2])
# line 1 points 
# plotting the line 1 points 
plt.plot(t, FRR_eye1, label = "FRR") 

# line 2 points 
# plotting the line 2 points 
plt.plot(t, FAR_eye1, label = "FAR") 

# naming the x axis 
plt.xlabel('threshold') 
# naming the y axis 
plt.ylabel('Error_Rate') 
# giving a title to my graph 
plt.title('FAR and FRR with different thresholds!') 


# show a legend on the plot 
plt.legend() 

# function to show the plot 
plt.show()<jupyter_output><empty_output><jupyter_text>Eye2 Verification<jupyter_code>#open files from your local file system
from google.colab import files

uploaded_eye2 = files.upload()

for fn in uploaded_eye2.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded_eye2[fn])))<jupyter_output><empty_output><jupyter_text>Preparing data items and their labels to feed to the train_test_split function<jupyter_code>Images_X = []
for key, value in uploaded_eye2.items():
          img_path = key
          img = image.load_img(img_path, target_size=(128, 128))#loads as image in the PIL format
          x = image.img_to_array(img)#equal to cv2
          x = np.expand_dims(x, axis=0)#to respond to the input dimensions of the model
          x = preprocess_input(x)#normalizing pixel values to caffe style
          Images_X.append(x)
Images_X = np.array(Images_X)
Images_X = Images_X.reshape(Images_X.shape[0],128, 128, 3)
Images_X.shape
keys=[]
for key, value in uploaded_eye2.items():
  keys.append(key[1:3])
keys = [key.replace('_', '') for key in keys]
Images_Y = np.array([int(i) for i in keys])<jupyter_output><empty_output><jupyter_text>train_test_split<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(Images_X, Images_Y, test_size=0.33, random_state=42)<jupyter_output><empty_output><jupyter_text>one hot encoding the labels to feed the keras model<jupyter_code>Y_train = convert_to_one_hot(y_train,32).T
Y_test = convert_to_one_hot(y_test,32).T<jupyter_output><empty_output><jupyter_text>Model<jupyter_code>img_height,img_width = 128,128
num_classes = 32
base_model = applications.resnet50.ResNet50(weights= 'imagenet', include_top=False, input_shape= (img_height,img_width,3))
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dropout(0.7)(x)
predictions = Dense(num_classes, activation= 'softmax')(x)
model_eye2 = Model(inputs = base_model.input, outputs = predictions)
from keras.optimizers import SGD, Adam
# sgd = SGD(lr=lrate, momentum=0.9, decay=decay, nesterov=False)
adam = Adam(lr=0.0001)
model_eye2.compile(optimizer= adam, loss='categorical_crossentropy', metrics=['accuracy'])
model_eye2.fit(X_train, Y_train, epochs = 50, batch_size = 32)
preds = model_eye2.evaluate(X_test, Y_test)
print ("Loss = " + str(preds[0]))
print ("Test Accuracy = " + str(preds[1]))
len(X_test)<jupyter_output><empty_output><jupyter_text>Evaluation   False Rejection Rate<jupyter_code>TP_eye2 = 0
FN_eye2 = 0 #False Negative(False Rejection)/typeI error
FRR_eye2 = []
for T in threshold: 
  #for key, value in uploaded_eye_test.items():
  for i in range(0, 319):
    
            x = np.expand_dims(X_test[i], axis=0)#to respond to the input dimensions of the model
      
            label = y_test[i]
        
            p = model_eye2.predict(x)
          
            if np.amax(p)>=T and label == p.argmax(): # Top matched value's label is equal to the probe's label and the probabiliy surpasses the T
              TP_eye2+=1

            if np.amax(p)<T and  label == p.argmax(): # Top matched value's label is the same as the probe's class but this value is lower than the threshold set so, the genuine probe won't be allowed in the system and this is a false reject
              FN_eye2+=1

            #if np.amax(p) >=T and label != p.argmax(): # Top matched value's label is not equal to the label (wrong match) and this probability surpasses the T value so we get a False Acceptance error
            #  FP+=1
  FRR_eye2.append(FN_eye2/(FN_eye2+TP_eye2))    
  TP_eye2=0
  FN_eye2=0<jupyter_output><empty_output><jupyter_text>False Acceptance Rate<jupyter_code>#open files from your local file system
from google.colab import files

uploaded_imposter_eye2 = files.upload()

for fn in uploaded_imposter_eye2.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded_imposter_eye2[fn])))
imposter_keys_eye2=[]
for key in uploaded_imposter_eye2.keys():
  imposter_keys_eye2.append(key[1:3])
TN_eye2 = 0
FP_eye2 = 0 #False Positive(False Acceptance)/typeII error
FAR_eye2=[]
#predicts = []
for T in threshold:
  key_index = 0
  for key, value in uploaded_imposter_eye2.items():
            img_path = key
            img = image.load_img(img_path, target_size=(128, 128))#loads as image in the PIL format
            x = image.img_to_array(img)#equal to cv2
            x = np.expand_dims(x, axis=0)#to respond to the input dimensions of the model
            x = preprocess_input(x)#normalizing pixel values to caffe style
            label = int(imposter_keys_eye2[key_index])
            key_index+=1

            p = model_eye2.predict(x)
            #predicts.append(p)
            if np.amax(p)>=T and label == p.argmax(): # An imposter pretending to be one of genuine probes, top matches and this probabbility surpasses the T value
              FP_eye2+=1

            if np.amax(p)<T: # An imposter pretening to be a genuine probe, matches the highest but this probability does not surpass the T value
              TN_eye2+=1

            if np.amax(p)>T and label != p.argmax():
              TN_eye2+=1

            #if np.amax(p) >=T and label != p.argmax(): # Top matched value's label is not equal to the label (wrong match) and this probability surpasses the T value so we get a False Acceptance error
            #  FP+=1

            #L.append([p, label, (np.amax(p), p.argmax())])

  FAR_eye2.append(FP_eye2/(TN_eye2+FP_eye2))    
  FP_eye2=0
  TN_eye2=0<jupyter_output><empty_output><jupyter_text>Plots<jupyter_code># importing the required module 
import matplotlib.pyplot as plt 

# x axis values 
# FRR 
# corresponding y axis values 
# t

# plotting the points 
plt.plot(t, FRR_eye2) 

# naming the x axis 
plt.xlabel('threshold') 
# naming the y axis 
plt.ylabel('Error_rate') 

# giving a title to my graph 
plt.title('FRR') 

# function to show the plot 
plt.show() 
# plotting the points 
plt.plot(t, FAR_eye2) 

# naming the x axis 
plt.xlabel('threshold') 
# naming the y axis 
plt.ylabel('FAR') 

# giving a title to my graph 
plt.title('FAR') 

# functionto show the plot 
plt.show()
#plt.axis([0, 1, -0, 0.150])
# line 1 points 
# plotting the line 1 points 
plt.plot(t, FRR_eye2, label = "FRR") 

# line 2 points 
# plotting the line 2 points 
plt.plot(t, FAR_eye2, label = "FAR") 

# naming the x axis 
plt.xlabel('threshold') 
# naming the y axis 
plt.ylabel('Error_Rate') 
# giving a title to my graph 
plt.title('FAR and FRR with different thresholds!') 


# show a legend on the plot 
plt.legend() 

# function to show the plot 
plt.show()<jupyter_output><empty_output><jupyter_text>Multibiometrics  Experimental section - to be completed 1.   Face+Eye12.   Face+Eye23.   Face+Eye1+Eye24.   Eye1+Eye2  Face+Eye1<jupyter_code>face_test_keys=face_test_keys[0:10]
zip(face_test_keys, eye_test_keys)
TP = 0
FN = 0 #False Negative(False Rejection)/typeI error
FRR = []
for T in threshold: 
  for face_key, eye_key in zip(face_test_keys, eye_test_keys):
            face_path = face_key
            img = image.load_img(face_path, target_size=(128, 128))#loads as image in the PIL format
            x = image.img_to_array(img)#equal to cv2
            x = np.expand_dims(x, axis=0)#to respond to the input dimensions of the model
            x = preprocess_input(x)#normalizing pixel values to caffe style
            label = int(face_key[1])
            p_face = model.predict(x)
            
            eye_path = eye_key
            img = image.load_img(eye_path, target_size=(128, 128))#loads as image in the PIL format
            x = image.img_to_array(img)#equal to cv2
            x = np.expand_dims(x, axis=0)#to respond to the input dimensions of the model
            x = preprocess_input(x)#normalizing pixel values to caffe style
            #label_eye = int(eye_key[1])

            p_eye = model_eye.predict(x)
            
            
            p = np.array([x + y for x, y in zip(p_face, p_eye)]) # summing the list of probabilities predicted by two modals
            
            if np.amax(p)>=T and label == p.argmax(): # Top matched value's label is equal to the probe's label and the probabiliy surpasses the T
              TP+=1

            if np.amax(p)<T and  label == p.argmax(): # Top matched value's label is the same as the probe's class but this value is lower than the threshold set so, the genuine probe won't be allowed in the system and this is a false reject
              FN+=1


            #if np.amax(p) >=T and label != p.argmax(): # Top matched value's label is not equal to the label (wrong match) and this probability surpasses the T value so we get a False Acceptance error
            #  FP+=1
  FRR.append(FN/(FN+TP))    
  TP=0
  FN=0
# importing the required module 
import matplotlib.pyplot as plt 

# x axis values 
# FRR 
# corresponding y axis values 
# t

# plotting the points 
plt.plot(t, FRR) 

# naming the x axis 
plt.xlabel('threshold') 
# naming the y axis 
plt.ylabel('Error_rate') 

# giving a title to my graph 
plt.title('FRR') 

# function to show the plot 
plt.show() 
# face_imposter_keys
# eye_imposter_keys
TP = 0
FN = 0 #False Negative(False Rejection)/typeI error
FAR = []
for T in threshold: 
  for face_key, eye_key in zip(face_imposter_keys, eye_imposter_keys):
            face_path = face_key
            img = image.load_img(face_path, target_size=(128, 128))#loads as image in the PIL format
            x = image.img_to_array(img)#equal to cv2
            x = np.expand_dims(x, axis=0)#to respond to the input dimensions of the model
            x = preprocess_input(x)#normalizing pixel values to caffe style
            label = int(face_key[1])
            p_face = model.predict(x)
            
            eye_path = eye_key
            img = image.load_img(eye_path, target_size=(128, 128))#loads as image in the PIL format
            x = image.img_to_array(img)#equal to cv2
            x = np.expand_dims(x, axis=0)#to respond to the input dimensions of the model
            x = preprocess_input(x)#normalizing pixel values to caffe style
            #label_eye = int(eye_key[1])

            p_eye = model_eye.predict(x)
            
            
            p = np.array([x + y for x, y in zip(p_face, p_eye)]) # summing the list of probabilities predicted by two modals
            
            if np.amax(p)>=T and label == p.argmax(): # Top matched value's label is equal to the probe's label and the probabiliy surpasses the T
              TP+=1

            if np.amax(p)<T and  label == p.argmax(): # Top matched value's label is the same as the probe's class but this value is lower than the threshold set so, the genuine probe won't be allowed in the system and this is a false reject
              FN+=1


            #if np.amax(p) >=T and label != p.argmax(): # Top matched value's label is not equal to the label (wrong match) and this probability surpasses the T value so we get a False Acceptance error
            #  FP+=1
  FRR.append(FN/(FN+TP))    
  TP=0
  FN=0<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11770310381472388, 'fraction_numerical': 0.03008538238850819, 'mean_word_length': 3.6970740103270225, 'pattern_counts': {'":': 0, '<': 131, '<?xml version=': 0, '>': 141, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '31', 'dir': 'jupyter-structured-clean-dedup', 'id': '132340', 'license': 'MIT', 'n_tokens_mistral': 10325, 'n_tokens_neox': 9362, 'n_words': 2680, 'path': 'Unimodal Biometrics.ipynb', 'repo_name': 'samin91/Biometric-Systems', 'size': '27289'}