Does the randomisation process weight more recent photos more heavily? #76
Replies: 12 comments 33 replies
-
|
I don't believe it does. I use the Immich |
Beta Was this translation helpful? Give feedback.
-
|
That does make sense, although it would give months with less photos a higher frequency/likligood than they deserve. Eg if January 2024 has only 1 photo, but every other month from 2023 to 2024 (eg 20 months) had 1000 in each, then there’s a 1 in 20 chance you choose January 2024, and when you choose that month you have to serve up that same image. Despite the fact that there’s actually 20,001 images you would see the same image once every 20.
Of course, that’s an extreme example but something approaching that could occur.
How do you handle multiple personIDs?
a similar thing may happen there too, as you’d be bucketing based on uneven numbers but giving the buckets even weight.
Is this a big deal? Not really, it’ll probably be ok! But the better way is for Immich Core code to offer a true randomized asset with particular inclusion criteria (person ID/s or album IDs or dates etc)
…----- Original message -----
From: "Damon - notifications at github.com" ***@***.***>
To: "damongolding/immich-kiosk - immich-kiosk at noreply.github.com" ***@***.***>
Cc: semiligneous ***@***.***>, "Author - author at noreply.github.com" ***@***.*** ***@***.***>>
Subject: Re: [damongolding/immich-kiosk] Does the randomisation process weight more recent photos more heavily? (Discussion #76)
Date: Thursday, 12 September 2024 19:38
I have already reached out to the creator of ImmichFrame to ask how he deals with this issue but I have already found a solution. I just need to implement it.
My intended implementation:
• You can get a list/buckets of a persons assets broken down into months (a timestamp is given). I would probably cache this response.
• Then we would grab one of these months at random, then retrieve the bucket of assets.
• Randomise those assets and retrieve the first asset that matches the users criteria (this logic already exists in Kiosk)
• Finally grab the images raw data and serve it up.
—
Reply to this email directly, view it on GitHub <#76 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AOYQN4JG3J63A3W3SIPVROTZWFOIXAVCNFSM6AAAAABN6U5OMCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANRSGQYTONY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
I'm not sure if this is a real problem, but what if a month has > 1000 assets? If that's the case, months probably wouldn't be the hoped-for solution. Per this this immich discussion it appears that the recommended move to go > 1000 entries is to use the search-metadata API call, as it can be paginated. (Why isn't everything paginated is a good question. :)) Not sure if this helps, but thought I'd throw it out there. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for this. It’s good to know that personsID is AND, as I thought it was OR. My main issue with this route (which will be super easy in Go) is do I cache the results, as that could be a lot of data. I guess I could store a number of filtered results and when those run out repeat the process 🤔
…On 12 Sep 2024 at 8:56 PM +0100, jschwalbe ***@***.***>, wrote:
FWIW I did some playing around with it and was able to generate results using search-metadata with input of personIds (but haven't figured out a way to pull an album, which may not even be a problem).
curl -L '$IP:$PORT/api/search/metadata' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'x-api-key: $API_KEY' -d '{
"personIds" : [ "$PERSON_ID1", "$PERSON_ID2" ], "page": $PAGE, "size": 1000
}'
Of note: personIds is ANDed, so if $PERSON_ID1 and $PERSON_ID2 are not both identified in the same picture, zero items are returned. You'd need two separate API calls to get all pictures with $PERSON_ID1 and all pictures with $PERSON_ID2. I assume that would be the plan unless a config option was changed.
The very end of the output contains "nextpage" which is either a number or null. Also, $PAGE starts at 1, not 0.
Randomizing is up to you from here :)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
I think that’s my fundamental point: at some point, with larger enough albums or people or whatever, you end up needing to potentially cache a lot of data just to serve up one random photo!
It seems inefficient overall, for what really should be a lightweight client.
From my point of view, working directly with Alex and the core Immich team to see if you can update the the getRandom endpoint to be more customizable would benefit ImmichFrame, Immich-Kiosk and other future projects. And would be a far more efficient and elegant solution overall!
|
Beta Was this translation helpful? Give feedback.
-
|
I'm preparing a pull request for immich that works on the My question, @damongolding, and maybe I could make this a new discussion, is how do you handle the case where someone has a face and an album defined? Do you alternate between each source, or something different? Seems like there is never going to be a way to ask immich for a random asset from 3 different buckets (even with my changes). |
Beta Was this translation helpful? Give feedback.
-
|
If a user had a person and an album ID set, they are all put into a slice/array and one is picked at random. Depending on the “type” Kiosk then goes about fetching the asset. I did try going down the path of trying to satisfy both ids at the start of Kiosk i.e. find a album image with person in but that wasn’t a good idea lol
…On 14 Sep 2024 at 7:41 PM +0100, jschwalbe ***@***.***>, wrote:
I'm preparing a pull request for immich that works on the searchMetadata function here. The new code, if approved and merged, would allow for data to be sorted randomly. (Currently it appears to be sorted by fileCreatedAt date.)
My question, @damongolding, and maybe I could make this a new discussion, is how do you handle the case where someone has a face and an album defined? Do you alternate between each source, or something different? Seems like there is never going to be a way to ask immich for a random asset from 3 different buckets (even with my changes).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Out of curiosity does your pull request make alterations to the `order` param or does it add a new one?
…On 14 Sep 2024 at 7:41 PM +0100, jschwalbe ***@***.***>, wrote:
I'm preparing a pull request for immich that works on the searchMetadata function here. The new code, if approved and merged, would allow for data to be sorted randomly. (Currently it appears to be sorted by fileCreatedAt date.)
My question, @damongolding, and maybe I could make this a new discussion, is how do you handle the case where someone has a face and an album defined? Do you alternate between each source, or something different? Seems like there is never going to be a way to ask immich for a random asset from 3 different buckets (even with my changes).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
@semiligneous @jschwalbe do you fancy testing the beta of Kiosk 0.10.0 for me? I have implemented some asset weighting. So if you have 2 album IDs in which one has 1 image and the other has 1000. In 0.10.0 you shouldn't see the album with 1 image 50%(ish) of the time anymore. The beta docker image is |
Beta Was this translation helpful? Give feedback.
-
|
Sorry I didn't get a chance to test it, but it sounds like it passed! BTW: here's my PR for immich; currently in litigation. |
Beta Was this translation helpful? Give feedback.
-
|
If they want to add filters to the randomApi endpoint then it’s a huge win.
…On 19 Sep 2024 at 2:18 PM +0100, jschwalbe ***@***.***>, wrote:
I made the changes they requested, and was prepared to push them, but then I was chatting with the immich devs and they wanted to do something different still! So I may try to do the next different thing, or let them do it. But it's on their radar at least :)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
The v2 package doesn’t require seeding as it’s done automatically.
…On 5 Sep 2025 at 3:22 PM +0100, nadimz ***@***.***>, wrote:
> This is due to the stats being the same each reload/asset grab. I put this down to the "Gambler's Fallacy" concept.
Makes sense :).
By the way, I noticed that math/rand/v2 is not seeded before being used. To be fair, I haven't noticed predictable image picks.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Everything works fine, I have kiosk set up to display photos of particular people (the kids). The photos that are shown seem to all be from the last few months, occasionally older, but rarely from before May 2024 it seems . Of course, maybe I missed one but I reduced the refresh to 5 seconds and watched a while!
If I change the person to someone else, who I only have older photos for, I see the older photos. So I have 2 hypotheses:
The randomisation deliberately weights more recent photos. If so, that is sensible, but I'd like to control it somewhat as it seems too weighed to recent ones.
the search process to get a random photo somehow only returns a subset of the possible photos, and the order is accidentally done by date.
I do have a lot of photos for these faces, 7,000 for one and 17,000 for the other in immich stretching back multiple years.
Any thoughts?
Beta Was this translation helpful? Give feedback.
All reactions