Profile
Back to NewsBack
GitHub Trending 28 min
Reader Mode
seeARMS/keystone: A free, open-source virtual AI Key and AI Port for UniFi Protect: plain-English search, event descriptions and third-party camera detections with local models.

seeARMS/keystone: A free, open-source virtual AI Key and AI Port for UniFi Protect: plain-English search, event descriptions and third-party camera detections with local models.

15 hours ago

Keystone

A free, virtual AI Key and AI Port for UniFi Protect.

Website · Dashboard demo · Install · Turn on features · Hardware · FAQ

UniFi Protect's best AI features — plain-English search, detailed event descriptions, face and license plate recognition, and smart detections on third-party cameras — normally require Ubiquiti's AI Key ($799) and AI Port ($199 for up to three HD cameras). Keystone is free software that takes their place: run it on a computer you already own, and open models do the same jobs on your own network.

Protect adopts Keystone in UniFi Protect → UniFi Devices as a virtual AI Key (and optionally a virtual AI Port), just like real Ubiquiti hardware. No database hacks, no patched Protect files, and no cloud subscriptions.

Works with both UniFi and third-party cameras. UniFi cameras with smart detections (G4 and newer) get plain-English search and event descriptions, and G4/G5 cameras also get face and license plate recognition. Third-party ONVIF cameras (Reolink, Amcrest, or Nest through Scrypted) and older UniFi cameras without smart detections pair with the optional virtual AI Port to get all of that plus Protect's smart detections.

Unofficial community project; not affiliated with or endorsed by Ubiquiti Inc. No vendor firmware, proprietary binaries, or vendor model weights are included. Tested on UniFi Protect 7.3.74 and 7.4.112.

!UniFi Protect showing Keystone adopted as a virtual AI Key and AI Port

What you get

  • Plain-English & photo search (Find Anything) — on by default
Type "red Tesla today" or "person with a backpack last hour" — or upload a reference photo — right in Protect's native search bar. Works locally on CPU with no extra setup.
  • Event descriptions — needs a vision model (Ollama or API)
Turn vague "Vehicle detected" alerts into sentences like "White sedan driving past on the driveway" or "UPS driver carrying a cardboard box to the front porch." Checks multiple moments in each clip so passing cars aren't called parked, shares recent context across cameras, and supports one-click summaries on any event.
  • Smart detections on third-party cameras (virtual AI Port) — off by default
Pair up to 10 HD ONVIF cameras (Reolink, Amcrest, or Nest via Scrypted) to get native person, vehicle, animal, package, and audio detections, plus custom zones, line crossing, and loitering — all inside Protect.
  • Face recognition & Enhance Face — off by default
Recognize people on G4, G5, and paired third-party cameras directly in Protect's Faces, optionally use household names in captions ("Alex walks up to the front door"), and sharpen blurry face crops with Enhance Face. Unknown people stay unnamed.
  • License plate recognition — off by default
Read plates locally on G4, G5, and paired third-party cameras and file them under Protect's Known Vehicles. Optionally map plates in config.yaml so captions say "Alice's sedan pulls into the driveway."
  • Speech transcripts & smart audio — off by default
Transcribe what was said on audio-capable cameras into Protect's event timeline (speech-to-text, not spoken narration of descriptions). Paired third-party cameras also support all 9 Protect Smart Audio alarms (speech, barking, baby crying, smoke/CO alarms, sirens, burglar/car alarms, car horns, and glass break).
  • Native Protect filters, alarms & Home Assistant
Descriptions automatically map to Protect's built-in tags (tesla, ups, dog, backpack, red, …) so Protect filters and automations work out of the box. Optional webhooks and MQTT send descriptions to Home Assistant or ntfy.

Keystone's local status dashboard: overall health, service cards, paired cameras and the activity feed

Quick start

Pick the install method that matches your setup. Every method sets up both Keystone and the local search database Protect 7.3+ uses for Find Anything.

Docker Compose

On a Linux host with Docker Compose and Python 3 (no repository clone needed):

mkdir keystone && cd keystone
curl -fsSLO https://raw.githubusercontent.com/seeARMS/keystone/main/docker-compose.yml
curl -fsSLO https://raw.githubusercontent.com/seeARMS/keystone/main/scripts/setup-compose.py
python3 setup-compose.py
docker compose up -d

During setup, enter your UniFi Protect controller's IP address. If you want event descriptions, enter your Ollama or AI server URL; press Enter to skip descriptions for now (Find Anything search still works right away).

