Skip to main content

TST, Hongkong

DeepFace

docker build -t tensorflow/deepface .
docker run --ipc=host --gpus all -ti --rm \
-v $(pwd)/notebooks:/opt/app/notebooks \
-v $(pwd)/weights:/root/.deepface/weights \
-p 8888:8888 --name deepface \
tensorflow/deepface

Comparing a few models for face detection and recognition with deepface:

from deepface import DeepFace
import glob
import os
import pandas as pd
import matplotlib.pyplot as plt
images = glob.glob('./assets/*.jpg')
plt.figure(figsize=(12,10))

for i in range(25):
ax = plt.subplot(5,5,i+1)
plt.title(images[i][9:-4])
img = plt.imread(images[i])
plt.imshow(img)
plt.axis('off')

png

Face Match

Compare an image to a reference image.

VariableDescriptionOptions
model_nameModel for face recognition.VGG-Face, Facenet, Facenet512, OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet (default is VGG-Face).
detector_backendFace detector backend.opencv, retinaface, mtcnn, ssd, dlib, mediapipe, yolov8, centerface, skip (default is opencv).
distance_metricMetric for measuring similarity.cosine, euclidean, euclidean_l2 (default is cosine).
result1 = DeepFace.verify(
img1_path = "assets/Benedict_Wong_01.jpg",
img2_path = "assets/Benedict_Wong_03.jpg",
model_name = "VGG-Face",
detector_backend = "opencv",
distance_metric = "cosine",
enforce_detection = True,
align = True,
expand_percentage = 0,
normalization = "base",
silent = True,
threshold = 0.75,
)
print(pretty_print(result1))

Match: True, Distance: 0.2371475924188441, Threshold: 0.75, Time: 0.43, Detections :: x,y,w,h,left_eye,right_eye IMG1: 149,79,167,167,(260, 144),(199, 146) IMG2: 77,85,157,157,None,None None

result2 = DeepFace.verify(
img1_path = "assets/Benedict_Wong_01.jpg",
img2_path = "assets/Benedict_Wong_02.jpg",
model_name = "VGG-Face",
detector_backend = "opencv",
distance_metric = "cosine",
enforce_detection = True,
align = True,
expand_percentage = 0,
normalization = "base",
silent = True,
threshold = 0.75,
)
print(pretty_print(result2))

Match: True, Distance: 0.36789182962805234, Threshold: 0.75, Time: 0.4, Detections :: x,y,w,h,left_eye,right_eye IMG1: 149,79,167,167,(260, 144),(199, 146) IMG2: 60,24,52,52,None,None None

result3 = DeepFace.verify(
img1_path = "assets/Benedict_Wong_01.jpg",
img2_path = "assets/John_Bradley_04.jpg",
model_name = "VGG-Face",
detector_backend = "opencv",
distance_metric = "cosine",
enforce_detection = True,
align = True,
expand_percentage = 0,
normalization = "base",
silent = True,
threshold = 0.75,
)
print(pretty_print(result3))

Match: False, Distance: 0.8878862927720679, Threshold: 0.75, Time: 0.41, Detections :: x,y,w,h,left_eye,right_eye IMG1: 149,79,167,167,(260, 144),(199, 146) IMG2: 25,74,185,185,(151, 149),(83, 150) None

Compare Image to a set of Images

VGG-Face / OpenCV

  • vgg_face_weights.h5 - 552.3 MB
  • 24-05-09 12:32:58 - Searching assets/Eiza_Gonzalez_03.jpg in 26 length datastore
  • 24-05-09 12:32:58 - Find function duration 0.21913480758666992 seconds
result4 = DeepFace.find(
img_path = "assets/Eiza_Gonzalez_03.jpg",
db_path = "assets",
model_name = "VGG-Face",
distance_metric = "cosine",
enforce_detection = True,
detector_backend = "opencv",
align = True,
expand_percentage = 0,
threshold = 0.9,
normalization = "base",
silent = False,
)

24-05-09 12:32:58 - Searching assets/Eiza_Gonzalez_03.jpg in 26 length datastore 24-05-09 12:32:58 - find function duration 0.21913480758666992 seconds

#identityhashtarget_xtarget_ytarget_wtarget_hsource_xsource_ysource_wsource_hthresholddistance
0assets/Eiza_Gonzalez_03.jpgc851bc623b011079548c899eedc96a0b8c1a926442277171422771710.9-2.220446e-16
1assets/Eiza_Gonzalez_05.jpg4e3c950ef9084dd264e056711afd7a949dfb5f954961148148422771710.95.568067e-01
2assets/John_Bradley_01.jpg7619cdf25b6b4071aa6ebd9408e001f372cee5bc69142236236422771710.98.328525e-01
3assets/John_Bradley_04.jpgd4c9635f2c37df80ade71f405b296ac98d68e6902574185185422771710.98.535972e-01
4assets/Eiza_Gonzalez_02.jpg220a99ec5380b5d4033dd18f6f54353a49bb341b462125246246422771710.98.668110e-01
5assets/Jess_Hong_02.jpg1233412de754501680ab281fdd0b3c0b7e63427934198181422771710.98.805470e-01
image_results = [
['./assets/Eiza_Gonzalez_03.jpg', 1.0000000000000002],
['./assets/Eiza_Gonzalez_05.jpg', 0.4431933],
['./assets/John_Bradley_01.jpg', 0.1671475],
['./assets/John_Bradley_04.jpg', 0.14640280000000006],
['./assets/Eiza_Gonzalez_02.jpg', 0.133189],
['./assets/Jess_Hong_02.jpg', 0.11945300000000003]
]
plt.figure(figsize=(12,8))

for i in range(len(image_results)):
ax = plt.subplot(2,3,i+1)
plt.title(
image_results[i][0][9:-4]+'\n Similarity: '+str(round(image_results[i][1],2))
)
img = plt.imread(image_results[i][0])
plt.imshow(img)
plt.axis('off')

png

data_images = [
'Eiza_Gonzalez_03.jpg',
'Eiza_Gonzalez_05.jpg',
'John_Bradley_01.jpg',
'John_Bradley_04.jpg',
'Eiza_Gonzalez_02.jpg',
'Jess_Hong_02.jpg'
]

distance_data = [
-2.220446e-16,
5.568067e-01,
8.328525e-01,
8.535972e-01,
8.668110e-01,
8.805470e-01
]

similarity_data = [
1.0000000000000002,
0.4431933,
0.1671475,
0.14640280000000006,
0.133189,
0.11945300000000003
]

result_4_df = pd.DataFrame({
'Images': data_images,
'Distance': distance_data,
'Similarity': similarity_data
})

result_4_df
ImagesDistanceSimilarity
0Eiza_Gonzalez_03.jpg-2.220446e-161.000000
1Eiza_Gonzalez_05.jpg5.568067e-010.443193
2John_Bradley_01.jpg8.328525e-010.167148
3John_Bradley_04.jpg8.535972e-010.146403
4Eiza_Gonzalez_02.jpg8.668110e-010.133189
5Jess_Hong_02.jpg8.805470e-010.119453
result_4_df.plot(x="Images", y="Similarity", kind="bar")

png

Dlib / dlib

  • dlib_face_recognition_resnet_model_v1.dat.bz2 - 20.4 MB
  • 24-05-09 10:29:22 - Searching assets/Eiza_Gonzalez_03.jpg in 26 length datastore
  • 24-05-09 10:29:23 - Find function duration 0.13037323951721191 seconds
result5 = DeepFace.find(
img_path = "assets/Eiza_Gonzalez_03.jpg",
db_path = "assets",
model_name = "Dlib",
distance_metric = "cosine",
enforce_detection = True,
detector_backend = "dlib",
align = True,
expand_percentage = 0,
threshold = 0.60,
normalization = "base",
silent = False,
)

24-05-09 10:29:22 - Searching assets/Eiza_Gonzalez_03.jpg in 26 length datastore 24-05-09 10:29:23 - find function duration 0.13037323951721191 seconds

