GNU General Public License v3.0

项目介绍

Meltedd/scarecrow 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 GNU General Public License v3.0 许可证,目前获得 329 个 Star、23 次 Fork。

仓库全名
Meltedd/scarecrow
开源许可证
GNU General Public License v3.0
Star 数
329
Fork 数
23

README 摘要

scarecrow Adversarial frame pattern optimization for evading ALPR (automated license plate recognition). Given a photo of your plate, scarecrow generates an optimized grayscale frame pattern and can export an SVG frame template for that pattern, aiming to suppress detection while keeping the plate readable to humans. Keeps the flock away. [!WARNING] This project is a research tool for personal privacy against…

完整内容见 GitHub 原始 README 或本页 。

常见问题

scarecrow 用什么语言开发?

主要使用 Python 编写,采用 GNU General Public License v3.0 许可证,目前有 329 个 Star。

scarecrow 可以免费商用吗?

仓库标注的许可证为 GNU General Public License v3.0,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 scarecrow 的源码?

可以直接克隆仓库:git clone https://github.com/Meltedd/scarecrow.git;安装与运行步骤见仓库 README。

scarecrow 最近还在维护吗?

仓库最近一次更新为 6月6日,当前没有未关闭的 Issue;Star 数为 329,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

An adversarial frame pattern optimizer for evading automated license plate recognition, personalized to your plate.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

Python

Release

贡献者

README

scarecrow

PyPI Python 3.11+ License: GPL-3.0

Adversarial frame pattern optimization for evading ALPR (automated license plate recognition). Given a photo of your plate, scarecrow generates an optimized grayscale frame pattern and can export an SVG frame template for that pattern, aiming to suppress detection while keeping the plate readable to humans. Keeps the flock away.

Warning 警告

This project is a research tool for personal privacy against warrantless mass surveillance. It is not intended for evading law enforcement in the commission of a crime. Frame patterns do not obstruct or alter plate text, but laws around devices placed near the plate vary by jurisdiction and are evolving. Please check your local laws before use.

Why

Flock Safety and other ALPR cameras are in thousands of our neighborhoods, parking lots, and police networks across the US. They capture and index every plate that passes, feeding a searchable surveillance database with no warrant, no notification, and in most cases no public oversight.

A system that can track anyone, anywhere, with no transparency or accountability is fundamentally immoral. This project is my way of exploring what can be done about it, ethically and legally.

Inspired by Ben Jordan’s PlateShapez and his investigations into Flock Safety. Where his approach uses random geometric perturbations on the plate, scarecrow uses gradient-based optimization of a frame pattern around it, aiming to be more robust and legally viable since the plate itself is never altered.

Results

On the included test plate, scarecrow drops detection confidence from 0.84 to 0.00 (full evasion) in 1000 steps, and the plate remains human-readable. OCR is sometimes corrupted as a side effect, roughly 40% of the time depending on the random seed.

Before After
before after

How It Works

Scarecrow optimizes a grayscale frame pattern using gradient descent against a YOLO plate detection model. The pattern sits in the border region around the plate, inside a printable frame, and is tuned specifically to minimize the detector’s confidence on your specific plate.

To keep the pattern from overfitting to the reference photo, each optimization step applies random augmentations that simulate what a camera might actually see:

  • Radial lens distortion: barrel/pincushion from real camera optics
  • Rotation & perspective warp: different viewing angles
  • Brightness & contrast shifts: varying lighting and IR illumination
  • Gaussian blur: camera motion and focus
  • Additive noise: sensor noise in low light
  • Scale jitter: different distances from the camera

Flock and most ALPR cameras are rear-facing and mounted at 8 to 12 feet, so the viewing geometry is fairly constrained. The augmentation ranges were chosen with this in mind: rotation stays within 10 degrees, perspective within 20 to 25 degrees, and scale varies from 0.5x to 1.2x to cover plates captured at different distances from the camera.

Optimizing the pattern across this whole range of transformations is called Expectation over Transformation (EoT), and the loss uses logsumexp to upweight the hardest samples, so optimization focuses on the conditions where the pattern is weakest.

The included detection model is a YOLO11n plate detector exported via torch.export. If you’re targeting a different detector, see Using your own detection model below.

Installation

Scarecrow requires Python 3.11+. It is published on PyPI as scarecrow-alpr, and installs the scarecrow command.

Install the uv package manager before running these commands.

For the simpler (but slower) CPU install:

uv tool install scarecrow-alpr --torch-backend cpu

If you want GPU acceleration:

uv tool install scarecrow-alpr --torch-backend auto

For RapidOCR support, add the ocr extra to either command:

uv tool install "scarecrow-alpr[ocr]" --torch-backend cpu

Usage

Take a photo of your plate from the front, straight on, in even lighting. See test_plate.jpg for an example.

Generate the reusable pattern, then export the printable SVG frame:

scarecrow generate plate.jpg
scarecrow export plate.jpg --pattern plate_pattern.png

By default, these commands create plate_pattern.png and plate_frame.svg, respectively.

Preview the pattern on your reference photo, or check detection results:

scarecrow apply plate.jpg --pattern plate_pattern.png
scarecrow eval plate.jpg --pattern plate_pattern.png

Other useful options:

# Reproducible generation with a fixed seed
scarecrow generate plate.jpg --seed 42

# Choose the SVG output path
scarecrow export plate.jpg --pattern plate_pattern.png -o my_frame.svg

# Evaluate RapidOCR reads (requires the ocr extra)
scarecrow eval plate.jpg --pattern plate_pattern.png --ocr

# Emit structured eval results
scarecrow eval plate.jpg --pattern plate_pattern.png --json

Development

For local development from a checkout, use uv sync and run the CLI through uv run:

uv sync
uv run scarecrow generate test_plate.jpg --steps 10

Add RapidOCR support with:

uv sync --extra ocr

Using your own detection model

Warning 警告

torch.export.load uses pickle, so loading an untrusted .pt2 can execute arbitrary code. Only use --weights from sources you trust.

Convert ultralytics weights

Scarecrow works with any plate detection model, not just the included YOLO11n. The model needs to be in torch.export format (.pt2).

If you have ultralytics .pt weights, you can convert them like this:

uv run --with ultralytics python3 -c "
import torch; from ultralytics import YOLO
m = YOLO('your-model.pt').model.eval()
for p in m.parameters(): p.requires_grad_(False)
ep = torch.export.export(m, (torch.randn(1, 3, 640, 640),))
torch.export.save(ep, 'your-model.pt2')
"

Then pass --weights your-model.pt2 to any scarecrow command.

Limitations

  • I haven’t tested this against a real ALPR camera, only in simulation against rendered composites. If you have access to Flock or other ALPR hardware and can benchmark, I’d love to hear how it performs.
  • The included model is a single YOLO11n plate detector, and adversarial patterns can transfer across similar architectures, but how well they transfer to other detectors (including Flock Safety’s proprietary YOLO variant) is untested.

License

Scarecrow’s code is licensed under GPL-3.0, while the bundled detector model is licensed under AGPL-3.0. See THIRD_PARTY_NOTICES.md for the model source.

评论

暂无评论