Repository navigation
fix(similar): find-similar requires dHash agreement, skips near-featureless pHash - #41
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
find_similar()compared only pHash, with no cross-check and no guard against near-uniform hashes - the exact false-positive modededupe._perceptual_groupsalready 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.pyalready uses for clustering:threshold+2, same tolerance) whenever both sides have oneKeyframe 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