Skip to main content

openmoderate

CI PyPI Python Docs Docker License

Open-source, self-hosted image and video content moderation for Python. Detect nudity, sexual content, violence, gore, weapons, hate symbols, drugs, self-harm, alcohol and tobacco in uploaded images and videos — with one pip install, no cloud account, no per-image fees, and no ML experience needed.

Think of it as an open alternative to Amazon Rekognition's DetectModerationLabels that runs inside your own app.

Terminal demo: openmoderate scans a folder, flagging a pistol (weapons 100%), a riot (violence 99%) and a swastika (hate_symbols 100%) while a beach, a dog and a US flag pass as safe; then the REST server flags a cigarette photo as tobacco (0.96).

from openmoderate import Moderator

mod = Moderator()
result = mod.analyze("upload.jpg")

if not result.is_safe:
    print(result.violations)
    # [Label(name='weapons', confidence=0.9612, parent='violence', threshold=0.5)]

How openmoderate works: upload, normalize, embed with CLIP, compare against category and safe prompts, score, and decide with your thresholds. Use it as a Python library, a CLI or a REST API. Detects 11 categories out of the box, plus your own.

Documentation · Benchmarks · Changelog · Security

Install

pip install openmoderate

Python 3.9+. The first call downloads the CLIP model weights (~600 MB) once; after that everything runs offline, on CPU, CUDA or Apple Silicon. Extras: openmoderate[server], [video], [fastapi], [flask], [django]. See the install notes for CPU-only servers.

What you can do with it

Pick the accuracy you need — Moderator(preset="accurate") uses a larger model: 82% recall with 4% of safe images flagged, versus 77% / 6.5% for the default (benchmarks).

Tune the policy — thresholds, categories and your own categories as plain text, no training data needed (guide):

mod = Moderator(thresholds={"weapons": 0.3}, exclude=["alcohol", "tobacco"])
mod = Moderator("policy.yaml")   # custom categories like "gambling" in YAML

Scan from the command line — folders, URLs and videos; --fail-on-violation for CI (guide):

openmoderate scan ./uploads

Train on your own images for better accuracy in your domain (guide):

openmoderate train ./dataset -o my_head.omh      # dataset/<label>/*.jpg + dataset/safe/

Moderate videos with timestamped segments (guide):

Moderator().analyze_video("clip.mp4").segments   # weapons 0:03–0:06, violence 0:09–0:12

Protect uploads in FastAPI, Flask or Django with one line (guide):

async def avatar(file: ModeratedFile): ...                          # FastAPI
avatar = models.ImageField(validators=[ModerationValidator()])      # Django

Call it over HTTP from any language — REST server and Docker image (guide):

docker run -p 8000:8000 -e OPENMODERATE_API_KEY=change-me ghcr.io/karammm/openmoderate
curl -H "X-API-Key: change-me" -F file=@upload.jpg localhost:8000/v1/moderate

Accuracy

Measured on a held-out set of hand-reviewed, openly licensed photos (full results and method, reproducible with python benchmark/run.py):

Category Recall Precision
drugs 85% 82%
alcohol 84% 100%
violence 82% 100%
weapons 79% 100%
hate_symbols 61% 100%
tobacco 59% 89%

6% of safe images (including look-alikes such as kitchen knives, milk and medicine) were flagged. The accurate preset raises average recall to 82% while flagging 4%. Sets are small, so read these as ±10 points. Nudity, sexual content, gore and self-harm are not benchmarked by the maintainers — evaluate them on your own data.

Zero-shot moderation is good at clear-cut cases and will miss subtle ones. Evaluate on a sample of your own traffic, adjust thresholds, and send borderline scores to human review for high-stakes decisions. How it works and its limits.

Contributing

Contributions are welcome — better prompts, new categories, benchmark images and bug reports especially. See CONTRIBUTING.md. Report security issues privately (SECURITY.md).

Responsible use

openmoderate is meant to help keep platforms safe. Do not use it to surveil individuals or to profile people by protected characteristics. Moderation models make mistakes; give users a way to appeal automated decisions.

License

Apache 2.0. Benchmark images keep their own licences (see benchmark/manifest.csv).

Metadata

Release files for openmoderate 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openmoderate 1.1.0
File Size Uploaded
openmoderate-1.1.0.tar.gz 424.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openmoderate 1.1.0
File Interpreter ABI Platform
openmoderate-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 476.4 kB

Release files / openmoderate-1.1.0.tar.gz

Download URL openmoderate-1.1.0.tar.gz
Size 424.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6b29a14009541d72dc292e76af6e8ca4a180c88bf6d4481d97a8a3da55b9996e
BLAKE2b-256 checksum
How to use checksums
43eec846b29267973bc94dbf29caa7061940625079779dc5fdabf2362624c32e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / openmoderate-1.1.0-py3-none-any.whl

Download URL openmoderate-1.1.0-py3-none-any.whl
Size 51.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
653c8889c82cd74c5c76fe43889088f7d964d951733d9217c5dea1e27d84c8de
BLAKE2b-256 checksum
How to use checksums
056d91a961b2e5121169b381ba74c0316ace8bfc20b94137a8eb097cd2953ced
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.2

2 release files

1.1.1

2 release files

This release

1.1.0 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page