d00ml0rdz/nsfwspy

NsfwSpy is a nudity/pornography image and video classifier built for

NET model has been trained against the ResNet V250 neural net architecture with 537,000 images (186GB), from 4 different categories:

NsfwSpy is a nudity/pornography image and video classifier built for

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

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

.NET CLI

Classify an Image File

Classify a Web Image

Classify an Image from a Byte Array

Classify Multiple Image Files

Classify a Gif File

Classify a Web Gif

Classify a Video File

Classify a Web Video

Dependency Injection

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:

Ubuntu

Install FFmpeg on Ubuntu using the following command:

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

.NET CLI

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 [email protected] 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.

Issues

Quick list of the latest Issues we found

justinphamnz

justinphamnz

Icon For Comments7

Thanks for a great work. I just tried to add this package to my test C# API and failed to run it on MacOS Monterey.

After successfully adding to our project, when the code hit NSFW Spy, it exits immediately without any error. Any tips would be appreciated.

  • Installed SciSharp.TensorFlow.Redist
  • Injected dependency
  • Environment: .NET SDK Version: 6.0.105 Commit: 1c35735293

Runtime Environment: OS Name: Mac OS X OS Version: 12.4 OS Platform: Darwin RID: osx.12-x64 Base Path: /usr/local/share/dotnet/x64/sdk/6.0.105/

Host (useful for support): Version: 6.0.5 Commit: 70ae3df4a6

.NET SDKs installed: 3.1.419 [/usr/local/share/dotnet/x64/sdk] 5.0.408 [/usr/local/share/dotnet/x64/sdk] 6.0.105 [/usr/local/share/dotnet/x64/sdk]

Versions

Quick list of the latest released versions

v3.4.3 - May 28, 2022

  • Update the version of the Mime package to 3.4.0 to fix getting the "Could not find any valid magic files!" error on Linux.

v3.4.2 - May 18, 2022

  • Fix an issue when classifying videos where the frames wouldn't render correctly.

v3.4.1 - May 17, 2022

  • Added missing ClassifyGif method to INsfwSpy.

v3.4.0 - May 03, 2022

  • Convert .webp files to .png before classifying.

v3.3.1 - May 03, 2022

  • Throw ClassificationFailedException if the image failed to classify.
  • Fix an issue when classifying gifs where the frames wouldn't render correctly.

v3.3.0 - Apr 25, 2022

  • Improvements to all NSFW classification types.

v3.2.0 - Apr 15, 2022

  • Reduced the risk of neutral images being classified as hentai.

v3.1.0 - Dec 24, 2021

  • Improved hentai classification.

v3.0.1 - Dec 14, 2021

  • Fixed ClassifyVideo methods for Linux and Mac.

v3.0.0 - Dec 08, 2021

  • Added video classification support. This requires FFmpeg to be installed alongside NsfwSpy.
  • Renamed GifOptions to VideoOptions.
  • Renamed NsfwSpyGifResult to NsfwSpyFramesResult.

v2.5.0 - Nov 03, 2021

  • Updated model

v2.4.0 - Oct 09, 2021

  • Improved NsfwSpy model.

v2.3.0 - Oct 06, 2021

  • ClassifyGifAsync methods.
  • ClassifyGif using a byte array.

v2.2.0 - Oct 06, 2021

  • Use Magick.NET to handle Gif frames.
  • Classify Gif frames in parallel.
  • Remove the need for libgdiplus on macOS and Linux.

v2.1.0 - Sep 24, 2021

  • ClassifyImages now works in parallel

v2.0.0 - Sep 23, 2021

  • Removed the 'Drawing' classification as it was felt it was unnecessary. Drawings will now be classified as neutral if they are not sexual in nature.

v1.2.0 - Sep 19, 2021

  • Classify Gif Images.
  • Include INsfwSpy interface for dependency injection.

v1.1.1 - Sep 19, 2021

  • Remove parallel processing of ClassifyImages due to thread safety

v1.1.0 - Sep 18, 2021

  • Updated model with improved performance

v1.0.11 - Sep 17, 2021

  • Included SciSharp.TensorFlow.Redist-Linux-GPU to support Linux installs.
  • Change Nuget icon to a .png to fix it not displaying in Visual Studio.

v1.0.8 - Sep 16, 2021

Initial stable release

Library Stats (Sep 14, 2022)

Subscribers: 2
Stars: 146
Forks: 7
Issues: 1

dotnet-sshdeploy

here, otherwise you are in the right place

dotnet-sshdeploy

SharpeningCobaltStrike

In realtime compiling of dotnet v35/v40 exe/dll binaries + obfuscation with ConfuserEx on your linux cobalt strike server

SharpeningCobaltStrike

Dotnet client for Tarantool NoSql database

Some methods are not implemented yet because there are no direct analogs in IProto

Dotnet client for Tarantool NoSql database

dotnet-coverageconverter

coverage (binary format) files to

dotnet-coverageconverter

dotnet-stellar-sdk Stellar API SDK for

Report Bug · Report Security Vulnerability

dotnet-stellar-sdk Stellar API SDK for

dotnet-jwk is a JSON Web Key manager for dotnet

It allow to generate, encrypt, decrypt, convert and check JWK

dotnet-jwk is a JSON Web Key manager for dotnet

dotnet add package Brighid

Protecting the Client Secret

dotnet add package Brighid

dotnet-real-time-chat

A real time chat using C# dotnet and RabbitMQ

dotnet-real-time-chat

Run command line tools inside CSharp

Example running some dotnet CLI commands:

Run command line tools inside CSharp

Run command line tools inside CSharp

Example running some dotnet CLI commands:

Run command line tools inside CSharp
dotnet tool install --global dotnet-extract