vladmandic / face-api

FaceAPI: AI-powered Face Detection & Rotation Tracking, Face Description & Recognition, Age & Gender & Emotion Prediction for Browser and NodeJS using TensorFlow/JS
https://vladmandic.github.io/face-api/demo/webcam.html
MIT License
852 stars 153 forks source link

How does detectAllFaces function will handle fake image photo by mobile #68

Closed danies8 closed 3 years ago

danies8 commented 3 years ago

Hi, I used this code that detect all faces, I want to avoid that user will photo himself by cellular and show the cellular photo to camera , how I avoid by code ? For know fake image by cellular also work. I saw this link in history issue and there is no option do install through npm ? https://github.com/vladmandic/anti-spoofing

 const ssdOptions = { minConfidence: 0.1, maxResults: 10 };
      const optionsSSDMobileNet = new faceapi.SsdMobilenetv1Options(ssdOptions);
      const faces = await faceapi
        .detectAllFaces(tensor, optionsSSDMobileNet)
        .withFaceLandmarks()
        .withFaceExpressions()
        .withFaceDescriptors()
        .withAgeAndGender();
vladmandic commented 3 years ago

faceapi does not perform any analysis on the detected face - real or fake or doctored or anything
and given that faceapi here is strictly in maintenance mode, this request is out of scope

danies8 commented 3 years ago

Thanks a lot:) I tested this link and is not solved the problem: https://github.com/vladmandic/anti-spoofing

vladmandic commented 3 years ago

that is just a test - a very simple model and trained on small dataset to detect real people vs fake images. it has nothing to do with photo on the phone.

danies8 commented 3 years ago

Hi, Do you know any other lib that will solved this issue, that I can add to my solution for detecting fake images ?

vladmandic commented 3 years ago

i dont, sorry...

danies8 commented 3 years ago

thanks a lot

vladmandic commented 3 years ago

update: i just ran into https://github.com/Prem95/face-liveness-detector
its a keras model with a lot of dead code, but could be converted to tfjs and quantized

danies8 commented 3 years ago

Hi, My project is node js and this project is pyton , how they can come together ? Thanks,

vladmandic commented 3 years ago

Model is not in Python, model is in Keras. It's just that implementation is in Python

If the model converts cleanly from Keras to TFJS (there is one custom op SparseCategoricalFocalLoss that may need reimplementing, but maybe it can be skipped), the rest is easy - just ignore Python code

  1. Detect face using FaceAPI
  2. Crop the face from original input using tf.image.cropAndResize
  3. Optionally normalize it using something like tf.div(input, 255) - all depends what value range model expects
  4. Run model using model.execute and pass it cropped/resized/normalized input
  5. Get results, its a float32 value that represents percentage change
danies8 commented 3 years ago

Hi, Can you give an example how to do it ? It also good for picture not only phone ?

vladmandic commented 3 years ago

Can you give an example how to do it ?

Example would be to write it all. I may do it, but its not a priority.

It also good for picture not only phone ?

Looks that way.

danies8 commented 3 years ago

Thanks a lot, we are waiting.

danies8 commented 3 years ago

Hi, Did you have a chance to write it ?

vladmandic commented 3 years ago

no and not likely soon.

danies8 commented 3 years ago

Thank you.