Skip to main content

Graffiti Detection AI Model

Graffiti Detection AI logo

CI PyPI version Supported Python versions MIT License

YOLOv8-based graffiti detection for Python applications, model training, batch inference, camera monitoring, alerts, and API integration.

Why I Built It

I built this project because I hate seeing my city being destroyed and ruined by graffiti. It is intended to help maintenance and response teams detect incidents earlier and act faster.

What Makes It Useful

  • A small Python API for image inference
  • End-to-end scripts for dataset preparation, training, evaluation, and video inference
  • Multi-camera monitoring with email, SMS, webhook, Discord, Slack, and OneSignal alerts
  • FastAPI and Docker deployment options
  • Private, offline Core ML inference on iPhone and iPad
  • Street-scene augmentation for poor lighting, weather, perspective, and CCTV artifacts

Model weights are not bundled. Train a model with this project or provide compatible Ultralytics YOLO weights.

Installation

Python 3.9 or newer is required.

pip install graffiti-detection-ai-model

Install every runtime feature for training, alerts, and the API:

pip install "graffiti-detection-ai-model[all]"

For development from source:

git clone https://github.com/EfficientTools/graffiti-detection-ai-model.git
cd graffiti-detection-ai-model
python -m venv venv
source venv/bin/activate
python -m pip install -e ".[dev]"

Python Usage

from graffiti_detection import GraffitiDetector

detector = GraffitiDetector("models/best.pt", conf_threshold=0.25)
detections = detector.predict("image.jpg")

Each detection contains class_id, class_name, confidence, and an xyxy box.

Command Line

# Prepare a YOLO-format dataset
python scripts/prepare_dataset.py --data-dir data/raw --output-dir data --validate --copy

# Train and evaluate
python scripts/train.py --data configs/dataset.yaml --model yolov8n --epochs 100
python scripts/evaluate.py --model models/best.pt --data configs/dataset.yaml --split test

# Run image, directory, video, or webcam inference
python scripts/inference.py --model models/best.pt --source image.jpg

For camera monitoring, copy the example camera and alert files, insert your own credentials locally, then run:

python scripts/multi_camera_surveillance.py \
  --model models/best.pt \
  --cameras configs/cameras.json \
  --alert-config configs/alerts.json

Start the API with:

MODEL_PATH=models/best.pt uvicorn api.graffiti_detector:app --host 0.0.0.0 --port 8000

See DEPLOYMENT.md for Docker instructions.

iPhone and iPad

The universal SwiftUI app in ios/GraffitiGuard runs a bundled Core ML detector entirely on-device and overlays detected regions. Export your trained weights, then regenerate the Xcode project:

python -m pip install -e ".[apple]"
python scripts/export_coreml.py --weights models/best.pt
xcodegen generate --spec ios/GraffitiGuard/project.yml

See the app README for Xcode and TestFlight instructions.

Development

ruff check .
pytest tests/ -m "not gpu"
python -m build
twine check dist/*

Author

Pierre-Henry Soria

Pierre-Henry Soria

Software AI engineer building practical systems for real-world problems.

Website | GitHub | Bluesky | X | Support

License

Distributed under the MIT License.

Responsible Use

Comply with local privacy, surveillance, and data-retention laws. Human review should remain part of any enforcement or response process.

Metadata

Release files for graffiti-detection-ai-model 1.4.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 graffiti-detection-ai-model 1.4.0
File Size Uploaded
graffiti_detection_ai_model-1.4.0.tar.gz 27.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for graffiti-detection-ai-model 1.4.0
File Interpreter ABI Platform
graffiti_detection_ai_model-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 54.7 kB

Release files / graffiti_detection_ai_model-1.4.0.tar.gz

Download URL graffiti_detection_ai_model-1.4.0.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8d5f0327447b2e7f524302450a78ceaabee399f9be450aaa803c6e87d7da4772
BLAKE2b-256 checksum
How to use checksums
a48805cadf99a00a0462fe081b2c942b5807c003bb6ed4a8a600e73df818229d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Jul 18, 2026.

Transparency log

Release files / graffiti_detection_ai_model-1.4.0-py3-none-any.whl

Download URL graffiti_detection_ai_model-1.4.0-py3-none-any.whl
Size 26.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f911760834f0e68e69d8f04903ee0805e6a0d9e20eed4a6d1664ff0c838480f6
BLAKE2b-256 checksum
How to use checksums
37b826d05af1611e46e25f8efa89a06cf8061f975ceff97dc59126cb2f619c4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Jul 18, 2026.

Transparency log

Release history Release notifications | RSS feed

1.6.0

2 release files

1.5.0

2 release files

This release

1.4.0 This release

2 release files

1.3.0

2 release files

0.1.0

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