#identityhashtarget_xtarget_ytarget_wtarget_hsource_xsource_ysource_wsource_hthresholddistance
0assets/Eiza_Gonzalez_03.jpgc851bc623b011079548c899eedc96a0b8c1a926445326262453262620.6-2.220446e-16
1assets/Eiza_Gonzalez_01.jpgdd70311d238d2be8b47aee363e3f228b741c3b5020181155155453262620.63.507291e-02
2assets/Eiza_Gonzalez_04.jpg863a9e1f9f06ff1da45ef39de64f03a24d76816424536362453262620.65.434244e-02
3assets/Eiza_Gonzalez_05.jpg4e3c950ef9084dd264e056711afd7a949dfb5f955382129129453262620.67.985102e-02
4assets/Eiza_Gonzalez_02.jpg220a99ec5380b5d4033dd18f6f54353a49bb341b464167223223453262620.68.234110e-02
5assets/Alex_Sharp_02.jpgc95ee8e7698895fe15c561a9cb5adeda43f56ef446468990453262620.61.173593e-01
6assets/Jess_Hong_01.jpg46312c1e70040518e2e9ed9e6068cefed5724c0895615252453262620.61.268085e-01
7assets/Jess_Hong_02.jpg1233412de754501680ab281fdd0b3c0b7e63427938307575453262620.61.458864e-01
8assets/John_Bradley_03.jpg9686d791c5a87ff6060e721caf66f2532f92300a4432107108453262620.61.475067e-01
9assets/John_Bradley_02.jpg7f0317379f612eb44096207202e3cc91e441a58e107666363453262620.61.524923e-01
10assets/John_Bradley_01.jpg7619cdf25b6b4071aa6ebd9408e001f372cee5bc68142223223453262620.61.616775e-01
11assets/Benedict_Wong_04.jpgdbb025ab8039915335d84700c6423fadfa91c5b311466262453262620.61.624690e-01
12assets/Jess_Hong_03.jpg9b056b12303c62eeee91c49456bdda7f494aa07819944107108453262620.61.630522e-01
13assets/Alex_Sharp_01.jpg7155ec0a507fd98583c179beb164c9fcfa0fa91721144107108453262620.61.663933e-01
14assets/Alex_Sharp_03.jpg48a617ed38787e3dd5e7d7e87e2a56b37214ce3882142267267453262620.61.686072e-01
15assets/Jovan_Adepo_01.jpg47bc06e224a2538aa258c0b5d03f478e5713b8bc38307575453262620.61.723205e-01
16assets/Liam_Cunningham_04.jpg48cfc1ce0fec1aa61293d5d95478c694fa8406865677165186453262620.61.757963e-01
17assets/John_Bradley_04.jpgd4c9635f2c37df80ade71f405b296ac98d68e6901598186186453262620.61.834919e-01
18assets/Liam_Cunningham_02.jpg5b5aa2bddb00a676c599ab365031336ec1c9e00e0268690453262620.61.899648e-01
19assets/Benedict_Wong_02.jpgf8aa9b6edaf2e71f3c69cec9548c27519ba1914c60265252453262620.61.958830e-01
20assets/Liam_Cunningham_01.jpga157a9143b88b9844ea65f1ccea484a33767085398170321321453262620.61.977721e-01
21assets/Benedict_Wong_05.jpg4f14065c9065e745f63b1ca22c206649922eaee240264444453262620.62.021431e-01
22assets/Jovan_Adepo_02.jpgf5428170e3323a333121ceb196675526d8ad02c66782129129453262620.62.065918e-01
23assets/Liam_Cunningham_03.jpgd349c11690daa1a9e118df5d4ae08d554852a96a9881155155453262620.62.114577e-01
24assets/Benedict_Wong_01.jpg5594e234a03a4a8fb8c8c2a29310cb6497635317167110129129453262620.62.213369e-01
25assets/Benedict_Wong_03.jpg7626233c27c3925bb4d15b301f525ec82e14c86896110129129453262620.62.251138e-01
image_results = [
['./assets/Eiza_Gonzalez_03.jpg', 1.0000000000000002],
['./assets/Eiza_Gonzalez_01.jpg', 0.96492709],
['./assets/Eiza_Gonzalez_04.jpg', 0.94565756],
['./assets/Eiza_Gonzalez_05.jpg', 0.92014898],
['./assets/Eiza_Gonzalez_02.jpg', 0.9176588999999999],
['./assets/Alex_Sharp_02.jpg', 0.8826407000000001]
]
plt.figure(figsize=(12,8))

for i in range(len(image_results)):
ax = plt.subplot(2,3,i+1)
plt.title(
image_results[i][0][9:-4]+'\n Similarity: '+str(round(image_results[i][1],2))
)
img = plt.imread(image_results[i][0])
plt.imshow(img)
plt.axis('off')

png

data_images = [
'Eiza_Gonzalez_03.jpg',
'Eiza_Gonzalez_01.jpg',
'Eiza_Gonzalez_04.jpg',
'Eiza_Gonzalez_05.jpg',
'Eiza_Gonzalez_02.jpg',
'Alex_Sharp_02.jpg',
'Jess_Hong_01.jpg',
'Jess_Hong_02.jpg',
'John_Bradley_03.jpg',
'John_Bradley_02.jpg',
'John_Bradley_01.jpg',
'Benedict_Wong_04.jpg',
'Jess_Hong_03.jpg',
'Alex_Sharp_01.jpg',
'Alex_Sharp_03.jpg',
'Jovan_Adepo_01.jpg',
'Liam_Cunningham_04.jpg',
'John_Bradley_04.jpg',
'Liam_Cunningham_02.jpg',
'Benedict_Wong_02.jpg',
'Liam_Cunningham_01.jpg',
'Benedict_Wong_05.jpg',
'Jovan_Adepo_02.jpg',
'Liam_Cunningham_03.jpg',
'Benedict_Wong_01.jpg',
'Benedict_Wong_03.jpg'
]

distance_data = [
-2.220446e-16,
3.507291e-02,
5.434244e-02,
7.985102e-02,
8.234110e-02,
1.173593e-01,
1.268085e-01,
1.458864e-01,
1.475067e-01,
1.524923e-01,
1.616775e-01,
1.624690e-01,
1.630522e-01,
1.663933e-01,
1.686072e-01,
1.723205e-01,
1.757963e-01,
1.834919e-01,
1.899648e-01,
1.958830e-01,
1.977721e-01,
2.021431e-01,
2.065918e-01,
2.114577e-01,
2.213369e-01,
2.251138e-01,
]

similarity_data = [
1.0000000000000002,
0.96492709,
0.94565756,
0.92014898,
0.9176588999999999,
0.8826407000000001,
0.8731915,
0.8541136,
0.8524933,
0.8475077,
0.8383225,
0.837531,
0.8369478,
0.8336067,
0.8313927999999999,
0.8276795,
0.8242037,
0.8165081,
0.8100352,
0.804117,
0.8022279,
0.7978569,
0.7934082,
0.7885423,
0.7786630999999999,
0.7748862,
]

result_5_df = pd.DataFrame({
'Images': data_images,
'Distance': distance_data,
'Similarity': similarity_data
})

result_5_df
ImagesDistanceSimilarity
0Eiza_Gonzalez_03.jpg-2.220446e-161.000000
1Eiza_Gonzalez_01.jpg3.507291e-020.964927
2Eiza_Gonzalez_04.jpg5.434244e-020.945658
3Eiza_Gonzalez_05.jpg7.985102e-020.920149
4Eiza_Gonzalez_02.jpg8.234110e-020.917659
5Alex_Sharp_02.jpg1.173593e-010.882641
6Jess_Hong_01.jpg1.268085e-010.873192
7Jess_Hong_02.jpg1.458864e-010.854114
8John_Bradley_03.jpg1.475067e-010.852493
9John_Bradley_02.jpg1.524923e-010.847508
10John_Bradley_01.jpg1.616775e-010.838322
11Benedict_Wong_04.jpg1.624690e-010.837531
12Jess_Hong_03.jpg1.630522e-010.836948
13Alex_Sharp_01.jpg1.663933e-010.833607
14Alex_Sharp_03.jpg1.686072e-010.831393
15Jovan_Adepo_01.jpg1.723205e-010.827680
16Liam_Cunningham_04.jpg1.757963e-010.824204
17John_Bradley_04.jpg1.834919e-010.816508
18Liam_Cunningham_02.jpg1.899648e-010.810035
19Benedict_Wong_02.jpg1.958830e-010.804117
20Liam_Cunningham_01.jpg1.977721e-010.802228
21Benedict_Wong_05.jpg2.021431e-010.797857
22Jovan_Adepo_02.jpg2.065918e-010.793408
23Liam_Cunningham_03.jpg2.114577e-010.788542
24Benedict_Wong_01.jpg2.213369e-010.778663
25Benedict_Wong_03.jpg2.251138e-010.774886
def pretty_print(result):
print(f"Match: {result['verified']},\nDistance: {result['distance']},\nThreshold: {result['threshold']},\nTime: {result['time']},\nDetections :: x,y,w,h,left_eye,right_eye\n IMG1: {result['facial_areas']['img1']['x']},{result['facial_areas']['img1']['y']},{result['facial_areas']['img1']['w']},{result['facial_areas']['img1']['h']},{result['facial_areas']['img1']['left_eye']},{result['facial_areas']['img1']['right_eye']}\n IMG2: {result['facial_areas']['img2']['x']},{result['facial_areas']['img2']['y']},{result['facial_areas']['img2']['w']},{result['facial_areas']['img2']['h']},{result['facial_areas']['img2']['left_eye']},{result['facial_areas']['img2']['right_eye']}")

