# NSFW Image Detector & Content Moderation (No API Key) (`freecamp008/nsfw-image-detector`) Actor

Classify images as safe, suggestive or explicit with a self-hosted AI model. Per-class scores (porn, sexy, hentai, drawings, neutral), threshold-based verdicts and fast batch processing of image URLs. No external moderation API.

- **URL**: https://apify.com/freecamp008/nsfw-image-detector.md
- **Developed by:** [Camp8 fr0](https://apify.com/freecamp008) (community)
- **Categories:** AI, Developer tools, For creators
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 image classifieds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## NSFW Image Detector: Content Moderation for Images (Safe / Suggestive / Explicit, No API Key)

Check images for **nudity and adult content** at scale. The Actor classifies every image URL as **safe, suggestive or explicit**, with per-class scores (porn, sexy, hentai, drawings, neutral) and a configurable threshold-based verdict. The AI model runs inside the Actor on CPU, so no image is ever sent to a third-party moderation API and you do not need any API key.

### What does NSFW Image Detector do?

For each image URL, the Actor:

1. downloads the image (several in parallel) and decodes it (JPEG, PNG, WebP, AVIF, GIF, TIFF),
2. runs a **Vision Transformer (ViT) NSFW classifier** fine-tuned on 5 classes: `neutral`, `drawings`, `sexy`, `porn`, `hentai`,
3. combines them into three easy scores: **safe** (neutral + drawings), **suggestive** (sexy) and **explicit** (porn + hentai),
4. applies your thresholds and returns a verdict: `safe`, `suggestive` or `explicit`.

### Key features

- **Three-level verdict**: safe, suggestive (swimwear, lingerie, partial nudity) and explicit (pornographic or sexual content)
- **Raw class scores** for all 5 classes, including **hentai / drawings** for anime and illustrated content
- **Adjustable thresholds** for stricter or more relaxed moderation
- **Fast batch processing**: parallel downloads while the model classifies; around 0.1-0.5 s per image depending on memory
- **Self-hosted model**: no OpenAI, Google Vision, AWS Rekognition or Sightengine account needed
- **HTTP API (Standby mode)** for real-time moderation of uploads
- **Pay per image**; failed images are free

### Use cases

- **User-generated content moderation**: screen profile pictures, listings, comments and uploads
- **Marketplaces and classifieds**: block adult images in product listings
- **Ad and brand safety**: check creatives and landing page images before publishing
- **Dating and social apps**: flag explicit photos for human review
- **Dataset cleaning**: remove NSFW images from scraped datasets before training AI models
- **Parental control and education platforms**: filter image feeds

### How to use NSFW Image Detector

#### In Apify Console

1. Paste image links into **Image URLs** (one per line).
2. Optionally change the **Explicit** and **Suggestive thresholds**.
3. Click **Start**. Each row shows the image, its verdict and scores.

#### Via the Apify API

```bash
curl -X POST "https://api.apify.com/v2/acts/freecamp008~nsfw-image-detector/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"imageUrls": ["https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/football-match.jpg"]}'
```

#### Standby mode (instant HTTP endpoint)

Standby keeps the model loaded, ideal for checking uploads in real time. Send the input as GET query parameters or as a POST JSON body. The response is `{ "count": n, "items": [...] }`.

```bash
## GET: arrays are comma-separated
curl "https://freecamp008--nsfw-image-detector.apify.actor/?token=YOUR_APIFY_TOKEN&imageUrls=https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/anime.png"

## POST
curl -X POST "https://freecamp008--nsfw-image-detector.apify.actor/?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"imageUrls": ["https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/football-match.jpg"], "explicitThreshold": 0.3}'
```

**AI agents can pay per call:** the Actor uses pay-per-event pricing and only default storages, so AI agents can call it and pay per request with **x402** through Apify.

### Input example

```json
{
  "imageUrls": [
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/football-match.jpg",
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/anime.png"
  ],
  "explicitThreshold": 0.5,
  "suggestiveThreshold": 0.5,
  "includeClassScores": true,
  "downloadConcurrency": 8
}
```

| Field | Description |
|---|---|
| `imageUrls` | Image links. One result per image. |
| `explicitThreshold` | Explicit score (porn + hentai) at or above this makes the verdict `explicit` (default 0.5). |
| `suggestiveThreshold` | NSFW score (sexy + porn + hentai) at or above this makes a non-explicit image `suggestive` (default 0.5). |
| `includeClassScores` | Include the 5 raw class probabilities (default on). |
| `downloadConcurrency` | Parallel downloads (default 8). |

### Output example

```json
{
  "imageUrl": "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/anime.png",
  "verdict": "safe",
  "isSafe": true,
  "nsfwScore": 0.0001,
  "explicitScore": 0.0001,
  "suggestiveScore": 0,
  "safeScore": 0.9999,
  "isDrawing": true,
  "topClass": "drawings",
  "classScores": { "drawings": 0.9998, "hentai": 0.0001, "neutral": 0.0001, "porn": 0, "sexy": 0 },
  "width": 640,
  "height": 480,
  "format": "png",
  "processingMs": 118
}
```

- `verdict`: `safe`, `suggestive` or `explicit`. `isSafe` is true only for `safe`.
- `nsfwScore` = suggestive + explicit; `safeScore` = neutral + drawings. All scores are 0-1.
- `isDrawing`: the image is an illustration, cartoon or anime (drawings + hentai >= 0.5).
- Failed images produce `{ "imageUrl": "...", "error": "...", "isError": true }` and are **not charged**.

### Pricing

This Actor uses **pay-per-event** pricing:

| Event | Price | Per 1,000 |
|---|---|---|
| `image-classified`: one image checked, with verdict and scores | $0.002 | **$2.00** |

Apify platform usage (compute, storage) is billed separately according to your plan. Use **Maximum cost per run** to cap spending; the Actor stops cleanly when the limit is reached.

### FAQ

**How accurate is it?**
On our test set of everyday photos (people, sports, cities, animals, classical paintings, anime) every image was classified `safe`, and swimwear / topless beach photos were classified `suggestive` with scores near 1.0. Like every NSFW classifier it makes mistakes on edge cases: medical or breastfeeding images, art with nudity, skin-colored objects, very small or low-resolution images. For high-stakes moderation, send `suggestive` and borderline results (scores between 0.2 and 0.8) to human review.

**What counts as suggestive vs. explicit?**
`suggestive` comes from the model's *sexy* class: revealing clothing, swimwear, lingerie, provocative poses, partial nudity. `explicit` comes from the *porn* and *hentai* classes: sexual acts, exposed genitals, explicit drawings. Classical nude paintings are usually classified as *drawings* (safe).

**Does it detect violence, gore, drugs or weapons?**
No. It is trained only for sexual content. Use an object detector or a dedicated model for other categories.

**What are the limits?**
Images up to 30 MB; animated GIFs use the first frame; videos are not supported. The model looks at a 224 x 224 version of the whole image, so a small explicit detail in a very large image may be missed.

**Are my images private?**
Yes. Images are downloaded and classified inside your Apify run and are not sent to any external service or stored by the Actor.

**Is it legal to use?**
Yes, content moderation is a standard and legitimate use. You are responsible for having the right to process the images you submit and for complying with laws on handling illegal content (e.g. reporting obligations). The Actor does not detect CSAM specifically and must not be relied on as a CSAM filter.

**Which model and license are used?**
[LukeJacob2023/nsfw-image-detector](https://huggingface.co/LukeJacob2023/nsfw-image-detector), a ViT-base classifier released under **Apache-2.0** (commercial use allowed), run in fp32 via the ONNX export [onnx-community/nsfw-image-detector-ONNX](https://huggingface.co/onnx-community/nsfw-image-detector-ONNX) and transformers.js. The model is bundled in the Actor image.

# Actor input Schema

## `imageUrls` (type: `array`):

Direct links to images (JPEG, PNG, WebP, AVIF, GIF, TIFF; animated images use the first frame). Each image becomes one result with a verdict and scores.

## `explicitThreshold` (type: `number`):

0-1. An image is <b>explicit</b> when its explicit score (porn + hentai) is at or above this value. Lower it for stricter moderation.

## `suggestiveThreshold` (type: `number`):

0-1. A non-explicit image is <b>suggestive</b> when its NSFW score (sexy + porn + hentai) is at or above this value (swimwear, lingerie, partial nudity). Otherwise it is <b>safe</b>.

## `includeClassScores` (type: `boolean`):

Add the model's raw probabilities for all 5 classes (drawings, hentai, neutral, porn, sexy) to each result.

## `downloadConcurrency` (type: `integer`):

How many images are downloaded in parallel while the model classifies (1-32).

## Actor input object example

```json
{
  "imageUrls": [
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/football-match.jpg"
  ],
  "explicitThreshold": 0.5,
  "suggestiveThreshold": 0.5,
  "includeClassScores": true,
  "downloadConcurrency": 8
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "imageUrls": [
        "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/football-match.jpg",
        "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/tiger.jpg",
        "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/anime.png"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("freecamp008/nsfw-image-detector").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "imageUrls": [
        "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/football-match.jpg",
        "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/tiger.jpg",
        "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/anime.png",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("freecamp008/nsfw-image-detector").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "imageUrls": [
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/football-match.jpg",
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/tiger.jpg",
    "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/anime.png"
  ]
}' |
apify call freecamp008/nsfw-image-detector --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,freecamp008/nsfw-image-detector"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/TPatMkqxTuB1Xscfh/builds/MDMeLPZgzvXDMFdIc/openapi.json
