AdamCodd's 86M-Parameter ViT Hits 870K Downloads Replacing Paid Moderation APIs
An open-source Vision Transformer fine-tuned for two-class NSFW image moderation hits 96.5% accuracy, ONNX-ready, and crosses 870K downloads.
Takeaways
- Vision Transformer fine-tuned for binary NSFW/SFW image classification, Apache-2.0 licensed on Hugging Face
- 96.54% accuracy and 0.9948 AUC on eval, trained on ~25K mixed images
- 86.1M parameters, ships as Safetensors and ONNX, runs in-browser via Transformers.js
- Weak on AI-generated images; author released separate vit-nsfw-stable-diffusion for that
- Trained one epoch, Adam optimizer, lr 3e-05, batch size 32 on Google's vit-base-patch16-384
- 870K+ downloads and 16 Spaces already using it for moderation pipelines
A compact Vision Transformer built for one job has quietly become one of the most downloaded moderation models on Hugging Face. AdamCodd/vit-base-nsfw-detector is an Apache-2.0 licensed image classifier that ships in Safetensors and ONNX formats, runs in the browser via Transformers.js, and weighs in at 86 million parameters, small enough to embed in almost any upload pipeline. It does exactly one thing: sort safe-for-work images from not-safe-for-work ones.
The model fine-tunes Google's vit-base-patch16-384 backbone on roughly 25,000 images spanning drawings, photos, and 3D renders. It outputs two labels: sfw and nsfw. The training recipe was deliberately minimal: learning rate 3e-05, batch size 32, Adam optimizer with betas (0.9, 0.999) and epsilon 1e-08, a single epoch, seed 42. A clean dataset and a solid pretrained ViT backbone can go a long way.
The numbers
On the held-out evaluation set, the reported metrics are strong for a single-epoch fine-tune:
- Loss: 0.0937
- Accuracy: 0.9654
- AUC: 0.9948
- Confusion matrix: 1076 / 37 and 60 / 1627 across the two classes