png

Dlib / Mediapipe

  • dlib_face_recognition_resnet_model_v1.dat.bz2 - 20.4 MB
  • shape_predictor_5_face_landmarks.dat.bz2 - 5.4 MB
  • 24-05-10 07:38:39 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore
  • 24-05-10 07:38:39 - Find function duration 0.3898661136627197 seconds
result6 = DeepFace.find(
img_path = "assets/Eiza_Gonzalez_03.jpg",
db_path = "assets",
model_name = "Dlib",
distance_metric = "cosine",
enforce_detection = True,
detector_backend = "mediapipe",
align = True,
expand_percentage = 0,
threshold = 0.60,
normalization = "base",
silent = False,
)

24-05-10 07:38:39 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore 24-05-10 07:38:39 - find function duration 0.3898661136627197 seconds

INFO: Created TensorFlow Lite XNNPACK delegate for CPU.

#identityhashtarget_xtarget_ytarget_wtarget_hsource_xsource_ysource_wsource_hthresholddistance
0assets/Eiza_Gonzalez_03.jpgc851bc623b011079548c899eedc96a0b8c1a926437366565373665650.60.000000
1assets/Eiza_Gonzalez_02.jpg220a99ec5380b5d4033dd18f6f54353a49bb341b509181197197373665650.60.058698
2assets/Eiza_Gonzalez_04.jpg863a9e1f9f06ff1da45ef39de64f03a24d76816416418080373665650.60.069220
3assets/Eiza_Gonzalez_05.jpg4e3c950ef9084dd264e056711afd7a949dfb5f954984133133373665650.60.070974
4assets/Jess_Hong_01.jpg46312c1e70040518e2e9ed9e6068cefed5724c08113714848373665650.60.116602
5assets/Jess_Hong_02.jpg1233412de754501680ab281fdd0b3c0b7e63427939287575373665650.60.122306
6assets/John_Bradley_03.jpg9686d791c5a87ff6060e721caf66f2532f92300a3236104104373665650.60.127752
7assets/Alex_Sharp_02.jpgc95ee8e7698895fe15c561a9cb5adeda43f56ef43847101101373665650.60.145324
8assets/Alex_Sharp_01.jpg7155ec0a507fd98583c179beb164c9fcfa0fa91720257107107373665650.60.148071
9assets/John_Bradley_02.jpg7f0317379f612eb44096207202e3cc91e441a58e120775353373665650.60.154632
10assets/Liam_Cunningham_02.jpg5b5aa2bddb00a676c599ab365031336ec1c9e00e12298484373665650.60.163341
11assets/John_Bradley_01.jpg7619cdf25b6b4071aa6ebd9408e001f372cee5bc96184208208373665650.60.164641
12assets/Alex_Sharp_03.jpg48a617ed38787e3dd5e7d7e87e2a56b37214ce38106156267267373665650.60.164873
13assets/Eiza_Gonzalez_02.jpg220a99ec5380b5d4033dd18f6f54353a49bb341b55271201201373665650.60.168053
14assets/Liam_Cunningham_04.jpg48cfc1ce0fec1aa61293d5d95478c694fa8406864499151151373665650.60.171255
15assets/Benedict_Wong_04.jpgdbb025ab8039915335d84700c6423fadfa91c5b313465656373665650.60.178435
16assets/Benedict_Wong_02.jpgf8aa9b6edaf2e71f3c69cec9548c27519ba1914c64344343373665650.60.186274
17assets/Benedict_Wong_05.jpg4f14065c9065e745f63b1ca22c206649922eaee241294040373665650.60.191297
18assets/John_Bradley_04.jpgd4c9635f2c37df80ade71f405b296ac98d68e69027111168168373665650.60.197620
19assets/Liam_Cunningham_01.jpga157a9143b88b9844ea65f1ccea484a337670853114215262262373665650.60.202479
20assets/Jovan_Adepo_02.jpgf5428170e3323a333121ceb196675526d8ad02c65996125125373665650.60.204949
21assets/Benedict_Wong_01.jpg5594e234a03a4a8fb8c8c2a29310cb6497635317150107160160373665650.60.223669
22assets/Jovan_Adepo_01.jpg47bc06e224a2538aa258c0b5d03f478e5713b8bc42367171373665650.60.246249
image_results = [
['./assets/Eiza_Gonzalez_03.jpg', 1.000000000000000],
['./assets/Eiza_Gonzalez_02.jpg', 0.941302],
['./assets/Eiza_Gonzalez_04.jpg', 0.9307799999999999],
['./assets/Eiza_Gonzalez_05.jpg', 0.929026],
['./assets/Jess_Hong_01.jpg', 0.883398],
['./assets/Jess_Hong_02.jpg', 0.877694]
]
plt.figure(figsize=(12,8))

for i in range(len(image_results)):
ax = plt.subplot(2,3,i+1)
plt.title(
image_results[i][0][9:-4]+'\n Similarity: '+str(round(image_results[i][1],2))
)
img = plt.imread(image_results[i][0])
plt.imshow(img)
plt.axis('off')

png

data_images = [
'Eiza_Gonzalez_03.jpg',
'Eiza_Gonzalez_02.jpg',
'Eiza_Gonzalez_04.jpg',
'Eiza_Gonzalez_05.jpg',
'Jess_Hong_01.jpg',
'Jess_Hong_02.jpg',
'John_Bradley_03.jpg',
'Alex_Sharp_02.jpg',
'Alex_Sharp_01.jpg',
'John_Bradley_02.jpg',
'Liam_Cunningham_02.jpg',
'John_Bradley_01.jpg',
'Alex_Sharp_03.jpg',
'Eiza_Gonzalez_02.jpg',
'Liam_Cunningham_04.jpg',
'Benedict_Wong_04.jpg',
'Benedict_Wong_02.jpg',
'Benedict_Wong_05.jpg',
'John_Bradley_04.jpg',
'Liam_Cunningham_01.jpg',
'Jovan_Adepo_02.jpg',
'Benedict_Wong_01.jpg',
'Jovan_Adepo_01.jpg'
]

distance_data = [
0.000000,
0.058698,
0.069220,
0.070974,
0.116602,
0.122306,
0.127752,
0.145324,
0.148071,
0.154632,
0.163341,
0.164641,
0.164873,
0.168053,
0.171255,
0.178435,
0.186274,
0.191297,
0.197620,
0.202479,
0.204949,
0.223669,
0.246249
]

similarity_data = [
1.0,
0.941302,
0.9307799999999999,
0.929026,
0.883398,
0.877694,
0.872248,
0.854676,
0.8519289999999999,
0.845368,
0.836659,
0.835359,
0.835127,
0.831947,
0.8287450000000001,
0.821565,
0.813726,
0.808703,
0.80238,
0.797521,
0.795051,
0.776331,
0.7537510000000001
]

result_6_df = pd.DataFrame({
'Images': data_images,
'Distance': distance_data,
'Similarity': similarity_data
})

