Resurrecting Yahoo’s discontinued NSFW model in Keras 3
It revives Yahoo’s discontinued Caffe NSFW classifier as a modern Keras 3 implementation with TensorFlow and JAX backends.

What it does
This is a Keras reimplementation of Yahoo’s discontinued Open-NSFW model, which was originally built in the now-obsolete Caffe framework. It focuses specifically on detecting pornographic images and videos, wrapping the old weights in a simple high-level API for single images, batches, and video frames. Lower-level primitives are also exposed if you want to fine-tune the model or build your own pipeline.
The interesting bit
The project preserves Yahoo’s original preprocessing pipeline—including an optional JPEG round-trip that matches the Caffe implementation—alongside a simpler modern alternative, and it auto-downloads the original pre-trained weights so the model works out of the box. It targets Keras 3 with both TensorFlow and JAX backends, though the README candidly notes that PyTorch support is an afterthought with divergent output.
Key highlights
- Supports both Keras 3 (TensorFlow or JAX) and legacy
tf-keras. - End-to-end APIs for images, image batches, and video frame analysis with configurable aggregation.
- Can generate Grad-CAM overlays to highlight prediction hotspots (TensorFlow backend only).
- Automatically fetches pre-trained Yahoo weights on first use.
- Video processing includes frame skipping, probability aggregation, and optional annotated output.
Caveats
- PyTorch backend works but produces noticeably different inference results and runs slower; the README explicitly advises against using it.
- Grad-CAM visualization is only available when using the TensorFlow backend.
- The model is narrowly scoped to pornographic content and does not claim to detect other forms of NSFW material.
Verdict
Developers who need a drop-in, offline NSFW classifier for images or video should look here; those seeking a general-purpose content moderation tool or a PyTorch-native workflow should probably keep looking.
Frequently asked
- What is bhky/opennsfw2?
- It revives Yahoo’s discontinued Caffe NSFW classifier as a modern Keras 3 implementation with TensorFlow and JAX backends.
- Is opennsfw2 open source?
- Yes — bhky/opennsfw2 is open source, released under the MIT license.
- What language is opennsfw2 written in?
- bhky/opennsfw2 is primarily written in Python.
- How popular is opennsfw2?
- bhky/opennsfw2 has 518 stars on GitHub.
- Where can I find opennsfw2?
- bhky/opennsfw2 is on GitHub at https://github.com/bhky/opennsfw2.