deepinsight / insightface

State-of-the-art 2D and 3D Face Analysis Project
https://insightface.ai
22.75k stars 5.34k forks source link

What detector used on Recognition demo? #2122

Open zerodwide opened 1 year ago

zerodwide commented 1 year ago

dear @nttstar What detector used on Recognition demo at http://demo.insightface.ai:7008?

Thanks in advance.

javiabellan commented 1 year ago

I'm also interested in this question. It seems they are not using any detector because every image is a single face. Maybe just a centerCrop followed by a 112x112 resizing? I don't know. I wish the code of that demo were public.

Im also intersetd in the onnx files of the models used here (r100-w2m and insightface-private) because i can't find them in https://github.com/deepinsight/insightface/tree/master/model_zoo#1-face-recognition-models

javiabellan commented 1 year ago

By the way, I tried to replicate the demo with the only public model r50-600k (IR50 trained on WebFace-600K) avaliable here and those are the results I got.

My preprocesing is first 112x122 resizing and then normalize (mean=127.5, std=128) My postprocesing is L2 normalization of the embedding. The score is the dot procuct of the 2 (L2 normalized) embeddings.

1 Demo result: They ARE the same person; Score: 0.4821.

2 Demo result: They are NOT the same person; Score: -0.0354.

3 Demo result: They are NOT the same person; Score: 0.1879.

4 Demo result: They ARE the same person; Score: 0.3136.

5 Demo result: They ARE the same person; Score: 0.2825.

6 Demo result: They are LIKELY TO be the same person; Score: 0.2586.

You can see that demo results and my results differs a lot.

nttstar commented 1 year ago

@zerodwide SCRFD-10GF @javiabellan You should do face-alignment, not image resizing.

javiabellan commented 1 year ago

Thanks @nttstar for answering.

Any plans form making code of the demo public or the models used (r100-w2m and insightface-private) public aswell?

nttstar commented 1 year ago

No such plan. For r100-w2m you can train it by yourself.

HeChengHui commented 1 year ago

@javiabellan Possible for you to share your code for face recognition?

javiabellan commented 1 year ago

@HeChengHui No sorry, but i can give you the full pipeline:

  1. infer with SCRFD-10GF
    • Prepro: Resize max size to 640px and normalize img
    • Postpro: Rescale boxes and landmarks to original image resolution
  2. Use the landmarks (5 facial keypoints) to do face aligment (this returns a 112x112 img)-> code
  3. Infer face recognizer (IResNet50-WebFace-600K)
    • Prepro: Normalize img
    • Postpro: L2 normalization of the embedding

The similarity of 2 faces is the dot product of the L2-normalized embeddings.

HeChengHui commented 1 year ago

@javiabellan

3. Infer face recognizer (IResNet50-WebFace-600K)

could you perhaps point me to any reference code?

I tried doing

handler = insightface.model_zoo.get_model("w600k_r50.onnx", providers=['CUDAExecutionProvider']) 
handler.prepare(ctx_id=0)
handler.compute_sim(ref, ref)

where ref is an image, but i get 5.576827495436904e-09 as the score.

Another question is that during the preprocessing, did you normalise both reference and probe or only one?

HeChengHui commented 1 year ago

@nttstar is normed_embedding still being used? it is returning me None when doing the following

app = FaceAnalysis(name='antelope', allowed_modules=['detection'], providers=['CUDAExecutionProvider'])
app.prepare(ctx_id=0, det_size=(640, 640), det_thresh=0.3)
for probe_face in probe_faces:
    probe_emb = probe_face.normed_embedding
    print("probe",probe_emb)

>>> None
kiashann commented 6 months ago

@HeChengHui No sorry, but i can give you the full pipeline:

  1. infer with SCRFD-10GF

    • Prepro: Resize max size to 640px and normalize img
    • Postpro: Rescale boxes and landmarks to original image resolution
  2. Use the landmarks (5 facial keypoints) to do face aligment (this returns a 112x112 img)-> code
  3. Infer face recognizer (IResNet50-WebFace-600K)

    • Prepro: Normalize img
    • Postpro: L2 normalization of the embedding

The similarity of 2 faces is the dot product of the L2-normalized embeddings.

Hi, how did you use buffalo_l or other face recognition models without default face detection models? Which one is correct for computing the similarity between two images?

handler = insightface.model_zoo.get_model(r"C:\Users\windows.insightface\models\buffalo_l\w600k_r50.onnx") handler.prepare(ctx_id=-1)

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

out = handler.compute_sim(f1, f2) print(out) or similarity = np.dot(f1, f2.T) print(similarity)