ChenyangSi Wauplin HF staff commited on
Commit
ee59508
1 Parent(s): c4cf9eb

[Feature] Add User history (#5)

Browse files

- [Feature] Add User history (00d5d79e86d537b53c780c310b2fd7844023a138)
- Update README.md (a5d9316ae94fabc5582c2436c483f276d5f6e66f)
- Update requirements.txt (ad9844afd88e673012943650288abca23f71b01e)


Co-authored-by: Lucain Pouget <[email protected]>

Files changed (3) hide show
  1. README.md +1 -0
  2. app.py +11 -3
  3. requirements.txt +3 -1
README.md CHANGED
@@ -7,6 +7,7 @@ sdk: gradio
7
  sdk_version: 3.44.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
7
  sdk_version: 3.44.0
8
  app_file: app.py
9
  pinned: false
10
+ hf_oauth: true
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -4,7 +4,7 @@ import torch
4
 
5
  from diffusers import DiffusionPipeline
6
  from free_lunch_utils import register_free_upblock2d, register_free_crossattn_upblock2d
7
-
8
 
9
 
10
  model_id = "stabilityai/stable-diffusion-2-1"
@@ -21,7 +21,7 @@ sd_options_prev = None
21
  seed_prev = None
22
  sd_image_prev = None
23
 
24
- def infer(prompt, sd_options, seed, b1, b2, s1, s2):
25
  global prompt_prev
26
  global sd_options_prev
27
  global seed_prev
@@ -65,6 +65,9 @@ def infer(prompt, sd_options, seed, b1, b2, s1, s2):
65
  # First SD, then freeu
66
  images = [sd_image, freeu_image]
67
 
 
 
 
68
  return images
69
 
70
 
@@ -209,7 +212,12 @@ with block:
209
  maximum=1000,
210
  step=1,
211
  value=42)
212
-
 
 
 
 
 
213
  with gr.Row():
214
  with gr.Group():
215
  # btn = gr.Button("Generate image", scale=0)
 
4
 
5
  from diffusers import DiffusionPipeline
6
  from free_lunch_utils import register_free_upblock2d, register_free_crossattn_upblock2d
7
+ import gradio_user_history as gr_user_history
8
 
9
 
10
  model_id = "stabilityai/stable-diffusion-2-1"
 
21
  seed_prev = None
22
  sd_image_prev = None
23
 
24
+ def infer(prompt, sd_options, seed, b1, b2, s1, s2, profile: gr.OAuthProfile | None):
25
  global prompt_prev
26
  global sd_options_prev
27
  global seed_prev
 
65
  # First SD, then freeu
66
  images = [sd_image, freeu_image]
67
 
68
+ gr_user_history.save_image(label=prompt + ' (SD)', image=sd_image, profile=profile, metadata={"prompt": prompt, "pipe": sd_options, "b1": 1.0, "b2": 1.0, "s1": 1.0, "s2": 1.0})
69
+ gr_user_history.save_image(label=prompt + ' (FreeU)', image=freeu_image, profile=profile, metadata={"prompt": prompt, "pipe": "freeu", "b1": b1, "b2": b2, "s1": s1, "s2": s2})
70
+
71
  return images
72
 
73
 
 
212
  maximum=1000,
213
  step=1,
214
  value=42)
215
+
216
+ with gr.Group():
217
+ with gr.Row():
218
+ with gr.Accordion("Past generations", open=False):
219
+ gr_user_history.render()
220
+
221
  with gr.Row():
222
  with gr.Group():
223
  # btn = gr.Button("Generate image", scale=0)
requirements.txt CHANGED
@@ -5,4 +5,6 @@ xformers==0.0.21
5
  git+https://github.com/huggingface/open-muse.git@patrickvonplaten-patch-1
6
 
7
  --extra-index-url https://download.pytorch.org/whl/cu118
8
- torch
 
 
 
5
  git+https://github.com/huggingface/open-muse.git@patrickvonplaten-patch-1
6
 
7
  --extra-index-url https://download.pytorch.org/whl/cu118
8
+ torch
9
+
10
+ git+https://huggingface.co/spaces/Wauplin/gradio-user-history