result_6_df
ImagesDistanceSimilarity
0Eiza_Gonzalez_03.jpg0.0000001.000000
1Eiza_Gonzalez_02.jpg0.0586980.941302
2Eiza_Gonzalez_04.jpg0.0692200.930780
3Eiza_Gonzalez_05.jpg0.0709740.929026
4Jess_Hong_01.jpg0.1166020.883398
5Jess_Hong_02.jpg0.1223060.877694
6John_Bradley_03.jpg0.1277520.872248
7Alex_Sharp_02.jpg0.1453240.854676
8Alex_Sharp_01.jpg0.1480710.851929
9John_Bradley_02.jpg0.1546320.845368
10Liam_Cunningham_02.jpg0.1633410.836659
11John_Bradley_01.jpg0.1646410.835359
12Alex_Sharp_03.jpg0.1648730.835127
13Eiza_Gonzalez_02.jpg0.1680530.831947
14Liam_Cunningham_04.jpg0.1712550.828745
15Benedict_Wong_04.jpg0.1784350.821565
16Benedict_Wong_02.jpg0.1862740.813726
17Benedict_Wong_05.jpg0.1912970.808703
18John_Bradley_04.jpg0.1976200.802380
19Liam_Cunningham_01.jpg0.2024790.797521
20Jovan_Adepo_02.jpg0.2049490.795051
21Benedict_Wong_01.jpg0.2236690.776331
22Jovan_Adepo_01.jpg0.2462490.753751
result_6_df.plot(x="Images", y="Similarity", kind="bar")

png

Dlib / YOLOv8

  • dlib_face_recognition_resnet_model_v1.dat.bz2 - 20.4 MB
  • yolov8n-face.pt - 6.1 MB
  • 24-05-10 07:37:37 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore
  • 24-05-10 07:37:37 - Find function duration 0.12443137168884277 seconds
result7 = DeepFace.find(
img_path = "assets/Eiza_Gonzalez_03.jpg",
db_path = "assets",
model_name = "Dlib",
distance_metric = "cosine",
enforce_detection = True,
detector_backend = "yolov8",
align = True,
expand_percentage = 0,
threshold = 0.60,
normalization = "base",
silent = False,
)

24-05-10 07:37:37 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore 24-05-10 07:37:37 - find function duration 0.12443137168884277 seconds

#identityhashtarget_xtarget_ytarget_wtarget_hsource_xsource_ysource_wsource_hthresholddistance
0assets/Eiza_Gonzalez_03.jpgc851bc623b011079548c899eedc96a0b8c1a926439196284391962840.60.000000
1assets/Eiza_Gonzalez_01.jpgdd70311d238d2be8b47aee363e3f228b741c3b5020365139183391962840.60.045388
2assets/Eiza_Gonzalez_05.jpg4e3c950ef9084dd264e056711afd7a949dfb5f955753119163391962840.60.046588
3assets/Jess_Hong_02.jpg1233412de754501680ab281fdd0b3c0b7e63427943146789391962840.60.055280
4assets/Eiza_Gonzalez_04.jpg863a9e1f9f06ff1da45ef39de64f03a24d76816419237997391962840.60.063742
5assets/Jess_Hong_01.jpg46312c1e70040518e2e9ed9e6068cefed5724c08110544869391962840.60.066402
6assets/Alex_Sharp_02.jpgc95ee8e7698895fe15c561a9cb5adeda43f56ef4391692135391962840.60.084785
7assets/Liam_Cunningham_04.jpg48cfc1ce0fec1aa61293d5d95478c694fa8406865852140207391962840.60.086134
8assets/Jess_Hong_03.jpg9b056b12303c62eeee91c49456bdda7f494aa07820624101135391962840.60.086582
9assets/Eiza_Gonzalez_02.jpg220a99ec5380b5d4033dd18f6f54353a49bb341b497132192252391962840.60.086979
10assets/Benedict_Wong_04.jpgdbb025ab8039915335d84700c6423fadfa91c5b319315274391962840.60.088260
11assets/John_Bradley_03.jpg9686d791c5a87ff6060e721caf66f2532f92300a362095134391962840.60.091857
12assets/Alex_Sharp_01.jpg7155ec0a507fd98583c179beb164c9fcfa0fa9172074293123391962840.60.104845
13assets/John_Bradley_04.jpgd4c9635f2c37df80ade71f405b296ac98d68e6903160166214391962840.60.104869
14assets/Eiza_Gonzalez_02.jpg220a99ec5380b5d4033dd18f6f54353a49bb341b69218132157391962840.60.104911
15assets/John_Bradley_01.jpg7619cdf25b6b4071aa6ebd9408e001f372cee5bc99114198282391962840.60.108680
16assets/Liam_Cunningham_02.jpg5b5aa2bddb00a676c599ab365031336ec1c9e00e111080104391962840.60.111524
17assets/John_Bradley_02.jpg7f0317379f612eb44096207202e3cc91e441a58e119625575391962840.60.113892
18assets/Benedict_Wong_05.jpg4f14065c9065e745f63b1ca22c206649922eaee245183649391962840.60.125120
19assets/Alex_Sharp_03.jpg48a617ed38787e3dd5e7d7e87e2a56b37214ce38110111248345391962840.60.126874
20assets/Benedict_Wong_02.jpgf8aa9b6edaf2e71f3c69cec9548c27519ba1914c64234454391962840.60.127946
21assets/Benedict_Wong_01.jpg5594e234a03a4a8fb8c8c2a29310cb649763531716674138185391962840.60.134841
22assets/Benedict_Wong_03.jpg7626233c27c3925bb4d15b301f525ec82e14c8688984130173391962840.60.145167
23assets/Jovan_Adepo_01.jpg47bc06e224a2538aa258c0b5d03f478e5713b8bc46166492391962840.60.146045
24assets/Liam_Cunningham_01.jpga157a9143b88b9844ea65f1ccea484a337670853137163231319391962840.60.151728
25assets/Jovan_Adepo_02.jpgf5428170e3323a333121ceb196675526d8ad02c66359117169391962840.60.153202
26assets/Liam_Cunningham_03.jpgd349c11690daa1a9e118df5d4ae08d554852a96a11858130184391962840.60.157119
image_results = [
['./assets/Eiza_Gonzalez_03.jpg', 1.000000000000000],
['./assets/Eiza_Gonzalez_01.jpg', 0.954612],
['./assets/Eiza_Gonzalez_05.jpg', 0.953412],
['./assets/Jess_Hong_02.jpg', 0.94472],
['./assets/Eiza_Gonzalez_04.jpg', 0.936258],
['./assets/Jess_Hong_01.jpg', 0.933598]
]
plt.figure(figsize=(12,8))

for i in range(len(image_results)):
ax = plt.subplot(2,3,i+1)
plt.title(
image_results[i][0][9:-4]+'\n Similarity: '+str(round(image_results[i][1],2))
)
img = plt.imread(image_results[i][0])
plt.imshow(img)
plt.axis('off')

png

data_images = [
'Eiza_Gonzalez_03.jpg',
'Eiza_Gonzalez_01.jpg',
'Eiza_Gonzalez_05.jpg',
'Jess_Hong_02.jpg',
'Eiza_Gonzalez_04.jpg',
'Jess_Hong_01.jpg',
'Alex_Sharp_02.jpg',
'Liam_Cunningham_04.jpg',
'Jess_Hong_03.jpg',
'Eiza_Gonzalez_02.jpg',
'Benedict_Wong_04.jpg',
'John_Bradley_03.jpg',
'Alex_Sharp_01.jpg',
'John_Bradley_04.jpg',
'Eiza_Gonzalez_02.jpg',
'John_Bradley_01.jpg',
'Liam_Cunningham_02.jpg',
'John_Bradley_02.jpg',
'Benedict_Wong_05.jpg',
'Alex_Sharp_03.jpg',
'Benedict_Wong_02.jpg',
'Benedict_Wong_01.jpg',
'Benedict_Wong_03.jpg',
'Jovan_Adepo_01.jpg',
'Liam_Cunningham_01.jpg',
'Jovan_Adepo_02.jpg',
'Liam_Cunningham_03.jpg'
]

distance_data = [
0.000000,
0.045388,
0.046588,
0.055280,
0.063742,
0.066402,
0.084785,
0.086134,
0.086582,
0.086979,
0.088260,
0.091857,
0.104845,
0.104869,
0.104911,
0.108680,
0.111524,
0.113892,
0.125120,
0.126874,
0.127946,
0.134841,
0.145167,
0.146045,
0.151728,
0.153202,
0.157119
]

