xpunge
v0.1.8
Published
On-device NSFW detection for React Native. No uploads. No cloud.
Maintainers
Readme
xpunge
On-device NSFW detection for React Native. No uploads. No cloud. Zero marginal cost per image.
Why on-device?
Server-side moderation (AWS Rekognition, etc.) costs ~$1 per 1,000 images and sends your users' photos to a third party. xPunge runs the model directly on the device — images never leave the phone, and there is no per-image cost.
Installation
npm install xpungeiOS
cd ios && pod installAndroid
No extra steps. The native module links automatically.
Setup
Get a free API key at xpunge-backend.onrender.com/dashboard.
Usage
import { initialize, analyzeImage, analyzeFile, Detection } from 'xpunge';
// Call once at app startup
await initialize('xp1.YOUR_KEY_HERE');
// Analyze from base64
const detections: Detection[] = await analyzeImage(base64ImageString);
// Or analyze directly from a file path
const detections: Detection[] = await analyzeFile('/path/to/image.jpg');API
initialize(apiKey: string): Promise<void>
Loads the on-device model and validates your API key. Call once before any detection — typically in your app's startup sequence. Throws if the key is invalid, expired, or registered for a different app bundle/package.
analyzeImage(base64: string): Promise<Detection[]>
Analyzes an image from a base64-encoded string. Returns an array of detections (empty array = clean image).
analyzeFile(filePath: string): Promise<Detection[]>
Analyzes an image from a local file path. Supports JPEG, PNG, HEIF, and WebP on Android; JPEG, PNG, and HEIF on iOS.
Detection result
interface Detection {
label: 'breast' | 'penis' | 'anus' | 'rear' | 'vagina';
confidence: number; // 0.0–1.0
x: number; // normalized bounding box, 0.0–1.0
y: number;
width: number;
height: number;
}Bounding box coordinates are normalized to the image dimensions (0 = left/top edge, 1 = right/bottom edge). On the free tier, x, y, width, and height are always 0 — only label and confidence are returned.
Tiers
| Feature | Free | Paid | |---|---|---| | Image detection | ✓ | ✓ | | Bounding boxes | — | ✓ | | File path input | ✓ | ✓ |
Paid plans are based on Monthly Active Users. See xpunge dashboard for pricing.
Platform support
| Platform | Minimum version | |---|---| | Android | API 24 (Android 7.0) | | iOS | 14.0 |
License
See LICENSE.
