← all repositories
GantMan/nsfw_model

A Keras model that knows its hentai from its anime

This repo packages a pre-trained Keras image classifier that sorts photos into five categories, from safe anime drawings to explicit content, for offline content moderation.

nsfw_model
Not currently ranked — collecting fresh signals.
star history

What it does The project provides a pre-trained Keras model trained on over 60 gigabytes of images to classify pictures into five labels: drawings, hentai, neutral, porn, and sexy. You load a model file—Inception v3 or MobileNet v2 variants—and pass it image paths to get back probability scores for each category. It is the backend behind the browser-based NSFW JS library, meaning the same logic can run locally without sending images to a third-party API.

The interesting bit The five-class taxonomy is more nuanced than a simple safe/unsafe toggle: it specifically separates SFW drawings (including anime) from hentai, and distinguishes sexually explicit imagery from full pornography. That granularity is useful if you want to apply different policies to different edge cases rather than bluntly blocking everything.

Key highlights

  • Claims 93% accuracy based on an Inception V3 confusion matrix shown in the README.
  • Ships multiple model formats: Keras .h5, TensorFlow .pb, and quantized TensorFlow.js bundles for browser or mobile deployment.
  • Includes training scripts for transfer learning on Inception v3 and MobileNet v2, plus a self_clense.py utility to cross-validate and clean noisy training data.
  • Powers the offline NSFW JS demo, so it can run entirely client-side.

Caveats

  • The README notes there is “no easy way to distribute the training data,” so reproducing or fine-tuning the model on your own dataset requires sourcing images yourself.
  • The project appears to target TensorFlow 1.x based on the TF1 Training Folder Contents note, which may require compatibility shims for modern pipelines.

Verdict Worth a look if you need client-side or offline content moderation and would rather drop in a pre-trained model than build one from scratch. Skip it if you need a guaranteed enterprise-grade moderation API or a PyTorch-native workflow—though the community has forked a ResNet-based PyTorch version if that’s your stack.

Frequently asked

What is GantMan/nsfw_model?
This repo packages a pre-trained Keras image classifier that sorts photos into five categories, from safe anime drawings to explicit content, for offline content moderation.
Is nsfw_model open source?
Yes — GantMan/nsfw_model is an open-source project tracked on heatdrop.
What language is nsfw_model written in?
GantMan/nsfw_model is primarily written in Python.
How popular is nsfw_model?
GantMan/nsfw_model has 2.1k stars on GitHub.
Where can I find nsfw_model?
GantMan/nsfw_model is on GitHub at https://github.com/GantMan/nsfw_model.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.