Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what is the best threshold for face search #161

Open
wuxuedaifu opened this issue Oct 25, 2024 · 2 comments
Open

what is the best threshold for face search #161

wuxuedaifu opened this issue Oct 25, 2024 · 2 comments

Comments

@wuxuedaifu
Copy link

for AdaFace, what is the best smilarity threshold for face search?

@mk-minchul
Copy link
Owner

It depends on the evaluation setting. But for one example, checking out the threshold that gives the best verification accuracy over 5 fold cross validations of popular verificaiton dataset (LFW, CFPFP, etc) should give you good number to work with. In my experience, 0.3 was a good number, but it is a rough guess.

@macqueen09
Copy link

After extracting features during model reasoning, what are the recommended methods to process the output features for comparing the similarity of faces?

@torch.no_grad()
def extract_feature(model, batch):
    batch = batch.to(device)
    # batch = torch.stack(processed_imgs)  # (batch_size, C, H, W)
    feature, _  = model(batch)
    features = feature.cpu().numpy()
    normalized_features = features / np.linalg.norm(features, axis=1, keepdims=True)
    return normalized_features

after that i use python
import faiss
to search face in a bank:

res = faiss.StandardGpuResources()
index= faiss.read_index(INDEX_FILE_FACE)

def search_face_in_index(feature, index, filenames):
    feature = feature.reshape(1, -1).astype("float32")
    distances, indices = index.search(feature, 1)
    best_match_idx = indices[0][0]
    best_match_file = filenames[best_match_idx]
    best_distance = distances[0][0]
    return best_match_file, best_distance

@mk-minchul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants