justadudewhohacks / face-api.js

JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js
MIT License
16.53k stars 3.68k forks source link

How to remove score when drawing the face detection ? #913

Open MathieuCesbron opened 1 year ago

MathieuCesbron commented 1 year ago

Hello and thanks for the great work,

I have this in my code: faceapi.draw.drawDetections(canvasDraw, resizedDetections);

It works but I would like to remove the score on the top of the rectangle, I cannot find where to pass the options.

May be it is something like this ? faceapi.draw.drawDetections(canvasDraw, resizedDetections, {withScore: false});

Have a good day,

kamal-vcloudx commented 1 year ago

@justadudewhohacks can you please provide an option to remove score from top of the detection rectangle. Thanks!

AndreyTepaykin commented 1 year ago

Need to customize method drawDetections. In face-api.js find function drawDetections and add options={withScore:true} as third argument. Than inside this function change row var label = score ? "" + round(score) : undefined; to var label = options.withScore && score ? "" + round(score) : undefined; After these changes call faceapi.draw.drawDetections with third argument {withScore: false}

borihan-p commented 8 months ago

drawDetections won't draw score if we provide IRect object. The code below works for me

          const box: IRect = {
            x: resizedDetections.detection.box.left,
            y: resizedDetections.detection.box.top,
            width: resizedDetections.detection.box.width,
            height: resizedDetections.detection.box.height,
          };
          faceapi.draw.drawDetections(canvasDraw, box);