Products

SIGN UPLOG IN

Models / Nudity Detection

Nudity Detection

This page describes an old version of the Nudity Detection. The latest version is available here.

Overview

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

  • 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 women in lingerie
  • Partial nudity due to the presence of bare-chested males
  • Partial nudity due to the presence of suggestive cleavages / necklines
  • Partial nudidy due to the presence of miniskirts or suggestive shorts
  • No nudity (safe content)

For convenience, types are grouped into three levels: raw nudity, partial nudity and safe.

Illustration

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

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

Raw Nudity — sometimes referred to as explicity 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
  • Female or male Genitals
  • Nude breasts and Female Nipples
  • Nude buttocks
  • Pubic hair

On most sites and apps, images containing raw nudity are expected to be systematically removed.

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 was been found.

Types of partial nudity that we detect are:

  • Bare male chests
  • Women in lingerie
  • Suggestive cleavages / necklines
  • Women in bikini
  • Miniskirts / suggestive shorts

In any case, if explicit content or an explicit pose is found alongside one of those concepts, the image will be classified as containing Raw Nudity. For instance, a woman having intercourse while wearing lingerie will not generate a "lingerie" class but rather a "raw nudity" class.

Types of Partial Nudity

Bare male chest

Displays of nude male torso, chest, abs and/or stomach. Images that show only part of the torso are included. This includes displays of males in underwear or swim trunks.

Woman in lingerie

Displays of women in lingerie (brassieres, undergarments, garter...). Not included: If genitals or breasts are visible, the images will be classified as raw nudity

Suggestive cleavage

Cleavages shown in a suggestive way. Can be due to any combination of the person's pose, the picture's angle, or revealing clothes...

Woman in bikini

Woman in a two-piece swimsuit — as long as the fabric covers the nipples and does not reveal the central parts of the buttocks.

Miniskirt

Displays of women with a very short skirt or suggestive shorts. A skirt is generally considered a miniskirt if the hemline is at mid-thigh level or higher. Miniskirts that reveal part of the buttocks or pictures taken in a position or from an angle where the underwear or the buttocks become visible will be classified as raw nudity.

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, lingerie, chest, miniskirt

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

Safe

Images that contain neither raw nudity nor partial nudity are considered "safe" in the context of Nudity detection.

The image is safe: (safe value = 0.99)

Use the model

The Nudity Detection model works both with Images, GIFs and Videos.

Most types and formats of images or videos are supported. Nudity Detection will even work with black and white media or images with filters.

Getting started

If you haven't already, create an account to get your own API keys.

Detect nudity

Let's say you want to moderate the following image:

You can either share a public URL to the image, or upload the raw binary image. Here's how to proceed if you choose to share the image's public URL:


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


# this example uses requests
import requests
import json

params = {
  'url': 'https://sightengine.com/assets/img/examples/example-fac-1000.jpg',
  'models': 'nudity-1.1',
  'api_user': '{api_user}',
  'api_secret': '{api_secret}'
}
r = requests.get('https://api.sightengine.com/1.0/check.json', params=params)

output = json.loads(r.text)


$params = array(
  'url' =>  'https://sightengine.com/assets/img/examples/example-fac-1000.jpg',
  'models' => 'nudity-1.1',
  'api_user' => '{api_user}',
  'api_secret' => '{api_secret}',
);

// this example uses cURL
$ch = curl_init('https://api.sightengine.com/1.0/check.json?'.http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

$output = json_decode($response, true);


// this example uses axios
const axios = require('axios');

axios.get('https://api.sightengine.com/1.0/check.json', {
  params: {
    'url': 'https://sightengine.com/assets/img/examples/example-fac-1000.jpg',
    'models': 'nudity-1.1',
    'api_user': '{api_user}',
    'api_secret': '{api_secret}',
  }
})
.then(function (response) {
  // on success: handle response
  console.log(response.data);
})
.catch(function (error) {
  // handle error
  if (error.response) console.log(error.response.data);
  else console.log(error.message);
});

The API will then return a JSON response:

                    
                    
{
    "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://sightengine.com/assets/img/examples/example-fac-1000.jpg"
    }
}
                    
                

You can now use the nudity.raw, nudity.partial and nudity.safe values to determine what the image contains.

nudity.raw

Decimal 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.

nudity.partial

Decimal between 0 and 1. Images with a value close to 1 are images with a high probability of containing partial nudity while images with a probability closer to 0 have a lower probability of containing partial nudity.
If this value is larger than nudity.raw nudity.safe then a nudity.partial_tag field will be added to describe the type of partial nudity found.

nudity.safe

Decimal between 0 and 1. Images with a value close to 1 are images with a high probability of being safe (i.e. no nudity) while images with a probability closer to 0 have a lower probability of being safe.

Recommended thresholds

1. If nudity.raw ≥ max(nudity.partial, nudity.safe) then the image contains raw nudity.

2. If nudity.partial ≥ max(nudity.raw, nudity.safe) then the image contains partial nudity. You should check nudity.partial_tag for more details on the type of partial nudity.

3. If neither 1. nor 2. are true, then the image is considered safe (no nudity).

Any other needs?

See our full list of Image/Video models for details on other filters and checks you can run on your images and videos. You might also want to check our Text models to moderate text-based content: messages, reviews, comments, usernames...

Was this page helpful?