All Projects → EugenCepoi → nsfw_api

EugenCepoi / nsfw_api

Licence: BSD-2-Clause license
Python REST API to detect images with adult content

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to nsfw api

nsfw-classification-tensorflow
NSFW classify model implemented with tensorflow.
Stars: ✭ 58 (-18.31%)
Mutual labels:  image-classification, nsfw, nsfw-recognition
Nude.js
Nudity detection with JavaScript and HTMLCanvas
Stars: ✭ 2,236 (+3049.3%)
Mutual labels:  image-classification, nudity-detection
VideoAudit
📹 一个短视频APP视频内容安全审核的思路调研及实现汇总
Stars: ✭ 221 (+211.27%)
Mutual labels:  caffe, nsfw
Caffe Android Demo
An android caffe demo app exploiting caffe pre-trained ImageNet model for image classification
Stars: ✭ 254 (+257.75%)
Mutual labels:  caffe, image-classification
Deepdetect
Deep Learning API and Server in C++14 support for Caffe, Caffe2, PyTorch,TensorRT, Dlib, NCNN, Tensorflow, XGBoost and TSNE
Stars: ✭ 2,306 (+3147.89%)
Mutual labels:  caffe, image-classification
Have Fun With Machine Learning
An absolute beginner's guide to Machine Learning and Image Classification with Neural Networks
Stars: ✭ 4,912 (+6818.31%)
Mutual labels:  caffe, image-classification
Seefood
Inspired by HBO's Silicon Valley: SeeFood is an iOS app that uses CoreML to detect various dishes
Stars: ✭ 445 (+526.76%)
Mutual labels:  caffe, image-classification
content-moderation-image-api
An NSFW Image Classification REST API for effortless Content Moderation built with Node.js, Tensorflow, and Parse Server
Stars: ✭ 50 (-29.58%)
Mutual labels:  nsfw, nsfw-recognition
deep-parking
Code to reproduce 'Deep Learning for Decentralized Parking Lot Occupancy Detection' paper.
Stars: ✭ 81 (+14.08%)
Mutual labels:  caffe, image-classification
ePillID-benchmark
ePillID Dataset: A Low-Shot Fine-Grained Benchmark for Pill Identification (CVPR 2020 VL3)
Stars: ✭ 54 (-23.94%)
Mutual labels:  image-classification
Caffe-installation-Raspberry-Pi-3
No description or website provided.
Stars: ✭ 23 (-67.61%)
Mutual labels:  caffe
CoreML-and-Vision-with-a-pre-trained-deep-learning-SSD-model
This project shows how to use CoreML and Vision with a pre-trained deep learning SSD (Single Shot MultiBox Detector) model. There are many variations of SSD. The one we’re going to use is MobileNetV2 as the backbone this model also has separable convolutions for the SSD layers, also known as SSDLite. This app can find the locations of several di…
Stars: ✭ 16 (-77.46%)
Mutual labels:  image-classification
ImVisible
ImVisible: Pedestrian Traffic Light Dataset, Neural Network, and Mobile Application for the Visually Impaired (CAIP '19, ICCVW'19)
Stars: ✭ 32 (-54.93%)
Mutual labels:  image-classification
get-sauce
A command line program to download hentai videos and images from multiple websites
Stars: ✭ 40 (-43.66%)
Mutual labels:  nsfw
CNN-Image-Classifier
A Simple Deep Neural Network to classify images made with Keras
Stars: ✭ 65 (-8.45%)
Mutual labels:  image-classification
Deep-Learning-with-GoogleColab
Deep Learning Applications (Darknet - YOLOv3, YOLOv4 | DeOldify - Image Colorization, Video Colorization | Face-Recognition) with Google Colaboratory - on the free Tesla K80/Tesla T4/Tesla P100 GPU - using Keras, Tensorflow and PyTorch.
Stars: ✭ 63 (-11.27%)
Mutual labels:  image-classification
FNet-pytorch
Unofficial implementation of Google's FNet: Mixing Tokens with Fourier Transforms
Stars: ✭ 204 (+187.32%)
Mutual labels:  image-classification
NudeDetectorPHP
PHP implementation of Rigan Ap-Apid's "An Algorithm for Nudity Detection"
Stars: ✭ 16 (-77.46%)
Mutual labels:  nudity-detection
serving-tensorflow-models
Serving TensorFlow models with TensorFlow Serving 📙
Stars: ✭ 41 (-42.25%)
Mutual labels:  image-classification
pigallery
PiGallery: AI-powered Self-hosted Secure Multi-user Image Gallery and Detailed Image analysis using Machine Learning, EXIF Parsing and Geo Tagging
Stars: ✭ 35 (-50.7%)
Mutual labels:  image-classification

