This release is a pre-release and may not be stable for production use.

Guard Local Detector
A local detection engine for the Guard Python client, integrating visual safety filters into your applications
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
Recommended Way
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
Using the Unified Client (Recommended)
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
# Violence: 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
-
Clone the repository:
git clone https://github.com/elhio/guard-local-python.git cd guard-local-python
-
Sync the environment:
uv syncThis command automatically creates a
.venvvirtual environment, reads theuv.lockfile, and installs all core and development dependencies exactly as they were locked. -
Run tests:
uv run pytest
-
Formatting, linting, and type checking:
uv run ruff format uv run ruff check uv run mypy
-
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file guard_local_detector-0.0.1rc1.tar.gz.
File metadata
- Download URL: guard_local_detector-0.0.1rc1.tar.gz
- Upload date:
- Size: 7.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c86ad37bb465f3fe4879e4bcb64491801635190acae7d51992b72d45d793bd13
|
|
| MD5 |
b927e3da9eb87583132f03d82d8e5d5c
|
|
| BLAKE2b-256 |
4610dae7957e0746e10528180eb1797cd5ce7f526c769173e4d3666a41718faa
|
Provenance
The following attestation bundles were made for guard_local_detector-0.0.1rc1.tar.gz:
Publisher:
release.yml on elhio/guard-local-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
guard_local_detector-0.0.1rc1.tar.gz -
Subject digest:
c86ad37bb465f3fe4879e4bcb64491801635190acae7d51992b72d45d793bd13 - Sigstore transparency entry: 2365915071
- Sigstore integration time:
-
Permalink:
elhio/guard-local-python@c78e242aafa8aa0fd70919c37059fa133b34b2d9 -
Branch / Tag:
refs/tags/v0.0.1rc1 - Owner: https://github.com/elhio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c78e242aafa8aa0fd70919c37059fa133b34b2d9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file guard_local_detector-0.0.1rc1-py3-none-any.whl.
File metadata
- Download URL: guard_local_detector-0.0.1rc1-py3-none-any.whl
- Upload date:
- Size: 7.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73563da3e65dd565df93879d9d62c9bc01e314e2ff0a00443aa44afe8d056e66
|
|
| MD5 |
5e1bdfde31da27d5d63dbebafb686a99
|
|
| BLAKE2b-256 |
83a5bc1be169daa196dca8c983a9de100ac5d91234b02483f394dc9e79d3f47e
|
Provenance
The following attestation bundles were made for guard_local_detector-0.0.1rc1-py3-none-any.whl:
Publisher:
release.yml on elhio/guard-local-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
guard_local_detector-0.0.1rc1-py3-none-any.whl -
Subject digest:
73563da3e65dd565df93879d9d62c9bc01e314e2ff0a00443aa44afe8d056e66 - Sigstore transparency entry: 2365915190
- Sigstore integration time:
-
Permalink:
elhio/guard-local-python@c78e242aafa8aa0fd70919c37059fa133b34b2d9 -
Branch / Tag:
refs/tags/v0.0.1rc1 - Owner: https://github.com/elhio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c78e242aafa8aa0fd70919c37059fa133b34b2d9 -
Trigger Event:
release
-
Statement type: