mirror of
https://github.com/serengil/deepface.git
synced 2025-06-06 19:45:21 +00:00
unit tests
This commit is contained in:
parent
eeaf1253da
commit
6438075233
@ -135,13 +135,9 @@ def test_cases():
|
||||
|
||||
print("-----------------------------------------")
|
||||
|
||||
print("Face recognition tests")
|
||||
|
||||
passed_tests = 0; test_cases = 0
|
||||
print("Facial recognition tests")
|
||||
|
||||
for model in models:
|
||||
#prebuilt_model = DeepFace.build_model(model)
|
||||
#print(model," is built")
|
||||
for metric in metrics:
|
||||
for instance in dataset:
|
||||
img1 = instance[0]
|
||||
@ -150,43 +146,32 @@ def test_cases():
|
||||
|
||||
resp_obj = DeepFace.verify(img1, img2
|
||||
, model_name = model
|
||||
#, model = prebuilt_model
|
||||
, distance_metric = metric)
|
||||
|
||||
prediction = resp_obj["verified"]
|
||||
distance = round(resp_obj["distance"], 2)
|
||||
threshold = resp_obj["threshold"]
|
||||
|
||||
evaluate( prediction == result )
|
||||
passed = prediction == result
|
||||
|
||||
test_result_label = "failed"
|
||||
if prediction == result:
|
||||
passed_tests = passed_tests + 1
|
||||
evaluate(passed)
|
||||
|
||||
if passed:
|
||||
test_result_label = "passed"
|
||||
else:
|
||||
test_result_label = "failed"
|
||||
|
||||
if prediction == True:
|
||||
classified_label = "verified"
|
||||
else:
|
||||
classified_label = "unverified"
|
||||
|
||||
test_cases = test_cases + 1
|
||||
|
||||
print(img1.split("/")[-1], "-", img2.split("/")[-1], classified_label, "as same person based on", model,"and",metric,". Distance:",distance,", Threshold:", threshold,"(",test_result_label,")")
|
||||
|
||||
print("--------------------------")
|
||||
|
||||
#-----------------------------------------
|
||||
|
||||
print("Passed unit tests: ",passed_tests," / ",test_cases)
|
||||
|
||||
min_score = 70
|
||||
|
||||
accuracy = 100 * passed_tests / test_cases
|
||||
accuracy = round(accuracy, 2)
|
||||
|
||||
print("--------------------------")
|
||||
|
||||
#-----------------------------------
|
||||
print("--------------------------")
|
||||
|
||||
print("Passing numpy array to analyze function")
|
||||
|
Loading…
x
Reference in New Issue
Block a user