Skip to content

Repository files navigation

mfm

Moderation of NSFW media files via AI.

Installation

ONNX Runtime

The project uses ONNX Runtime for ML model inference. Install the ONNX Runtime shared library:

  • macOS:
brew install onnxruntime

Model

Download ONNX NSFW detection models and configure their paths in .env file. The service requires environment variables to be set:

  • MODEL_OPEN - absolute path to OpenNSFW2 model
  • MODEL_VIT - absolute path to ViT model

Models should accept input shape [batch_size, 224, 224, 3] (float32, normalized 0-1) and output shape [batch_size, 1] (float32, probability of NSFW) for OpenNSFW2 or [batch_size, 2] for ViT (probability pair: normal, nsfw).

If environment variables are not set, the service will panic with an error message.

See details on model conversion: doc/models/<model>.md

ffmpeg

  • macOS:
brew install ffmpeg

Other Dependencies

make

Environment Variables

Copy the .env.example file to .env and configure the environment variables:

cp .env.example .env

Test content

Create assets/[1..7].png and assets/video[1..2].mp4

About

Media files moderation via AI

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages