Image Sentiment

Overview

Image Sentiment is one of the intelligence services of the Filestack platform. You can detect general emotions of the uploaded images.

Processing API

Image Sentiment is available as a synchronous operation in the Processing API using the following task:

image_sentiment

To use this task in Processing API, you have to use security policy and signature. Read more about security policies here.

Response

Input image:

Photo by Candice Picard on Unsplash
{
    "emotions": {
        "HAPPY": 99.74745178222656,
        "FEAR": 0.09662599116563797,
        "SAD": 0.04409734904766083,
        "ANGRY": 0.039630014449357986,
        "SURPRISED": 0.03320338949561119,
        "DISGUSTED": 0.013468324206769466,
        "CONFUSED": 0.01307707466185093,
        "CALM": 0.012453563511371613
    }
}
  • If no emotional content was detected:

    {
    "emotions": {
    }
    }

Response Parameters

emotions dictionary Contains detected emotions

Examples

  • Get the sentiment of your uploaded file:

    https://cdn.filestackcontent.com/security=p:<POLICY>,s:<SIGNATURE>/image_sentiment/<HANDLE>
  • Use image_sentiment in a chain with other tasks such as tagging:

    https://cdn.filestackcontent.com/security=p:<POLICY>,s:<SIGNATURE>/tags/image_sentiment/<HANDLE>
  • Use image_sentiment with an external URL:

    https://cdn.filestackcontent.com/<FILESTACK_API_KEY>/security=p:<POLICY>,s:<SIGNATURE>/image_sentiment/<EXTERNAL_URL>
  • Use image_sentiment with Storage Aliases:

    https://cdn.filestackcontent.com/<FILESTACK_API_KEY>/security=p:<POLICY>,s:<SIGNATURE>/image_sentiment/src://<STORAGE_ALIAS>/<PATH_TO_FILE>

Workflows Task Configuration

In order to learn how you can use Workflows UI to configure tasks and logic items, please visit Creating Workflows Tutorial.

Image Sentiment task is available in Intelligence tasks category.

Workflows Parameters

Task Name string Unique name of the task which will be included in the webhook response and can be used to build logic below.

Logic

Image Senriment task returns following response to the workflow:

{
  "data": {
    "emotions": {
        "HAPPY": 99.25,
        "SURPRISED": 0.40,
        "CALM": 0.18,
        "CONFUSED": 0.05,
        "ANGRY": 0.04,
        "SAD": 0.03,
        "FEAR": 0.01,
        "DISGUSTED": 0.01
    }
  }
}

or

{
  "data": {
    "emotions": {
    }
  }
}

Logic Parameters

data dictionary Includes the information of image sentiment task.
emotions dictionary Contains detected emotions.

Considering the response from the task, you can build logic in order to make independent flows with different executing tasks. For example, if you would like to run another depending on the happiness level detected, you can use the following rule:

emotions.HAPPY gt 90.0 or emotions.HAPPY lt 10.0

In Workflows UI this command would be similar to the example below:

Visit Creating Workflows Tutorial to learn how you can use Workflows UI to configure your tasks and logic between them.

Webhook

Below you can find an example webhook payload for image sentiment task

{
    "id": 65374401,
    "action": "fs.workflow",
    "timestamp": 1551126197,
    "text": {
        "workflow": "c516549f-3755-4fb5-85a4-15ae4b31d475",
        "createdAt": "2020-01-25T20:21:53.929686791Z",
        "updatedAt": "2020-01-25T20:21:56.716186597Z",
        "sources": [
            "H2swKXwhRxKFrylakLwcd"
        ],
        "results": {
            "image_sentiment_1551120182170": {
                "data": {
                    "emotions": {
                        "HAPPY": 99.25,
                        "SURPRISED": 0.40,
                        "CALM": 0.18,
                        "CONFUSED": 0.05,
                        "ANGRY": 0.04,
                        "SAD": 0.03,
                        "FEAR": 0.01,
                        "DISGUSTED": 0.01
                    }
                }
            }
        },
        "status": "Finished"
    }
}

Please visit the webhooks documentation page to learn more.