All Projects → rahiel → open_nsfw--

rahiel / open_nsfw--

Licence: BSD-3-Clause, BSD-2-Clause licenses found Licenses found BSD-3-Clause LICENSE.txt BSD-2-Clause LICENSE-yahoo.txt
API to classify images as SFW/NSFW.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to open nsfw--

Nude.js
Nudity detection with JavaScript and HTMLCanvas
Stars: ✭ 2,236 (+3892.86%)
Mutual labels:  nudity-detection
nsfw api
Python REST API to detect images with adult content
Stars: ✭ 71 (+26.79%)
Mutual labels:  nudity-detection
NudeDetectorPHP
PHP implementation of Rigan Ap-Apid's "An Algorithm for Nudity Detection"
Stars: ✭ 16 (-71.43%)
Mutual labels:  nudity-detection

open_nsfw--

This is a fork of Yahoo's open_nsfw. The goal is to make the Not Suitable for Work (NSFW) classification model easily accessible through an HTTP API deployable with Docker.

Install

First install Docker (available in Debian as docker.io), then give the user you want to run the API as permission to use Docker:

sudo gpasswd -a $USER docker

You need to logout and login again for this to take effect.

Now build the image, this might take a while:

docker build -t open_nsfw https://raw.githubusercontent.com/rahiel/open_nsfw--/master/Dockerfile

Then you can start the API:

docker run -p <port>:8080 open_nsfw

where you replace <port> with the port number you want to have the API accessible on your local machine.

Usage

The API is very simple, you POST an url of an image and the API will then fetch it, classify it and return the probability that it's NSFW. The probability is expressed as a real number between 0 and 1.

In the following examples I assume you picked 8080 for the port number, so the API is running at localhost:8080.

With curl:

curl -d 'url=http://example.com/image.jpg' localhost:8080

With Python:

import requests
r = requests.post("http://localhost:8080", data={"url": "http://example.com/image.jpg"})
nsfw_prob = float(r.text)

HTTP Errors

400 Bad Request: Missing url POST parameter

You need to specify url as a POST parameter.

404 Not Found

The requested url leads to an HTTP 404 Not Found error.

415 Unsupported Media Type: Invalid image

The requested url is not a valid image.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].