Skip to content

Count highly similar shots as duplicates; Bursts and Duplicates tabs in albums - #38

Merged
sgoggins merged 3 commits into
mainfrom
similar-groups
Nov 26, 2026
Merged

sgoggins merged 3 commits into
mainfrom
similar-groups

Conversation

@sgoggins

Copy link
Copy Markdown
Contributor

Changeset

  • Highly similar shots are one picture.
    • What changed: two shots of one scene now count as alike when their visual (CLIP) embeddings are at least similar_clip percent similar. Before, their perceptual hashes had to be within stack_hamming bits. The hash test is still kept, so shots not yet visually analysed are covered.
    • Why: a subject shot again a little reframed, like the painting and the crane in "20261118-Out-Around", now stacks.
    • The setting: default 93, allowed 80–99, 0 turns it off. It is on the Settings page and in archivis settings.
  • Duplicates are redefined. A set is identical images (the same phash) found anywhere in the catalogue, joined with the stacks, i.e. the highly similar shots of a scene. If an identical copy of a stacked shot exists elsewhere, it joins that stack's set. A photo is still in only one set, so dup_id, the photo page's list (now headed "Duplicates") and the Duplicates page keep working as before.
  • Bursts and Duplicates inside albums.
    • Every album (and iPhone) gets Photos · Bursts · Duplicates tabs.
    • /bursts and /duplicates accept the album's dir/iphone. They then list only groups with a photo in that album or its subfolders, and show just those photos. They keep the album's filters, crumbs and way back, and Reset stays inside the album.
    • For a small album (under 200k photos), the groups are found from its photos through the path index.
  • Regrouping. groupsVersion is now 7 and groups_similar is stamped, so every catalogue regroups once in the background after updating, and again whenever the setting changes.

Notes

  • Scope. Similarity is only compared within a scene: one camera's shots, each within the scene gap of the last, in chunks of at most 1000 shots, which is the same window stacks already use. So the cost stays bounded. Exact copies are still matched across the whole catalogue by phash.
  • Comparison. Each shot is compared with its stack's best shot, best first, so a slow pan doesn't chain into one stack. Embeddings are loaded per chunk from photo_clip and scaled to unit length.
  • Timing. On a synthetic catalogue of 100k photos with embeddings, a first regroup took about 5 s with the setting on (0.9 s with it off). That puts the first regroup of a 263k-photo catalogue at about 13 s.
  • Effect on the Duplicates page. Every stack now also shows on the Duplicates page, as you chose ("same rule"). To make stacks and duplicates stricter, raise similar_clip.
  • Tests (each checked to fail without its change):
    • TestStackFramesBySimilarity: shots stack by similarity though their hashes are far apart; at 99%, or with the setting off, only hashes count; without an embedding, the hash is the fallback.
    • TestSimilarShotsAreDuplicates: the painting/crane album. Each three stack and form one duplicate set. An identical copy joins its set; a like shot from another scene does not. Changing the setting regroups, and with it off only the exact copy is left.
    • TestSimilarGroupsMatchReference: a randomized catalogue with embeddings matches the in-memory reference, which now merges stacks with exact copies.
    • TestAlbumBurstsAndDuplicates: the tabs carry the album and its filters. The album's Bursts and Duplicates pages list only its groups, with crumbs, an on-tab, a Reset that stays in the album, and filters still applied.
    • TestSimilaritySetting, and the store and CLI settings tests: the setting is saved, and out-of-range values are refused.
  • DEPLOY.md (Settings, Stacks, "Bursts and duplicates") and the README are updated.

Related issues/PRs


Generated by Claude Code

…in albums

Shots of one scene now count as one picture when they look alike by
their CLIP embeddings (the new similar_clip setting, 93% by default,
80-99, 0 off), not only when their perceptual hashes are close, so a
subject shot again a little reframed stacks. The same rule makes
duplicates: a set is the identical images (same phash) anywhere,
joined with the stacks, so an identical copy of a stacked shot joins
its stack's set. Groups are worked out again once (groups version 7)
and whenever the setting changes.

Each album gets Photos, Bursts and Duplicates tabs. /bursts and
/duplicates take the album's dir (or iphone), keep its filters and
crumbs, and list only the groups with a photo in it, with just those
photos; a small album's groups are found from its photos.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WwontTm7iEMh1uyZbQbJ9d
@sgoggins
sgoggins requested a balanced review from Copilot November 22, 2026 13:18
@sgoggins sgoggins self-assigned this Nov 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An active performance finding notes that grouping computes unnecessary 512-component dot products even when perceptual hashes already satisfy the grouping rule.

1 open issue
What changed in this PR

This PR expands Archivis’s duplicate grouping to include highly similar shots from the same scene and adds album-scoped Bursts and Duplicates views.

Changes:

  • Adds configurable visual similarity for stacking, joins stacks with identical-copy sets, and triggers regrouping when rules change.
  • Adds album tabs with scoped groups, preserved filters, breadcrumbs, and album-local Reset links.
  • Updates settings, documentation, and tests for the new grouping and navigation behavior.
