Why encoding a face with the "num_jitters" parameter affects the encoding of another face (with the "num_jitters" parameter as well)?
I have an face_encode variable, which is "Har.png" image encode (with num_jitters = 10)
When processing the same image and comparing them, I get the same value (face_encode and test are identical).
However, after uncommenting this line: new = encode("Ani.png", 10)[0] "Face_encode" and "test" become non-identical (np.allclose(face_encode, test) return False). This means that processing one face affects the encoding of another face.
Note: If we will change the num_itters to 1 in new = encode("Ani.png", 1)[0], the print(np.allclose(face_encode, test)) will give a True. This mean that jittering affect on face encode of another image
import cv2
import face_recognition
import numpy as np
face_encode = np.array([-0.03383258, 0.1522091 , 0.00778023, -0.02392919, -0.12134701,
0.02448359, -0.12119899, 0.00130317, 0.17482917, -0.00608639,
0.07468938, 0.01706824, -0.21361005, 0.04690374, -0.10125306,
0.13845484, -0.23481546, -0.1003552 , -0.09002965, -0.08902221,
0.009046 , 0.06367773, -0.01593469, 0.04676583, -0.17100905,
-0.31411591, -0.08375659, -0.10543557, 0.04868974, -0.12692517,
0.02808667, -0.0059777 , -0.1129951 , -0.03772227, 0.02010387,
0.03789502, -0.04583764, -0.06205031, 0.18120724, 0.11010844,
-0.12902826, 0.04678808, 0.03990007, 0.37248898, 0.17482039,
0.10718967, 0.02596617, -0.05392049, 0.14223413, -0.26670438,
0.07981005, 0.22440179, 0.02152029, 0.08013226, 0.06920523,
-0.12548962, 0.0365652 , 0.18923151, -0.24735497, 0.07125427,
0.07109451, 0.0370005 , -0.02891098, -0.07094251, 0.22352193,
0.13761494, -0.1292235 , -0.11606612, 0.12919654, -0.16925484,
-0.08498519, -0.04782813, -0.11302817, -0.13826026, -0.34820935,
0.0340745 , 0.40744266, 0.17069298, -0.10228713, 0.01735803,
-0.04485941, -0.05013431, 0.01530067, 0.05060982, -0.19970088,
-0.01855213, -0.04743322, 0.05434962, 0.15309754, 0.0527404 ,
-0.02121131, 0.14636354, 0.03430861, -0.0306342 , 0.01154729,
0.04730092, -0.2055707 , -0.0561384 , -0.15399964, -0.05845002,
0.04407276, -0.04798348, 0.02185482, 0.16238688, -0.17582887,
0.19120233, 0.0242596 , -0.08013647, -0.03035241, 0.07667085,
-0.17627513, -0.04133784, 0.25034377, -0.17164004, 0.16634598,
0.18308365, 0.08592145, 0.08905195, 0.11517368, 0.04827499,
-0.08297287, 0.03901137, -0.15337615, -0.08358597, 0.01340009,
-0.05940268, 0.05974644, 0.03913205])
def encode(image, jit):
#Declare you :)
known_image = cv2.imread(image)
reversed_img = cv2.cvtColor(known_image, cv2.COLOR_BGR2RGB)
face_location = face_recognition.face_locations(reversed_img)
your_face_encoding = face_recognition.face_encodings(reversed_img, face_location, num_jitters = jit)
return your_face_encoding
# new = encode("Ani.png", 10)[0]
test = encode("Har.png", 10)[0]
print(np.allclose(face_encode, test))
You can test it with any image..
And u can print the test value (and compare with person_encode ) to make sure that the value (encode) is changed after computing the new encode.