similarity_data = [
1,
0.954612,
0.953412,
0.94472,
0.936258,
0.933598,
0.915215,
0.913866,
0.913418,
0.913021,
0.91174,
0.908143,
0.895155,
0.895131,
0.895089,
0.89132,
0.888476,
0.886108,
0.87488,
0.8731260000000001,
0.872054,
0.865159,
0.854833,
0.853955,
0.848272,
0.8467979999999999,
0.842881
]

result_7_df = pd.DataFrame({
'Images': data_images,
'Distance': distance_data,
'Similarity': similarity_data
})

result_7_df
ImagesDistanceSimilarity
0Eiza_Gonzalez_03.jpg0.0000001.000000
1Eiza_Gonzalez_01.jpg0.0453880.954612
2Eiza_Gonzalez_05.jpg0.0465880.953412
3Jess_Hong_02.jpg0.0552800.944720
4Eiza_Gonzalez_04.jpg0.0637420.936258
5Jess_Hong_01.jpg0.0664020.933598
6Alex_Sharp_02.jpg0.0847850.915215
7Liam_Cunningham_04.jpg0.0861340.913866
8Jess_Hong_03.jpg0.0865820.913418
9Eiza_Gonzalez_02.jpg0.0869790.913021
10Benedict_Wong_04.jpg0.0882600.911740
11John_Bradley_03.jpg0.0918570.908143
12Alex_Sharp_01.jpg0.1048450.895155
13John_Bradley_04.jpg0.1048690.895131
14Eiza_Gonzalez_02.jpg0.1049110.895089
15John_Bradley_01.jpg0.1086800.891320
16Liam_Cunningham_02.jpg0.1115240.888476
17John_Bradley_02.jpg0.1138920.886108
18Benedict_Wong_05.jpg0.1251200.874880
19Alex_Sharp_03.jpg0.1268740.873126
20Benedict_Wong_02.jpg0.1279460.872054
21Benedict_Wong_01.jpg0.1348410.865159
22Benedict_Wong_03.jpg0.1451670.854833
23Jovan_Adepo_01.jpg0.1460450.853955
24Liam_Cunningham_01.jpg0.1517280.848272
25Jovan_Adepo_02.jpg0.1532020.846798
26Liam_Cunningham_03.jpg0.1571190.842881
result_7_df.plot(x="Images", y="Similarity", kind="bar")

png

VGG-Face / YOLOv8

  • vgg_face_weights.h5 - 552.3 MB
  • yolov8n-face.pt - 6.1 MB
  • 24-05-09 12:31:57 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore
  • 24-05-09 12:31:57 - find function duration 0.21353983879089355 seconds
result8 = DeepFace.find(
img_path = "assets/Eiza_Gonzalez_03.jpg",
db_path = "assets",
model_name = "VGG-Face",
distance_metric = "cosine",
enforce_detection = True,
detector_backend = "yolov8",
align = True,
expand_percentage = 0,
threshold = 0.90,
normalization = "base",
silent = False,
)

24-05-09 12:31:57 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore 24-05-09 12:31:57 - find function duration 0.21353983879089355 seconds

#identityhashtarget_xtarget_ytarget_wtarget_hsource_xsource_ysource_wsource_hthresholddistance
0assets/Eiza_Gonzalez_03.jpgc851bc623b011079548c899eedc96a0b8c1a926439196284391962840.9-2.220446e-16
1assets/Eiza_Gonzalez_01.jpgdd70311d238d2be8b47aee363e3f228b741c3b5020365139183391962840.94.798819e-01
2assets/Eiza_Gonzalez_05.jpg4e3c950ef9084dd264e056711afd7a949dfb5f955753119163391962840.95.464998e-01
3assets/Eiza_Gonzalez_04.jpg863a9e1f9f06ff1da45ef39de64f03a24d76816419237997391962840.95.515515e-01
4assets/Eiza_Gonzalez_02.jpg220a99ec5380b5d4033dd18f6f54353a49bb341b497132192252391962840.97.510090e-01
5assets/John_Bradley_01.jpg7619cdf25b6b4071aa6ebd9408e001f372cee5bc99114198282391962840.98.351889e-01
6assets/Jess_Hong_02.jpg1233412de754501680ab281fdd0b3c0b7e63427943146789391962840.98.763548e-01
7assets/Jess_Hong_03.jpg9b056b12303c62eeee91c49456bdda7f494aa07820624101135391962840.98.841409e-01
8assets/John_Bradley_03.jpg9686d791c5a87ff6060e721caf66f2532f92300a362095134391962840.98.854007e-01
9assets/John_Bradley_04.jpgd4c9635f2c37df80ade71f405b296ac98d68e6903160166214391962840.98.909801e-01
10assets/Benedict_Wong_05.jpg4f14065c9065e745f63b1ca22c206649922eaee245183649391962840.98.979046e-01
image_results = [
['./assets/Eiza_Gonzalez_03.jpg', 1.0000000000000002],
['./assets/Eiza_Gonzalez_01.jpg', 0.5201181],
['./assets/Eiza_Gonzalez_05.jpg', 0.4535002],
['./assets/Eiza_Gonzalez_04.jpg', 0.4484485],
['./assets/Eiza_Gonzalez_02.jpg', 0.24899099999999996],
['./assets/John_Bradley_01.jpg', 0.1648111]
]
plt.figure(figsize=(12,8))

for i in range(len(image_results)):
ax = plt.subplot(2,3,i+1)
plt.title(
image_results[i][0][9:-4]+'\n Similarity: '+str(round(image_results[i][1],2))
)
img = plt.imread(image_results[i][0])
plt.imshow(img)
plt.axis('off')

png

data_images = [
'Eiza_Gonzalez_03.jpg',
'Eiza_Gonzalez_01.jpg',
'Eiza_Gonzalez_05.jpg',
'Eiza_Gonzalez_04.jpg',
'Eiza_Gonzalez_02.jpg',
'John_Bradley_01.jpg',
'Jess_Hong_02.jpg',
'Jess_Hong_03.jpg',
'John_Bradley_03.jpg',
'John_Bradley_04.jpg',
'Benedict_Wong_05.jpg'
]

distance_data = [
-2.220446e-16,
4.798819e-01,
5.464998e-01,
5.515515e-01,
7.510090e-01,
8.351889e-01,
8.763548e-01,
8.841409e-01,
8.854007e-01,
8.909801e-01,
8.979046e-01
]

similarity_data = [
1.0000000000000002,
0.5201181,
0.4535002,
0.4484485,
0.24899099999999996,
0.1648111,
0.12364520000000001,
0.11585909999999999,
0.11459929999999996,
0.10901989999999995,
0.10209539999999995
]

result_8_df = pd.DataFrame({
'Images': data_images,
'Distance': distance_data,
'Similarity': similarity_data
}) Facenet512 / YOLOv8

result_8_df
ImagesDistanceSimilarity
0Eiza_Gonzalez_03.jpg-2.220446e-161.000000
1Eiza_Gonzalez_01.jpg4.798819e-010.520118
2Eiza_Gonzalez_05.jpg5.464998e-010.453500
3Eiza_Gonzalez_04.jpg5.515515e-010.448449
4Eiza_Gonzalez_02.jpg7.510090e-010.248991
5John_Bradley_01.jpg8.351889e-010.164811
6Jess_Hong_02.jpg8.763548e-010.123645
7Jess_Hong_03.jpg8.841409e-010.115859
8John_Bradley_03.jpg8.854007e-010.114599
9John_Bradley_04.jpg8.909801e-010.109020
10Benedict_Wong_05.jpg8.979046e-010.102095
result_8_df.plot(x="Images", y="Similarity", kind="bar")

png

Facenet512 / YOLOv8

  • facenet512_weights.h5 - 90.6 MB
  • yolov8n-face.pt - 6.1 MB
  • 24-05-10 06:14:06 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore
  • 24-05-10 06:14:07 - find function duration 0.1690361499786377 seconds
result9 = DeepFace.find(
img_path = "assets/Eiza_Gonzalez_03.jpg",
db_path = "assets",
model_name = "Facenet512",
distance_metric = "cosine",
enforce_detection = True,
detector_backend = "yolov8",
align = True,
expand_percentage = 0,
threshold = 0.90,
normalization = "base",
silent = False,
)

24-05-10 06:14:06 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore 24-05-10 06:14:07 - find function duration 0.1690361499786377 seconds

