Repository navigation
Find similar: matches and similar content, indexed in the background - #200
Merged
Merged
Conversation
…a screenshot Right-click > Find similar compared one 64-bit pHash of the whole picture at a fixed threshold. Measured on 300 photos from a real 26,586-image phone case, each edited 15 ways and hidden among the whole case, it found 53% of the copies (none mirrored, rotated 90 degrees or cropped 25%; 6-10% of those bordered, captioned or pasted into a phone screenshot) and 9% of what it returned was unrelated. gleapp/simindex.py builds a Find-similar index from the thumbnails processing already made (about 400 bytes an image, in the case file) and searches it in two stages. Shortlist: 256-bit pHashes of the picture, of it with solid borders trimmed and of five 75% windows (the searched image also mirrored and turned), plus the visual words of SIFT points on the thumbnail, which find a picture inside another one; the best 150 of each. Confirmation: SIFT points matched one-to-one must fit one shape-preserving transform, at least 10 of them covering 5% of either image; a picture with too little detail for points is confirmed by a strict fingerprint match instead. Same test, through find_copies: 95.5% of the copies of the 262 photos with detail found (82% in a phone screenshot, 92-99% for every other edit); 36% for 38 smooth wallpapers, gradients and flat fills. Other files returned were, in a hand-checked sample, related pictures already in the case. Index 10.6 MB and 6 minutes for 31,086 images; a search took about 1 s, at most 8 s. Until the index is built (Duplicates > Build Find-similar index, the shared background job) Find similar runs the old check and the banner says so; videos keep the key-frame pHash search. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copies share pixels; other photos of the same person, place, object or scene do not, and neither the old check nor the copy index finds them. gleapp/ content.py describes each image and video thumbnail with DINOv2-small (Meta AI, Apache-2.0) through OpenCV's DNN module and ranks the case by cosine similarity. The model is not shipped: the examiner imports the file once (Duplicates > Import content model), accepted only with the expected SHA-256 and copied under the app's data folder; the source and hash are in the manual. Find similar now answers in one list: the searched file, its copies (exact duplicates always, then the copy index or the old check), then similar content, ranked, down to a strictness the banner's slider sets (70% default). Measured on a real laptop case, 93 images in 9 hand-labeled groups among 5,000 others: the other members came first for a chair (10 photos, every angle), a sticker character in 25 poses, a team photo taken three ways and 16 renders of one room; above 0.65, 97% of group members were found. Through the app's own import, build and route on 590 of those images: 3/3, 9/9, 24/24 (1 other) and 15/15. Scores differ by subject, hence ranking plus a slider. Building runs at about 25 images a second on an 8-core laptop; ONNX Runtime was measured no faster (23.8 vs 26.7 a second), so no new dependency. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er pictures Processing now builds both Find-similar indexes as its last stages (copies always; content when the model has been imported), so a right-click works as soon as a case is processed. Both add only what is not indexed yet. The content index describes each picture once however many exact copies the case holds, skips pictures under 128 pixels (icons, cursors, buttons), and does the operating system's and applications' own artwork last, larger pictures first. On a Windows laptop case this left 4,975 of 57,406 images: 4 min 16 s instead of about 40 min, with the hand-labeled groups still found (THANK YOU team 12/12 links, room renders 240/240, $100 fronts 132/132). Two phone cases: 15,346 of 27,188 and 19,888 of 33,109. A duplicate that was not described itself searches with its group's description, and the group is left to the copies list. The copy index likewise keeps one entry per group. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Find similar's similar content needed the examiner to download and import the model file. It now ships in gleapp/models/dinov2_small.onnx, so processing builds the content index on every machine and there is no import step (its button, route and file dialog are gone). The file is Meta's own facebook/dinov2-small weights (Apache-2.0, Hugging Face revision ed25f3a31f01632728cabb09d1542f84ab7b0056) converted to ONNX with PyTorch 2.14 (opset 17), 88,411,480 bytes, SHA-256 b88d3157...e2822, which tests/test_content.py checks. Its vectors match those of the onnx-community conversion the feature was measured with (cosine 1.00000 on 300 real thumbnails). A half-precision conversion was 44 MB but about 25% slower in OpenCV, so the full-precision one ships. Meta's licence text, the LICENSE of facebookresearch/dinov2 at 7764ea0f912e, ships beside it as gleapp/models/LICENSE-dinov2, is in the notices and the licence metadata, and is pinned byte for byte like the SFace and YuNet ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… called a copy On a phone case whose copy index was not built, Find similar on a video listed 25 "copies" (walking emoji, app icons) from the old perceptual-hash key-frame check, labeled as copies. Now: - the copy index holds videos too, by their thumbnail frame, and a video search checks its thumbnail and each key frame, so a re-encoded copy or a still taken from it is confirmed by point matching like any picture (on that case the same video now has none, and screen recordings find the screenshots of the same screen); - without the copy index the old check's results are "quick match?", counted apart in the banner, which says how to build the index; - a copy must cover at least 2% of both pictures: the TikTok logo and a "TikTok Shop" banner matched whole inside TikTok frames were 4 false copies of two videos; at 2% there were none and every copy in the 300-photo test was still found (5% lost a tenth of those pasted into a screenshot); - one "Build Find-similar indexes" button builds copies then content, for a case processed before this version (processing builds both already). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sults A video search ran the whole image search once per frame (thumbnail and up to six key frames). Measured on 30 videos of a real phone case, the time went mostly to comparing each frame's fingerprints with every picture in the case, a byte at a time through a lookup table. - fingerprints are compared 64 bits at a time with NumPy 2's bitwise_count (the byte table stays for the declared NumPy floor, 1.24, and a test ties the two); - a key frame within 20 of 256 bits of a frame already searched is skipped, and each candidate is checked only against the frames that shortlisted it; - the check uses up to 500 points a thumbnail instead of 800: the same copies found on the 300-photo test and on the 30 videos, 20-25% faster. First search in a session 2.65 s to 1.53 s, later ones 1.50 s to 0.69 s; an image search about 0.64 s. The 30 videos returned the same 289 copies before and after, and the 300-photo test still finds 95.5% of copies. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… indexes The Find-similar build button and its status sat under Duplicates. They now have their own "Find similar" section, which says what a right-click does and shows how much each index holds. Processing always builds both indexes as its last stages (no option), so Find similar works as soon as a case is processed, and later runs index just their new files. The button is for a case processed before the indexes existed. Two hints that still pointed at Duplicates now point here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Building both indexes as processing's last stages added about 8 to 20 minutes to an ingest on four real cases. Processing in the app now ends as it did before Find similar's indexes existed, and gleapp/web/indexer.py builds them in the background while the examiner works: - one thread per open case, started when a case opens, at half the cores so the gallery stays responsive; likely examiner material first, the system's and applications' own artwork last; Find similar searches whatever is indexed so far, and its banner says indexing is still under way; - it pauses while any job runs (an ingest, screening, a re-scan) and picks up new files after it; it stops before a case closes or a snapshot is restored; both builders write in chunks and resume where they left off; - the Find similar section shows each index's progress, updating itself; its button appears only to restart indexing after an error. The command line still builds the indexes at the end of processing. The copy index now reads each thumbnail once instead of twice: the second pass only counted points, and all that count decides (fewer than 25 or not) the first pass answers exactly. On a 13,867-file phone case the build went from 175 s to 79 s, with the same 289 copies for 30 videos as before; the vocabulary is sampled in id order so the new build order cannot change it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
While a search runs, the indexer skips the files in hand and waits until no search is running, since both use the same cores. Measured on 8 videos of a real phone case while the content index was being built: first searches 3.59 s to 2.86 s on average (worst 8.59 s to 6.33 s), repeat searches 1.14 s to 0.81 s. The copy index's vocabulary sample is never cut short, so a stop cannot change it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A video search checks its thumbnail and every key frame, which took up to 6 s on a first search of a large video. The page now asks for the thumbnail's results first (?quick=1), shows them, and fills in the full answer when the key frames are done; the banner says the key frames are still being searched. The full answer is the same search as before. Measured through the route on 30 videos of a real phone case: first results on screen in 0.60 s on average (at most 1.98 s), the full answer 1.36 s after that (at most 4.95 s), and the full answers identical to before for all 30. A picture has one frame and still comes back in one step. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Some matches are screenshots or frames of the same picture rather than
copies of the file, so the badge now reads "match · N pts" ("match" alone
when confirmed by fingerprint) and the banner counts matches. Exact
duplicates still read "identical".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g, less text
- background indexing shows on the shared progress bar at the bottom of the
left pane, like every other background task ("Find similar: indexing
matches 24% · 3,400/14,000"); a job's own progress takes the bar while it
runs;
- only an ingest (and evidence added to a case already indexed) starts
indexing by itself; opening, creating or restoring a case never does, and a
case that was not indexed on ingest shows "Build indexes" in the Find
similar section until the examiner clicks it;
- the Find similar section is one instruction line and one status line; the
details moved to the button's tooltip and the help; the results banner's
notes are shorter.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A picture's exact duplicates share its content description, so similar content showed a hit once and left out its duplicates. Each hit is now followed by its exact duplicates at the same score, and a searched file's own duplicates come first. On a real laptop case, 90 labeled searches returned everything they did before and 754 duplicates they had left out. Sharing one description across processing's looser visual-copy groups too would have cut the content index a further 20-36% on five cases, but lost 89 of those searches' results (members can look quite different to the model), so it is not done; the docstring records why. Co-Authored-By: Claude Opus 5.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.
Right-click → Find similar compared one 64-bit pHash of the whole picture at a fixed threshold. It found about half of a picture's copies (none mirrored, rotated 90° or cropped 25%) and about 9% of what it returned was unrelated. This replaces it with two indexes and one ranked answer: matches (the same picture edited or re-shared), then similar content (other photos of the same person, place or object).
What the examiner sees
How it works
gleapp/simindex.py): 256-bit pHashes of each thumbnail (whole, border-trimmed, five 75% windows; the query is also tried mirrored and rotated) plus SIFT visual words shortlist candidates; each is confirmed by one-to-one SIFT matches fitting one shape-preserving transform (≥10 points covering ≥5% of one picture and ≥2% of the other). Featureless pictures fall back to a strict fingerprint match. About 400 bytes an image, in the case file.gleapp/content.py): DINOv2-small (Meta AI, Apache-2.0) through OpenCV's DNN module, cosine similarity over one vector per picture; exact duplicates share one, icons under 128 px are skipped.gleapp/web/indexer.py): one thread per open case, chunked and resumable builds.Measured
Several speed-ups were measured and not adopted because they lost results (a word-overlap prefilter, shorter key-frame shortlists, sharing one description across visual-copy groups); the code comments record why.
Note for review
gleapp/models/dinov2_small.onnxis 88.4 MB. It is Meta'sfacebook/dinov2-small(Hugging Face revisioned25f3a3) converted to ONNX with PyTorch 2.14, opset 17; its SHA-256 is pinned incontent.pyand checked by a test. Meta's licence text ships beside it (LICENSE-dinov2, pinned byte for byte) and is in the notices and the licence metadata. The model and its licence go into the frozen build like SFace.gleapp.simindexandgleapp.contentare in the spec's hidden imports.bitwise_count, with a tested fallback for the declared floor (1.24).Tests
tests/test_simindex.pyandtests/test_content.py(synthetic images and hand-made vectors), plus the notices, licence-metadata and pipeline tests. Locally on Windows, merged with currentmain: 699 passed, 3 skipped; lint (changed files), import smoke, line endings and the wheel check pass.🤖 Generated with Claude Code