A 17 kB bouncer for your iOS app
Tiny CoreML model that tries to tell Instagram thirst traps from actual porn, running entirely on-device.

What it does
NSFWDetector is a single-purpose iOS library: feed it a UIImage, get back a confidence score (0–1) that the image contains nudity/porn. It’s a thin Swift wrapper around a CoreML model trained with Apple’s CreateML, distributed via Swift Package Manager or CocoaPods. The whole model weighs 17 kB — small enough that the authors contrast it favorably against Yahoo’s much heftier open_nsfw model.
The interesting bit
The explicit design goal is nuance: distinguishing “instagram model like pictures” from actual porn, rather than blanket-flagging any skin. That’s a harder classification problem than it sounds, and the 17 kB size is genuinely unusual for on-device ML — though the README doesn’t specify accuracy numbers or the training dataset size.
Key highlights
- Runs entirely on-device via CoreML; no network round-trips for image analysis
- Model file is 17 kB; wrapper code is minimal Swift glue
- Supports iOS 12.0+, requires Xcode 10+ to compile (CreateML artifact)
- Can use just the
.mlmodelfile without the wrapper if preferred - BSD licensed
Caveats
- No published accuracy, false positive rate, or benchmark comparisons — just the Yahoo size comparison
- Threshold tuning is left entirely to the developer (the sample uses 0.9, but notes “stricter boundaries” need lower thresholds, which is… backwards?)
- Single maintainer contact; no visible issue/discussion activity in the README
Verdict
Worth a look if you need lightweight, offline content moderation in an iOS app and are willing to validate the model against your own data. Skip it if you need transparency on training data, cross-platform support, or rigorous accuracy metrics.