Smart slideshow clustering for Immich#341
Open
artyfarty wants to merge 2 commits into
Open
Conversation
Temporal clustering of the Immich asset pool: sort by localDateTime, group assets within a configurable gap, play one random representative per cluster. Bursts and photo-heavy single events collapse to one slot each so they don't dominate against long-span collection albums. Albums matching an optional regex (e.g. film scans, where timestamps are scanning-session artefacts) bypass clustering and are sampled by a configurable keep-percent. Settings live under a new "Smart slideshow" category in the Immich source screen; disabled by default. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
P.S. i will rpobably iterate on this project more in following days as i accumulate experience on how well it works. When developing we were creating simulated sets as webpages to find usable clusterisation parameters. Maybe i'll make it so every display of a slot uses random member of the cluster. Also i already implemented an auto refresh in another branch, because slideshow may run for weeks on my TV. Anyway, feedback will be appreciated. |
Previously the smart slideshow picked one representative per temporal
cluster at fetch time and froze that choice for the lifetime of the
playlist — across an entire session the same cluster always showed the
same photo, with the other members completely hidden until the next
provider refresh.
Now every cluster's other members travel with the representative on the
AerialMedia object (new `clusterAlternates: List<Uri>` field). When the
slot comes up for rendering, ImagePlayerView picks one of
{primary} ∪ {alternates} uniformly at random. Over repeated playlist
loops the user sees the whole cluster rotate through the same slot,
while the clustering's airtime-evening effect on album-vs-album mix is
preserved.
Attached metadata (album name, source pool, date, location) stays that
of the representative — cluster members are by definition within a
small time/location window so the numbers remain representative enough
for overlay captions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Added in-slot randomizer |
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.
Hey, i'm not sure how useful / fitting this PR as is, and the settings that regulate this sort system may not be very intuitive for broader audience. Concept is mine, implementaion - entirely vibe coded, but it seems to work well for my case. Feel free to review it, or just reuse the concepts in future versions.
Summary
Adds an optional Smart slideshow mode for the Immich provider that evens out playback when you've selected a mix of single-day event albums and long-span collection albums.
The problem this solves: with the current flat random, a 1000-photo vacation album drowns out a 50-photo themed collection because randomization has no notion of "one event = one moment". Burst sequences (several shots seconds apart) further compound the issue by occupying consecutive slideshow slots with near-duplicate frames.
What it does
Inside the Immich provider, before mapping assets to
AerialMedia:localDateTime, group consecutive assets when the gap is below a user-configurable threshold (default 30 min, options 1/10/30/60/360/1440). One random representative per cluster survives into the playlist. Clusters get re-randomized each fetch, so across sessions the user still sees the non-representative frames.dateTimeOriginalreflects the scan session, not the actual shoot time, and would collapse an entire roll into one slot. Default empty (opt-in).All three knobs live under a new "Smart slideshow"
PreferenceCategoryon the Immich source screen. Feature is off by default — existing playback behaviour is unchanged for anyone who doesn't opt in.Files
providers/immich/ImmichClusterer.kt— the algorithm (pure, ~90 LOC, testable)providers/immich/ImmichMediaProvider.kt— call site, gates on new prefmodels/prefs/ImmichMediaPrefs.kt— three new prefsres/xml/sources_immich_videos.xml— new PreferenceCategoryres/values/arrays.xml+strings.xml— UI strings and entriesTest plan
localDateTime(falls through to a separate un-dated bucket, returned verbatim).Notes
Scope kept intentionally narrow to the Immich pipeline. The clusterer is a pure function and safe to ignore for other providers. A follow-up PR will add DATE_TIME_TAKEN and SOURCE_POOL overlay tags + optional periodic playlist refresh (see #TBD).