Spaces:
Running
on
Zero
Running
on
Zero
Update id selector
Browse files
app.py
CHANGED
@@ -34,7 +34,7 @@ image_size = 512
|
|
34 |
|
35 |
@spaces.GPU # Uncomment if using ZeroGPU
|
36 |
def infer(
|
37 |
-
|
38 |
background,
|
39 |
pose,
|
40 |
negative_prompt,
|
@@ -46,7 +46,7 @@ def infer(
|
|
46 |
num_images=1
|
47 |
):
|
48 |
|
49 |
-
full_lora_weights_path = f"{folder_of_lora_weights}/{
|
50 |
pipe.load_lora_weights(full_lora_weights_path)
|
51 |
|
52 |
if randomize_seed:
|
@@ -55,7 +55,7 @@ def infer(
|
|
55 |
generator = torch.Generator().manual_seed(seed)
|
56 |
|
57 |
id = "ID_0"
|
58 |
-
gender = gender_dict[
|
59 |
|
60 |
# Construct prompt from dropdown selections
|
61 |
prompt = f"face {pose.lower()} photo of {gender} sks person, {background.lower()} background"
|
@@ -87,38 +87,54 @@ with gr.Blocks(css=css) as demo:
|
|
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 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
# Set up click handlers
|
105 |
-
def select_identity(id):
|
106 |
-
|
107 |
-
|
108 |
-
for btn, identity in zip(identity_selectors, folder_of_identity_images):
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
)
|
115 |
|
116 |
with gr.Row():
|
117 |
-
which_id = gr.Dropdown(
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
)
|
122 |
|
123 |
background = gr.Dropdown(
|
124 |
label="Background",
|
|
|
34 |
|
35 |
@spaces.GPU # Uncomment if using ZeroGPU
|
36 |
def infer(
|
37 |
+
selected_identity,
|
38 |
background,
|
39 |
pose,
|
40 |
negative_prompt,
|
|
|
46 |
num_images=1
|
47 |
):
|
48 |
|
49 |
+
full_lora_weights_path = f"{folder_of_lora_weights}/{selected_identity}/{which_checkpoint}/{lora_name}"
|
50 |
pipe.load_lora_weights(full_lora_weights_path)
|
51 |
|
52 |
if randomize_seed:
|
|
|
55 |
generator = torch.Generator().manual_seed(seed)
|
56 |
|
57 |
id = "ID_0"
|
58 |
+
gender = gender_dict[selected_identity]
|
59 |
|
60 |
# Construct prompt from dropdown selections
|
61 |
prompt = f"face {pose.lower()} photo of {gender} sks person, {background.lower()} background"
|
|
|
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 |
+
|
93 |
with gr.Row():
|
94 |
#gr.Markdown("### Choose an Identity:")
|
95 |
identity_selectors = []
|
96 |
|
97 |
+
def make_identity_selector(identity, image_path):
|
98 |
+
with gr.Column():
|
99 |
+
img = gr.Image(value=image_path, show_label=False, interactive=False, width=128, height=128)
|
100 |
+
btn = gr.Button(value=f"Select {identity}")
|
101 |
+
btn.click(
|
102 |
+
fn=lambda: (identity, identity),
|
103 |
+
inputs=[],
|
104 |
+
outputs=[selected_identity],
|
105 |
+
)
|
106 |
+
|
107 |
+
for identity in id_list:
|
108 |
+
image_path = os.path.join(folder_of_identity_images, identity + ".jpg")
|
109 |
+
make_identity_selector(identity, image_path)
|
110 |
+
|
111 |
+
# for id in id_list:
|
112 |
+
# btn = gr.Image(
|
113 |
+
# value=os.path.join(folder_of_identity_images, id + ".jpg"),
|
114 |
+
# label=id,
|
115 |
+
# interactive=True,
|
116 |
+
# height=128,
|
117 |
+
# width=128,
|
118 |
+
# )
|
119 |
+
# identity_selectors.append(btn)
|
120 |
|
121 |
# Set up click handlers
|
122 |
+
# def select_identity(id):
|
123 |
+
# return id
|
124 |
+
|
125 |
+
# for btn, identity in zip(identity_selectors, folder_of_identity_images):
|
126 |
+
# btn.select(
|
127 |
+
# select_identity,
|
128 |
+
# inputs=[],
|
129 |
+
# outputs=[selected_identity],
|
130 |
+
# )
|
|
|
131 |
|
132 |
with gr.Row():
|
133 |
+
# which_id = gr.Dropdown(
|
134 |
+
# label="Identity",
|
135 |
+
# choices=id_list,
|
136 |
+
# value=id_list[0],
|
137 |
+
# )
|
138 |
|
139 |
background = gr.Dropdown(
|
140 |
label="Background",
|