Skip to main content

Stand-alone wrapper for Yahoo's OpenNSFW model using Tensorflow.

Project description


License: MIT CircleCI

A small library for intergrating yahoo/open_nsfw model directly into an application.

This library wraps an Tensorflow version of yahoo/open_nsfw, provided by tensorflow-open_nsfw. The TensorFlow model was exported so there is no direct dependency on yahoo/open_nsfw or tensorflow-open_nsfw.


  • Tensorflow 2.x
  • NumPy 1.x


$ pip install opennsfw-standalone



import sys

from opennsfw_standalone import OpenNSFWInferenceRunner

inference_runner = OpenNSFWInferenceRunner.load()

for image_filename in sys.argv[1:]:
    with open(image_filename, "rb") as fp:
        nsfw_score = inference_runner.infer(
        print(image_filename, nsfw_score)


$ python -m opennsfw_standalone myimage.jpeg mysecondimage.jpeg
myimage.jpg 0.9997739
mysecondimage.jpg 0.9984438


Although this repository is MIT licensed, the model itself is subject to the BSD 2-Clause license Yahoo provided.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opennsfw-standalone-0.0.1.tar.gz (44.3 MB view hashes)

Uploaded source

Built Distribution

opennsfw_standalone-0.0.1-py3-none-any.whl (88.6 MB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page