YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(redact): ship rfdetr_v11 image PII model — v9 under-detected on real screens
Louis Beaumont83983942150f
diff --git a/crates/screenpipe-engine/src/cli/mod.rs b/crates/screenpipe-engine/src/cli/mod.rsindex bb186c00c..55299e4df 100644--- a/crates/screenpipe-engine/src/cli/mod.rs+++ b/crates/screenpipe-engine/src/cli/mod.rs@@ -415,10 +415,10 @@ pub struct RecordArgs {pub async_pii_redaction: bool,/// Enable the async IMAGE-PII reconciliation worker. Independent- /// of `--async-pii-redaction` (text). Runs the rfdetr_v8 detector+ /// of `--async-pii-redaction` (text). Runs the rfdetr_v11 detector/// over each captured frame, blacks out detected PII regions in/// the JPG (atomic overwrite of the source file). Requires- /// `rfdetr_v8.onnx` at `~/.screenpipe/models/` and the binary+ /// `rfdetr_v11.onnx` at `~/.screenpipe/models/` and the binary/// built with one of the `onnx-*` cargo features. Off by default.#[arg(long, default_value_t = false)]pub async_image_pii_redaction: bool,diff --git a/crates/screenpipe-redact/src/adapters/rfdetr.rs b/crates/screenpipe-redact/src/adapters/rfdetr.rsindex c92e2f059..4cd14c766 100644--- a/crates/screenpipe-redact/src/adapters/rfdetr.rs+++ b/crates/screenpipe-redact/src/adapters/rfdetr.rs@@ -20,20 +20,21 @@//!//! ## Reference benchmark numbers//!-//! `rfdetr_v9` (384×384 input, FP32 ONNX, ~108 MB):+//! `rfdetr_v11` (512×512 input, FP32 ONNX, ~109 MB)://!-//! | platform | EP | p50 |-//! |----------------------------|-----------|---------:|-//! | macOS Apple Silicon (M1+) | CoreML | ~66 ms |-//! | macOS Apple Silicon (M1+) | CPU | ~163 ms |-//! | Windows + DirectX 12 GPU | DirectML | ~50 ms |-//! | Linux + NVIDIA | CUDA | ~20 ms |-//! | CPU-only | CPU | ~140 ms |+//! p50 latency, macOS Apple Silicon (M1+) CoreML: ~120 ms — measured.+//! The 512² input is ~2.5× the pixels of v8's 320² (v9 was 384²), so+//! v11 runs ~1.5–2× slower than the v9 figures previously listed here;+//! still well within real-time for per-frame redaction. Other-platform+//! p50s (DirectML / CUDA / CPU) scale similarly — re-measure before+//! quoting.//!//! Bench accuracy on `screenpipe-pii-bench-image` val (221 images):-//! 95.3 % zero-leak / 0 % oversmash. The synthetic bench's stable-//! ceiling at this corpus size; gains beyond come from training on-//! more real-screen failure modes (tracked in the bench's backlog).+//! 98.9 % zero-leak / 0 % oversmash (v11, realworld-augmented). v11+//! replaces v9, which under-detected badly on real screens (≈0+//! detections on real frames despite passing the synthetic bench);+//! v11 restores real-frame detection AND raises the synthetic ceiling+//! from v8's 95.3 %.use std::path::{Path, PathBuf};@@ -45,7 +46,7 @@ use crate::RedactError;use crate::SpanLabel;const RFDETR_NAME: &str = "rfdetr";-const RFDETR_VERSION: u32 = 9; // matches the rfdetr_v9 ONNX+const RFDETR_VERSION: u32 = 11; // matches the rfdetr_v11 ONNX#[cfg(feature = "onnx-cpu")]const NUM_CLASSES: usize = 12;@@ -73,12 +74,12 @@ const CLASSES: [SpanLabel; NUM_CLASSES] = [/// Configuration for [`RfdetrRedactor`].#[derive(Debug, Clone)]pub struct RfdetrConfig {- /// Path to `rfdetr_vN.onnx`. We default to `~/.screenpipe/models/rfdetr_v9.onnx`+ /// Path to `rfdetr_vN.onnx`. We default to `~/.screenpipe/models/rfdetr_v11.onnx`/// in [`Self::default_model_path`] but callers may override (e.g./// for an INT8-quantized variant in the future).pub model_path: PathBuf,/// Square input size baked into the ONNX (320 for v8, 384 for- /// v2/v5). Must match the model — auto-detected if 0.+ /// v9, 512 for v11). Must match the model — auto-detected if 0.pub input_size: u32,/// Score floor below which detections are dropped before the/// adapter even returns them. The downstream@@ -104,14 +105,14 @@ impl Default for RfdetrConfig {}impl RfdetrConfig {- /// `~/.screenpipe/models/rfdetr_v9.onnx`. Created lazily by+ /// `~/.screenpipe/models/rfdetr_v11.onnx`. Created lazily by/// [`Self::ensure_model_present`] on first run.pub fn default_model_path() -> PathBuf {dirs::home_dir().unwrap_or_else(|| PathBuf::from(".")).join(".screenpipe").join("models")- .join("rfdetr_v9.onnx")+ .join("rfdetr_v11.onnx")}/// HuggingFace download URL for the canonical ONNX. Pinned to@@ -119,16 +120,16 @@ impl RfdetrConfig {/// (URL + expected SHA-256 + [`RFDETR_VERSION`] all bumped/// together).pub const HF_DOWNLOAD_URL: &'static str =- "https://huggingface.co/screenpipe/pii-image-redactor/resolve/main/rfdetr_v9.onnx";+ "https://huggingface.co/screenpipe/pii-image-redactor/resolve/main/rfdetr_v11.onnx";- /// Expected SHA-256 of the canonical `rfdetr_v9.onnx`. Verified+ /// Expected SHA-256 of the canonical `rfdetr_v11.onnx`. Verified/// after every download. If a future training run produces a new/// best, bump [`RFDETR_VERSION`], re-publish to HF, update this/// constant. Note: the worker is destructive-only and does NOT/// re-redact already-processed frames, so a model-version bump/// only takes effect for newly-captured frames going forward.pub const EXPECTED_SHA256: &'static str =- "179a5e08ab12bfc70ff1e8dc1e2a67379de2a3be93eb2e7e1f8ec3dbd973f662";+ "13912b66f17f74839e6d07c2399f5b11fd98523f26e78ac7bdaa676472129cb3";/// Make sure the ONNX is present on disk. Idempotent — does/// nothing if [`Self::model_path`] already exists with the@@ -157,7 +158,7 @@ impl RfdetrConfig {tracing::info!(url = Self::HF_DOWNLOAD_URL,target = %self.model_path.display(),- "downloading rfdetr_v9.onnx (~108 MB) — first-run only"+ "downloading rfdetr_v11.onnx (~108 MB) — first-run only");let resp = reqwest::Client::new().get(Self::HF_DOWNLOAD_URL)@@ -194,7 +195,7 @@ impl RfdetrConfig {tracing::info!(target = %self.model_path.display(),bytes = bytes.len(),- "rfdetr_v9.onnx ready"+ "rfdetr_v11.onnx ready");Ok(())}@@ -494,7 +495,7 @@ mod tests {fn default_path_lives_under_screenpipe_dir() {let p = RfdetrConfig::default_model_path();let s = p.to_string_lossy();- assert!(s.contains(".screenpipe/models/rfdetr_v9.onnx"));+ assert!(s.contains(".screenpipe/models/rfdetr_v11.onnx"));}#[test]@@ -554,7 +555,7 @@ mod tests {// (Real download path is exercised by integration tests off// the unit-test harness.)let d = tempdir().unwrap();- let p = d.path().join("models").join("rfdetr_v9.onnx");+ let p = d.path().join("models").join("rfdetr_v11.onnx");std::fs::create_dir_all(p.parent().unwrap()).unwrap();std::fs::write(&p, b"not the real model").unwrap();let cfg = RfdetrConfig {