[Feat] Add user history

#4
by Wauplin HF staff - opened

The goal of this PR is to add the possibility for users to store their history. It works using OAuth to authenticate the user and Persistent Storage to store the images. The persistent storage is kept between reboots of the Space and across multiple replicas.

In addition to this PR, a few settings have to be configured:

  • Add a Persistent Storage in the Space settings. 150GB should be enough for now? Worst case scenario, it's possible to increase it to 1TB.
  • Add HISTORY_FOLDER="/data/history" as Space variable

And that should be it!

About the feature itself:

  • if the user is not logged in, the Space works as it is now
  • if the user is logged in, a Gallery will list their past images with the used prompt. At the moment other parameters are not saved with it.
  • if an error happen for any reason, the history gallery stays empty but the rest of the Space still works similarly

Check out this Space to see a live example + screenshots below

EDIT: I updated the layout of the gallery (fixed height 300px, 3 images per row, no preview by default).
EDIT 2:: removed the download button as well

image.png

Wauplin changed pull request title from Upload folder using huggingface_hub to WIP
Wauplin changed pull request title from WIP to Add user history
Wauplin changed pull request title from Add user history to [Feat] Add user history

EDIT: added a message to warn users that we don't commit on keeping their history forever

image.png

dome272 changed pull request status to merged

User history is now live. I'm stopping this demo Space for now.

Sign up or log in to comment