File Description
README.md Summarizes visual and album-scoped duplicate detection.
internal/​web/​web.go Updates duplicate terminology on photo pages.
internal/​web/​web_test.go Adjusts photo-page heading assertions.
internal/​web/​templates/​settings.html Adds the visual similarity setting and guidance.
internal/​web/​templates/​photo.html Relabels and explains duplicate sets.
internal/​web/​templates/​layout.html Adds shared album navigation and updates grouping notices.
internal/​web/​templates/​duplicates.html Displays album context and revised duplicate semantics.
internal/​web/​templates/​bursts.html Displays album context for bursts.
internal/​web/​templates/​albums.html Adds album view tabs.
internal/​web/​static/​app.css Styles album tabs and their active state.
internal/​web/​settings.go Exposes similarity limits and logs setting changes.
internal/​web/​groups.go Scopes group pages and Reset links to albums.
internal/​web/​albums.go Shares album resolution and builds tab links.
internal/​web/​album_groups_test.go Tests album group views and similarity settings.
internal/​store/​store.go Updates comments describing duplicate membership.
internal/​store/​similar_test.go Tests similarity stacking and merged duplicate sets.
internal/​store/​settings.go Adds similarity defaults, validation, and accessors.
internal/​store/​settings_test.go Tests similarity persistence and valid ranges.
internal/​store/​groups.go Implements visual grouping, merged duplicates, and album query selection.
internal/​store/​groups_test.go Updates reference grouping and existing stack tests.
DEPLOY.md Documents similarity settings and album group views.
cmd/​archivis/​settings.go Documents the new CLI setting.
cmd/​archivis/​settings_test.go Tests CLI similarity setting behavior.
cmd/​archivis/​main.go Updates groups command help terminology.
cmd/​archivis/​groups.go Updates group help and failure-message terminology.

Review effort: Balanced

Comment thread internal/store/groups.go Resolved
alike accepts a pair when either rule does, so testing the cheap hash
rule first gives the same stacks and skips the 512-component dot
product whenever the hashes already match (identical copies, RAW and
JPEG pairs). A chunk of 1000 identical copies now stacks in about
107 us instead of about 460 us.

TestAlikeEitherRule checks alike against both rules on random pairs
covering every combination; BenchmarkStackFramesCopies measures the
copies case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WwontTm7iEMh1uyZbQbJ9d

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Center-cropped CLIP embeddings can cause substantially different photos to be labelled as duplicates and hidden without a full-frame check.

1 open issue
2 previously missed issues

In code that hasn't changed since last review

Medium severity Skip visual stacking for photos with unknown cameras

internal/​store/​groups.go:626

Dated photos with no camera metadata share the same scene key, and this now loads embeddings for them too. Unrelated exports minutes apart can therefore be stacked and hidden solely on visual similarity, despite the one-camera scene rule. Skip the visual comparison for unknown cameras while retaining the hash fallback.

Medium severity Preserve album search when switching group tabs

internal/​web/​albums.go:436

Switching from an album search to Bursts or Duplicates drops q because carried excludes it, so clicking Photos again shows the unsearched album. Preserve the search text in the tab links as navigation state; the group handlers can continue ignoring it when listing groups.

1 resolved since last review

Review effort: Max

Comment thread internal/store/groups.go Resolved
…lbum search across tabs

CLIP sees only the centre square of a frame, so a match on looks alone
(hashes far apart) now also needs both shots' sizes known, neither
wider than 2:1 (the crop covers at least half of each frame) and their
shapes within 10% of each other, whichever way up. Panoramas, mixed
shapes and shots of unknown size stack by their hashes only.

Dated photos without a camera share one "scene", so exports and scans
minutes apart no longer stack on looks; their hashes still may, and
exact copies are still duplicates anywhere. Groups version 8 regroups.

An album's search text now rides along on its Bursts and Duplicates
tabs, their filter form and Reset, so the Photos tab brings the search
back; the group pages still ignore it when listing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WwontTm7iEMh1uyZbQbJ9d

Copy link
Copy Markdown
Contributor Author

On review 6013195542. Its two "previously missed" points have no threads, so I'm answering them here. Both were real, and both are fixed in 5942da6.

Photos without a camera stacking on looks (groups.go:626): dated photos with no make or model are keyed as one camera, so exports or scans minutes apart shared a "scene". chunkDetails now drops their embeddings before stacking. Their hashes still stack them as before, and exact copies are still duplicates anywhere. TestSimilarShotsAreDuplicates adds two camera-less shots a minute apart with like embeddings; they stay apart. The test fails without the change, as does TestSimilarGroupsMatchReference.

Album search lost across tabs (albums.go:436): the tabs now carry the album's search text to Bursts and Duplicates. Those pages still ignore it when listing groups, but keep it in their filter form, Reset link and Photos tab, so coming back restores the search. TestAlbumBurstsAndDuplicates covers the trip and checks the search doesn't narrow the sets. It fails without the change.

The high-severity centre-crop point is answered on its thread.


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the documented grouping, album-navigation, settings, and terminology changes.

No open issues 🎉

1 resolved since last review

Review effort: Lite

@sgoggins
sgoggins merged commit 92128e4 into main Nov 26, 2026
10 checks passed
@sgoggins sgoggins mentioned this pull request Nov 26, 2026
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.

3 participants