model_name and distance_metric check

This commit is contained in:
Sefik Ilkin Serengil 2020-02-13 10:35:43 +03:00 committed by GitHub
parent 79e27f9a07
commit 9f785003b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,12 +27,6 @@ def verify(img1_path, img2_path
#------------------------- #-------------------------
#print("Face verification will be applied on ",model_name," model and ",distance_metric," metric")
functions.validateInputs(model_name, distance_metric)
#-------------------------
#tuned thresholds for model and metric pair #tuned thresholds for model and metric pair
threshold = functions.findThreshold(model_name, distance_metric) threshold = functions.findThreshold(model_name, distance_metric)
@ -53,6 +47,9 @@ def verify(img1_path, img2_path
model = Facenet.loadModel() model = Facenet.loadModel()
input_shape = (160, 160) input_shape = (160, 160)
else:
raise ValueError("Invalid model_name passed - ", model_name)
#------------------------- #-------------------------
#crop face #crop face
@ -80,6 +77,8 @@ def verify(img1_path, img2_path
elif distance_metric == 'euclidean_l2': elif distance_metric == 'euclidean_l2':
print("Using euclidean distance l2 form") print("Using euclidean distance l2 form")
distance = dst.findEuclideanDistance(dst.l2_normalize(img1_representation), dst.l2_normalize(img2_representation)) distance = dst.findEuclideanDistance(dst.l2_normalize(img1_representation), dst.l2_normalize(img2_representation))
else:
raise ValueError("Invalid distance_metric passed - ", distance_metric)
#------------------------- #-------------------------
#decision #decision