Skip to content

fix(similar): find-similar requires dHash agreement, skips near-featureless pHash - #41

Merged
charpy4n6 merged 1 commit into
mainfrom
fix/similar-requires-dhash-agreement
Sep 5, 2026
Merged

charpy4n6 merged 1 commit into
mainfrom
fix/similar-requires-dhash-agreement

Conversation

@charpy4n6

Copy link
Copy Markdown
Collaborator

find_similar() compared only pHash, with no cross-check and no guard against near-uniform hashes - the exact false-positive mode dedupe._perceptual_groups already documents and guards against for clustering (gradients, flat screenshots, and dark frames collapse pHash to near-all-zero/all-one, and a lone pHash agreeing is coincidence often enough to matter). Two visually unrelated images could land within the loose 14-bit "Find similar" threshold of each other purely by chance and get reported as each other's closest, or only, match.

Brings the same two guards dedupe.py already uses for clustering:

  • skip any pHash whose bit_count falls outside 12-52 (near-uniform, carries no signal)
  • require dHash to also agree (within threshold+2, same tolerance) whenever both sides have one

Keyframe pHashes have no dHash to cross-check, so that lane (video-to-still matching) keeps the single-hash comparison but still skips near-featureless hashes.

Tested: pytest tests -q - 178 passed, 3 skipped, 3 pre-existing failures reproduced identically on a clean origin/main checkout (unrelated: a search-fixture assertion and a missing local piexif install). Lint-changed gate clean.

🤖 Generated with Claude Code

…reless pHash

find_similar() compared only pHash, with no cross-check and no guard against
near-uniform hashes - the exact false-positive mode dedupe._perceptual_groups
already documents and guards against for clustering (gradients, flat
screenshots, and dark frames collapse pHash to near-all-zero/all-one, and a
lone pHash agreeing is coincidence often enough to matter). Two visually
unrelated images could land within the loose 14-bit "Find similar" threshold
of each other purely by chance and get reported as each other's closest, or
only, match.

Brings the same two guards dedupe.py already uses for clustering: skip any
pHash whose bit_count falls outside 12-52 (near-uniform, carries no signal),
and require dHash to also agree (within threshold+2, same tolerance) whenever
both sides have one. Keyframe pHashes have no dHash to cross-check, so that
lane (video-to-still matching) keeps the single-hash comparison but still
skips near-featureless hashes.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@charpy4n6
charpy4n6 merged commit 260f8e3 into main Sep 5, 2026
8 checks passed
@charpy4n6
charpy4n6 deleted the fix/similar-requires-dhash-agreement branch September 5, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant