NsfwSpy 3.5.0
dotnet add package NsfwSpy --version 3.5.0
NuGet\Install-Package NsfwSpy -Version 3.5.0
<PackageReference Include="NsfwSpy" Version="3.5.0" />
paket add NsfwSpy --version 3.5.0
#r "nuget: NsfwSpy, 3.5.0"
// Install NsfwSpy as a Cake Addin #addin nuget:?package=NsfwSpy&version=3.5.0 // Install NsfwSpy as a Cake Tool #tool nuget:?package=NsfwSpy&version=3.5.0
Introduction
NsfwSpy is a nudity/pornography image and video 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 537,000 images (186GB), from 4 different categories:
Label | Description | Files |
---|---|---|
Pornography | Images that depict sexual acts and nudity. | 108,000 |
Sexy | Images of people in their underwear and men who are topless. | 76,000 |
Hentai | Drawings or animations of sexual acts and nudity. | 83,000 |
Neutral | Images that are not sexual in nature. | 268,000 |
Other Projects
Looking for a JavaScript version of NsfwSpy? We have you covered - NsfwSpy.js 😎
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.
Pornography | Sexy | Hentai | Neutral | |
---|---|---|---|---|
Is Nsfw (pornography + sexy + hentai >= 0.5) | 96.5% | 97.2% | 95.1% | 3.7% |
Correctly Predicted Label | 86.0% | 83.2% | 91.8% | 96.8% |
Quick Start
Looking to quickly try out NsfwSpy? Check out our steps to use NsfwSpy.App.
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 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);
Classify a Video File
var nsfwSpy = new NsfwSpy();
var result = nsfwSpy.ClassifyVideo(@"C:\Users\username\Documents\happy.mp4");
Classify a Web Video
var uri = new Uri("https://raw.githubusercontent.com/d00ML0rDz/NsfwSpy/main/NsfwSpy.Test/Assets/bikini.mp4");
var nsfwSpy = new NsfwSpy();
var result = nsfwSpy.ClassifyVideo(uri);
Dependency Injection
services.AddScoped<INsfwSpy, NsfwSpy>();
Classify Video Support
To be able to make use of the ClassifyVideo methods, FFmpeg needs to be installed and available in the command line via the 'ffmpeg' command.
Windows
Follow this guide to download FFmpeg, extract it to your C:\ drive and add the required environment path variable.
macOS
Install FFmpeg on macOS using Homebrew via the following command:
brew install ffmpeg
Ubuntu
Install FFmpeg on Ubuntu using the following command:
sudo apt install ffmpeg
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
.NET CLI
dotnet add package SciSharp.TensorFlow.Redist --version 2.3.1
Please note that Macs that use M1 chips currently do not support TensorFlow with ML.NET and cannot make use of NsfwSpy.
Contact Us
Interested to get involved in the project? Whether you fancy adding features, providing images to train NsfwSpy with or something else, feel free to contact us via email at nsfwspy@outlook.com or find us on Twitter at @nsfw_spy.
Notes
Using NsfwSpy? Let us know! We're keen to hear how the technology is being used and improving the safety of applications.
Got a feature request or found something not quite right? Report it here on GitHub and we'll try to help as best as possible.
Product | Versions 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. |
-
.NETCoreApp 2.0
- Magick.NET-Q16-AnyCPU (>= 11.1.2)
- Microsoft.ML (>= 1.6.0)
- Microsoft.ML.Vision (>= 1.6.0)
- Mime (>= 3.4.0)
- SciSharp.TensorFlow.Redist-Linux-GPU (>= 2.3.1)
- SciSharp.TensorFlow.Redist-Windows-GPU (>= 2.3.1)
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 (1)
Showing the top 1 popular GitHub repositories that depend on NsfwSpy:
Repository | Stars |
---|---|
Redns/North
一个易于搭建的图床服务
|
Version | Downloads | Last updated | |
---|---|---|---|
3.5.0 | 62,147 | 11/5/2022 | |
3.4.3 | 7,906 | 5/28/2022 | |
3.4.2 | 6,348 | 5/18/2022 | |
3.4.1 | 5,525 | 5/17/2022 | |
3.4.0 | 7,152 | 5/3/2022 | |
3.3.1 | 5,817 | 5/3/2022 | |
3.3.0 | 6,185 | 4/25/2022 | |
3.2.0 | 5,941 | 4/15/2022 | |
3.1.0 | 5,403 | 12/24/2021 | |
3.0.1 | 4,579 | 12/14/2021 | |
3.0.0 | 4,724 | 12/8/2021 | |
2.5.0 | 4,562 | 11/3/2021 | |
2.4.0 | 5,086 | 10/9/2021 | |
2.3.0 | 4,691 | 10/6/2021 | |
2.2.0 | 4,688 | 10/6/2021 | |
2.2.0-beta.1 | 331 | 10/6/2021 | |
2.2.0-alpha | 4,303 | 10/6/2021 | |
2.1.0 | 4,532 | 9/24/2021 | |
2.0.0 | 4,528 | 9/23/2021 | |
1.2.0 | 4,640 | 9/19/2021 | |
1.1.1 | 4,501 | 9/19/2021 | |
1.1.0 | 4,479 | 9/18/2021 | |
1.0.11 | 4,622 | 9/17/2021 | |
1.0.10 | 4,386 | 9/17/2021 | |
1.0.9 | 4,665 | 9/17/2021 | |
1.0.8 | 4,802 | 9/16/2021 | |
1.0.7 | 4,543 | 9/16/2021 | |
1.0.6 | 2,762 | 9/16/2021 | |
1.0.5 | 2,862 | 9/16/2021 | |
1.0.4 | 2,775 | 9/16/2021 | |
1.0.3 | 4,690 | 9/16/2021 | |
1.0.2 | 968 | 9/16/2021 | |
1.0.1 | 1,050 | 9/16/2021 | |
1.0.0 | 940 | 9/16/2021 |