Updating, shared Docker hosts (OMV / TrueNAS / Synology), and why host networking?

  • Updating: Run docker compose pull && docker compose up -d. If a release updates docker-compose.yml or setup options, re-download docker-compose.yml and setup-compose.py and rerun python3 setup-compose.py first — it keeps your existing settings and database password.
  • Pinning versions or building locally: latest tracks the newest release. Set KEYSTONE_IMAGE_TAG in .env to pin a version (for example KEYSTONE_IMAGE_TAG=0.1.1) or follow main with edge. To build from a cloned checkout instead of pulling from GHCR, run docker compose -f docker-compose.yml -f docker-compose.build.yml up -d --build.
  • Why host networking? Both containers use network_mode: host so Protect can discover Keystone on your LAN and reach the exact ports it expects. PostgreSQL restricts its admin account to 127.0.0.1 and Protect's account strictly to your controller's IP over TLS; Keystone runs as a non-root user with only NET_BIND_SERVICE on python3.
  • Shared Docker hosts (OMV, TrueNAS, Synology, Portainer): Host networking can collide with existing services on ports 443, 5432, 8080, or 10001/udp. Run the all-in-one image (ghcr.io/seearms/keystone-aio) on its own LAN IP with Docker macvlan, set KEYSTONE_CONTROLLER_HOST to Protect's IP, and mount persistent storage at /data. See dedicated-IP deployments.

Proxmox LXC, Debian, or Ubuntu

On a Proxmox host (creates a Debian 13 LXC with 2 cores, 4 GB RAM, and a 16 GB disk):

bash -c "$(curl -fsSL https://raw.githubusercontent.com/seeARMS/keystone/main/scripts/proxmox-lxc.sh)"

Inside an existing Debian 13+ or Ubuntu 24.04+ container or VM (run as root):

bash -c "$(curl -fsSL https://raw.githubusercontent.com/seeARMS/keystone/main/scripts/install.sh)"

Enter your Protect controller's IP and an optional vision server URL (leave it blank to start with Find Anything search only). The first start downloads about 1.6 GB of models.

VLANs, static IPs, and updating Proxmox / Linux installs

  • The Proxmox script uses vmbr0 with DHCP by default. Set KEYSTONE_VLAN, or KEYSTONE_IP and KEYSTONE_GATEWAY, before running it for a VLAN or static IP (other options are listed at the top of scripts/proxmox-lxc.sh). Give the container a fixed address (DHCP reservation or static IP) so Protect keeps finding it.
  • Config lives at /etc/keystone/config.yaml. Apply edits with systemctl restart keystone.
  • To update, run the install.sh one-liner again inside the container or VM — it keeps your config, database, and state.

Unraid

