To fix the 9th floor screensaver demo, following changes are implemented:
In the new implementation, the openrtist client.py writes style-transferred image stream to a linux pipe. A screensaver script launches mpv to display images from the pipe. When the screensaver script is killed (due to user wake-up or switching among screensavers), mpv no longer reads from the pipe and the pipe becomes broken. client.py exits gracefully due to pipe broken error.
stream_for_screensaver.py will re-launch client.py after it exits. client.py would wait for a pipe reader, before writing style-transferred stream into the pipe. Such exit-and-launch loop is used to make sure no single image is half written/read. Since we are not encoding the image, there is no way to know in the program if an image is half written/read.
client.py used to have a queue without explicit capacity that holds the results that have not been displayed. This behavior goes against the intuition that we only care about the most recent frame. I've modified the queue to have a capacity of 1, so that undisplayed results will be overwritten once a new frame comes.
It does not make sense to hard code the openrtist server ip into config.py. config.py should better be used for parameters that do not usually change. I moved the server ip into a cmd argument.
To fix the 9th floor screensaver demo, following changes are implemented: