exadel-inc / CompreFace

Leading free and open-source face recognition system
https://exadel.com/accelerator-showcase/compreface/
Apache License 2.0
5.5k stars 753 forks source link

Face Detection Service does not recognize biggest faces first #1081

Open calloatti opened 1 year ago

calloatti commented 1 year ago

Describe the bug

When submitting an image with 2 faces, when using "limit=1" the smallest of the 2 faces in the image is returned instead of the biggest face.

To Reproduce

Steps to reproduce the behavior:

  1. Create a detection service
  2. Send a request to detect faces in image using ""http://localhost:8000/api/v1/detection/detect?limit=0
  3. 2 faces are recognized, smallest face first:
{
  "result" : [ {
    "age" : {
      "probability" : 1.0,
      "high" : 32,
      "low" : 32
    },
    "box" : {
      "probability" : 0.999154806137085,
      "x_max" : 106,
      "y_max" : 482,
      "x_min" : 3,
      "y_min" : 337
    }
  }, {
    "age" : {
      "probability" : 1.0,
      "high" : 38,
      "low" : 38
    },
    "box" : {
      "probability" : 0.9985826015472412,
      "x_max" : 360,
      "y_max" : 646,
      "x_min" : 153,
      "y_min" : 342
    }
  } ]
}
  1. Send the same request using the same image but using "limit=1"
  2. The smallest first face is returned instead of the second bigger face:
{
  "result" : [ {
    "age" : {
      "probability" : 1.0,
      "high" : 32,
      "low" : 32
    },
    "box" : {
      "probability" : 0.999154806137085,
      "x_max" : 106,
      "y_max" : 482,
      "x_min" : 3,
      "y_min" : 337
    }
  } ]
}

Expected behavior

When using "limit=1" on an image with 2 faces, the bigger face should be returned, not the smallest one, as described in the docs: "maximum number of faces on the image to be recognized. It recognizes the biggest faces first. Value of 0 represents no limit. Default value: 0"

Screenshots

00007068-20230316140338-2

Desktop (please complete the following information):

Additional context

Using Docker on Windows 10 subcenter-arcface-r100 custom build v 1.1.0

calloatti commented 1 year ago

Also, maybe add a "size" or "area" property to "box", with the value of the actual size of the face rectangle? Just to avoid having to do (x_max - x_min) * (y_max - y_min) for each face to get the value. I am calculating it now to avoid obvious false detections where the area is too small to be a real face.

pospielov commented 1 year ago

Thanks for reporting this. It looks like some models work properly, and some sort results by probability, not the face size. We will change it in the next release.