serengil / deepface

A Lightweight Face Recognition and Facial Attribute Analysis (Age, Gender, Emotion and Race) Library for Python

Home Page:https://www.youtube.com/watch?v=WnUVYQP4h44&list=PLsS_1RYmYQQFdWqxQggXHynP1rqaYXv_E&index=1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible to add InsightFace

ethaniel opened this issue · comments

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?

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

Besides, GhostFace is a recently published model.

@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?

Backbone: Resnet34
Trianing: CASIA, E40
LFW: 0.9946

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.

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.

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!

Which onnx fits you?

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.

But cannot find buffalo_l's onnx in that page

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.

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.

@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.

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

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

@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)