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

Possible to add InsightFace #1187

Open
ethaniel opened this issue Apr 14, 2024 · 18 comments
Open

Possible to add InsightFace #1187

ethaniel opened this issue Apr 14, 2024 · 18 comments
Labels
enhancement New feature or request

Comments

@ethaniel
Copy link

Hi! Thank you for the amazing library, it really was a gentle introduction into the world of facial recognition.

However, I've noticed that none of the models really work for my face, I get false and false positive results (I've tried different detectors and normalizers too). I've also noticed that the models that you've linked are all around 4 years old.

Perhaps, adding some newer models (like InsightFace) would be possible?

@serengil
Copy link
Owner

serengil commented Apr 14, 2024

ArcFace is the facial recognition model of insightface project. It is already supported in deepface.

@serengil serengil added enhancement New feature or request question Further information is requested labels Apr 14, 2024
@serengil
Copy link
Owner

Besides, GhostFace is a recently published model.

@serengil serengil closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2024
@ethaniel
Copy link
Author

@serengil thank you! One small thing - looks like Arcface has released new models (r100,AdaFace back in 2022. Is that the one that you ported to deepface?

@serengil
Copy link
Owner

Backbone: Resnet34
Trianing: CASIA, E40
LFW: 0.9946

@ethaniel
Copy link
Author

ethaniel commented Apr 15, 2024

Thank you! Any chance that r100,AdaFace could be ported into your library?

I've got an asian face and no matter how much I try, I couldn't get Arcface (or any other model in the library) to provide correct embeddings that would match me on different photos through the last 10 years. I was hoping that one of the newer models from Arcface could have possibly fixed that.

@serengil
Copy link
Owner

of course, will try to add AdaFace model as well but its lfw score is very close, do not think it will resolve your problem.

@ethaniel
Copy link
Author

InsightFace have also been experimenting with south asian and east asian faces (https://github.com/deepinsight/insightface/tree/master/model_zoo), getting good results on their R100,Glint360K model. However that's onnx format and waay over my head to understand if it's even possible to be ported into deepface.

Sefik, I just wanted to say that I appreciate you and everything that you do! Thank you so so much for opening the world of facial recognition for people that want to learn!

@serengil serengil reopened this Apr 15, 2024
@serengil
Copy link
Owner

Which onnx fits you?

@ethaniel
Copy link
Author

ethaniel commented Apr 15, 2024

Looking again at that list, "buffalo_l" model seems like the overall winner. It has the best South Asian (93.16) and East Asian (74.96) accuracy of all + the LFW is at 99.83.

@serengil
Copy link
Owner

But cannot find buffalo_l's onnx in that page

@ethaniel
Copy link
Author

buffalo_l can be downloaded from here: https://github.com/deepinsight/insightface/tree/master/python-package

@serengil serengil removed the question Further information is requested label Apr 17, 2024
@Raghucharan16
Copy link

Raghucharan16 commented Apr 18, 2024

I too am another one waiting for buffalo_l to be integrated into deepface. and I find difficulty while using multi threading of deepface.

I had this code and I'm always getting segmentation fault, double linked list core dumped, and free(): invalid next size (fast) errors. i actually tried find method and it is not giving accurate results compared to verify method {even this too gives some false positives but better when compared to find method. so basically want to extract unique faces from a folder and store it to another folder and this should use multi threading to save time as folder may contain many images.

@serengil
Copy link
Owner

will add buffalo_l model into the portfolio soon - possibly this weekend

yeah i know the library becomes unstable because of tf dependency when being called with multithread. recommend not to use multi-threading for now.

@Raghucharan16
Copy link

Raghucharan16 commented Apr 18, 2024

@serengil thanks for the response and we really appreciate your work on this. keep building such unique,amazing and simple to use things for the community.

@Raghucharan16
Copy link

Raghucharan16 commented Apr 22, 2024

@ethaniel did you figured out any way of implementing buffalo_l model into script?

@Raghucharan16
Copy link

Raghucharan16 commented Apr 23, 2024

Hey @serengil when can we expect the buffalo_l model in deepface? Any tentative time??

@serengil
Copy link
Owner

soon

@Raghucharan16
Copy link

@serengil thank you! One small thing - looks like Arcface has released new models (r100,AdaFace back in 2022. Is that the one that you ported to deepface?

Hey @ethaniel I've figured out a way to use those onnx file formats but for me it is taking lot of time to execute, in my usecase i have to compare 2 folder of faces and extract unique faces among them. may be that's not your case, you can use the onnx models of insight face in this way

import insightface
import cv2
import numpy as np
from numpy.linalg import norm

def compare(feat1, feat2):

distance = np.dot(feat2, feat1) / norm(feat2) * norm(feat1)

return distance

img1 = cv2.imread(r"20240127_120414.png")
img2 = cv2.imread(r"IMG_20240205_140538.jpg")

handler = insightface.model_zoo.get_model("model.onnx")#specify your model path
handler.prepare(ctx_id=-1)

f1 = handler.get_feat(img1)
f2 = handler.get_feat(img2)

out = handler.compute_sim(f1, f2)
print(out)
dis = compare(f1, f2)
print(dis)

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

No branches or pull requests

3 participants