Git Product home page Git Product logo

Comments (16)

serengil avatar serengil commented on June 12, 2024 1

definetely i will. we will add it because of its accuracy for asian faces.

btw - feel free to continue discussion this thread. the reason I closed it that I only set tickets open only if that requires code change.

from deepface.

serengil avatar serengil commented on June 12, 2024

you are using different models in verify and find functions. one is vgg, other is dlib.

TLDR: find and verify do the same, just find stores already calculated thresholds in a pickle file to find faster in next run.

from deepface.

Raghucharan16 avatar Raghucharan16 commented on June 12, 2024

My bad I pasted wrong code, I tried with the same models and I edited the same, with same model, with the same threshold results are different. i think this needs a fix. I also tried loosening the threshold distance of find function but there is no improvements. so how can i achieve faster and accurate results using find similar to verify method. Anyway thanks for this amazing repo.

from deepface.

serengil avatar serengil commented on June 12, 2024

if a photo has many faces, then verify considers the most similar one between the other photo.

on the other hand, find calculates distances for each face. this is the only difference.

from deepface.

Raghucharan16 avatar Raghucharan16 commented on June 12, 2024

ok. but i'm extracting all the faces in an image and saving them as individual images into a folder. and using this folder i'm checking the unique_faces folder. so there aren't any mutliple faces in a single image.

from deepface.

serengil avatar serengil commented on June 12, 2024

you may try to print distance values between image pairs. if you see any difference on these distance values for same image pair, we can continue to discuss.

from deepface.

Raghucharan16 avatar Raghucharan16 commented on June 12, 2024

yes...that is what I'm exactly trying to say...
here is the code for verify function

import os
from deepface import DeepFace

def verify_image_against_folder(image_path, folder_path):
    try:
        verified_results = {}
        for filename in os.listdir(folder_path):
            if filename.endswith(('.jpg', '.jpeg', '.png')):
                image_to_compare_path = os.path.join(folder_path, filename)
                result = DeepFace.verify(image_path, image_to_compare_path)
                if result["verified"]:
                    verified_results[filename] = result
    except:
        pass
    return verified_results

# Usage example:
reference_image_path = "Madhursample.jpg"
folder_path_to_compare = "dbmod"

results = verify_image_against_folder(reference_image_path, folder_path_to_compare)

# Print results
for filename, result in results.items():
    print(f"Verification result for {filename}: {result['verified']}")
    print(f"Distance: {result['distance']}")

and the output is

Verification result for AdityaVikramBudholiya_EMqaTest-3$00-0000-0000-000000024758_face.jpg: True
Distance: 0.6586338087844334
Verification result for VivekKumarGupta_EMqaTest-3$00-0000-0000-000000024832_face.jpg: True
Distance: 0.6253741569539091

and for find function the code is

from deepface import DeepFace
result=DeepFace.find("Madhursample.jpg",db_path="dbmod",enforce_detection=False)
print(result)

and the output is

[                                            identity                                      hash  target_x  target_y  ...  source_w  source_h  threshold  distance
0  dbmod/AlokKumar_EMqaTest-3$00-0000-0000-000000...  de05dfb9108ac362273ee2f033e1db9a961cd360        47       209  ...        73        73       0.68  0.533479
1  dbmod/VivekKumarGupta_EMqaTest-3$00-0000-0000-...  69e1254b38d6875b382ffb4012261f98761fcc06        50        60  ...        73        73       0.68  0.625374
2  dbmod/ManishRanjan_EMqaTest-3$00-0000-0000-000...  3c107ea80669c3a2c37526ef9a102e505d398905        88       276  ...        73        73       0.68  0.639899
3                              dbmod/Madhur_face.jpg  aaa8fe54fc30574dba2ce19ec28eb60fa49fc49b        47        50  ...        73        73       0.68  0.640093
4  dbmod/AdityaVikramBudholiya_EMqaTest-3$00-0000...  ff05c12f927aa766d5834d9015e01af5cee31be1        32        77  ...        73        73       0.68  0.658634
5  dbmod/SiddarthJain_EMqaTest-3$00-0000-0000-000...  32eab590a3ddec2225fa854a2a4e6596fcc644ac        37       176  ...        73        73       0.68  0.679664

[6 rows x 12 columns]]

As you can see, between the 2 results even though input image and folder are same, model [by default is VGG-face] so only difference is methods.

from deepface.

serengil avatar serengil commented on June 12, 2024

As I see from your results, find and verify are returning same. What is different?

Madhursample.jpg vs AdityaVikramBudholiya_EMqaTest-3$00-0000-0000-000000024758_face.jpg
Verify: 0.6586338087844334
Find: 0.658634

Madhursample.jpg vs VivekKumarGupta_EMqaTest-3$00-0000-0000-000000024832_face.jpg
Verify: 0.6253741569539091
Find: 0.625374

from deepface.

Raghucharan16 avatar Raghucharan16 commented on June 12, 2024

distances are same but the results are not. That is my concern..

from deepface.

serengil avatar serengil commented on June 12, 2024

if distances are same, then there is nothing wrong from the library's perspective.

the procedure to list images in your implementation and find function are different. for instance, if an image is webp but its extension is jpg/png, then this is discarded in find function but it is not discarded in your implementation.

https://github.com/serengil/deepface/blob/master/deepface/commons/image_utils.py#L16

from deepface.

Raghucharan16 avatar Raghucharan16 commented on June 12, 2024

No, I took care of that already, I have only .jpg files.

from deepface.

Raghucharan16 avatar Raghucharan16 commented on June 12, 2024

May be using insightface would give me better results as it got better accuracy on south asian and east asian faces..

from deepface.

Raghucharan16 avatar Raghucharan16 commented on June 12, 2024

yeah got it. i have a folder of faces and an empty folder, [unique_faces_folder name]. now I'll add first face to the folder and from 2nd image i have to compare it if it is previously there in the folder or not, so incase there are n images stored in the unique_faces folder and i have to check for another m images it is taking too much time and the results are not that good but satisfactory. but if we choose find method, even though it needs to fetch new representations and save them it is giving results very quickly but varying from verify method.

from deepface.

serengil avatar serengil commented on June 12, 2024

Most probably, your logic is buggy because verify gives same distances with find when tested directly.

from deepface.

serengil avatar serengil commented on June 12, 2024

For instance, listdir does not list files in subfolders. But find function considers sub folders. You are running a different logic.

from deepface.

Raghucharan16 avatar Raghucharan16 commented on June 12, 2024

Oh I didn't know that, but also there are no sub folders inside my current working directory.

from deepface.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.