#identityhashtarget_xtarget_ytarget_wtarget_hsource_xsource_ysource_wsource_hthresholddistance
0assets/Eiza_Gonzalez_03.jpgc851bc623b011079548c899eedc96a0b8c1a926439196284391962840.94.440892e-16
1assets/Eiza_Gonzalez_01.jpgdd70311d238d2be8b47aee363e3f228b741c3b5020365139183391962840.92.783114e-01
2assets/Eiza_Gonzalez_04.jpg863a9e1f9f06ff1da45ef39de64f03a24d76816419237997391962840.93.291848e-01
3assets/Eiza_Gonzalez_05.jpg4e3c950ef9084dd264e056711afd7a949dfb5f955753119163391962840.93.929502e-01
4assets/Eiza_Gonzalez_02.jpg220a99ec5380b5d4033dd18f6f54353a49bb341b497132192252391962840.94.768916e-01
5assets/Jovan_Adepo_01.jpg47bc06e224a2538aa258c0b5d03f478e5713b8bc46166492391962840.97.567952e-01
6assets/Jess_Hong_02.jpg1233412de754501680ab281fdd0b3c0b7e63427943146789391962840.98.551544e-01
7assets/Benedict_Wong_04.jpgdbb025ab8039915335d84700c6423fadfa91c5b319315274391962840.98.763277e-01
8assets/Jovan_Adepo_02.jpgf5428170e3323a333121ceb196675526d8ad02c66359117169391962840.98.765136e-01
9assets/Alex_Sharp_03.jpg48a617ed38787e3dd5e7d7e87e2a56b37214ce38110111248345391962840.98.860148e-01
10assets/John_Bradley_03.jpg9686d791c5a87ff6060e721caf66f2532f92300a362095134391962840.98.862074e-01
11assets/Liam_Cunningham_03.jpgd349c11690daa1a9e118df5d4ae08d554852a96a11858130184391962840.98.896595e-01
12assets/John_Bradley_02.jpg7f0317379f612eb44096207202e3cc91e441a58e119625575391962840.98.998877e-01
image_results = [
['./assets/Eiza_Gonzalez_03.jpg', 0.9999999999999996],
['./assets/Eiza_Gonzalez_01.jpg', 0.7216886],
['./assets/Eiza_Gonzalez_04.jpg', 0.6708152000000001],
['./assets/Eiza_Gonzalez_05.jpg', 0.6070498],
['./assets/Eiza_Gonzalez_02.jpg', 0.5231083999999999],
['./assets/Jovan_Adepo_01.jpg', 0.2432048]
]
plt.figure(figsize=(12,8))

for i in range(len(image_results)):
ax = plt.subplot(2,3,i+1)
plt.title(
image_results[i][0][9:-4]+'\n Similarity: '+str(round(image_results[i][1],2))
)
img = plt.imread(image_results[i][0])
plt.imshow(img)
plt.axis('off')

png

data_images = [
'Eiza_Gonzalez_03.jpg',
'Eiza_Gonzalez_01.jpg',
'Eiza_Gonzalez_04.jpg',
'Eiza_Gonzalez_05.jpg',
'Eiza_Gonzalez_02.jpg',
'Jovan_Adepo_01.jpg',
'Jess_Hong_02.jpg',
'Benedict_Wong_04.jpg',
'Jovan_Adepo_02.jpg',
'Alex_Sharp_03.jpg',
'John_Bradley_03.jpg',
'Liam_Cunningham_03.jpg',
'John_Bradley_02.jpg'
]

distance_data = [
4.440892e-16,
2.783114e-01,
3.291848e-01,
3.929502e-01,
4.768916e-01,
7.567952e-01,
8.551544e-01,
8.763277e-01,
8.765136e-01,
8.860148e-01,
8.862074e-01,
8.896595e-01,
8.998877e-01,
]

similarity_data = [
0.9999999999999996,
0.7216886,
0.6708152000000001,
0.6070498,
0.5231083999999999,
0.2432048,
0.14484560000000002,
0.12367229999999996,
0.1234864,
0.11398520000000001,
0.11379260000000002,
0.11034049999999995,
0.10011230000000004
]

result_9_df = pd.DataFrame({
'Images': data_images,
'Distance': distance_data,
'Similarity': similarity_data
})

result_9_df
ImagesDistanceSimilarity
0Eiza_Gonzalez_03.jpg4.440892e-161.000000
1Eiza_Gonzalez_01.jpg2.783114e-010.721689
2Eiza_Gonzalez_04.jpg3.291848e-010.670815
3Eiza_Gonzalez_05.jpg3.929502e-010.607050
4Eiza_Gonzalez_02.jpg4.768916e-010.523108
5Jovan_Adepo_01.jpg7.567952e-010.243205
6Jess_Hong_02.jpg8.551544e-010.144846
7Benedict_Wong_04.jpg8.763277e-010.123672
8Jovan_Adepo_02.jpg8.765136e-010.123486
9Alex_Sharp_03.jpg8.860148e-010.113985
10John_Bradley_03.jpg8.862074e-010.113793
11Liam_Cunningham_03.jpg8.896595e-010.110340
12John_Bradley_02.jpg8.998877e-010.100112
result_9_df.plot(x="Images", y="Similarity", kind="bar")

png

Facenet / YOLOv8

  • facenet_weights.h5 - 87.9 MB
  • yolov8n-face.pt - 6.1 MB
  • 24-05-10 06:31:52 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore
  • 24-05-10 06:31:53 - find function duration 0.1595611572265625 seconds
result10 = DeepFace.find(
img_path = "assets/Eiza_Gonzalez_03.jpg",
db_path = "assets",
model_name = "Facenet",
distance_metric = "cosine",
enforce_detection = True,
detector_backend = "yolov8",
align = True,
expand_percentage = 0,
threshold = 0.90,
normalization = "base",
silent = False,
)

24-05-10 06:31:52 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore 24-05-10 06:31:53 - find function duration 0.1595611572265625 seconds

#identityhashtarget_xtarget_ytarget_wtarget_hsource_xsource_ysource_wsource_hthresholddistance
0assets/Eiza_Gonzalez_03.jpgc851bc623b011079548c899eedc96a0b8c1a926439196284391962840.9-2.220446e-16
1assets/Eiza_Gonzalez_01.jpgdd70311d238d2be8b47aee363e3f228b741c3b5020365139183391962840.91.577659e-01
2assets/Eiza_Gonzalez_05.jpg4e3c950ef9084dd264e056711afd7a949dfb5f955753119163391962840.93.097999e-01
3assets/Eiza_Gonzalez_04.jpg863a9e1f9f06ff1da45ef39de64f03a24d76816419237997391962840.94.673658e-01
4assets/Eiza_Gonzalez_02.jpg220a99ec5380b5d4033dd18f6f54353a49bb341b497132192252391962840.97.133165e-01
5assets/Benedict_Wong_05.jpg4f14065c9065e745f63b1ca22c206649922eaee245183649391962840.98.396030e-01
6assets/Liam_Cunningham_01.jpga157a9143b88b9844ea65f1ccea484a337670853137163231319391962840.98.708137e-01
7assets/Jovan_Adepo_01.jpg47bc06e224a2538aa258c0b5d03f478e5713b8bc46166492391962840.98.942636e-01
8assets/Liam_Cunningham_03.jpgd349c11690daa1a9e118df5d4ae08d554852a96a11858130184391962840.98.980692e-01
image_results = [
['./assets/Eiza_Gonzalez_03.jpg', 1.0000000000000002],
['./assets/Eiza_Gonzalez_01.jpg', 0.8422341],
['./assets/Eiza_Gonzalez_05.jpg', 0.6902001],
['./assets/Eiza_Gonzalez_04.jpg', 0.5326342],
['./assets/Eiza_Gonzalez_02.jpg', 0.2866835],
['./assets/Benedict_Wong_05.jpg', 0.160397]
]
plt.figure(figsize=(12,8))

for i in range(len(image_results)):
ax = plt.subplot(2,3,i+1)
plt.title(
image_results[i][0][9:-4]+'\n Similarity: '+str(round(image_results[i][1],2))
)
img = plt.imread(image_results[i][0])
plt.imshow(img)
plt.axis('off')

png

