Skip to content

Commit 9b56b4e

Browse files
committed
Faces: Add note on background filtering to background.go and docs photoprism#5167
Signed-off-by: Michael Mayer <[email protected]>
1 parent 22d8a63 commit 9b56b4e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

internal/ai/face/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Key changes:
1313
- All face embeddings are now L2-normalized at creation, midpoint calculation, and deserialization time to keep cosine and Euclidean comparisons consistent.
1414
- Benchmarks were added to track the cost of hotspot routines (`Embedding.Dist` and `EmbeddingsMidpoint`).
1515

16+
> **TODO:** Persist detector provenance in `FaceSrc` (e.g., use `entity.SrcONNX` for SCRFD detections) so hybrid libraries can toggle background filtering per embedding source when upgrading from Pigo.
17+
1618
### Detection Pipeline
1719

1820
PhotoPrism now supports two interchangeable detection engines:

internal/ai/face/background.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ func (m Embedding) IsBackground() bool {
1111

1212
// Background contains out-of-distribution (OOD) embeddings
1313
// of inputs that are not faces, such as plants, the sky, etc.
14+
//
15+
// NOTE: Checking an embedding against this list requires ~3–4 µs when it
16+
// fails to match (BenchmarkIsBackgroundMiss, temporary bench) because every
17+
// call scans all 24 clusters. We currently invoke IsBackground from:
18+
// - Embedding.CanMatch() -> NewEmbeddings() at ingest time
19+
// - Embeddings.Kind() / Embedding.SkipMatching() via entity.Face.SetEmbeddings()
20+
// - buildFaceIndex() in internal/photoprism/faces_match.go
21+
//
22+
// Enabling IgnoreBackground therefore shortens index rebuilds roughly 5×,
23+
// but also removes the legacy guard that filtered Pigo false positives. When
24+
// we add detector provenance (TODO: record entity.SrcONNX on SCRFD detections),
25+
// we can conditionally skip this scan for ONNX-derived embeddings only.
1426
var Background = Clusters{
1527
{
1628
Radius: 0.35,

0 commit comments

Comments
 (0)