Products

SIGN UP LOG IN

Models / Nudity Detection

Nudity Detection

This page describes version 2.0 of the Nudity Detection. The older version is available here.

Overview

The Advanced Nudity Detection API is an A.I.-based service to determine the nudity content of images and videos. There are 5 main nudity classes, also called "nudity levels" along with multiple sub-classes, that you can use to automatically understand the content of your images/videos, and set the appropriate rules.

Nudity Classes and sub-classes

There are 5 main Nudity Classes, each subdivided into further sub-classes. The classes are presented here in descending order of expliciteness, from the most explicit (sexual activity) down to the safest.

  • Sexual activity: Actual or simulated sexual activity with exposed nudity.
    nudity.sexual_activity
    • Sexual intercourse with clear nudity, including genital-genital and oral-genital activity
    • Masturbation
    • Direct touching of genitals
    • Sex toys involved in sexual activity: penetrating mouth, anus or genitals. Includes dildos, sex dolls, fleshlights, plugs.
    • Semen or vaginal fluids on faces or body parts
  • Sexual display: Explicit exposure of genitals/sexual organs
    nudity.sexual_display
    • Female genitals: exposed genitalia, vulva or anus, either directly visible or through transparent, see-through or sheer clothing
    • Male genitals, male penises, both erect and non-erect, testicles, either directly visible or through transparent, see-through or sheer clothing
    • The above applies to transgender individuals
    • Sex toys not in use: dildos, sex dolls, fleshlights, butt plugs & beads
  • Erotica: Exposure of breasts, nude buttocks or the pubic region
    nudity.erotica
    • Female breasts with visible nipples or areola
    • Nude buttocks, both male and female, in a non-sexual setting
    • Pubic region, pubic hair, female crotch region or area around genitals with no genitals visible
  • Suggestive: Situations that can be considered sexually suggestive or inappropriate, but do not include full nudity or sexual acts
    nudity.suggestive
    • Women wearing lingerie, wearing visible bras (the cup has to be visible, and sports bras are excluded), or wearing visible underwear, panties or thongs nudity.suggestive_classes.lingerie
    • Shirtless men: men where most of the area between the belly button and shoulders is visible (bare chest, topless, nude torso) nudity.suggestive_classes.male_chest
    • Suggestive cleavage / neckline, but where the areola and nipples are not visible nudity.suggestive_classes.cleavage
    • Women wearing bikinis, microbikinis or two-piece swimsuits nudity.suggestive_classes.bikini
  • None: This class includes all cases where none of the above suggestive or explicit situations occur. As an example, this would include situations such as:
    nudity.none
    • Exposed arms, legs in a non-sexual setting
    • People hugging or making non-sexual contact
    • People kissing (mouth-mouth)
    • People wearing tank tops or stringers without nipples visible
    • Exposed back of a woman or man, if no buttocks, no genitals and no torso is visible
    • Panties, thongs, bras, swimwear shown but not worn by a person (such as on the floor)
    • Women in one-piece swimsuits
    • Underwear worn such that only the waistband is visible
    • Unclothed dolls with no sexual organs, such as Barbie dolls

Understanding the scoring

The scores are returned in a way that puts the emphasis on the most explicit class corresponding to the image/video. As an example, the class sexual_display shouldn't be understood as "is there sexual display in the image?" but rather "is there sexual display AND no sexual activity in the image?".

As an illustration, an image of a woman in lingerie will score highly on the suggestive class. But if that woman is engaged in a sexual act, the API will focus on the most explicit class (sexual_activity) and return a very low score for the less explicit one (suggestive and suggestive.lingerie), because the image as a whole is explicit and should not be labelled as simply "suggestive" or "lingerie".

Use the model

The Nudity Detection model works 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 URL to the image, or upload the raw binary image.

URL-based

Here's how to proceed if you choose to share the image URL:


curl -X GET -G 'https://api.sightengine.com/1.0/check.json' \
    -d 'models=nudity-2.0' \
    -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-2.0',
  '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-2.0',
  '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-2.0',
    '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);
});

Raw image-based

Here's how to proceed if you choose to upload the raw image:


curl -X POST 'https://api.sightengine.com/1.0/check.json' \
    -F 'media=@/path/to/image.jpg' \
    -F 'models=nudity-2.0' \
    -F 'api_user={api_user}' \
    -F 'api_secret={api_secret}'


# this example uses requests
import requests
import json

params = {
  'models': 'nudity-2.0',
  'api_user': '{api_user}',
  'api_secret': '{api_secret}'
}
files = {'media': open('/path/to/image.jpg', 'rb')}
r = requests.post('https://api.sightengine.com/1.0/check.json', files=files, data=params)

output = json.loads(r.text)


$params = array(
  'media' => new CurlFile('/path/to/image.jpg'),
  'models' => 'nudity-2.0',
  'api_user' => '{api_user}',
  'api_secret' => '{api_secret}',
);

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

$output = json_decode($response, true);


// this example uses axios and form-data
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

data = new FormData();
data.append('media', fs.createReadStream('/path/to/image.jpg'));
data.append('models', 'nudity-2.0');
data.append('api_user', '{api_user}');
data.append('api_secret', '{api_secret}');

axios({
  method: 'post',
  url:'https://api.sightengine.com/1.0/check.json',
  data: data,
  headers: data.getHeaders()
})
.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);
});

API response

The API will then return a JSON response with the following structure:

                    
                    
{
    "status": "success",
    "request": {
        "id": "req_1SJJxJjUHnSVWreApx9fF",
        "timestamp": 1510153177.0043,
        "operations": 1
    },
    "nudity": {
        "sexual_activity": 0.01,
        "sexual_display": 0.01,
        "erotica": 0.01,
        "suggestive": 0.01,
        "suggestive_classes": {
          "bikini": 0.01,
          "cleavage": 0.01,
          "male_chest": 0.01,
          "lingerie": 0.01,
          "miniskirt": 0.01
        },
        "none": 0.98
    },
    "media": {
        "id": "med_1SJJEFuLqeSedThQjhNoS",
        "uri": "https://sightengine.com/assets/img/examples/example-fac-1000.jpg"
    }
}
                    
                

You can use the classes under the nudity object to determine the nudity level of the image. In the above example the winning class is nudity.none with a confidence of 0.98, meaning that the API is very confident in its classification.

As you can see, the default configuration of the API does not return details on all the sub-classes within each class. If you need access to sub-class information, please reach out.

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?

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more

OK