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

Good Recognition Score Threshold #502

Open
ceyxasm opened this issue Nov 6, 2024 · 1 comment
Open

Good Recognition Score Threshold #502

ceyxasm opened this issue Nov 6, 2024 · 1 comment
Assignees

Comments

@ceyxasm
Copy link

ceyxasm commented Nov 6, 2024

Issue Description
Hey @vladmandic I am using faceres and faceres-deep of human to calculate similarity scores between two faces. (Calculating embeddings, then their Euclidean distance, followed by their normalization).

for i, entry in enumerate(data):
    embedding_i = np.array(entry["result"]["face"][0]["embedding"])
    similarities = []

    # Compare with every other entry
    for j, other_entry in enumerate(data):
        if i != j:  # Skip comparing the entry with itself
            embedding_j = np.array(other_entry["result"]["face"][0]["embedding"])
            score = euclidean_distance(embedding_i, embedding_j)
            _min = 0
            _max = 1
            norm_score = null
            if (score == 0): 
                norm_score = 1
            else:        
                root = score**0.5
                norm = (1 - (root / 100) - _min) / (_max - _min)
                clamp = max(min(norm, 1), 0)
                norm_score = clamp
            similarities.append({"index": j, "score": norm_score})
    # Sort similarities by score in descending order and get the top 10
    top_similar = sorted(similarities, key=lambda x: x["score"], reverse=True)[:7]

My question is what similarity score is considered a good score for threshold. In my use case, I am capturing faces on the fly and matching them with faces in my archive. But I cannot just take the most similar face because what if the face captured is not even in the archive and hence a minimum threshold is required.
Moreover I ran a few tests with images of politicians and and even dissimilar faces have a very high score.

    {
        "filename": "../recog/images/kamala-01.png",
        "top_similar_faces": [
            {
                "filename": "../recog/images/kamala-02.png",
                "score": 0.9741146265169502
            },
            {
                "filename": "../recog/images/kamala-03.png",
                "score": 0.973418896214827
            },
            {
                "filename": "../recog/images/kamala-04.png",
                "score": 0.9723309845538807
            },
            {
                "filename": "../recog/images/kamala-06.png",
                "score": 0.9723104988689575
            },
            {
                "filename": "../recog/images/kamala-05.png",
                "score": 0.970410842672599
            },
            {
                "filename": "../recog/images/trump-04.png",
                "score": 0.9687091084578349
            },
            {
                "filename": "../recog/images/trump-01.png",
                "score": 0.9685781702956071
            }
        ]
    },

Is this expected or am I doing something wrong??
Images used for the experimentation can be found here

@ceyxasm
Copy link
Author

ceyxasm commented Nov 6, 2024

Also an additional question about the faceres model. In the credits you have mentioned HSE-faceres repo. There they provide mobilenet and resent models.
Is the faceres (TFJS) model used in human same as their vgg-mobilenet model??

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

2 participants