ujin-song commited on
Commit
f619b74
1 Parent(s): 35aa53a

update app.py

Browse files

1st modification for public

Files changed (1) hide show
  1. app.py +83 -69
app.py CHANGED
@@ -182,7 +182,7 @@ examples_context = [
182
  'in front of Eiffel tower'
183
  ]
184
 
185
- examples_region1 = ['wearing red hat, high resolution, best quality','bright smile, wearing pants, best quality']
186
  examples_region2 = ['smilling, wearing blue shirt, high resolution, best quality']
187
 
188
  with open('multi-concept/pose_data/pose.json') as f:
@@ -199,62 +199,91 @@ css="""
199
  with gr.Blocks(css=css) as demo:
200
  gr.Markdown(f"""
201
  # Orthogonal Adaptation
202
- Currently running on : {power_device}
 
 
203
  """)
204
 
205
  with gr.Row():
206
- with gr.Column(elem_id="col-container", scale=2):
 
207
  gr.Markdown(f"""
208
- ### 🕹️ Global and Region prompts:
209
  """)
210
-
211
- prompt = gr.Text(
212
- label="ContextPrompt",
213
- show_label=False,
214
- max_lines=1,
215
- placeholder="Enter your context(global) prompt",
216
- container=False,
217
- )
218
- with gr.Row():
219
 
220
- region1_concept = gr.Dropdown(
221
- ["Elsa", "Moana"],
222
- label="Character 1",
223
- info="Will add more characters later!"
224
- )
225
- region2_concept = gr.Dropdown(
226
- ["Elsa", "Moana"],
227
- label="Character 2",
228
- info="Will add more characters later!"
229
- )
230
 
231
- with gr.Row():
 
 
 
 
 
 
 
 
 
 
 
232
 
233
- region1_prompt = gr.Textbox(
234
- label="Region1 Prompt",
235
- show_label=False,
236
- max_lines=2,
237
- placeholder="Enter your regional prompt for character 1",
238
- container=False,
239
- )
240
 
241
- region2_prompt = gr.Textbox(
242
- label="Region2 Prompt",
243
- show_label=False,
244
- max_lines=2,
245
- placeholder="Enter your regional prompt for character 2",
246
- container=False,
247
- )
248
 
249
- gr.Markdown(f"### 🧭 Spatial Condition for regionally controllable sampling: ")
250
- gallery = gr.Gallery(label = "Select pose for characters",
251
- value = [obj[1]for obj in pose_image_list],
252
- elem_id = [obj[0]for obj in pose_image_list],
253
- interactive=False, show_download_button=False,
254
- preview=True, height = 200, object_fit="scale-down")
255
-
256
- pose_image_id = gr.Textbox(visible=False)
257
- gallery.select(on_select, None, pose_image_id)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
  run_button = gr.Button("Run", scale=1)
260
 
@@ -301,30 +330,15 @@ with gr.Blocks(css=css) as demo:
301
  step= 0.01,
302
  value=1.0,
303
  )
304
-
305
- with gr.Column(scale=1):
306
-
307
- gr.Examples(
308
- label = 'Global Prompt example',
309
- examples = examples_context,
310
- inputs = [prompt]
311
- )
312
-
313
- with gr.Row():
314
- gr.Examples(
315
- label = 'Region1 Prompt example',
316
- examples = examples_region1,
317
- inputs = [region1_prompt]
318
- )
319
-
320
- gr.Examples(
321
- label = 'Region2 Prompt example',
322
- examples = [examples_region2],
323
- inputs = [region2_prompt]
324
- )
325
-
326
  result = gr.Image(label="Result", show_label=False)
327
 
 
 
 
 
 
328
  run_button.click(
329
  fn = generate,
330
  inputs = [region1_concept,
 
182
  'in front of Eiffel tower'
183
  ]
184
 
185
+ examples_region1 = ['wearing red hat, high resolution, best quality']
186
  examples_region2 = ['smilling, wearing blue shirt, high resolution, best quality']
187
 
188
  with open('multi-concept/pose_data/pose.json') as f:
 
199
  with gr.Blocks(css=css) as demo:
200
  gr.Markdown(f"""
201
  # Orthogonal Adaptation
202
+ Describe your world with a **🪄 text prompt (global and local)** and choose two characters to merge.
203
+ Select their **👯 poses (spatial conditions)** for regionally controllable sampling to generate a unique image using our model.
204
+ Let your creativity run wild! (Currently running on : {power_device} )
205
  """)
206
 
207
  with gr.Row():
208
+ with gr.Column(elem_id="col-container"):
209
+
210
  gr.Markdown(f"""
211
+ ### 🪄 Global and Region prompts
212
  """)
213
+ with gr.Group():
214
+ prompt = gr.Text(
215
+ label="ContextPrompt",
216
+ show_label=False,
217
+ max_lines=1,
218
+ placeholder="Enter your global context prompt",
219
+ container=False,
220
+ )
 
221
 
 
 
 
 
 
 
 
 
 
 
222
 
223
+ with gr.Row():
224
+
225
+ region1_concept = gr.Dropdown(
226
+ ["Elsa", "Moana"],
227
+ label="Character 1",
228
+ info="Will add more characters later!"
229
+ )
230
+ region2_concept = gr.Dropdown(
231
+ ["Elsa", "Moana"],
232
+ label="Character 2",
233
+ info="Will add more characters later!"
234
+ )
235
 
 
 
 
 
 
 
 
236
 
237
+ with gr.Row():
 
 
 
 
 
 
238
 
239
+ region1_prompt = gr.Textbox(
240
+ label="Region1 Prompt",
241
+ show_label=False,
242
+ max_lines=2,
243
+ placeholder="Enter your regional prompt for character 1",
244
+ container=False,
245
+ )
246
+
247
+ region2_prompt = gr.Textbox(
248
+ label="Region2 Prompt",
249
+ show_label=False,
250
+ max_lines=2,
251
+ placeholder="Enter your regional prompt for character 2",
252
+ container=False,
253
+ )
254
+
255
+
256
+ gr.Examples(
257
+ label = 'Global Prompt example',
258
+ examples = examples_context,
259
+ inputs = [prompt]
260
+ )
261
+
262
+ with gr.Row():
263
+ gr.Examples(
264
+ label = 'Region1 Prompt example',
265
+ examples = examples_region1,
266
+ inputs = [region1_prompt]
267
+ )
268
+
269
+ gr.Examples(
270
+ label = 'Region2 Prompt example',
271
+ examples = [examples_region2],
272
+ inputs = [region2_prompt]
273
+ )
274
+
275
+ gr.Markdown(f"""
276
+ ### 👯 Spatial Condition
277
+ """)
278
+ with gr.Group():
279
+ gallery = gr.Gallery(label = "Select pose for characters",
280
+ value = [obj[1]for obj in pose_image_list],
281
+ elem_id = [obj[0]for obj in pose_image_list],
282
+ interactive=False, show_download_button=False,
283
+ preview=True, height = 200, object_fit="scale-down")
284
+
285
+ pose_image_id = gr.Textbox(visible=False)
286
+ gallery.select(on_select, None, pose_image_id)
287
 
288
  run_button = gr.Button("Run", scale=1)
289
 
 
330
  step= 0.01,
331
  value=1.0,
332
  )
333
+
334
+ with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
  result = gr.Image(label="Result", show_label=False)
336
 
337
+ gr.Markdown(f"""
338
+ *Image generation may take longer for the first time you use a new combination of characters. <br />
339
+ This is because the model needs to load weights for each concept involved.*
340
+ """)
341
+
342
  run_button.click(
343
  fn = generate,
344
  inputs = [region1_concept,