Facial Emotion Classifier

Get this modelTry the API Try in a Node-RED flow


This model first detects faces in an input image. Then, each face is passed to the emotion classification model which predicts the emotional state of the human, from a set of 8 emotion classes: neutral, happiness, surprise, sadness, anger, disgust, fear, contempt. The output of the model is a set of bounding box coordinates and predicted probabilities for each of the emotion classes, for each face detected in the image. The format of the bounding box coordinates is [ymin, xmin, ymax, xmax], where each coordinate is normalized by the appropriate image dimension (height for y or width for x). Each coordinate is therefore in the range [0, 1].

The model is based on the Emotion FER+ ONNX Model Repo.

Model Metadata

Domain Application Industry Framework Training Data Input Data Format
Vision Facial Recognition General ONNX FER+ Emotion Dataset Image (PNG/JPG)



Component License Link
This repository Apache 2.0 LICENSE
Model Weights MIT Emotion FER+ ONNX Model
Model Code (3rd party) MIT Emotion FER+ ONNX Model
Test assets Various Asset README

Options available for deploying this model

This model can be deployed using the following mechanisms:

  • Deploy from Dockerhub:
docker run -it -p 5000:5000 codait/max-facial-emotion-classifier
  • Deploy on Kubernetes:
kubectl apply -f https://raw.githubusercontent.com/IBM/MAX-Facial-Emotion-Classifier/master/max-facial-emotion-classifier.yaml

Example Usage

You can test or use this model

Test the model using cURL

Once deployed, you can test the model from the command line. For example:

$ curl -F "image=@assets/happy-baby.jpeg" -XPOST http://localhost:5000/model/predict

You should see a JSON response like that below:

    "status": "ok",
    "predictions": [
            "detection_box": [
            "emotion_predictions": [
                    "label_id": "1",
                    "label": "happiness",
                    "probability": 0.9860254526138306
                    "label_id": "0",
                    "label": "neutral",
                    "probability": 0.011981048621237278
                    "label_id": "2",
                    "label": "surprise",
                    "probability": 0.0014637531712651253

Test the model in a Node-RED flow

Complete the node-red-contrib-model-asset-exchange module setup instructions and import the facial-emotion-classifier getting started flow.