data_images = [
'Eiza_Gonzalez_03.jpg',
'Eiza_Gonzalez_01.jpg',
'Eiza_Gonzalez_05.jpg',
'Eiza_Gonzalez_04.jpg',
'Eiza_Gonzalez_02.jpg',
'Benedict_Wong_05.jpg',
'Liam_Cunningham_01.jpg',
'Jovan_Adepo_01.jpg',
'Liam_Cunningham_03.jpg'
]

distance_data = [
-2.220446e-16,
1.577659e-01,
3.097999e-01,
4.673658e-01,
7.133165e-01,
8.396030e-01,
8.708137e-01,
8.942636e-01,
8.980692e-01
]

similarity_data = [
1.0000000000000002,
0.8422341,
0.6902001,
0.5326342,
0.2866835,
0.160397,
0.12918629999999998,
0.10573639999999995,
0.10193079999999999
]

result_10_df = pd.DataFrame({
'Images': data_images,
'Distance': distance_data,
'Similarity': similarity_data
})

result_10_df
ImagesDistanceSimilarity
0Eiza_Gonzalez_03.jpg-2.220446e-161.000000
1Eiza_Gonzalez_01.jpg1.577659e-010.842234
2Eiza_Gonzalez_05.jpg3.097999e-010.690200
3Eiza_Gonzalez_04.jpg4.673658e-010.532634
4Eiza_Gonzalez_02.jpg7.133165e-010.286683
5Benedict_Wong_05.jpg8.396030e-010.160397
6Liam_Cunningham_01.jpg8.708137e-010.129186
7Jovan_Adepo_01.jpg8.942636e-010.105736
8Liam_Cunningham_03.jpg8.980692e-010.101931
result_10_df.plot(x="Images", y="Similarity", kind="bar")

png

ArcFace / YOLOv8

  • arcface_weights.h5 - 130.7 MB
  • yolov8n-face.pt - 6.1 MB
  • 24-05-10 06:51:33 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore
  • 24-05-10 06:51:34 - Find function duration 0.14449524879455566 seconds
result11 = DeepFace.find(
img_path = "assets/Eiza_Gonzalez_03.jpg",
db_path = "assets",
model_name = "ArcFace",
distance_metric = "cosine",
enforce_detection = True,
detector_backend = "yolov8",
align = True,
expand_percentage = 0,
threshold = 0.90,
normalization = "base",
silent = False,
)

24-05-10 06:59:27 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore 24-05-10 06:59:27 - find function duration 0.14449524879455566 seconds

#identityhashtarget_xtarget_ytarget_wtarget_hsource_xsource_ysource_wsource_hthresholddistance
0assets/Eiza_Gonzalez_03.jpgc851bc623b011079548c899eedc96a0b8c1a926439196284391962840.90.000000
1assets/Eiza_Gonzalez_01.jpgdd70311d238d2be8b47aee363e3f228b741c3b5020365139183391962840.90.491314
2assets/Eiza_Gonzalez_04.jpg863a9e1f9f06ff1da45ef39de64f03a24d76816419237997391962840.90.534116
3assets/Eiza_Gonzalez_05.jpg4e3c950ef9084dd264e056711afd7a949dfb5f955753119163391962840.90.597161
4assets/Eiza_Gonzalez_02.jpg220a99ec5380b5d4033dd18f6f54353a49bb341b497132192252391962840.90.784296
5assets/Alex_Sharp_03.jpg48a617ed38787e3dd5e7d7e87e2a56b37214ce38110111248345391962840.90.828761
6assets/Jovan_Adepo_01.jpg47bc06e224a2538aa258c0b5d03f478e5713b8bc46166492391962840.90.858612
7assets/Jovan_Adepo_02.jpgf5428170e3323a333121ceb196675526d8ad02c66359117169391962840.90.866306
8assets/Alex_Sharp_01.jpg7155ec0a507fd98583c179beb164c9fcfa0fa9172074293123391962840.90.887515
image_results = [
['./assets/Eiza_Gonzalez_03.jpg', 1.000000000000000],
['./assets/Eiza_Gonzalez_01.jpg', 0.508686],
['./assets/Eiza_Gonzalez_04.jpg', 0.46588399999999996],
['./assets/Eiza_Gonzalez_05.jpg', 0.40283899999999995],
['./assets/Eiza_Gonzalez_02.jpg', 0.215704],
['./assets/Alex_Sharp_03.jpg', 0.17123900000000003]
]
plt.figure(figsize=(12,8))

for i in range(len(image_results)):
ax = plt.subplot(2,3,i+1)
plt.title(
image_results[i][0][9:-4]+'\n Similarity: '+str(round(image_results[i][1],2))
)
img = plt.imread(image_results[i][0])
plt.imshow(img)
plt.axis('off')

png

data_images = [
'Eiza_Gonzalez_03.jpg',
'Eiza_Gonzalez_01.jpg',
'Eiza_Gonzalez_04.jpg',
'Eiza_Gonzalez_05.jpg',
'Eiza_Gonzalez_02.jpg',
'Alex_Sharp_03.jpg',
'Jovan_Adepo_01.jpg',
'Jovan_Adepo_02.jpg',
'Alex_Sharp_01.jpg'
]

distance_data = [
0.000000,
0.491314,
0.534116,
0.597161,
0.784296,
0.828761,
0.858612,
0.866306,
0.887515
]

similarity_data = [
1.0,
0.508686,
0.46588399999999996,
0.40283899999999995,
0.215704,
0.17123900000000003,
0.14138799999999996,
0.13369399999999998,
0.11248499999999995
]

result_11_df = pd.DataFrame({
'Images': data_images,
'Distance': distance_data,
'Similarity': similarity_data
})

result_11_df
ImagesDistanceSimilarity
0Eiza_Gonzalez_03.jpg0.0000001.000000
1Eiza_Gonzalez_01.jpg0.4913140.508686
2Eiza_Gonzalez_04.jpg0.5341160.465884
3Eiza_Gonzalez_05.jpg0.5971610.402839
4Eiza_Gonzalez_02.jpg0.7842960.215704
5Alex_Sharp_03.jpg0.8287610.171239
6Jovan_Adepo_01.jpg0.8586120.141388
7Jovan_Adepo_02.jpg0.8663060.133694
8Alex_Sharp_01.jpg0.8875150.112485
result_11_df.plot(x="Images", y="Similarity", kind="bar")

png

GhostFaceNet / YOLOv8

  • GhostFaceNet_W1.3_S1_ArcFace.h5 - 16.5 MB
  • yolov8n-face.pt - 6.1 MB
  • 24-05-10 07:47:47 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore
  • 24-05-10 07:47:47 - Find function duration 0.16495823860168457 seconds
result12 = DeepFace.find(
img_path = "assets/Eiza_Gonzalez_03.jpg",
db_path = "assets",
model_name = "GhostFaceNet",
distance_metric = "cosine",
enforce_detection = True,
detector_backend = "yolov8",
align = True,
expand_percentage = 0,
threshold = 0.90,
normalization = "base",
silent = False,
)

24-05-10 07:47:47 - Searching assets/Eiza_Gonzalez_03.jpg in 27 length datastore 24-05-10 07:47:47 - find function duration 0.16495823860168457 seconds

#identityhashtarget_xtarget_ytarget_wtarget_hsource_xsource_ysource_wsource_hthresholddistance
0assets/Eiza_Gonzalez_03.jpgc851bc623b011079548c899eedc96a0b8c1a926439196284391962840.90.000000
1assets/Eiza_Gonzalez_01.jpgdd70311d238d2be8b47aee363e3f228b741c3b5020365139183391962840.90.588340
2assets/Eiza_Gonzalez_05.jpg4e3c950ef9084dd264e056711afd7a949dfb5f955753119163391962840.90.713904
3assets/Jess_Hong_02.jpg1233412de754501680ab281fdd0b3c0b7e63427943146789391962840.90.799567
4assets/Eiza_Gonzalez_04.jpg863a9e1f9f06ff1da45ef39de64f03a24d76816419237997391962840.90.814843
5assets/Jess_Hong_03.jpg9b056b12303c62eeee91c49456bdda7f494aa07820624101135391962840.90.857111
6assets/Benedict_Wong_05.jpg4f14065c9065e745f63b1ca22c206649922eaee245183649391962840.90.861572
7assets/Eiza_Gonzalez_02.jpg220a99ec5380b5d4033dd18f6f54353a49bb341b497132192252391962840.90.890497
image_results = [
['./assets/Eiza_Gonzalez_03.jpg', 1.000000000000000],
['./assets/Eiza_Gonzalez_01.jpg', 0.41166],
['./assets/Eiza_Gonzalez_05.jpg', 0.286096],
['./assets/Jess_Hong_02.jpg', 0.20043299999999997],
['./assets/Eiza_Gonzalez_04.jpg', 0.18515700000000002],
['./assets/Jess_Hong_03.jpg', 0.14288900000000004]
]
plt.figure(figsize=(12,8))

