NSFW Image Moderation API for Generative and Virtual Images: A Quick Guide for Developers
Tags: webdev, ai, midjourney, api
Published: 2023-03-25 20:40:24

As developers and programmers, we know that image moderation can be a challenging task, especially when it comes to generative and virtual images. That's why we're excited to introduce our new NSFW Image Moderation API, designed specifically for developers working with generative and virtual images.

Visit : https://skymel.com/api-services.html

## Overview
Our NSFW Image Moderation API uses advanced machine learning algorithms to analyze images and determine whether they contain NSFW content. It is especially effective for generative and virtual images, which can be particularly challenging to moderate due to their unique characteristics.

The API takes an image as input and returns a binary classification label indicating whether the image is safe or not safe for work.

## Examples

### Image Anime
![Image 2](https://ae01.alicdn.com/kf/Heeb2636df04049cda13fa02a4c0b5cfd1/RuleMylife-sexy-anime-girl-with-swimsuit-underwear-car-stickers-decal-anime-cute-car-accessories-decoration-pegatinas.png_640x640.png)

### response Image Anime

```
{
  "error_code": 0,
  "predictions": {
    "appearance_clothing_swimwear_bikini": 0.89,
    "artificial-images": 0.98,
    "artificial-images_fictional-characters-shows": 0.59,
    "artificial-images_hentai": 0.59,
    "composition_one_entity": 0.56,
    "composition_one_female": 0.62,
    "unsafe": 0.85
  }
}
```

### Image Female
![Image 2](https://images.pexels.com/photos/3806244/pexels-photo-3806244.jpeg?auto=compress&cs=tinysrgb&w=800)

### response Image Female

```
{
  "error_code": 0,
  "predictions": {
    "appearance_clothing_swimwear_bikini": 1.0,
    "body-parts_lower-body_genitalia_vulva_covered": 0.61,
    "body-parts_upper-body_breasts_covered": 0.59,
    "unsafe": 1.0
  }
}
```


### Image Male
![Image 3](https://media1.popsugar-assets.com/files/thumbor/rEkTP3hAxW1usdtfgWCypC0cSkw/fit-in/2048xorig/filters:format_auto-!!-:strip_icc-!!-/2014/12/16/052/n/3019466/5fcbb7e5b7e21486_thumb_temp_image156739581418765648/i/Sexy-Guys-Follow-Instagram.jpg)

### response Image Male

```
{
  "error_code": 0,
  "predictions": {
    "appearance_clothing_topless_male": 0.61,
    "body-parts_head_lips-mouth": 0.73,
    "body-parts_upper-body_breasts_male": 0.76,
    "body-parts_upper-body_breasts_partially_or_completely_exposed": 0.99,
    "body-parts_upper-body_midriff_male": 0.66,
    "unsafe": 0.98
  }
}
```

### Image Cute Couples

![Image 3](https://hips.hearstapps.com/hmg-prod/images/romantic-couple-captions-1627502747.jpg?crop=0.668xw:1.00xh;0.219xw,0&resize=980:*)

### response Image Cute Couples

```
{
  "error_code": 0,
  "predictions": {
    "body-parts_head_lips-mouth": 0.67,
    "safe": 0.84
  }
}
```


## Usage
To use the NSFW Classifier API in your application, you can send a POST request to the API endpoint with the base64 encoded image data as the payload. The API will return a JSON response with the classification label.
Here's an example Python script that demonstrates how to use the NSFW Classifier API:

### python

```
import base64
import json

import requests

image_url = "https://e7.pngegg.com/pngimages/856/913/png-clipart-female-character-illustration-character-youtube-animated-film-infant-youtube-child-black-hair-thumbnail.png"

encoded_image = base64.b64encode(requests.get(image_url).content).decode('utf-8')

url = 'https://modelpubsub.com/api-v1.0/SafeUnsafeImageWithTags'
data = {
    'api_key': 'test_image_devto',
    'base64_image': encoded_image
}
try:
    response = requests.request("POST", url, data=json.dumps(data))
except requests.exceptions.ConnectionError as _:
    response = None

if response is not None:
    print(response.content)
```


### Payload

The payload for the NSFW Classifier API should be a base64 encoded image data. example:
```
{
    'api_key': 'test_image_devto',
    'base64_image': encoded_image
}
```


### Response
The response from the NSFW Classifier API is a JSON object with the following fields:

**label: **A binary classification label indicating whether the image is safe or not safe for work. Possible values are 0 for safe and 1 for not safe.
**score:** A confidence score for the classification, ranging from 0 to 1. Higher scores indicate greater confidence in the classification.
Authentication
The NSFW Classifier API requires authentication using an API key. To obtain an API key, please contact our support team at [**contactus@skymel.com**](mailto:contactus@skymel.com).

## Available Labels:

The NSFW image classifier produces a probability score for each label it has been trained to detect as its output. In our image classifier, the probability scores are provided for the following labels.

* 'safe',
* 'unsafe',

* 'appearance_appearance-modification',
* 'appearance_appearance-modification_piercings',
* 'appearance_appearance-modification_tattoos',
* 'appearance_clothing',
* 'appearance_clothing_bodyparts-through-clothes',
* 'appearance_clothing_bottomless',
* 'appearance_clothing_bottomless_female',
* 'appearance_clothing_clothed-naked-pair',
* 'appearance_clothing_dresses',
* 'appearance_clothing_nsfw',
* 'appearance_clothing_open_shirt',
* 'appearance_clothing_shoes',
* 'appearance_clothing_shoes_high-heels',
* 'appearance_clothing_sportswear',
* 'appearance_clothing_stockings',
* 'appearance_clothing_swimwear',
* 'appearance_clothing_swimwear_bikini',
* 'appearance_clothing_swimwear_bikini_bottom',
* 'appearance_clothing_swimwear_bikini_top',
* 'appearance_clothing_swimwear_extreme',
* 'appearance_clothing_swimwear_microbikini',
* 'appearance_clothing_swimwear_one-piece',
* 'appearance_clothing_tight-clothing',
* 'appearance_clothing_tight-clothing_labia_outline',
* 'appearance_clothing_topless_female',
* 'appearance_clothing_topless_male',
* 'appearance_clothing_transparent',
* 'appearance_clothing_underwear',
* 'appearance_clothing_underwear_brassiere',
* 'appearance_clothing_underwear_garter-belt',
* 'appearance_clothing_underwear_lingerie',
* 'appearance_clothing_underwear_panties',
* 'appearance_clothing_underwear_thongs',
* 'appearance_clothing_undressed',
* 'appearance_clothing_uniforms-outfits',
* 'appearance_clothing_uniforms-outfits_cosplay',
* 'appearance_clothing_upskirt',
* 'appearance_clothing_upskirt-downblouse',
* 'appearance_expressions',
* 'appearance_nude',
* 'appearance_pose',
* 'appearance_pose_lifting_shirt',
* 'appearance_pose_pulling_panties',
* 'appearance_pose_spread_legs',

* 'artificial-images',
* 'artificial-images_fictional-characters-shows',
* 'artificial-images_hentai',
* 'artificial-images_photoshop',
* 'body-parts_head_hair',
* 'body-parts_head_hair_black',
* 'body-parts_head_hair_blonde',
* 'body-parts_head_hair_brunette',
* 'body-parts_head_hair_dyed',
* 'body-parts_head_hair_hairstyle',
* 'body-parts_head_hair_redhead',
* 'body-parts_head_lips-mouth',
* 'body-parts_lower-body',
* 'body-parts_lower-body_ass',
* 'body-parts_lower-body_ass_covered',
* 'body-parts_lower-body_ass_exposed',
* 'body-parts_lower-body_ass_exposed_female',
* 'body-parts_lower-body_ass_large',
* 'body-parts_lower-body_asshole',
* 'body-parts_lower-body_feet',
* 'body-parts_lower-body_feet_covered',
* 'body-parts_lower-body_gap',
* 'body-parts_lower-body_genitalia_penis',
* 'body-parts_lower-body_genitalia_vulva',
* 'body-parts_lower-body_genitalia_vulva_covered',
* 'body-parts_lower-body_genitalia_vulva_hair',
* 'body-parts_lower-body_genitalia_vulva_labia',
* 'body-parts_lower-body_hips',
* 'body-parts_lower-body_labia',
* 'body-parts_lower-body_legs',
* 'body-parts_lower-body_mons-pubis',
* 'body-parts_lower-body_pubic_hair',
* 'body-parts_lower-body_scrotum',
* 'body-parts_lower-body_thighs',
* 'body-parts_upper-body',
* 'body-parts_upper-body_arm-pits',
* 'body-parts_upper-body_breasts',
* 'body-parts_upper-body_breasts_cleavage',
* 'body-parts_upper-body_breasts_covered',
* 'body-parts_upper-body_breasts_covered_by_hands',
* 'body-parts_upper-body_breasts_from-an-angle',
* 'body-parts_upper-body_breasts_from_below',
* 'body-parts_upper-body_breasts_from_side',
* 'body-parts_upper-body_breasts_implants',
* 'body-parts_upper-body_breasts_large',
* 'body-parts_upper-body_breasts_male',
* 'body-parts_upper-body_breasts_nipples',
* 'body-parts_upper-body_breasts_small',
* 'body-parts_upper-body_midriff',
* 'body-parts_upper-body_midriff_female',
* 'body-parts_upper-body_midriff_male',
* 'body-parts_upper-body_navel',
* 'body-parts_upper-body_navel_female',

* 'composition_multiple_females',
* 'composition_multiple_males',
* 'composition_one_entity',
* 'composition_one_female',
* 'composition_one_male',
* 'composition_three_females',
* 'composition_two_females',
* 'composition_two_males',

* 'fetish',
* 'fetish_bdsm',
* 'fetish_bdsm_bondage',
* 'fetish_bdsm_domination-&-submission',
* 'fetish_bdsm_domination-&-submission_femdom',
* 'fetish_drugs',
* 'fetish_role-enactment',
* 'fetish_role-enactment_age-play',
* 'fetish_role-enactment_furry',
* 'fetish_role-enactment_pet-play',
* 'fetish_role-enactment_rape-abuse',
* 'fetish_watersports',

* 'general-categories',
* 'general-categories_artistic-or-borderline-porn',
* 'general-categories_desktop-wallpaper',
* 'general-categories_gifs',
* 'general-categories_humorous',
* 'general-categories_p.o.v.',
* 'general-categories_passionate',
* 'general-categories_videos',

* 'locations_man-made',
* 'locations_nature',
* 'locations_nature_beach',

* 'one_female_face',
* 'one_male_face',

* 'specific-actor-actress',
* 'specific-company',
* 'three_female_faces',
* 'three_male_faces',
* 'two_female_faces',
* 'two_male_faces',

* 'weapons',
* 'weapons_guns',


We hope this developer wiki helps you integrate the NSFW Classifier API into your application. Thank you for choosing our API!