mlkit icon indicating copy to clipboard operation
mlkit copied to clipboard

[Bug report] MlKit Face detection - no face found

Open Ibernato93 opened this issue 3 years ago • 5 comments

Describe the bug In the 'com.google.mlkit version: face-detection: 16.1.5 ', it happens to me that, in some frames, even if the face is visible, the FaceDetector returns me a list of empty faces. This does not happen with version 16.1.3

To Reproduce I have implemented an application where it requires some gestures to be made. When I make gestures, it often tells me that the face has not been found.

SDK Info:

  • SDK Name & Version [e.g. com.google.mlkit:face-detection:16.1.5]

Ibernato93 avatar Jul 01 '22 11:07 Ibernato93

Thanks for your report.

Could you share

  • the code how you build the face detector and how you run the inference?
  • the specific image where it has the regression

jackqdyulei avatar Jul 08 '22 22:07 jackqdyulei

@jackqdyulei the code is like this https://github.com/googlesamples/mlkit/blob/master/android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/facedetector/FaceDetectorProcessor.java

When I process a frame, in this method Task <List <Face>> detectInImage (InputImage image) checks if a face has been found by checking the size of the face list. If a face has been found then I allow to perform the gesture.

Maybe the problem is due to the smaller size of the tflite model? In facedetecor I set the minimum face to 0.3f With the 16.1.3 version, i have no problem.

Ibernato93 avatar Jul 09 '22 18:07 Ibernato93

In 16.1.3 we upgraded the model which has better performance in general.

For debugging, please share the code

  • how you build the face detector(e.g. contour on/off, fast or accurate mode)
  • what type of the input image you use(e.g. bitmap? Media Image)
  • If possible, the picture you used where in 16.1.3 it can't detect the face

Thanks

jackqdyulei avatar Jul 11 '22 04:07 jackqdyulei

@jackqdyulei The version I have problems is 16.1.5. Version 16.1.3 works fine

  • Face detector:
faceDetectorOptions = new FaceDetectorOptions.Builder()
                .setLandmarkMode(FaceDetectorOptions.LANDMARK_MODE_ALL)
                .setClassificationMode(FaceDetectorOptions.CLASSIFICATION_MODE_ALL)
                .setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_FAST)
                .setMinFaceSize(0.5f)
                .enableTracking()
                .build();
  • Input image
Image img = image.getImage(); //image is imageproxy
        InputImage firebaseVisionImage = InputImage.fromMediaImage(img,
                image.getImageInfo().getRotationDegrees());

After that, i process the image

 this.detector.process(firebaseVisionImage)
                .addOnSuccessListener(FaceDetectorProcessor.super::onSuccess)
                .addOnFailureListener(FaceDetectorProcessor.super::onFailure);

In the end , i check if face has been found (List<Face> faces)

Ibernato93 avatar Jul 11 '22 05:07 Ibernato93

sorry I meant that in 16.1.5 we upgraded the model...

If possible, please provide the image so our research team can check if there is an issue inside the model.

jackqdyulei avatar Jul 15 '22 16:07 jackqdyulei

I have same issue with some images This is a test photo 294_freddy-kearney-o-ioeoATbIM-unsplash

tyn17 avatar Dec 30 '22 07:12 tyn17

Same issue here! @jackqdyulei any updates on this? Any date that this model will be fixed and released?

farmaker47 avatar Mar 10 '23 03:03 farmaker47

Hello sir I am from India & my question regarding to MlKit Face detection API

I have successfully integrated MlKit face detection in my app using CameraX API , everything is perfect but when firebaseVisitionFaceDetector detect face and when I draw the rectangular fram on user face they are not overlay the same position on face , frame overlay the another side or outside the face

Code :-

detector.detectInImage(firebaseVisionImage) .addOnSuccessListener(faces -> { // Process each detected face // Draw a rectangle around the face

                        cameraControl.setExposureCompensationIndex(cameraInfo.getExposureState().getExposureCompensationIndex());
                        Bitmap originalBitmap = Bitmap.createBitmap(previewView.getWidth(), previewView.getHeight(), Bitmap.Config.ARGB_8888);
                        Canvas canvas = new Canvas(originalBitmap);
                        canvas.drawBitmap(previewView.getBitmap(), proccessImage.getLeft(), proccessImage.getTop(), null);

                        for (FirebaseVisionFace face : faces) {
                            
                            Toast.makeText(this, "Faces : " + face.getBoundingBox(), Toast.LENGTH_SHORT).show();

                            Rect boundingBox = face.getBoundingBox();

                                int left = boundingBox.left;
                                int right = boundingBox.right;
                                int top = boundingBox.top;
                                int bottom = boundingBox.bottom;


                                Paint paint = new Paint();
                                paint.setColor(Color.RED);
                                paint.setStyle(Paint.Style.STROKE);
                                paint.setStrokeWidth(6f);
                                canvas.drawRect(left, top, right, bottom, paint);



                        }

                        proccessImage.setImageBitmap(originalBitmap);
                        imageProxy.close();

ProgramWithSP avatar Mar 14 '23 11:03 ProgramWithSP

Hi ProgramWithSP, can you use the standalone API here, not the firebase version. Firebase version is obsolete that we will not maintain anymore.

As for the boundingbox, please check our sample app about how to draw the bounding box correctly. Thanks

jackqdyulei avatar Apr 05 '23 16:04 jackqdyulei

tyn17

Thanks for the image! I have sent it to research team to investigate. Will let you know if there is any update.

jackqdyulei avatar Apr 05 '23 16:04 jackqdyulei

Same issue here! @jackqdyulei any updates on this? Any date that this model will be fixed and released?

Could you also share your test image that doesn't work? Thanks!

jackqdyulei avatar Apr 05 '23 16:04 jackqdyulei

Hi all, I'm new to MLKit. I want to implement a nose slimming feature. How can I use MLKit's face features to make the nose slimmer? Would it be easy? Any tips would be helpful.

tjasmin111 avatar Aug 28 '23 16:08 tjasmin111

Hi, @jackqdyulei Any updates about this issue as it happened and is still with me?

AbdElrahman-Rafaat-Amer avatar Oct 04 '23 08:10 AbdElrahman-Rafaat-Amer

Hi @jackqdyulei , any news? I'm stuck with updates. I can't update my project because 16.1.5 has the bug I exposed.

It is very simple to replicate the problem. Implement camerax with image analyzer. At some point in a frame, ml kit detects multiple faces even though there is only one face. Or it doesn't detect any faces.

Ibernato93 avatar Oct 05 '23 13:10 Ibernato93

Hi Ibernato93, sorry for the late reply. This issue is in our list however we don't have plan to release new face detection SDK this year.

Given that, could you

  • Stick to old SDK if you think that model is better for your use case
  • Check whether face mesh SDK fit your use case. The API is very similar

jackqdyulei avatar Oct 13 '23 20:10 jackqdyulei

Feel free to open it and let me know anything else I can help

jackqdyulei avatar Oct 27 '23 16:10 jackqdyulei