0

I have a dataset that contains 1500 face images and i have selected 150 images as probe. Now 150 images are in probe folder and other images are in gallery folder.

I have facenet feature extractor which extract features from images and save into .npy array to compute euclidean distance.

How i can compare these 150 images with whole gallery folder and draw a accuracy graph of rank-1,5 and 10 and between similar images and compute mAP?

greg-449
  • 109,219
  • 232
  • 102
  • 145
Khawar Islam
  • 2,556
  • 2
  • 34
  • 56

2 Answers2

0

First, i will run feature extractor to the test image. Then calculate the difference between each 150 images feature extraction results (lets say train sets) and test image feature extraction results.

all_res = []
for set in train sets : 
   res = set - test_res
   res = sum(res)
   all_res.append(res)
all_res = all_rest.sort()

So the smallest index of the all_res list are the first rank and the biggest one is the latest rank. I hope it can be good reference. Also you can use sklearn to evaluate your model such as SVC, accuracy_score, etc.

0

Suppose that 1500 face images are stored in source folder, and 150 images are stored in target folder.

#!pip install deepface
from deepface import DeepFace
targets = ["img1.jpg", "img2.jpg", "img150.jpg"]
resp = DeepFace.find(img_path = targets, db_path = "source", model_name = "Facenet")

BTW, you can set Facenet, VGG-Face, OpenFace, DeepFace or DeepID as model name.

Response object will return list of pandas data frames. Each data frame is sorted from the most similar one to least similar one. That's why, I'll get the 1st one.

index = 0
for df in resp:
   if df.shape[0] > 0:
      #print(targets[index], ": ", df.head(1))
       df.to_csv("%s" % (targets[index]), index = False)
   index = index + 1

This will match identities in two folders.

johncasey
  • 1,250
  • 8
  • 14