# NSFW Image Detector (`babak/nsfw-image-detector`) Actor

This NSFW image detector is a fast and easy JPEG, PNG, BMP, and GIF nude checker, and content moderation tool. It marks indecent content from hundreds of image URLs in seconds. Let your users view 👙 porn, 🎌 hentai, and 😍 sexy content only when they want to!

- **URL**: https://apify.com/babak/nsfw-image-detector.md
- **Developed by:** [V Hzrok](https://apify.com/babak) (community)
- **Categories:** Automation, AI, Developer tools
- **Stats:** 30 total users, 0 monthly users, 100.0% runs succeeded, 3 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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

### **What can NSFW Image Detector do?**

This NSFW detector analyzes **JPEG**, **PNG**, **BMP**, and **GIF** images and categorizes them based on the following criteria:

- **🎨 Drawing:** Harmless art, safe for kids
- **🐙 Hentai:** Pornographic 18+ art, unsuitable for most work environments
- **😐 Neutral:** General inoffensive content
- **🍑 Porn:** Indecent 18+ content and actions, often involving genitalia
- **😏 Sexy:** Provocative content, may include nipples

Fast **~250ms per single image** and easy nude content classification comes with a pretty accurate **~93%** probability!

\**To start scrapping, please use at least one URL field*

### Results

You'll get a dataset containing the output of this actor. The length of the dataset will depend on the amount of results you've set/got. You can download those results as an *Excel, HTML, XML, JSON,* and *CSV* document or you can just use [Apify API](https://apify.com/babak/nsfw-image-detector/api) to get the data.

```json
{
    "image": "https://apify-image-uploads-prod.s3.amazonaws.com/Nbvb2ZAX96yhhtJQy/EQ2R5dkeB3Kizko6x-IMG_6685.png",
    "status": true,
    "resultType": "Neutral",
    "neutral": 0.99,
    "drawing": 0.01,
    "hentai": 0,
    "porn": 0,
    "sexy": 0
}, {
    "image": "https://xxx.gif",
    "status": true,
    "resultType": "Porn",
    "neutral": 0.1,
    "drawing": 0,
    "hentai": 0.01,
    "porn": 0.79,
    "sexy": 0.1
}
```

### Why would I use NSFW Image Detector?

**Content Moderation:** NSFW image detector APIs are crucial for content moderation on platforms that allow user-generated content. By automatically identifying and flagging explicit or inappropriate JPEG, PNG, BMP, and GIF images, this nsfw detection API help maintain a safe and suitable environment for all users. It enables platforms to proactively filter out potentially offensive, unsuitable, or harmful content.

**Compliance with Regulations and Policies:** Many jurisdictions and online platforms have strict policies and regulations regarding the display and distribution of explicit or adult content. NSFW image detector assists platforms in adhering to these guidelines by automatically preventing the dissemination of inappropriate images, ensuring compliance, and avoiding legal or reputational issues.

**Enhanced User Experience:** Implementing this API enhances the overall user experience on platforms that involve sharing or browsing visual content. By filtering out explicit or NSFW images, platforms can provide users with a more pleasant and appropriate browsing experience, increasing the likelihood of user engagement and longer platform usage.

**Data Quality and Relevance:** Scrapers are commonly used to gather information from various sources, including images. However, when scraping data, there's a risk of inadvertently collecting explicit or NSFW images that may not be suitable for the intended purpose or audience. By utilizing an NSFW image detector API, you can filter out inappropriate images during the scraping process, ensuring that the collected data maintains a high level of quality, relevance, and appropriateness.

### Integrations and NSFW Image Detector

NSFW Image Detector can be connected with almost any cloud service or web app thanks to integrations on the Apify platform. Integrate with Make, Zapier, Slack, Airbyte, GitHub, Google Sheets, Google Drive, and more. Or you can use webhooks to carry out an action whenever an event occurs, e.g. get a notification whenever Content Checker successfully finishes a run.

### Using NSFW Image Detector with the Apify API

The Apify API gives you programmatic access to the Apify platform. The API is organized around RESTful HTTP endpoints that enable you to manage, schedule, and run Apify actors. The API also lets you access any datasets, monitor actor performance, fetch results, create and update versions, and more. To access the API using Node.js, use the apify-client NPM package. To access the API using Python, use the apify-client PyPI package.Check out the Apify API reference docs for full details or click on the [API tab](https://apify.com/babak/nsfw-image-detector/api) for code examples.

### Your feedback

We’re always working on improving the performance of our Actors. So if you’ve got any technical feedback for xxx or simply found a bug, please create an issue on the Actor’s [Issues tab](https://console.apify.com/actors/6Hc9xfeuxPgdc6ngL/issues) in Apify Console.

# Actor input Schema

## `imgUrl` (type: `string`):

Image url which you want to check

## `directLinks` (type: `array`):

Direct imageURLs array.

## `directLinksFile` (type: `array`):

Image URLs

## Actor input object example

```json
{
  "imgUrl": "https://apify-image-uploads-prod.s3.amazonaws.com/Nbvb2ZAX96yhhtJQy/EQ2R5dkeB3Kizko6x-IMG_6685.png",
  "directLinks": [],
  "directLinksFile": []
}
```

# 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 = {
    "imgUrl": "https://apify-image-uploads-prod.s3.amazonaws.com/Nbvb2ZAX96yhhtJQy/EQ2R5dkeB3Kizko6x-IMG_6685.png",
    "directLinks": [],
    "directLinksFile": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("babak/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 = {
    "imgUrl": "https://apify-image-uploads-prod.s3.amazonaws.com/Nbvb2ZAX96yhhtJQy/EQ2R5dkeB3Kizko6x-IMG_6685.png",
    "directLinks": [],
    "directLinksFile": [],
}

# Run the Actor and wait for it to finish
run = client.actor("babak/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 '{
  "imgUrl": "https://apify-image-uploads-prod.s3.amazonaws.com/Nbvb2ZAX96yhhtJQy/EQ2R5dkeB3Kizko6x-IMG_6685.png",
  "directLinks": [],
  "directLinksFile": []
}' |
apify call babak/nsfw-image-detector --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,babak/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/6Hc9xfeuxPgdc6ngL/builds/MP9IkNLA9tMtq0x4E/openapi.json
