Facial Emotion Recognition

fer(data, {[apiKey]: String, [privateCloud]: String, [detect]: Boolean, [sensitivity]: Float})
Determine the emotions expressed in an image of a human face.

Current Version: 2

Arguments

data – refer to img format guide – required
[apiKey] – String – optional – your indico API key
[privateCloud] – String – optional – your private cloud subdomain
[v or version] – Integer – optional (defaults to 2) – specify model version
[detect] – Boolean (defaults to False) – optional – When True, FER detects all faces in the image and returns their locations with a FER dictionary for each face (see Output for more information) strong>When the image has a background or contains multiple faces, set this to true for best results.
[sensitivity] – Float (defaults to .8) – optional – The certainty threshold (between 0 and 1) the model uses to decide what to return as a face. Only used when detect is True.

Output

This function will return a dictionary with 6 key-value pairs. These key-value pairs represent the likelihood that each of 6 detectable emotions are expressed by the face in the analyzed image. The keys in the dictionary are strings containing the emotions (Angry, Sad, Neutral, Surprise, Fear, Happy) and the values are the probabilities that the face in the analyzed image is expressing each emotion.

Values less than 0.05 indicate that it is very unlikely the face is expressing the corresponding emotion.

Using the detect flag changes output format: When using the detect flag the results returned will be a list of dictionaries. Each dictionary in the list corresponds to a detected face. Each dictionary has two key-value pairs, the keys are “emotions” and “location”. The value of “emotions” is the same dictionary described above with 6 key-value pairs. The value of “location” is the bounding box of the detected face in the form [x position of top left corner, y position of top-left corner, width of bounding box, height of bounding box].

# single output
{
    'happy': 0.00004324968926091062,
    'sad': 0.007702528578033991,
    'angry': 0.0002575132225946431,
    'fear': 0.2071775132225946431,
    'surprise': 0.008160047807935744,
    'neutral': 0.00015069427192724994
}

# batch output
[
    {
        'happy': 0.00004324968926091062,
        'sad': 0.007702528578033991,
        'angry': 0.0002575132225946431,
        'fear': 0.2071775132225946431,
        'surprise': 0.008160047807935744,
        'neutral': 0.00015069427192724994
    }, 
    {
        'happy': 0.00004324968926091062,
        'sad': 0.007702528578033991,
        'angry': 0.0002575132225946431,
        'fear': 0.2071775132225946431,
        'surprise': 0.008160047807935744,
        'neutral': 0.00015069427192724994
    }
]

Example

var indico = require('indico.io');
indico.apiKey =  'YOUR_API_KEY';

var response = function(res) { console.log(res); }
var logError = function(err) { console.log(err); }
  
// single example
indico.fer("<IMAGE>")
  .then(response)
  .catch(logError);

// batch example
var batchInput = [
    "<IMAGE>",
    "<IMAGE>"
];
indico.fer(batchInput)
  .then(response)
  .catch(logError);