sfw

sfw / NudityDetection / 1.1.6

README.md

Note: There is a higher accuracy alternative to this algorithm called NudityDetectionI2v, you can check it out here: https://algorithmia.com/algorithms/sfw/NudityDetectioni2v

This algorithm detects nudity in pictures. For a demo of this algorithm, check out: https://isitnude.com/

Table of content

  1. Introduction
  2. Examples
  3. Credits

Introduction

The idea behind the algorithm is based primarily on observations that in general, nude images contain large amounts of skin, people have different skin tones, and skin regions in nude images are relatively close to each other. In order to make the algorithm more robust, we have incorporated face detection for skin ratio tweaking and skin color detection for limiting the generic skin color value interval. 

Input:

  • (Required): Image: You can send your input as a String (base64 encoded image, arbitrary Url pointing to an image or a data api Url pointing to an image) or pipe the image in as binary data.

Output:

  • JSON object containing values for "nude" and "confidence".

Examples

Example 1.

  • Parameter 1: Safe image URL
"https://s3.amazonaws.com/www.isitnude.com/assets/images/sample/obama.jpg"

Output:

{
    "nude": "false",
    "confidence": 0.95
}

Example 2.

  • Parameter 1: Nude image URL
"http://www.isitnude.com.s3-website-us-east-1.amazonaws.com/assets/images/sample/young-man-by-the-sea.jpg"

Output:

{
    "nude": "true",
    "confidence": 0.93
}

Credits

Implementation is based on: An Algorithm for Nudity Detection

The limits that decide on the skin regions are based on the values in RGB, HSV and normalized RGB color spaces in the book Human Computer Interaction Using Hand Gestures by Prashan Premaratne, derived from multiple papers as described in the book.


Changelog
1.1.3 - Adjusted the URL validator to urls from domains with more than 2 periods (IE: *.co.uk, *.com.br, etc)
1.1.4 - Allows self-signed ssl certificates, meaning all https// requests will be treated identically to http://