Add the template from the Unraid terminal (until it's in Community Applications):

wget -O /boot/config/plugins/dockerMan/templates-user/my-Keystone.xml \
  https://raw.githubusercontent.com/seeARMS/keystone/main/unraid/keystone.xml

Then go to Docker → Add Container and choose Keystone. Set Network Type to br0 with a fixed IP, enter your Protect controller's IP (and optionally a vision provider/URL for descriptions), and apply. Everything is stored in /mnt/user/appdata/keystone; template fields override the matching settings in config.yaml.

Manual install (Python 3.12+ / systemd without Docker)

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

keystone init --controller 192.0.2.10 --ollama http://192.0.2.20:11434 --model qwen3.5:9b keystone trust -c config.yaml --pin keystone run -c config.yaml

For Find Anything search on Protect 7.3+ without Docker Compose, install PostgreSQL 16+ with pgvector, enable TLS (ssl = on), run docker/init-protect-db.sql, and set device.sync_postgres_password: true in config.yaml.

Status dashboard: Keystone runs a local status page on 127.0.0.1:8088 (no login). On a headless host, tunnel it with ssh -L 8088:127.0.0.1:8088 [email protected] and open http://127.0.0.1:8088 — or set web.bind_host: 0.0.0.0 in config.yaml on a trusted LAN.

After adopting in Protect

Open UniFi Protect → UniFi Devices and adopt the discovered AI Key. Initial credentials are ubnt / ubnt and Protect rotates them automatically on adoption.

What works out of the box: Only Find Anything search is turned on by default. Event descriptions require a vision server (Ollama or an API), and optional features — speech transcripts, faces, license plates, Enhance Face, third-party camera detections, and backfilling older footage — start off in config.yaml so Keystone doesn't unexpectedly download extra models, use extra RAM, or enable biometric/audio features without you opting in.

| Feature | Default | Turn on in config.yaml | Turn on in UniFi Protect | | --- | --- | --- | --- | | Find Anything search | On | Already enabled (embeddings.enabled: true) | Settings → Intelligence → Basic Object Recognition, plus Smart Detections on each camera | | Event descriptions | Needs vision model (off if URL left blank) | Set vision.provider, vision.base_url, and vision.model | Settings → Intelligence → AI Summary | | Speech-to-Text (event transcripts) | Off | stt.enabled: true | Settings → Intelligence → Speech-to-Text, plus Speech audio detection on cameras with a mic | | Face recognition | Off | faces.enabled: true | G4/G5 cameras: Legacy Camera Enhancement → Face Recognition
Paired ONVIF cameras: Face smart detection | | License plates | Off | lpr.enabled: true | G4/G5 cameras: Legacy Camera Enhancement → License Plate Recognition
Paired ONVIF cameras: License Plate smart detection | | Enhance Face | Off | enhance.enabled: true | Enhance button on face crops in Protect | | Third-party cameras (AI Port) | Off | aiport.enabled: true | Adopt AI Port in UniFi Devices, pair ONVIF cameras, enable smart detections | | Backfill older events | Off | embeddings.retroactive_processing: true | Starts automatically once enabled |

After editing config.yaml, restart Keystone (docker compose restart, systemctl restart keystone, or restart the Unraid container). Protect picks up newly enabled features automatically — no re-adoption needed.

Tip: Not seeing descriptions or transcripts? Open the Keystone dashboard (:8088). Every service card shows whether it's Ready, Off / Disabled (with the config key to turn it on), or reporting an error. Note also that Speech-to-Text transcribes spoken audio from camera microphones into text — Keystone does not generate spoken audio narration of descriptions.

Setting up optional features

Event descriptions (Ollama, LM Studio, oMLX, OpenAI, Anthropic)

To turn on event descriptions, point vision in config.yaml at a vision-capable model, then turn on AI Summary under Protect → Settings → Intelligence.

  • Ollama (default provider): keep vision.provider: ollama and set vision.base_url (for example http://192.0.2.20:11434) and vision.model (default qwen3.5:9b, or qwen3.5:4b for smaller GPUs).
  • LM Studio, oMLX, llama.cpp, or vLLM: set provider: openai-compatible, use the server's /v1 base URL, and set model to the exact model ID it serves:
vision:
  provider: openai-compatible
  base_url: http://192.0.2.20:1234/v1
  model: your-vision-model
  # api_key: set-if-required
  • Hosted OpenAI or Anthropic: set provider to openai or anthropic, base_url to https://api.openai.com/v1 or https://api.anthropic.com/v1, plus model and api_key.
  • Skip descriptions: set vision.provider: disabled. Find Anything search and detections still work with no vision server.
Extra vision options (single-image models, camera layout hints)
  • OpenAI-compatible servers must accept image inputs and JSON mode (response_format: {"type": "json_object"}) on /v1/chat/completions.
  • If your model only accepts one image per request (or you want faster descriptions), set vision.frame_layout: strip to combine the 3 frames into one image, or hybrid for a motion strip plus one full-res keyframe. Lowering vision.max_image_side to 640 also speeds up prompt evaluation.
  • You can add optional per-camera layout hints under cameras: in config.example.yaml so descriptions know which way is entering vs. exiting or which road is the public street.

Third-party cameras (virtual AI Port & Nest)

Turn on the virtual AI Port in config.yaml:

aiport:
  enabled: true

Restart Keystone, adopt the discovered AI Port in UniFi Protect → UniFi Devices, pair your ONVIF cameras (or older UniFi cameras without smart detections) to it (up to 10 HD cameras), and enable the smart detections you want on each camera. Package detection and all 9 Protect Smart Audio alarms load automatically only when you enable them in Protect.

Nest and other cloud cameras: Protect only adds third-party cameras that speak ONVIF. Use Scrypted (with its Google Device Access and ONVIF plugins) to expose each Nest camera to Protect as an ONVIF camera, then pair it with Keystone's AI Port like any other third-party camera. UniFi and ONVIF cameras don't need Scrypted.

Speech-to-Text (event transcripts)

Off by default. Turn it on in config.yaml:

stt:
  enabled: true
  backend: onnx           # local Whisper on CPU (or "openai" for a remote Whisper server)
  model: whisper-base     # whisper-tiny | whisper-base | whisper-small

Restart Keystone, then enable Speech-to-Text under Protect → Settings → Intelligence (and Speech audio detection on audio-capable cameras). Runs locally on CPU with no extra packages; cameras without a microphone return an empty transcript instead of stalling.

License plate recognition

Off by default. Turn it on in config.yaml:

lpr:
  enabled: true

Optional: name known vehicles in event descriptions

vehicles:

ABC1234: "Alice's white sedan"

Restart Keystone, then enable Legacy Camera Enhancement → License Plate Recognition on G4/G5 cameras (or License Plate smart detection on cameras paired to the AI Port). Plates appear under Known Vehicles in Protect.

Face recognition & Enhance Face

Both are off by default. Turn on whichever you want in config.yaml:

faces:
  enabled: true           # feeds Protect's Faces (no photo folder required)

enhance: enabled: true # answers Protect's "Enhance" button on face crops backend: gfpgan # or "pillow" for a zero-download, low-RAM fallback

Restart Keystone, then enable Legacy Camera Enhancement → Face Recognition on G4/G5 cameras (or Face smart detection on AI Port cameras). You can name people directly inside Protect's Faces tab without creating a photo folder. If you also want household names used inside written event descriptions, add a local photo gallery (see below).

Model license notice: Face recognition downloads pretrained InsightFace weights at runtime (verified by SHA-256). InsightFace licenses these weights for non-commercial research only. For other uses, including routine household monitoring, obtain appropriate rights before enabling faces.enabled: true. See InsightFace's licensing terms. Keystone does not bundle or redistribute them.
> Biometric & privacy notice: When faces.enabled: true, Keystone computes a temporary face embedding for every clear face detected in person events (not only people in your gallery). You are responsible for complying with applicable local biometric and privacy laws — such as Illinois BIPA or GDPR — especially where cameras cover public or shared spaces.

Local face gallery (names in captions), CLI tools, and G6 merge tip

To use household names inside event descriptions ("Alex walks up to the front door"), put 5–10 clear, varied photos of each person in /faces// (one clear face per photo; lock down with chmod 700). Keystone syncs the folder automatically when files change.

Useful commands:

keystone faces list -c config.yaml                    # people, photo counts, look-alike check
keystone faces sync -c config.yaml --force            # re-embed the whole gallery
keystone faces test -c config.yaml frame.jpg clip.mp4 # test matches and scores
  • Conservative by default: Blurry, distant (min_face_px: 40), or side-profile faces are skipped, and a person is only named when their match clears min_similarity (0.45) and beats the runner-up by min_margin (0.10). The vision model is never allowed to guess a name.
  • Cross-camera carryover: When a person is clearly recognized on one camera, Keystone can carry their name to nearby cameras within 90 seconds if the appearance or companion object (car, dog, package) matches with high confidence and no conflicting face is visible.
  • G6 cameras: Keystone's face clusters start separate from G6 cameras' built-in clusters in Protect. Merge the same person's groups once in Protect → Faces and later sightings follow automatically.
  • Enhance Face (enhance.enabled: true): Uses GFPGAN v1.4 (Apache-2.0, ~340 MB download, ~1 s per face on 2 CPU threads) and automatically unloads from RAM after 5 idle minutes (idle_unload_seconds: 300). Falls back to pillow if the model can't load.

Backfilling older events (retroactive Find Anything search)

Off by default so existing installs don't kick off a multi-hour backfill unexpectedly. On Protect 7.3.74+, set embeddings.retroactive_processing: true (or KEYSTONE_EMBEDDINGS_RETROACTIVE=true) and restart Keystone.

  • Protect sends historical events in batches and marks each done as Keystone indexes it.
  • Live events always come first: Backfill uses its own separate queue and pauses whenever live camera events are waiting.
  • Low-power hosts: Set embeddings.retroactive_batch_delay_ms: 200 (or 500) on a Raspberry Pi or N100 mini PC to leave CPU headroom during long backfills.
  • Track progress on the dashboard's Find Anything card or in /api/status.

Hardware & sizing

What computer do I need?

  • RAM & CPU:
- 2–3 GB RAM (Raspberry Pi, N100 mini PC, small LXC): works for Find Anything search and a few cameras with low-RAM settings (embeddings.quantization: int8). - 4 GB RAM, 2–4 CPU cores (typical): comfortable for Find Anything search and up to ~7 HD third-party cameras on CPU. - 8 GB RAM: recommended if you turn on faces, license plates, speech transcripts, and Enhance Face all at once.
  • Do I need a GPU?
- Not for search, third-party detections, faces, plates, or transcripts — those all run well on CPU. - Helpful for local event descriptions: A discrete GPU with 6–12 GB VRAM (e.g. RTX 3060/4060, Intel Arc, or an Apple Silicon Mac on your LAN) writes descriptions in 2–5 seconds using qwen3.5:9b (or qwen3.5:4b on 6–8 GB cards). An integrated GPU works too, at about 20–25 seconds per description. Without a GPU, you can use a hosted OpenAI or Anthropic API or disable descriptions.
  • Google Coral: Not supported. Keystone uses ONNX models that don't fit in Coral's ~8 MB memory, and regular CPUs handle motion-gated detection easily (~6% CPU for seven 1080p cameras on an Intel Core Ultra 5).

Memory & speed at a glance

| Feature | Memory | Typical speed | Notes | | --- | --- | --- | --- | | Base (Find Anything + AI Port detections) | ~3.5–4.5 GB RAM (~2 GB with int8) | Instant search; ~6% CPU for 7× 1080p cameras | Runs on CPU | | Event descriptions (vision model) | 6–12 GB VRAM on your Ollama host (or cloud API) | 2–5 s (discrete GPU) / ~24 s (iGPU) | Optional; runs on separate box or cloud | | Face recognition (optional) | +0.3–0.5 GB RAM | ~0.1–0.3 s per frame | CPU | | Speech transcripts (optional) | +0.3 GB RAM (whisper-base) | < 1 s for a 30 s clip | CPU (whisper-small uses ~1 GB) | | License plates (optional) | +0.15 GB RAM | ~50 ms per frame | CPU; shared across AI Key & AI Port | | Package detection (AI Port) | ~11 MB model (loads only if used) | ~60–100 ms per scan | CPU; loads when enabled in Protect |

Tuning for 2–4 GB hosts (Raspberry Pi, N100, small LXCs) & faster descriptions

| Profile | Settings | CLIP RAM (measured)¹ | Est. Keystone total² | | --- | --- | --- | --- | | Full (default) | quantization: fp32, lazy_text_model: true, analyze_max_width: 960 | ~1.6 GB idle, ~2.3 GB after first text search | ~3.5–4.5 GB | | Balanced | quantization: int8 | ~0.42 GB idle, ~0.55–0.8 GB after first text search | ~2–3 GB | | Lite | int8, text_model_idle_unload_seconds: 300, analyze_max_width: 640, detector_variant: yolox_tiny, embeddings.threads: 2 | ~0.42–0.8 GB | ~1.5–2 GB |

  • embeddings.quantization: int8 (KEYSTONE_EMBEDDINGS_QUANTIZATION) is the biggest RAM saver (~65–74% less RAM than fp32). On ARM CPUs, search quality matches fp32 closely (cosine ≥ 0.986); on x86 AVX2 CPUs there is a slight drop in ranking precision, so keep fp32 if you have ≥ 4–6 GB RAM. Avoid fp16 on CPU (slower and uses more RAM; GPU only) and q4 (about 4× slower on CPU).
  • embeddings.lazy_text_model: true (default) only loads the search text encoder on your first Find Anything query. Set embeddings.text_model_idle_unload_seconds: 300 to free it again when idle.
  • aiport.analyze_max_width: 640 (default 960, min 320) lowers decode CPU on paired ONVIF cameras without affecting detection zone accuracy.
  • Faster descriptions: Set vision.frame_layout: hybrid or strip to cut vision latency roughly in half, or lower vision.max_image_side to 640.
¹ onnxruntime CPU provider, 4 threads, per-process RSS. ² Whole-process estimate; actual usage depends on camera count and enabled features.

Optional Intel GPU / NPU acceleration (OpenVINO & VA-API)

Keystone defaults to CPU and software video decode so it works everywhere with no drivers. On Intel Core Ultra, Arc, or N100 hosts, you can offload ONNX models to OpenVINO and AI Port video decode to VA-API:

pip install -e ".[openvino]"
acceleration:
  provider: auto                  # auto | cpu | openvino
  openvino_device: "AUTO:GPU,CPU" # GPU | NPU | CPU | AUTO:GPU,CPU | AUTO:NPU,GPU,CPU
  ffmpeg_hwaccel: auto            # none | auto | vaapi (AI Port decode only)

If OpenVINO or VA-API fails to initialize, Keystone logs a warning and falls back to CPU automatically. Active providers show up on the status dashboard and in /api/status.

Troubleshooting Intel GPU resets (Linux xe driver) & OpenVINO cache

  • Compiled OpenVINO blobs are cached in /ov_cache across restarts (acceleration.openvino_cache_dir). Precision defaults to openvino_precision: FP16 (GPU/NPU only) and VA-API defaults to ffmpeg_device: /dev/dri/renderD128.
  • GPU resets on Intel Linux xe drivers (Xe2/Xe3): OpenVINO's GPU plugin can hit a CCS page fault / Engine memory CAT error when Intel compute-runtime (NEO) packs pooled OpenCL USM buffers against an unmapped 16 MiB boundary. Keystone sets GPU_ENABLE_LARGE_ALLOCATIONS=YES by default on GPU sessions (acceleration.openvino_gpu_large_allocations: true) to bypass that pool. With onnxruntime-openvino 1.24 / OpenVINO 2025.4, set openvino_device: GPU directly so OpenVINO's AUTO plugin doesn't strip the property.
  • Automatic recovery: If a GPU reset still drops the OpenCL context (CL_OUT_OF_RESOURCES), after 3 device-lost errors within 2 minutes Keystone logs the cause and exits with code 75 so systemd or Docker restarts it with a fresh context. If that happens 3 times within 30 minutes, Keystone starts on CPU instead to prevent a restart loop, and the dashboard flags the GPU as suspended. A manual restart (systemctl restart keystone / docker compose restart) clears that history and retries the GPU. Tune or disable with acceleration.restart_on_gpu_loss, gpu_loss_max_restarts, and gpu_loss_window_minutes (set restart_on_gpu_loss: false if running without a process supervisor).

Under the hood (Technical details)

Architecture & protocol compatibility

  • AI Key (UP-AI-KEY, 0xa5f0): Advertises via Ubiquiti UDP 10001 discovery, serves /api/info, /api/adopt, and /api/readopt over HTTPS (:8080), authenticates to Protect via mTLS with pinned controller SHA-256 certificates, handles UCP4 control commands (:7442), and syncs rotated passwords to PostgreSQL (unifi-protect role) for Protect 7.3+ isSearchHost vector search.
  • Vision pipeline: Samples 3 chronological frames (±1.0s around each event's keyMoment, widened to ±2.0s on clips ≥ 15s, at 960px) for motion-aware VLM captions and maps outputs plus class-filtered attributes onto Protect's 5,375-tag ramTags vocabulary. Optionally injects per-camera spatial hints (cameras: in config.yaml) and multi-view, episode-chained chronological cross-camera sightings (vision.cross_camera_context_seconds, default 90s, strong similarity 0.62, cross-view floor 0.35, up to 3 sightings) so distant, rear, indoor, or IR angles benefit from earlier clearer cameras across vehicles, people, animals, and deliveries. Interactive on-demand summaries (RequestAI → :7968/on_demand_inference) narrow long exports to a 4-second window and run a fast 1-frame 640px pass to stay inside Protect's UI timeout.
  • Find Anything (:7443): Runs local CLIP ViT-L/14 (768-dim ONNX) for object crop indexing, NL_PARSE text queries (with relative time-window parsing), IMAGE_SEARCH, and optional CLIP reverification. Protect 7.4's release notes say detection confidence verification has been removed, so expect reverification jobs only from Protect 7.3.
  • Speech-to-Text (speechToText, featureFlags supportTts & supportStt): Fetches Protect's audio-only MP4 export (skipVideo=true, retrying transient 404s), decodes 16 kHz mono audio with FFmpeg, transcribes with Whisper (log-mel + timestamp-constrained greedy decoding on onnxruntime, with no-speech and leading-silence gating), and POSTs {camera, event, stt: [{startMs, endMs, text}]} to /internal/aiprocessors/speech-to-text. Segment timestamps use Unix epoch milliseconds for synchronized event playback; queued/active jobs are reported to Protect as UI_AUTO_STT.
  • Built-in AI Port (UP AI PORT X, 0xa5f5): Uses Protect's higher-capacity 0xa5f5 profile (3.0 capacity points, vs. 1.0 on a standard UP-AI-Port) so a single Keystone instance can pair up to 10x 1080p ONVIF cameras (in Protect's UI it appears as UP AI PORT X). Relays video to Protect's ms (:7550/:7551) using zero-video-transcode extendedFlv with AVC sequence-header normalization and automatic silent-audio fallback, runs motion-gated Apache-2.0 YOLOX ONNX detection, and evaluates Protect's configured polygon zones and excludeZones, line-crossing tripwires (lines, A2B/B2A/both with per-object counts) and loitering zones (loiterZones, per-object dwell times; tracks dwelling in a loiter zone are exempt from parked-object suppression until they trigger).
  • AI Port package detection (package / packageMaincam): Keystone advertises both package (smartDetectTypes) and packageMaincam (hasPackageZoneSupportForPrimaryLens) in features.smartDetect when aiport.package_enabled: true (default). The Apache-2.0 D-FINE Small Objects365 ONNX model (class 21, Storage box) loads lazily on the first scan for a camera where Protect enabled package, runs throttled every aiport.package_scan_interval_seconds during motion or person/vehicle presence plus +3s and +8s follow-up scans after a person leaves, filters by Protect's configured package zones and excludeZones, optionally checks each 15%-padded candidate crop via zero-shot CLIP cosine margin against parcel vs. porch false-positive prompts (falling back to a stricter D-FINE score floor if CLIP is unavailable), and suppresses already-reported stationary boxes by IoU (1800s TTL, cleared after 3 consecutive absent scans) so each delivered box emits one crisp EventSmartDetect arrival event with crop snapshot.
  • AI Port Smart Audio detection (all 9 alrm classes): For paired cameras with audio, Keystone advertises all 9 Protect AUDIO_TYPES (alrmSpeak, alrmBark, alrmBabyCry, alrmSmoke, alrmCmonx, alrmSiren, alrmBurglar, alrmCarHorn, alrmGlassBreak) in features.smartDetect (Protect derives smartDetectAudioTypes from it) and reports isAudioEventReady. When Protect enables any enableAlrm flags via ChangeAudioEventsSettings, Keystone starts one shared audio-only FFmpeg decoder (16 kHz mono PCM) for that camera. Silero VAD (MIT, shared ONNX session, per-camera RNN state) loads lazily only if alrmSpeak is enabled; Google YAMNet (Apache-2.0, shared ONNX session, 0.975 s sliding window / 0.48 s hop) loads lazily only if any of the other 8 audio alarms is enabled. Both feed a per-camera multi-alarm tracker (AudioEventTracker) that handles overlapping alarms cleanly and emits full 9-key EventSmartAudio enter / moving / leave payloads. Nothing runs while Protect has all audio detections off. Cameras that list an audio track but send no audio back off quietly (30s, then 60s), and FLV ingest retries audio on later reconnects after a transient startup timeout (aiport.flv_audio_header_timeout, default 15s). Tune with aiport.audio_vad_ and aiport.audio_alarms_, or disable either with audio_vad_enabled: false / audio_alarms_enabled: false.
  • Native Face Recognition (supportFaceRecognition / AI Port face): On the AI Key (G4/G5 cameras), each person event's recognize-anything upload carries a face part: one track per distinct face (same-event duplicates collapse at cosine ≥ 0.55, keeping the sharpest frame), a 512-dim ArcFace embedding, a square head-and-shoulders crop, and a link to Protect's person tracker. On the AI Port (paired ONVIF/Nest cameras), Keystone scans head-and-shoulders regions while a person is visible (at most every 1.5 s per camera, stopping once a sharp frontal face is held) and emits objectType: "face" tracks in EventSmartDetect, linked to the person. Cross-camera identity propagation carries recognized names within propagation_seconds when no conflicting local face is visible (unknown_quality_faces == 0) via direct multi-view person CLIP matching (≥ 0.85 fail-safe default) or companion-object/episode continuity with VLM visual corroboration. Webhook/MQTT payloads include identities and people.
  • License plate recognition (supportLicensePlateRecognition / AI Port licensePlate): On the AI Key, recognizeKeyFrames jobs with ramType: "videoWithRecognition" (or vehicleMeta) are scanned on up to lpr.max_frames vehicle frames decoded at up to 2560px. Keystone adds an lpr JSON part (Protect 7.4 lprInferenceSchema) plus one JPEG per plate crop to the same recognize-anything multipart POST as ram. Plate crops use tracker IDs from 920000 up, and lprAttrs carries both the plate tracker (objectType: "licensePlate") and Protect's own vehicle tracker (matchedName, string-only namesTopK, topKCandidate), so Protect's VehicleRecognizer files the car under vehicle_LPR-. On the AI Port, licensePlate is advertised in features.smartDetect. When Protect enables it in ChangeSmartDetectSettings, vehicle tracks are read (at most every 1.5 s per camera while moving, locked at ≥ 0.88) and the leave event carries smartDetectSnapshotName and trackerIDAttrMap[vehicle].matchedName. The YOLOv9 plate detectors from open-image-models are deliberately not used, because they derive from GPL-3.0 YOLOv9 code.
  • Retroactive processing (supportRetroactiveProcessing): When embeddings.retroactive_processing: true, Protect sends batches of recognizeKeyFrames (ramType: multipleImages) with stored detection thumbnails. getTaskQueueInfo shapes UI_TASK_NUM so Protect's batch budget (50 - UI_TASK_NUM) matches free retroactive queue slots (retroactive_max_queued, default 32) and pauses whenever live jobs are queued; UI_AUTO_RAM always reports the true backlog. Missing/corrupt thumbnails (404/410) are skipped individually, valid thumbnails run in one batched CLIP forward pass, and the callback always completes so Protect never loops on pruned events.

Security defaults

  • Dashboard: Binds to 127.0.0.1:8088 by default so captions and metadata are not exposed unauthenticated on the LAN. Set web.bind_host: 0.0.0.0 (or KEYSTONE_WEB_BIND_HOST) only on a trusted management network or behind an authenticating reverse proxy. The page is fully self-contained (no CDN or remote fonts) and is served with a hash-pinned Content-Security-Policy that only allows its own scripts and same-origin API calls.
  • TLS pinning: Controller control/media (:7442/:7444), search (:7443), and encrypted FLV relays enforce exact leaf SHA-256 pins (TOFU by default, or pre-verified via keystone trust --pin --control-fingerprint ...).
  • Enrollment credentials: Setting a custom device.password or aiport.password disables factory ubnt/ui fallbacks. Once adopted, Protect rotates credentials automatically, factory credentials are rejected permanently, adoption/management endpoints accept requests only from controller.host, and password verification runs off the event loop with per-IP backoff.

Required network ports (for segmented VLANs)

| Direction | Port | Purpose | | --- | --- | --- | | Keystone → Protect | TCP 7442 | UCP4 control WebSocket (ds) & AI Port avclient WSS | | Keystone → Protect | TCP 7443 | Find Anything NL Search WebSocket | | Keystone → Protect | TCP 7444 | Media export downloads & RAM callbacks | | Keystone → Protect | TCP 7550 / 7551 | AI Port extendedFlv video ingest (ms, when AI Port enabled) | | Keystone → Protect | TCP 7447 | RTSP restream of UniFi cameras paired with the AI Port | | Protect → Keystone | TCP 8080 | AI Key adoption management HTTPS (/api/info, /api/adopt, /api/readopt) | | Protect → Keystone | TCP 443 | AI Port adoption management HTTPS (/api/1.2/login, /api/1.2/manage, when AI Port enabled) | | Protect → Keystone | TCP 5432 | PostgreSQL + pgvector over TLS for Protect 7.3+ Find Anything (isSearchHost) | | Protect ↔ Keystone | UDP 10001 | Ubiquiti v1 LAN discovery (optional if adopted by IP) |

Kubernetes & dedicated-IP deployments

Networking requirements for Kubernetes, macvlan, and LoadBalancer setups

  1. Use one IP for adoption and search. Protect expects TCP 8080 (AI Key), 5432 (PostgreSQL), and 443 (when AI Port is enabled) on the same IP. Give ghcr.io/seearms/keystone-aio a dedicated LAN IP with Docker macvlan or a Multus network attachment. On Kubernetes, you can also expose one Pod through a LoadBalancer Service, using the all-in-one image or separate Keystone and PostgreSQL containers in that Pod. With MetalLB or Cilium BGP, set externalTrafficPolicy: Local so PostgreSQL sees Protect's real source IP.
  2. Advertise the IP Protect can reach. Without hostNetwork: true, set device.advertise_ip (KEYSTONE_DEVICE_ADVERTISE_IP) to the external IP, such as the LoadBalancer IP or the dedicated LAN IP. This keeps Keystone from advertising an internal pod IP.
  3. Give discovery a path to the LAN. UDP 10001 broadcast discovery needs Layer 2 reachability to Protect. Use hostNetwork, Multus, or Docker macvlan on Protect's LAN for automatic discovery. If you only have routed access, adopt by IP and allow the required connections in the table above.

Development

ruff check src tests
pytest -v

Status dashboard architecture, history storage, and frontend build

The status dashboard (:8088) is a React + shadcn/ui app in web/ (Vite, Tailwind CSS v4, TypeScript). It compiles to a single self-contained HTML file, src/keystone/ui/index.html, which is committed so pip install and Docker builds don't need Node. Keystone embeds a status snapshot in the page and polls for updates while the dashboard is live.

Keystone keeps 30 days of activity in /activity.sqlite3. Only the 20 most recent entries can retain thumbnail images. Keep the state directory across upgrades and restarts (Docker Compose already mounts it). History starts with the first run of a version that supports it. Events discarded by an older version are unavailable.

Use the Activity time selector to browse the last hour, 24 hours, 7 days, or 30 days. Timestamps use your browser's local time and show when Keystone recorded each item. Search and category filters cover the selected period, including older pages. The Cameras table uses the same period for its Events column, which counts AI Port smart detection and audio messages. One detection can produce several messages as it starts, updates, and ends. Frames are counted since startup.

If the database becomes unavailable, the dashboard shows recent activity and camera counts from the current session. Keystone retries buffered writes when storage recovers and marks known gaps in the archive. Restarting while the database is still unwritable loses entries held only in memory.

cd web
npm ci
KEYSTONE_URL=http://<keystone-host>:8088 npm run dev   # hot reload, proxies /api to a running Keystone
npm test                                               # derivation/formatting tests (vitest)
npm run build                                          # rewrites src/keystone/ui/index.html; commit it

CI fails if the committed bundle doesn't match a fresh build. To refresh the README screenshots (docs/images/dashboard.png dark, dashboard-light.png light; full page at 1280px, resized to 1600px wide), render the sanitized demo snapshot and open it in a browser:

python scripts/render_demo_dashboard.py -o /tmp/keystone-demo.html --json web/src/test/fixtures/demo.json

License & Acknowledgments

Licensed under the Apache License 2.0 (see LICENSE and NOTICE).

  • Portions of Keystone's Protect UCP4 AI Key control, adoption/management, TLS pinning, worker/CLIP reverification, and AI Port adoption code are adapted from Olli0103/unifi-protect-local-ai (Apache-2.0) and modified for Keystone; see NOTICE.
  • Find Anything embeddings use MIT-licensed OpenAI CLIP ViT-L/14 ONNX weights via Xenova/clip-vit-large-patch14 (pinned to an immutable commit and SHA-256 verified on download).
  • AI Port Smart Audio uses the MIT-licensed Silero VAD v6.3 ONNX model (alrmSpeak, pinned to commit 63d4a2a) and Apache-2.0 Google YAMNet ONNX via audiomagic/yamnet-onnx (all other 8 Protect audio alarms, pinned to commit f25b741, AudioSet ontology CC-BY-4.0); both are SHA-256 verified on download and load.
  • Optional speech-to-text uses MIT-licensed OpenAI Whisper ONNX exports from onnx-community (pinned to immutable commits and SHA-256 verified on download).
  • Optional face recognition uses InsightFace SCRFD and ArcFace (WebFace600K) ONNX weights, downloaded at runtime and SHA-256 verified; the weights are licensed by InsightFace for non-commercial research purposes only.
  • Optional Face Image Enhancement uses Apache-2.0 GFPGAN v1.4 ONNX weights via neurobytemind/GFPGANv1.4.onnx (pinned to an immutable commit and SHA-256 verified on download).
  • Optional license plate recognition uses an Apache-2.0 YOLOX plate detector, either faisalthaheem/open-lpr-models plate_yolox_tiny_640.onnx (default) or autolane/yolox-s-alpr yolox_plates_s.onnx, plus MIT-licensed fast-plate-ocr cct_*_v2_global OCR. Weights are pinned and SHA-256 verified on download and load; see NOTICE.
  • Optional ONVIF object detection uses Apache-2.0 YOLOX ONNX weights (SHA-256 verified on download).
  • AI Port package detection uses Apache-2.0 D-FINE Small Objects365 ONNX weights via onnx-community/dfine_s_obj365-ONNX (pinned to an immutable commit and SHA-256 verified on download and load; see NOTICE).

Built by Colin Armstrong

Chat with me