DarianT commited on
Commit
d826eac
·
1 Parent(s): 19b9ba3
Files changed (1) hide show
  1. app.py +26 -68
app.py CHANGED
@@ -79,10 +79,11 @@ def infer(
79
  css = """
80
  #col-container {
81
  margin: 0 auto;
82
- max-width: 640px;
83
  }
84
  """
85
 
 
86
  with gr.Blocks(css=css) as demo:
87
  with gr.Column(elem_id="col-container"):
88
  gr.Markdown(" # ID-Booth Demo")
@@ -91,66 +92,22 @@ with gr.Blocks(css=css) as demo:
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):
98
- image_path = os.path.join(folder_of_identity_images, identity + ".jpg")
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
- with gr.Column():
108
- make_identity_selector(id_list[0])
109
-
110
- with gr.Column():
111
- make_identity_selector(id_list[1])
112
-
113
- with gr.Column():
114
- make_identity_selector( id_list[2])
115
-
116
- with gr.Column():
117
- make_identity_selector(id_list[3])
118
-
119
- # with gr.Column():
120
- # identity = id_list[0]
121
- # image_path = os.path.join(folder_of_identity_images, identity + ".jpg")
122
- # make_identity_selector(identity, image_path)
123
- # for identity in id_list:
124
- # image_path = os.path.join(folder_of_identity_images, identity + ".jpg")
125
- # make_identity_selector(identity, image_path)
126
-
127
- # for id in id_list:
128
- # btn = gr.Image(
129
- # value=os.path.join(folder_of_identity_images, id + ".jpg"),
130
- # label=id,
131
- # interactive=True,
132
- # height=128,
133
- # width=128,
134
- # )
135
- # identity_selectors.append(btn)
136
-
137
- # Set up click handlers
138
- # def select_identity(id):
139
- # return id
140
-
141
- # for btn, identity in zip(identity_selectors, folder_of_identity_images):
142
- # btn.select(
143
- # select_identity,
144
- # inputs=[],
145
- # outputs=[selected_identity],
146
- # )
147
 
148
  with gr.Row():
149
- # which_id = gr.Dropdown(
150
- # label="Identity",
151
- # choices=id_list,
152
- # value=id_list[0],
153
- # )
154
 
155
  background = gr.Dropdown(
156
  label="Background",
@@ -165,8 +122,9 @@ with gr.Blocks(css=css) as demo:
165
  )
166
 
167
  run_button = gr.Button("Run", scale=0, variant="primary")
 
 
168
 
169
- result = gr.Image(label="Result", show_label=False)
170
 
171
  with gr.Accordion(open=False, label="Advanced Options"):
172
  negative_prompt = gr.Text(
@@ -206,18 +164,18 @@ with gr.Blocks(css=css) as demo:
206
  randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
207
 
208
 
209
- gr.Examples(
210
- examples=[
211
- [id_list[0], backgrounds_list[0], poses_list[0], "A beautiful photo of a person", 0, False, 512, 512, 7.5, 50],
212
- ],
213
- inputs=[selected_identity, background, pose],
214
- )
215
 
216
  gr.on(
217
  triggers=[run_button.click],
218
  fn=infer,
219
  inputs=[
220
- selected_identity,
221
  background,
222
  pose,
223
  negative_prompt,
@@ -227,7 +185,7 @@ with gr.Blocks(css=css) as demo:
227
  num_inference_steps,
228
  num_images
229
  ],
230
- outputs=[result, seed],
231
  )
232
 
233
  if __name__ == "__main__":
 
79
  css = """
80
  #col-container {
81
  margin: 0 auto;
82
+ max-width: 960px;
83
  }
84
  """
85
 
86
+
87
  with gr.Blocks(css=css) as demo:
88
  with gr.Column(elem_id="col-container"):
89
  gr.Markdown(" # ID-Booth Demo")
 
92
  gr.Markdown("### Choose an Identity:")
93
 
94
  with gr.Row():
95
+ for id in id_list:
96
+ image_path = os.path.join(folder_of_identity_images, id + ".jpg")
97
+ img = gr.Image(value=image_path, label=id,
98
+ width=100, height=164,
99
+ show_label=True, interactive=False,
100
+ show_download_button=False,
101
+ show_fullscreen_button=False,
102
+ )
103
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  with gr.Row():
106
+ identity = gr.Dropdown(
107
+ label="Identity",
108
+ choices=id_list,
109
+ value=id_list[0],
110
+ )
111
 
112
  background = gr.Dropdown(
113
  label="Background",
 
122
  )
123
 
124
  run_button = gr.Button("Run", scale=0, variant="primary")
125
+ # result = gr.Image(label="Result", show_label=False)
126
+ gallery_result = gr.Gallery(label="Generated Images", show_label=False)
127
 
 
128
 
129
  with gr.Accordion(open=False, label="Advanced Options"):
130
  negative_prompt = gr.Text(
 
164
  randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
165
 
166
 
167
+ # gr.Examples(
168
+ # examples=[
169
+ # [id_list[0], backgrounds_list[0], poses_list[0], "A beautiful photo of a person", 0, False, 512, 512, 7.5, 50],
170
+ # ],
171
+ # inputs=[selected_identity, background, pose],
172
+ # )
173
 
174
  gr.on(
175
  triggers=[run_button.click],
176
  fn=infer,
177
  inputs=[
178
+ identity,
179
  background,
180
  pose,
181
  negative_prompt,
 
185
  num_inference_steps,
186
  num_images
187
  ],
188
+ outputs=[gallery_result],
189
  )
190
 
191
  if __name__ == "__main__":