CoolFace
Apppublic

Wauplin/gradio-user-history

sourceHugging Faceupdated 2y agoView on Hugging Face
24likes
App README

Bring User History to your Spaces ๐Ÿš€

Gradio User History is a plugin (and package) that caches generated images for your Space users.

Key features:

  • โ€”๐Ÿค— Sign in with Hugging Face
  • โ€”Save generated images with their metadata: prompts, timestamp, hyper-parameters, etc.
  • โ€”Export your history as zip.
  • โ€”Delete your history to respect privacy.
  • โ€”Compatible with Persistent Storage for long-term storage.
  • โ€”Admin panel to check configuration and disk usage .

Want more? Please open an issue in the Community Tab! This is meant to be a community-driven implementation, enhanced by user feedback and contributions!

Integration

Integrate Gradio User History in just a few steps:

1. Enable OAuth to your Space

Simply edit your Space metadata in your README.md file:

yaml
# README.md
hf_oauth: true

2. Update your `requirements.txt`

bash
# requirements.txt
git+https://huggingface.co/spaces/Wauplin/gradio-user-history

3. Integrate into your Gradio app

py
# app.py
import gradio as gr
import gradio_user_history as gr_user_history
(...)

# => Inject gr.OAuthProfile
def generate(prompt: str, profile: gr.OAuthProfile | None):
    image = ...

    # => Save generated image(s)
    gr_user_history.save_image(label=prompt, image=image, profile=profile)
    return image


# => Render user history
with gr.Blocks() as demo:
    (...)

    with gr.Accordion("Past generations", open=False):
        gr_user_history.render()

4. (optional) Add Persistent Storage in your Space settings. Persistent Storage is suggested but not mandatory. If not enabled, the history is lost each time the Space restarts.

And you're done!

Useful links

  • โ€”Demo: https://huggingface.co/spaces/Wauplin/gradio-user-history
  • โ€”README: https://huggingface.co/spaces/Wauplin/gradio-user-history/blob/main/README.md
  • โ€”Source file: https://huggingface.co/spaces/Wauplin/gradio-user-history/blob/main/src/gradiouserhistory/userhistory.py
  • โ€”Questions and feedback: https://huggingface.co/spaces/Wauplin/gradio-user-history/discussions

Preview

Image preview