DarianT commited on
Commit
97797b4
·
1 Parent(s): 70854e0

Upload example images

Browse files
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  import numpy as np
3
  import random
4
  import spaces # Uncomment if using ZeroGPU
5
-
6
  from diffusers import StableDiffusionPipeline, DDPMScheduler
7
  import torch
8
 
@@ -21,12 +21,14 @@ folder_of_lora_weights = "./ID-Booth_LoRA_weights"
21
  which_checkpoint = "checkpoint-31-6400"
22
  lora_name = "pytorch_lora_weights.safetensors"
23
 
 
 
24
 
25
  backgrounds_list = ["forest", "city street", "beach", "office", "bus", "laboratory", "factory", "construction site", "hospital", "night club", ""]
26
  poses_list = ["portrait", "side-portrait"]
27
- id_list = ["ID_0", "ID_1", "ID_2"]
28
 
29
- gender_dict = {"ID_0": "male", "ID_1": "male", "ID_2": "female", "ID_2": "male"}
30
  MAX_SEED = 10000
31
  image_size = 512
32
 
@@ -85,6 +87,32 @@ with gr.Blocks(css=css) as demo:
85
  with gr.Column(elem_id="col-container"):
86
  gr.Markdown(" # ID-Booth Demo")
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  with gr.Row():
89
  which_id = gr.Dropdown(
90
  label="Identity",
 
2
  import numpy as np
3
  import random
4
  import spaces # Uncomment if using ZeroGPU
5
+ import os
6
  from diffusers import StableDiffusionPipeline, DDPMScheduler
7
  import torch
8
 
 
21
  which_checkpoint = "checkpoint-31-6400"
22
  lora_name = "pytorch_lora_weights.safetensors"
23
 
24
+ selected_identity = gr.State(value="ID_0") # Default selection
25
+ folder_of_identity_images = "./assets/example_images/"
26
 
27
  backgrounds_list = ["forest", "city street", "beach", "office", "bus", "laboratory", "factory", "construction site", "hospital", "night club", ""]
28
  poses_list = ["portrait", "side-portrait"]
29
+ id_list = ["ID_0", "ID_1", "ID_2", "ID_3"]
30
 
31
+ gender_dict = {"ID_1": "male", "ID_5": "male", "ID_16": "female", "ID_20": "male"}
32
  MAX_SEED = 10000
33
  image_size = 512
34
 
 
87
  with gr.Column(elem_id="col-container"):
88
  gr.Markdown(" # ID-Booth Demo")
89
 
90
+ with gr.Row():
91
+ #gr.Markdown("### Choose an Identity:")
92
+ identity_selectors = []
93
+
94
+ for id in id_list:
95
+ btn = gr.Image(
96
+ value=os.path.join(folder_of_identity_images, id + ".jpg"),
97
+ label=id,
98
+ interactive=True,
99
+ height=128,
100
+ width=128,
101
+ )
102
+ identity_selectors.append(btn)
103
+
104
+ # Set up click handlers
105
+ def select_identity(id):
106
+ return id
107
+
108
+ for btn, identity in zip(identity_selectors, folder_of_identity_images):
109
+ btn.select(
110
+ select_identity,
111
+ inputs=[],
112
+ outputs=[selected_identity],
113
+ _js=f"() => '{identity}'"
114
+ )
115
+
116
  with gr.Row():
117
  which_id = gr.Dropdown(
118
  label="Identity",
assets/example_images/ID_1.jpg ADDED
assets/example_images/ID_16.jpg ADDED
assets/example_images/ID_20.jpg ADDED
assets/example_images/ID_5.jpg ADDED