Man, very much interested as I am in the middle of a similar situation. My main library is over 100K pictures, but over the last few years I have scanned all of my own pictures, my parents and my mother in law. these accounts now for approximately 20K but a lot of duplicate pictures as we used to mail each other copies, plus I erroneously recalled many pictures etc. I also have prior scanned attempt also with photo throughout the year.
last week decisive to loo into vibe coding something and did a number of experiment with libraries and options available in python. the best results has been using the DINOv3 model to run on my Mac mini. tried quite a few of them on small batches and results not as good. Chatgpt tells me that embedding Gare kept at 32-bit and each picture is resized and normalized before going through the model.
Once embeddings are computed for all images in the library, the program matches photos by comparing these feature vectors. It uses cosine similarity—a measure of the angle between two vectors—to determine how close two embeddings are in the high‑dimensional space. For each “source” image, the system queries for the top‑K nearest neighbors by similarity, applies a similarity threshold to focus on close matches, and further refines results using optional perceptual‑hash (pHash) distances, which help catch duplicates that may have minor variations such as slight rotations or compressions.
for eery picture I also run it on all four orientations as was not paying attention during the scanning.
this process runs for several hours on 20K pictures or so and saved to a sqlite Db that has al of the data as well las thumbnails of all images.
I also then built a Mac native app that read the Db, and presents a source file on a pane, with the otehr pane showing top-k candidates that seem close. A drop‑down menu above the match list lets you choose a similarity filter preset. The application defines a handful of presets that map to specific cosine‑similarity thresholds and top‑K limits (for example “Most Alike” might use a threshold of 0.97 and K=50, “High Similarity” might use 0.95 and K=100, and so on). When you pick a preset, the page reloads with new query parameters and displays only the matches that meet the selected threshold, giving you intuitive control over how strict or broad the duplicate detection should be.
you Can delete any of the photos but you can also say they are not a match and then this is remembered so that if yo rerun later these not shown.
Still working this thing but I feel like within a week I will be able to really start using versus current test / development
That’s an impressive pipeline — embedding-based similarity & interactive UI is a powerful approach.
What you’re building is more of a semantic similarity explorer, whereas my script focuses on deterministic duplicate detection with low false positives and automated keeper selection.
Using DINOv3 + cosine similarity definitely increases recall across variation (especially for scanned images with slight crop/exposure differences), but at the cost of heavier compute and less deterministic grouping.
I really like the idea of persisting ‘not a match’ memory — that’s a very elegant human-in-the-loop refinement loop.
Your orientation trick also makes sense for scans where (my current) EXIF orientation isn’t reliable.
In a way, our approaches solve different layers: Perceptual hashing looking for precise structural duplicates vs deep embeddings looking for semantic similarity exploration.
They actually combine nicely — you could first prune exact/near duplicates cheaply, then run DINO embeddings on the reduced set for semantic clustering.
Would definitely be interested to see your repo once published!
View all comments
2
u/gusestrella Feb 17 '26
Man, very much interested as I am in the middle of a similar situation. My main library is over 100K pictures, but over the last few years I have scanned all of my own pictures, my parents and my mother in law. these accounts now for approximately 20K but a lot of duplicate pictures as we used to mail each other copies, plus I erroneously recalled many pictures etc. I also have prior scanned attempt also with photo throughout the year.
last week decisive to loo into vibe coding something and did a number of experiment with libraries and options available in python. the best results has been using the DINOv3 model to run on my Mac mini. tried quite a few of them on small batches and results not as good. Chatgpt tells me that embedding Gare kept at 32-bit and each picture is resized and normalized before going through the model.
Once embeddings are computed for all images in the library, the program matches photos by comparing these feature vectors. It uses cosine similarity—a measure of the angle between two vectors—to determine how close two embeddings are in the high‑dimensional space. For each “source” image, the system queries for the top‑K nearest neighbors by similarity, applies a similarity threshold to focus on close matches, and further refines results using optional perceptual‑hash (pHash) distances, which help catch duplicates that may have minor variations such as slight rotations or compressions.
for eery picture I also run it on all four orientations as was not paying attention during the scanning.
this process runs for several hours on 20K pictures or so and saved to a sqlite Db that has al of the data as well las thumbnails of all images.
I also then built a Mac native app that read the Db, and presents a source file on a pane, with the otehr pane showing top-k candidates that seem close. A drop‑down menu above the match list lets you choose a similarity filter preset. The application defines a handful of presets that map to specific cosine‑similarity thresholds and top‑K limits (for example “Most Alike” might use a threshold of 0.97 and K=50, “High Similarity” might use 0.95 and K=100, and so on). When you pick a preset, the page reloads with new query parameters and displays only the matches that meet the selected threshold, giving you intuitive control over how strict or broad the duplicate detection should be.
you Can delete any of the photos but you can also say they are not a match and then this is remembered so that if yo rerun later these not shown.
Still working this thing but I feel like within a week I will be able to really start using versus current test / development