raburgos / Face_mask

Face Mask - Object Detection
MIT License
3 stars 0 forks source link

face compare with/out mask #1

Open akeilox opened 4 years ago

akeilox commented 4 years ago

This is awesome! After running face_recognition in windows this was a breeze to up and running. Thank you for the detailed setup process.

I have a question on how to go about detecting a face belongs to the same person when they are wearing a mask.

For example in face_recognition one can do face_recognition.compare_faces to compare two faces belongs to the same person with certain probability. How can one go about doing the same with a mask on ?

In following example if unknown.jpg is biden with a mask on for instance:

import face_recognition known_image = face_recognition.load_image_file("biden.jpg") unknown_image = face_recognition.load_image_file("unknown.jpg")

biden_encoding = face_recognition.face_encodings(known_image)[0] unknown_encoding = face_recognition.face_encodings(unknown_image)[0]

results = face_recognition.compare_faces([biden_encoding], unknown_encoding)

raburgos commented 4 years ago

Hi @akeilox !

Excuse me for the delay to answer you. Actually this repo is solely about object detection problem (detecting mask or not), as face_recognition repo use object detection to detect faces. The second part involve in face_recognition is use another type of neural network to create an encoding of faces (vector of 128 elements for each face/ground truth).

I would like to add that functionality (face recognition) to this repo soon or later, but at this time is only a object detection model :)

One thing you can try before making a new model or making custom training with face_recognition repo is:

rb_examples.zip

This .zip file contains two codes (employee_base_vector.py and facerec_from_webcam_faster_rb.py). You have to unzip it in examples folder in your face_recognition local repo. Then you can do:

  1. Create an empty folder named ('base_empleados' inside 'examples' folder)
  2. Inside 'base_empleados' create new folders with the name of people you want to recognize (e.g: 'Person X', 'Person Y') and fill this folders with two images per Person (don´t worry about the name of pictures). You could try with one image with out mask and another with mask for each person.

examples ----base_empleados --------Ramiro ------------ramiro_mask.jpg ------------ramiro_no_mask.jpg --------Person X ------------person_x_mask.jpg ------------person_x_no_mask.jpg

  1. Open your terminal (or anaconda prompt) and activate your virtual environment (e.g: conda activate face_recognition)
  2. change your current directory to examples (e.g: cd ./face_recognition/examples).
  3. run: python employee_base_vector.py This will create a pickle file with the necessary encodings named vector_empleados.pickle. We use this file as ground truth to match or recognize new images
  4. Finally run your webcam to test! : python facerec_from_webcam_faster_rb.py

That's all! Let me know if you need anything else. Again sorry for the delay answering

Have a nice week!!