Skip to main content

Guard Logo
Guard Local Detector

A local detection engine for the Guard Python client, integrating visual safety filters into your applications

Version License: AGPL v3 PRs Welcome

Features

🛡️ Multi-Layered Content Moderation: Automatically detects AI-generated, violent, and explicit content in images and videos.

⚡ Fast Local Inference: Runs a lightweight computer vision model entirely on-device using ONNX Runtime. It operates with zero network latency and completely avoids pulling in massive deep-learning dependencies like PyTorch.

🏢 Seamless Production Testing: Designed to perfectly mirror the cloud API's data structures. This allows enterprise teams to easily build and test their integration logic locally before routing production traffic to the cloud API.

🧑‍💻 Instant Open-Source Baseline: Provides open-source developers and hobbyists with a free, immediately usable baseline classifier. Get a foundational media safety layer up and running in minutes, not days.

Installation

We highly recommend using this package as an optional extension of the main Guard client. This provides a single, unified API for both cloud and local detection.

pip install guard-client[local]

Standalone Way

pip install guard-local-detector

Quick Start

If you installed via guard-client[local], you do not need to import this package directly. Ask the client for the local engine and it routes every call here — no API key, and no network access.

from guard_client import GuardClient

with GuardClient(engine="local") as client:
    result = client.analyze("/local/paths/to/video.mp4")

    for item in result.results:
        print(f"{item.label}: {item.score}")  # AI-Generated: 71

The results carry the same labels, task ids, and 0-100 scores a cloud run returns, so the same code works against either engine. A cloud-configured client can also send a single call locally with client.analyze(source, engine="local").

Using the Standalone Engine

The engine works on bytes and a MIME type, never a path — reading the source is the caller's job.

import guard_local

engine = guard_local.LocalDetectorEngine()

with open("/local/paths/to/image.png", "rb") as handle:
    results = engine.analyze(handle.read(), "image/png")
    
for item in results:
    print(f"{item['label']}: {item['score']:.2f}")

# AI-Generated: 0.90
# Violent: 0.02
# Explicit: 0.01

Development

This project uses uv for lightning-fast Python package and environment management.

Prerequisites

  • uv (already installed on your system)

Setup

  1. Clone the repository:

    git clone https://github.com/elhio/guard-local-python.git
    cd guard-local-python
    
  2. Sync the environment:

    uv sync
    

    This command automatically creates a .venv virtual environment, reads the uv.lock file, and installs all core and development dependencies exactly as they were locked.

  3. Run tests:

    uv run pytest
    
  4. Formatting, linting, and type checking:

    uv run ruff format
    uv run ruff check
    uv run mypy
    
  5. Build for production:

    uv build
    

Contributing

We welcome contributions! Please note that all contributors must sign our automated CLA. Read more in our Contributing Guide.

License

This repository and its corresponding PyPI package are licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details.

Metadata

Release files for guard-local-detector 0.0.2

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

Source distribution (sdist)

Source distribution for guard-local-detector 0.0.2
File Size Uploaded Provenance Actions
guard_local_detector-0.0.2.tar.gz 7.4 MB With provenance Details for guard_local_detector-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for guard-local-detector 0.0.2
File Interpreter ABI Platform Actions
guard_local_detector-0.0.2-py3-none-any.whl Python 3 none any Details for guard_local_detector-0.0.2-py3-none-any.whl

Total release size: 14.7 MB

Release files / guard_local_detector-0.0.2.tar.gz

Download URL guard_local_detector-0.0.2.tar.gz
Size 7.4 MB
Tags Source
SHA-256 checksum
How to use checksums
8a63c9cc65caf4adc9299f97f866a2ba52e9ca5b69c0a5e1cb716bd64b446c4d
BLAKE2b-256 checksum
How to use checksums
89f189e3411bfa50e596703716a8d17f6e5f0488415a10290e88997cda091efa
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 20, 2026.

Transparency log

Release files / guard_local_detector-0.0.2-py3-none-any.whl

Download URL guard_local_detector-0.0.2-py3-none-any.whl
Size 7.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c63901a877bc83f4f8f8cc00098398741b5a0a88190b6abc9358f81c6604bca1
BLAKE2b-256 checksum
How to use checksums
64f228cd825ead07a341d0c8d9229b4eddf66e19be317e5ed224bad29d065f2e
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 20, 2026.

Transparency log

Security for guard-local-detector 0.0.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for guard_local_detector-0.0.2.tar.gz

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 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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