NsfwSpy 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package NsfwSpy --version 1.0.1
NuGet\Install-Package NsfwSpy -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NsfwSpy" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NsfwSpy --version 1.0.1
#r "nuget: NsfwSpy, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. 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=1.0.1

// Install NsfwSpy as a Cake Tool
#tool nuget:?package=NsfwSpy&version=1.0.1

<img src="https://raw.githubusercontent.com/d00ML0rDz/NsfwSpy/main/NsfwSpy-Logo.jpg" alt="NsfwSpy Logo" width="400"/>

Introduction

NsfwSpy is a nudity/pornography image classifier built for .NET 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 over 360,000 images, from 5 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 nudity and sexual acts.
Neutral Images that are not sexual in nature.
Drawing Drawings or animations that are not sexual in nature.

Performance

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.

a Pornography Sexy Hentai Neutral Drawing
IsNsfw <sub><sup>(pornography + sexy + hentai >= 0.5)</sup></sub> 96.4% 96.7% 95.7% 2.3% 2.5%
Correctly Predicted Label 86.8% 82.8% 87.1% 97.6% 89.6%

Quick Start

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

Package Manager

Install-Package NsfwSpy

.NET CLI

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 Multiple Image Files

var files = Directory.GetFiles(@"C:\Users\username\Pictures")
var nsfwSpy = new NsfwSpy();
nsfwSpy.ClassifyImages(files, (filePath, result) =>
{
    Console.WriteLine($"{filePath} - {result.PredictedLabel}");
});
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NsfwSpy:

Package Downloads
Frank.SemanticKernel.Extensions.NsfwSpyDotNet

NSFW detection 'filter' for Semantic Kernel

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.5.0 37,049 11/5/2022
3.4.3 7,391 5/28/2022
3.4.2 5,953 5/18/2022
3.4.1 5,091 5/17/2022
3.4.0 6,673 5/3/2022
3.3.1 5,406 5/3/2022
3.3.0 5,673 4/25/2022
3.2.0 5,458 4/15/2022
3.1.0 4,993 12/24/2021
3.0.1 4,304 12/14/2021
3.0.0 4,293 12/8/2021
2.5.0 4,191 11/3/2021
2.4.0 4,484 10/9/2021
2.3.0 4,274 10/6/2021
2.2.0 3,969 10/6/2021
2.2.0-beta.1 291 10/6/2021
2.2.0-alpha 4,003 10/6/2021
2.1.0 4,147 9/24/2021
2.0.0 4,049 9/23/2021
1.2.0 4,315 9/19/2021
1.1.1 4,091 9/19/2021
1.1.0 4,149 9/18/2021
1.0.11 4,278 9/17/2021
1.0.10 3,945 9/17/2021
1.0.9 4,324 9/17/2021
1.0.8 4,347 9/16/2021
1.0.7 4,189 9/16/2021
1.0.6 2,554 9/16/2021
1.0.5 2,674 9/16/2021
1.0.4 2,510 9/16/2021
1.0.3 4,274 9/16/2021
1.0.2 893 9/16/2021
1.0.1 971 9/16/2021
1.0.0 852 9/16/2021