Nudity Detection

Last updated June 3rd, 2018

Overview

The Nudity Detection Model determines if an image contains some level of nudity along with a description of the “level” of nudity. We currently distinguish 5 types of nudity:

  • Raw nudity (X-rated material such as genitals, bare breasts...)
  • Partial nudity due to the presence of women in bikini
  • Partial nudity due to the presence of bare-chested males
  • Partial nudity due to the presence of suggestive cleavages
  • No nudity (safe content)

Illustration

Partial Nudity (bare male chest)
Parital Nudity (suggestive cleavage)
No Nudity

Raw Nudity

Raw Nudity is nudity that is deemed highly inappropriate for publics below 18 (X-rated or adult content). This includes displays of:

  • Pornographic scenes
  • Sexual intercourse
  • Displays of Genitals
  • Displays of Breasts and Female Nipples
  • Displays of Nude buttocks

On most sites and apps, images containing raw nudity will be systematically removed.

Raw Nudity Detection works with black and white images as well as color images or images with filters.

Use-cases

  • Detect and remove pornographic content
  • Ban or suspend users submitting X-rated content
  • Protect children from unwanted nudity
  • Comply with advertising contracts preventing from displaying ads alongside adult content

Raw nudity probability

The value returned is between 0 and 1. Images with a value close to 1 are images with a high probability of containing raw nudity while images with a probability closer to 0 have a lower probability of containing raw nudity.

Recommended threshold

We recommend comparing the raw nudity probability to the other two probabilities returned: safe and partial_nudity. Whenever the raw_nudity value is higher than both safe and partial_nudity values, the image would be considered as containing raw nudity.

Partial Nudity

Partial Nudity is nudity that may be accepted in some contexts and may be prohibited in other contexts.

To help you determine if an image containing Partial Nudity is acceptable to you, an additional tag will be returned to describe the type of partial nudity that has been found.

Types of partial nudity are:

  • Bare male chests
  • Suggestive cleavages
  • Women in bikini

Illustration of Partial Nudity

Bare-chested male
Woman in bikini
Suggestive cleavage

Partial Nudity probability

The value returned is between 0 and 1, images with a partial value closer to 1 will have partial nudity on the image, while images with a partial value closer to 0 will not have partial nudity.

Images with Partial Nudity will include a "partial_tag" string describing the type of partial nudity. Possible values are bikini, cleavage, chest

The image contains partial nudity: (partial value 0.87, partial_tag value is "bikini")

Safe Images

Images that contain neither raw nudity nor partial nudity would be considered "safe".

The image is safe: (safe value 0.999)

Use the model

To start, you need to create an account to retrieve your API keys. Then you must install the SDK that corresponds to your programming language.


# install cURL: https://curl.haxx.se/download.html


pip install sightengine


composer require sightengine/client-php


npm install sightengine --save

Detect offensive content

Let say you want moderate the following image:

You can either upload a public URL to the image, or upload the raw binary image. Here's how to upload the


curl -X GET -G 'https://api.sightengine.com/1.0/check.json' \
    -d 'models=nudity' \
    -d 'api_user={api_user}&api_secret={api_secret}' \
    -d 'url=https://d3m9459r9kwism.cloudfront.net/img/examples/example-fac-1000.jpg'


 # if you haven't already, install the SDK with 'pip install sightengine'
from sightengine.client import SightengineClient
client = SightengineClient('{api_user}','{api_secret}')
output = client.check('nudity').set_url('https://d3m9459r9kwism.cloudfront.net/img/examples/example-fac-1000.jpg')


// if you haven't already, install the SDK with 'composer require sightengine/client-php'
use \Sightengine\SightengineClient;
$client = new SightengineClient('{api_user}','{api_secret}');
$client->check(['nudity'])->set_url('https://d3m9459r9kwism.cloudfront.net/img/examples/example-fac-1000.jpg');


// if you haven't already, install the SDK with 'npm install sightengine --save'
var sightengine = require('sightengine')('{api_user}','{api_secret}');
sightengine.check(['nudity']).set_url('https://d3m9459r9kwism.cloudfront.net/img/examples/example-fac-1000.jpg').then(function(result) {
    // The result of the API
}).catch(function(err) {
    // Error
});

Here is the result:

                    
                    
{
    "status": "success",
    "request": {
        "id": "req_1SJJxJjUHnSVWreApx9fF",
        "timestamp": 1510153177.0043,
        "operations": 1
    },
    "nudity": {
        "raw": 0.002564,
        "partial": 0.007122,
        "safe": 0.990314
    },
    "media": {
        "id": "med_1SJJEFuLqeSedThQjhNoS",
        "uri": "https://d3m9459r9kwism.cloudfront.net/img/examples/example-fac-1000.jpg"
    }
}
                    
                

Did you find this page helpful?

We're always looking for advice to help improve our documentation!

Let us know what you think