Score a suggestion against the people the user has named
The number beside a suggestion was the mean calibrated probability between the face and the rest of its group, which measures the wrong thing twice. It punishes coverage: a person with two hundred faces over fifteen years is *meant* to have members a given photograph is orthogonal to, so a correct suggestion onto a well-photographed person scored low for being well photographed. And it never asked who else the face might be — a face matching Anna at 0.95 and nobody else, and one matching Anna at 0.95 and her sister at 0.93, came out identical, when the second is the only one worth the user's attention. dr_face::assign answers both, and multiplies them: the mean of the best ten calibrated matches into the identity (the old mean, capped, which is what stops coverage counting against it), times that identity's share of the evidence against every *named* rival. Only named people compete, and per person rather than per group. Both halves of that had to be measured on a real 18,000-face library rather than reasoned about. Normalising across every group made the number useless — median suggestion 21%, four in five under half — because clustering leaves one person spread over many groups, so a face competed against itself; and keying rivals by group left Catherine competing with Catherine, median 39%. Per named person: median 99.5%. Rivals are gathered below the merge threshold, down to even odds: a named person matching at 0.6 will never be merged into but is exactly the competition to discount for. That would be a second similarity scan, the expensive half of regrouping a library, so cluster_scored scans once at the looser floor and hands the merge engine the subset at or above the threshold — pair for pair what it would have scanned for itself, held to that by a test. Leave-one-out over that library's 2,702 confirmations across 54 named people: 99.33% of faces placed on the right person against the old mean's 99.15%, and the number shown for the right person moves from a median of 90.4% to 99.3%. It errs low — 100% correct wherever it states 80% or more — which is the safe direction, and docs/faces.md §9.1 says plainly that the low bands are not calibrated. The example that measures it comes too: this is a claim about a library's numbers, and nobody should have to take it on faith. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+10
-36
@@ -543,7 +543,10 @@ pub fn recluster(
|
||||
ids.push(face_id);
|
||||
}
|
||||
|
||||
let clusters = dr_face::cluster(&candidates, &cal, min_probability);
|
||||
let dr_face::Grouping {
|
||||
clusters,
|
||||
confidence,
|
||||
} = dr_face::cluster_scored(&candidates, &cal, min_probability);
|
||||
|
||||
let mut suggested = 0usize;
|
||||
let mut created = 0usize;
|
||||
@@ -569,10 +572,12 @@ pub fn recluster(
|
||||
if confirmed.contains_key(&face) {
|
||||
continue;
|
||||
}
|
||||
// The probability the user is shown is the group's own coherence,
|
||||
// not the single best edge into it — a face admitted by one strong
|
||||
// match to an outlier should not present as certain.
|
||||
let p = group_probability(&candidates, c, m, &cal);
|
||||
// The probability the user is shown is this identity's share of
|
||||
// the evidence for the face, against every other identity that
|
||||
// could plausibly claim it (dr_face::assign) — not the single best
|
||||
// edge, which cannot tell a sole match from a coin toss between
|
||||
// two siblings.
|
||||
let p = confidence[m];
|
||||
if faces::suggest(conn, face, person, p)? {
|
||||
suggested += 1;
|
||||
}
|
||||
@@ -662,37 +667,6 @@ pub fn spawn_recluster(
|
||||
rx
|
||||
}
|
||||
|
||||
/// Mean calibrated probability between one member and the rest of its group.
|
||||
fn group_probability(
|
||||
candidates: &[dr_face::Candidate],
|
||||
cluster: &dr_face::Cluster,
|
||||
member: usize,
|
||||
cal: &Calibration,
|
||||
) -> f32 {
|
||||
let me = &candidates[member];
|
||||
let mut sum = 0.0;
|
||||
let mut n = 0.0;
|
||||
for &other in &cluster.members {
|
||||
if other == member {
|
||||
continue;
|
||||
}
|
||||
let them = &candidates[other];
|
||||
let cos: f32 = me
|
||||
.embedding
|
||||
.iter()
|
||||
.zip(&them.embedding)
|
||||
.map(|(a, b)| a * b)
|
||||
.sum();
|
||||
sum += cal.probability(cos, me.crop_px.min(them.crop_px), 0.0);
|
||||
n += 1.0;
|
||||
}
|
||||
if n == 0.0 {
|
||||
1.0
|
||||
} else {
|
||||
sum / n
|
||||
}
|
||||
}
|
||||
|
||||
/// A face cut out of its photograph, ready to draw.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FaceCrop {
|
||||
|
||||
Reference in New Issue
Block a user