for i in range(len(image_results)):
ax = plt.subplot(2,3,i+1)
plt.title(
image_results[i][0][9:-4]+'\n Similarity: '+str(round(image_results[i][1],2))
)
img = plt.imread(image_results[i][0])
plt.imshow(img)
plt.axis('off')

png

data_images = [
'Eiza_Gonzalez_03.jpg',
'Eiza_Gonzalez_01.jpg',
'Eiza_Gonzalez_05.jpg',
'Jess_Hong_02.jpg',
'Eiza_Gonzalez_04.jpg',
'Jess_Hong_03.jpg',
'Benedict_Wong_05.jpg',
'Eiza_Gonzalez_02.jpg'
]

distance_data = [
0.000000,
0.588340,
0.713904,
0.799567,
0.814843,
0.857111,
0.861572,
0.890497
]

similarity_data = [
1.0,
0.41166,
0.286096,
0.20043299999999997,
0.18515700000000002,
0.14288900000000004,
0.138428,
0.10950300000000002
]

result_12_df = pd.DataFrame({
'Images': data_images,
'Distance': distance_data,
'Similarity': similarity_data
})

result_12_df
ImagesDistanceSimilarity
0Eiza_Gonzalez_03.jpg0.0000001.000000
1Eiza_Gonzalez_01.jpg0.5883400.411660
2Eiza_Gonzalez_05.jpg0.7139040.286096
3Jess_Hong_02.jpg0.7995670.200433
4Eiza_Gonzalez_04.jpg0.8148430.185157
5Jess_Hong_03.jpg0.8571110.142889
6Benedict_Wong_05.jpg0.8615720.138428
7Eiza_Gonzalez_02.jpg0.8904970.109503
result_12_df.plot(x="Images", y="Similarity", kind="bar")

png

Face Analysis

  • facial_expression_model_weights.h5 - 5.7 MB
  • age_model_weights.h5 - 513.8 MB
  • gender_model_weights.h5 - 512.3 MB
  • race_model_single_batch.h5 - 512.3 MB
result13 = DeepFace.analyze(
img_path = "assets/Benedict_Wong_03.jpg",
actions = ["emotion", "age", "gender", "race"],
enforce_detection = True,
detector_backend = "yolov8",
align = True,
expand_percentage = 0,
silent = False,
)
pretty_print2(result13)

Emotions: angry 52.47458815574646, disgust 1.6047310500973637e-14, fear 1.1184778797579398e-08, happy 0.8838735520839691, sad 0.002243508606625255, surprise 1.661406301423085e-06, neutral 46.63929641246796 Dominant Emotion: angry, Confidence: 0.87, Age: 44, Female: 0.08514390792697668, Male: 99.91486072540283, Dominant Gender: Man, Asian: 99.96744990154802, Indian: 0.020422336582121944, Black: 3.538733961399402e-07, White: 0.0007214643549394969, Middle Eastern: 9.568194723961802e-09, Latino Hispanic: 0.011405441862250006, Dominant Race: asian, Detections :: x,y,w,h,left_eye,right_eye Regions: 89,84,130,173,(183, 149),(125, 146)

result14 = DeepFace.analyze(
img_path = "assets/Eiza_Gonzalez_03.jpg",
actions = ["emotion", "age", "gender", "race"],
enforce_detection = True,
detector_backend = "yolov8",
align = True,
expand_percentage = 0,
silent = False,
)
pretty_print2(result14)

Emotions: angry 61.89677715301514, disgust 0.0003831427875411464, fear 17.56562739610672, happy 0.024294608738273382, sad 7.415241003036499, surprise 0.0922270177397877, neutral 13.00545483827591 Dominant Emotion: angry, Confidence: 0.83, Age: 27, Female: 99.99103546142578, Male: 0.008965710730990395, Dominant Gender: Woman, Asian: 1.2231661533613387, Indian: 1.5839036579613277, Black: 0.15020265171857497, White: 51.279270801457265, Middle Eastern: 18.619856967908973, Latino Hispanic: 27.143603818846206, Dominant Race: white, Detections :: x,y,w,h,left_eye,right_eye Regions: 39,19,62,84,(91, 57),(66, 52)

result15 = DeepFace.analyze(
img_path = "assets/Jovan_Adepo_01.jpg",
actions = ["emotion", "age", "gender", "race"],
enforce_detection = True,
detector_backend = "yolov8",
align = True,
expand_percentage = 0,
silent = False,
)
pretty_print2(result15)

Emotions: angry 0.043431183439679444, disgust 1.5149926940131314e-11, fear 0.0003094855173912947, happy 4.4355454065225786e-05, sad 0.051101919962093234, surprise 2.526942033398427e-06, neutral 99.90511536598206 Dominant Emotion: neutral, Confidence: 0.86, Age: 35, Female: 0.016746165056247264, Male: 99.98325109481812, Dominant Gender: Man, Asian: 1.4956607063965066e-07, Indian: 4.022327360075906e-06, Black: 100.0, White: 2.5537931144792303e-10, Middle Eastern: 9.079970391019654e-11, Latino Hispanic: 1.2836626872569923e-06, Dominant Race: black, Detections :: x,y,w,h,left_eye,right_eye Regions: 46,16,64,92,(92, 51),(61, 50)

result16 = DeepFace.analyze(
img_path = "assets/Jess_Hong_01.jpg",
actions = ["emotion", "age", "gender", "race"],
enforce_detection = True,
detector_backend = "yolov8",
align = True,
expand_percentage = 0,
silent = False,
)
pretty_print2(result16)

Emotions: angry 21.61679118871689, disgust 0.002775121174636297, fear 8.90427678823471, happy 0.0006556400876434054, sad 53.71009111404419, surprise 0.0014677107174065895, neutral 15.763948857784271 Dominant Emotion: sad, Confidence: 0.85, Age: 35, Female: 96.56398296356201, Male: 3.4360110759735107, Dominant Gender: Woman, Asian: 96.5178076603642, Indian: 1.5434301481032195, Black: 0.11495926676803628, White: 0.3914411644409699, Middle Eastern: 0.02275169119265259, Latino Hispanic: 1.4096110310124121, Dominant Race: asian, Detections :: x,y,w,h,left_eye,right_eye Regions: 110,54,48,69,(132, 80),(114, 80)

models = [
'VGG-Face / OpenCV',
'Dlib / dlib',
'Dlib / Mediapipe',
'Dlib / YOLOv8',
'VGG-Face / YOLOv8',
'Facenet512 / YOLOv8',
'Facenet / YOLOv8',
'ArcFace / YOLOv8',
'GhostFaceNet / YOLOv8'
]

weight_size = [
552.3,
20.4,
25.8,
26.1,
558.4,
96.7,
94.0,
136.8,
22.6
]

run_time = [
0.21913480758666992,
0.13037323951721191,
0.3898661136627197,
0.12443137168884277,
0.21353983879089355,
0.1690361499786377,
0.1595611572265625,
0.14449524879455566,
0.16495823860168457
]

models_df = pd.DataFrame({
'Face Recognition / Detection': models,
'Combined Model Weight Size [MB]': weight_size,
'Detection Time [s]': run_time
})

models_df
Face Recognition / DetectionCombined Model Weight Size [MB]Detection Time [s]
0VGG-Face / OpenCV552.30.219135
1Dlib / dlib20.40.130373
2Dlib / Mediapipe25.80.389866
3Dlib / YOLOv826.10.124431
4VGG-Face / YOLOv8558.40.213540
5Facenet512 / YOLOv896.70.169036
6Facenet / YOLOv894.00.159561
7ArcFace / YOLOv8136.80.144495
8GhostFaceNet / YOLOv822.60.164958
models_df.plot(x="Face Recognition / Detection", y="Combined Model Weight Size [MB]", kind="bar")

png

models_df.plot(x="Face Recognition / Detection", y="Detection Time [s]", kind="bar")

png