How to recognise adult content programmatically?


I am currently developing a website for a client. It consists of users being able to upload pictures to be shown in a gallery on the site.

The problem we have is that when a user uploads an image it would obviously need to be verified to make sure it is safe for the website (no pornographic or explicit pictures). However my client would not like to manually have to accept every image that is being uploaded as this would be time consuming and the users’ images would not instantly be online.

I am writing my code in PHP. If needs be I could change to or C#. Is there any way that this can be done?


2019 Update

A lot has changed since this original answer way back in 2013, the main thing being machine learning. There are now a number of libraries and API’s available for programmatically detecting adult content:

Google Cloud Vision API, which uses the same models Google uses for safe search.

NSFWJS uses TensorFlow.js claims to achieve ~90% accuracy and is open source under MIT license.

Yahoo has a solution called Open NSFW under the BSD 2 clause license.

2013 Answer

There is a JavaScript library called nude.js which is for this, although I have never used it. Here is a demo of it in use.

There is also PORNsweeper.

Another option is to "outsource" the moderation work using something like Amazon Mechanical Turk, which is a crowdsourced platform which "enables computer programs to co-ordinate the use of human intelligence to perform tasks which computers are unable to do". So you would basically pay a small amount per moderation item and have an outsourced actual human to moderate the content for you.

The only other solution I can think of is to make the images user moderated, where users can flag inappropriate posts/images for moderation, and if nobody wants to manually moderate them they can simply be removed after a certain number of flags.

Here are a few other interesting links on the topic:

Answered By – Brett Gregson

Answer Checked By – David Goodson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.