Nudity image detection HTTP API

This project provides a ready to deploy REST API allowing to predict if an image is offensive or has adult content.

It relies on open_nsfw, which provides a pre-trained open source neural network model for Caffe.

The current project doesn't aim at improving the quality of the predictions. The main goal is to provide a ready to deploy solution for people that might need this kind of service for free.

Running and Deploying

The python REST API, with Caffe and open_nsfw are packaged all together in a Docker image. So in theory you could just use an existing build from Docker Hub or build your own.

Running locally

The API and everything needed for it to work is part of a docker image. So first you will need to install Docker for your OS. Then you can use a prebuilt image.

docker run -it -p 127.0.0.1:5000:5000/tcp --env PORT=5000 eugencepoi/nsfw_api:latest

The API should be up and running at

http://localhost:5000/?url=https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png`

Or if you want to tweak things around you can clone the repository and then build the image your self. Build it with docker-compose build and use docker-compose up to start the container.

Running on Heroku

A simple and quick option to get it up and ready for you to use from your website is via Heroku. You will need an Heroku account for that. If you are building your own image from a clone of this repository, then from inside the project directory do:

  • Login to the Heroku container registry heroku container:login
  • Create an app if one doesn't already exist heroku create YOUR_APP_NAME
  • Upload the image heroku container:push web (add optionally --app YOUR_APP_NAME)
  • Release it to your app heroku container:release web (add optionally --app YOUR_APP_NAME)

The service should be up and running. It might take a bit of time for the first request to be processed, though subsequent ones should be faster.

Running in offline mode

For now running in batch/offline mode is outside of the scope of the project but any contribution to do so is welcome.

API Usage

You can use the classification API via two endpoints.

Single prediction

To get a prediction score for one single image just use the GET endpoint with a parameter named url.

curl -X GET -H 'Content-Type: application/json' http://localhost:5000\?url\=https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png

{
  "score": 0.00016061133646871895,
  "url": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"
}

The response will be a json object with a score property having a value between 0 and 1, 1 meaning it is for sure adult content while 0 it isn't. If there is an error while fetching the URL there will be two properties error_code and error_reason instead of the score:

{
  "error_code": 500,
  "error_reason": "[Errno -2] Name or service not known",
  "url": "https://foobar"
}

Remark that doing the classification isn't a fast operation so you shouldn't call this API in places where you want the response in real time/low latency (for ex. to display it to the user), but instead call the API periodically for a batch of images using the endpoint below.

Batch predictions with streamed responses

The batch endpoint takes as input a list of images to classify and returns the result for each image. The response is being streamed back, so you could read it in a streaming fashion and process the results as they come in (as opposed to wait for the entire response before processing it). For that purpose use the batch classification API as follows.

curl -X POST -H 'Content-Type: application/json' \
 -d '{"images": [{"url": "http://foo.bar", "id": 1}, {"url": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png", "id": 2, "extra_props": {"foo": "bar"}}]}' \
 http://localhost:5000/batch-classify
 
{"predictions": [
{"url": "http://foo.bar", "error_reason": "[Errno -2] Name or service not known", "error_code": 500, "id": 1},
{"url": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png", "score": 0.00016061133646871895, "id": 2, "extra_props": {"foo": "bar"}}
]}

Each entry should have an url property pointing to the image accessible over HTTP/HTTPS. Any extra attribute will be preserved and sent back in the response. This allows easily to identify each entry and eventually pass along some context.

Failing to process one entry in the batch will not fail the entire operation, instead the result for this single entry will report the error. However if there is an error in handling the input JSON or some other global error the format of the response is not guaranteed so you should check the response status code.

License

Code licensed under the [BSD 2 clause license] (https://github.com/BVLC/caffe/blob/master/LICENSE). See LICENSE file for terms.

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].