There are a couple of options: use a cookie (reasonably modern browsers have other methods such as Web Storage, but they amount to the same thing), or fingerprint the browser (e.g. with something like fingerprintjs). Each has pros and cons:
Cookie
All you need to do is generate is psuedorandom number on the first visit and store it in a cookie. A cookie can remain unchanged for a long time, until the user manually deletes the cookie, recreates their browser profile, etc. at which point the image will likely change, but a user could reasonably expect to see some changes when they perform one of these actions. Some users may block your cookie altogether - that just means they'll all get the same image. There are some laws governing the use of cookies, particularly in Europe, so if you're not already using one and your site is popular in Europe, you may need to add a disclaimer.
Fingerprint
A fingerprint is created by querying things like the screen resolution, installed plugins, software versions etc. then hashing the result to produce a short number/string that identifies the system - you just need to convert that identifier into a number between 1 and 7. The value will change when any of those parameters changes, however it's not affected by cleaning cookies, nor by the same laws that require disclosure of cookie use in some regions (there may be other laws governing the use of browser fingerprinting).