mirror of
https://github.com/serengil/deepface.git
synced 2025-06-08 20:45:22 +00:00
distance in find function implemented
This commit is contained in:
parent
c67ae7fe6a
commit
4440d82d44
@ -435,7 +435,16 @@ def find(img_path, db_path
|
|||||||
distances = []
|
distances = []
|
||||||
for index, instance in df.iterrows():
|
for index, instance in df.iterrows():
|
||||||
source_representation = instance["representation"]
|
source_representation = instance["representation"]
|
||||||
|
|
||||||
|
if distance_metric == 'cosine':
|
||||||
distance = dst.findCosineDistance(source_representation, target_representation)
|
distance = dst.findCosineDistance(source_representation, target_representation)
|
||||||
|
elif distance_metric == 'euclidean':
|
||||||
|
distance = dst.findEuclideanDistance(source_representation, target_representation)
|
||||||
|
elif distance_metric == 'euclidean_l2':
|
||||||
|
distance = dst.findEuclideanDistance(dst.l2_normalize(source_representation), dst.l2_normalize(target_representation))
|
||||||
|
else:
|
||||||
|
raise ValueError("Invalid distance_metric passed - ", distance_metric)
|
||||||
|
|
||||||
distances.append(distance)
|
distances.append(distance)
|
||||||
|
|
||||||
df["distance"] = distances
|
df["distance"] = distances
|
||||||
|
Loading…
x
Reference in New Issue
Block a user