vladmandic / human

Human: AI-powered 3D Face Detection & Rotation Tracking, Face Description & Recognition, Body Pose Tracking, 3D Hand & Finger Tracking, Iris Analysis, Age & Gender & Emotion Prediction, Gaze Tracking, Gesture Recognition
https://vladmandic.github.io/human/demo/index.html
MIT License
2.37k stars 322 forks source link

Can't make multiple face detection #259

Closed okeoke85 closed 2 years ago

okeoke85 commented 2 years ago

Hello Vlad,

I hope you are well, i can't get multiple face result, it always return wit 1 faceresult from the images below, i have tried it with your demo application as well, maybe it is about options, it would be great if i can get help.

Best wishes.

Image1; screenshot-18

Image2; people

I use human.detect const result: vladHuman.Result = await human.detect(tensor) as vladHuman.Result;

To get tensor i use;

async function getHumanTensor(source: 'path' | 'url', path: string): Promise<undefined | any> {

    let data: Buffer;

    switch (source) {
        case 'path':
            data = fs.readFileSync(path);
            break;
        case 'url':
            //const fetch = require("node-fetch");
            const res = await fetch(path);
            data = await res.buffer();
            break;
    }

    const decoded = human.tf.node.decodeImage(data);
    const casted = decoded.toFloat();
    let tensor = casted;
    //let tensor = casted.expandDims(0);

    tensor = human.tf.tidy(() => {

        let res;
        //RGBA imaj varsa RGB ye dönüştürüyoruz
        if (tensor.shape[2] !== 3) {
            const channels = human.tf.split(tensor, 4, 2); // split rgba to channels
            const rgb = human.tf.stack([channels[0], channels[1], channels[2]], 2); // stack channels back to rgb and ignore alpha
            res = human.tf.reshape(rgb, [1, decoded.shape[0], decoded.shape[1], 3]); // move extra dim from the end of tensor and use it as batch number instead
        } else {
            res = casted.expandDims(0); // only add batch number
        }
        return res;

    });

    return tensor;
}

Options;

        const serverConfig = {
            backend: 'HumanGL',
            modelBasePath: options.modelBasePath,
            debug: true,
            videoOptimized: false,
            async: false,
            face: {
                enabled: true,
                detector: {
                    enabled: true,
                    rotation: true,
                    maxDetected: 5,
                },
                mesh: { enabled: true },
                iris: { enabled: false },
                description: { enabled: false },
                emotion: { enabled: false },
            },
            hand: {
                enabled: true,
            },
            // body: { modelPath: 'efficientpose.json', enabled: true },
            // body: { modelPath: 'blazepose.json', enabled: true },
            body: { enabled: true },
            object: { enabled: true },
        };
vladmandic commented 2 years ago

first photo is just a washout, there are no faces there at all, don't even want to try to detect that.

second photo is just really blurry when you look at it (even the girl in the foreground is blurry, not just background).

using a bit of sharpening and it does detect multiple people. and if you're running in browser, you can use built-in filters in human to do that. but if you're running in node, then you have to take care of the photo quality before running detection.

okeoke85 commented 2 years ago

Thank you.

ceyxasm commented 1 month ago

Hey @vladmandic I feel that no, it is indeed detecting only single faces.

The following image is from main-demo image

I get similar result when I use the library, PFA my human config:

  const humanConfig = { 
    modelBasePath: '/model/',
    backend: 'wasm', 
    filter: { enabled: false, equalization: false, flip: false },
    face: {
      enabled: true,
      detector: {
        rotation: false,
        skipFrames: 30,
        return: true
      },
      mesh: {enabled: false},
      attention: {enabled: true},
      iris: {enabled: false},
      description: {enabled: false},
      emotion: {
        enabled: false,
        skipFrames: 30,
      }
    },
    body: { enabled: false },
    hand: { enabled: false },
    gesture: { enabled: false },
    object: { enabled: false },
    segmentation: { enabled: false },
    debug: DEBUG,
  };