NsfwSpy 2.5.0

Install-Package NsfwSpy -Version 2.5.0
dotnet add package NsfwSpy --version 2.5.0
<PackageReference Include="NsfwSpy" Version="2.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NsfwSpy --version 2.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NsfwSpy, 2.5.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install NsfwSpy as a Cake Addin
#addin nuget:?package=NsfwSpy&version=2.5.0

// Install NsfwSpy as a Cake Tool
#tool nuget:?package=NsfwSpy&version=2.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.


NsfwSpy is a nudity/pornography image classifier built for .NET Core 2.0 and later, with support for Windows, macOS and Linux, to aid in moderating user-generated content for various different application types, written in C#. The ML.NET model has been trained against the ResNet V250 neural net architecture with 440,000 images (116GB), from 4 different categories:

Label Description
Pornography Images that depict sexual acts and nudity.
Sexy Images of people in their underwear and men who are topless.
Hentai Drawings or animations of sexual acts and nudity.
Neutral Images that are not sexual in nature.


NsfwSpy isn't perfect, but the accuracy should be good enough to detect approximately 96% of Nsfw images, those being images that are classed as pornography, sexy or hentai.

Pornography Sexy Hentai Neutral
Is Nsfw (pornography + sexy + hentai >= 0.5) 96.4% 96.9% 95.0% 2.9%
Correctly Predicted Label 87.2% 82.1% 87.2% 97.4%

Quick Start

This project is available as a NuGet package and can be installed with the following commands:

Package Manager

Install-Package NsfwSpy


dotnet add package NsfwSpy

Classify an Image File

var nsfwSpy = new NsfwSpy();
var result = nsfwSpy.ClassifyImage(@"C:\Users\username\Documents\flower.jpg");

Classify a Web Image

var uri = new Uri("https://raw.githubusercontent.com/d00ML0rDz/NsfwSpy/main/NsfwSpy.Test/Assets/flower.jpg");
var nsfwSpy = new NsfwSpy();
var result = nsfwSpy.ClassifyImage(uri);

Classify an Image from a Byte Array

var fileBytes = File.ReadAllBytes(filePath);
var nsfwSpy = new NsfwSpy();
var result = nsfwSpy.ClassifyImage(fileBytes);

Classify Multiple Image Files

var files = Directory.GetFiles(@"C:\Users\username\Pictures");
var nsfwSpy = new NsfwSpy();
var results = nsfwSpy.ClassifyImages(files, (filePath, result) =>
    Console.WriteLine($"{filePath} - {result.PredictedLabel}");

Classify a Gif File

var nsfwSpy = new NsfwSpy();
var result = nsfwSpy.ClassifyGif(@"C:\Users\username\Documents\happy.gif");

Classify a Web Gif

var uri = new Uri("https://raw.githubusercontent.com/d00ML0rDz/NsfwSpy/main/NsfwSpy.Test/Assets/cool.gif");
var nsfwSpy = new NsfwSpy();
var result = nsfwSpy.ClassifyGif(uri);

Dependency Injection

services.AddScoped<INsfwSpy, NsfwSpy>();

GPU Support

To get GPU support working, please follow the prerequisite steps here to install CUDA v10.1 and CUDNN v7.6.4. Later versions do not work (as I tried with CUDA v11.4). The SciSharp.TensorFlow.Redist-Windows-GPU and SciSharp.TensorFlow.Redist-Linux-GPU packages are already included as part of the NsfwSpy package.

macOS Support

To get NsfwSpy working on macOS, the SciSharp.TensorFlow.Redist v2.3.1 NuGet package also needs to be installed. This not included by default as it interfers with supporting GPUs on Windows and Linux. You can do this with either of the following commands:

Package Manager

Install-Package SciSharp.TensorFlow.Redist -Version 2.3.1


dotnet add package SciSharp.TensorFlow.Redist --version 2.3.1


Using NsfwSpy? Let us know! We're keen to hear how the technology is being used and improving the safety of applications.

Got an issue or found something not quite right? Report it here on GitHub and we'll try to help as best as possible.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.5.0 167 11/3/2021
2.4.0 131 10/9/2021
2.3.0 128 10/6/2021
2.2.0 143 10/6/2021
2.2.0-beta.1 39 10/6/2021
2.2.0-alpha 82 10/6/2021
2.1.0 220 9/24/2021
2.0.0 105 9/23/2021
1.2.0 137 9/19/2021
1.1.1 139 9/19/2021
1.1.0 167 9/18/2021
1.0.11 123 9/17/2021
1.0.10 107 9/17/2021
1.0.9 123 9/17/2021
1.0.8 123 9/16/2021
1.0.7 117 9/16/2021
1.0.6 161 9/16/2021
1.0.5 169 9/16/2021
1.0.4 138 9/16/2021
1.0.3 131 9/16/2021
1.0.2 142 9/16/2021
1.0.1 167 9/16/2021
1.0.0 144 9/16/2021