linoyts HF staff commited on
Commit
7ef9348
1 Parent(s): fb796b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -82
app.py CHANGED
@@ -227,23 +227,10 @@ logo = r"""
227
  <center><img src='https://photo-maker.github.io/assets/logo.png' alt='PhotoMaker logo' style="width:80px; margin-bottom:10px"></center>
228
  """
229
  title = r"""
230
- <h1 align="center">PhotoMaker V2: Improved ID Fidelity and Better Controllability than PhotoMaker V1</h1>
 
231
  """
232
 
233
- description = r"""
234
- <b>Official 🤗 Gradio demo</b> for <a href='https://github.com/TencentARC/PhotoMaker' target='_blank'><b>PhotoMaker: Customizing Realistic Human Photos via Stacked ID Embedding</b></a>.<br>
235
- How to use PhotoMaker V2 can be found in 🎬 <a href='https://photo-maker.github.io/assets/demo_pm_v2_full.mp4' target='_blank'>this video</a> 🎬.
236
- <br>
237
- <br>
238
- For previous version of PhotoMaker, you could use our original gradio demos [PhotoMaker](https://huggingface.co/spaces/TencentARC/PhotoMaker) and [PhotoMaker-Style](https://huggingface.co/spaces/TencentARC/PhotoMaker-Style).
239
- <br>
240
- ❗️❗️❗️[<b>Important</b>] Personalization steps:<br>
241
- 1️⃣ Upload images of someone you want to customize. One image is ok, but more is better. Although we do not perform face detection, the face in the uploaded image should <b>occupy the majority of the image</b>.<br>
242
- 2️⃣ Enter a text prompt, making sure to <b>follow the class word</b> you want to customize with the <b>trigger word</b>: `img`, such as: `man img` or `woman img` or `girl img`.<br>
243
- 3️⃣ Choose your preferred style template.<br>
244
- 4️⃣ <b>(Optional: but new feature)</b> Select the ‘Enable Drawing Doodle...’ option and draw on the canvas<br>
245
- 5️⃣ Click the <b>Submit</b> button to start customizing.
246
- """
247
 
248
  article = r"""
249
 
@@ -283,9 +270,9 @@ css = '''
283
  .gradio-container {width: 85% !important}
284
  '''
285
  with gr.Blocks(css=css) as demo:
286
- gr.Markdown(logo)
287
  gr.Markdown(title)
288
- gr.Markdown(description)
289
  # gr.DuplicateButton(
290
  # value="Duplicate Space for private use ",
291
  # elem_id="duplicate-button",
@@ -300,27 +287,76 @@ with gr.Blocks(css=css) as demo:
300
  uploaded_files = gr.Gallery(label="Your images", visible=False, columns=5, rows=1, height=200)
301
  with gr.Column(visible=False) as clear_button:
302
  remove_and_reupload = gr.ClearButton(value="Remove and upload new ones", components=files, size="sm")
303
- prompt = gr.Textbox(label="Prompt",
304
- info="Try something like 'a photo of a man/woman img', 'img' is the trigger word.",
305
- placeholder="A photo of a [man/woman img]...")
306
  style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME)
307
- aspect_ratio = gr.Dropdown(label="Output aspect ratio", choices=ASPECT_RATIO_LABELS, value=DEFAULT_ASPECT_RATIO)
308
  submit = gr.Button("Submit")
309
 
310
- enable_doodle = gr.Checkbox(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  label="Enable Drawing Doodle for Control", value=enable_doodle_arg,
312
  info="After enabling this option, PhotoMaker will generate content based on your doodle on the canvas, driven by the T2I-Adapter (Quality may be decreased)",
313
  )
314
- with gr.Accordion("T2I-Adapter-Doodle (Optional)", visible=False) as doodle_space:
315
- with gr.Row():
316
- sketch_image = gr.Sketchpad(
317
- label="Canvas",
318
- type="pil",
319
- crop_size=[1024,1024],
320
- layers=False,
321
- canvas_size=(350, 350),
322
- brush=gr.Brush(default_size=5, colors=["#000000"], color_mode="fixed")
323
- )
324
  with gr.Group():
325
  adapter_conditioning_scale = gr.Slider(
326
  label="Adapter conditioning scale",
@@ -337,48 +373,6 @@ with gr.Blocks(css=css) as demo:
337
  step=0.1,
338
  value=0.8,
339
  )
340
- with gr.Accordion(open=False, label="Advanced Options"):
341
- negative_prompt = gr.Textbox(
342
- label="Negative Prompt",
343
- placeholder="low quality",
344
- value="nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",
345
- )
346
- num_steps = gr.Slider(
347
- label="Number of sample steps",
348
- minimum=20,
349
- maximum=100,
350
- step=1,
351
- value=50,
352
- )
353
- style_strength_ratio = gr.Slider(
354
- label="Style strength (%)",
355
- minimum=15,
356
- maximum=50,
357
- step=1,
358
- value=20,
359
- )
360
- num_outputs = gr.Slider(
361
- label="Number of output images",
362
- minimum=1,
363
- maximum=4,
364
- step=1,
365
- value=2,
366
- )
367
- guidance_scale = gr.Slider(
368
- label="Guidance scale",
369
- minimum=0.1,
370
- maximum=10.0,
371
- step=0.1,
372
- value=5,
373
- )
374
- seed = gr.Slider(
375
- label="Seed",
376
- minimum=0,
377
- maximum=MAX_SEED,
378
- step=1,
379
- value=0,
380
- )
381
- randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
382
  with gr.Column():
383
  gallery = gr.Gallery(label="Generated Images")
384
  usage_tips = gr.Markdown(label="Usage tips of PhotoMaker", value=tips ,visible=False)
@@ -419,14 +413,14 @@ with gr.Blocks(css=css) as demo:
419
  outputs=[gallery, usage_tips]
420
  )
421
 
422
- gr.Examples(
423
- examples=get_example(),
424
- inputs=[files, prompt, style, negative_prompt],
425
- run_on_click=True,
426
- fn=upload_example_to_gallery,
427
- outputs=[uploaded_files, clear_button, files],
428
- )
429
 
430
- gr.Markdown(article)
431
 
432
  demo.launch()
 
227
  <center><img src='https://photo-maker.github.io/assets/logo.png' alt='PhotoMaker logo' style="width:80px; margin-bottom:10px"></center>
228
  """
229
  title = r"""
230
+ <h1 align="center">Olympics AI Photobooth 🥇📷: </h1>
231
+ <h2 align="center">Turn yourself into an Olympic Althele with PhotoMaker V2</h2>
232
  """
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
  article = r"""
236
 
 
270
  .gradio-container {width: 85% !important}
271
  '''
272
  with gr.Blocks(css=css) as demo:
273
+ #gr.Markdown(logo)
274
  gr.Markdown(title)
275
+ #gr.Markdown(description)
276
  # gr.DuplicateButton(
277
  # value="Duplicate Space for private use ",
278
  # elem_id="duplicate-button",
 
287
  uploaded_files = gr.Gallery(label="Your images", visible=False, columns=5, rows=1, height=200)
288
  with gr.Column(visible=False) as clear_button:
289
  remove_and_reupload = gr.ClearButton(value="Remove and upload new ones", components=files, size="sm")
290
+
 
 
291
  style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME)
292
+
293
  submit = gr.Button("Submit")
294
 
295
+
296
+
297
+ with gr.Accordion(open=False, label="Advanced Options"):
298
+ prompt = gr.Textbox(label="Prompt",
299
+ info="Try something like 'a photo of a man/woman img', 'img' is the trigger word.",
300
+ placeholder="A photo of a [man/woman img]...", value="a photo of a person img as an olypmic athlete, olympics")
301
+ aspect_ratio = gr.Dropdown(label="Output aspect ratio", choices=ASPECT_RATIO_LABELS, value=DEFAULT_ASPECT_RATIO)
302
+
303
+ with gr.Tab(label="more options"):
304
+
305
+ negative_prompt = gr.Textbox(
306
+ label="Negative Prompt",
307
+ placeholder="low quality",
308
+ value="nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",
309
+ )
310
+ num_steps = gr.Slider(
311
+ label="Number of sample steps",
312
+ minimum=20,
313
+ maximum=100,
314
+ step=1,
315
+ value=50,
316
+ )
317
+ style_strength_ratio = gr.Slider(
318
+ label="Style strength (%)",
319
+ minimum=15,
320
+ maximum=50,
321
+ step=1,
322
+ value=20,
323
+ )
324
+ num_outputs = gr.Slider(
325
+ label="Number of output images",
326
+ minimum=1,
327
+ maximum=4,
328
+ step=1,
329
+ value=2,
330
+ )
331
+ guidance_scale = gr.Slider(
332
+ label="Guidance scale",
333
+ minimum=0.1,
334
+ maximum=10.0,
335
+ step=0.1,
336
+ value=5,
337
+ )
338
+ seed = gr.Slider(
339
+ label="Seed",
340
+ minimum=0,
341
+ maximum=MAX_SEED,
342
+ step=1,
343
+ value=0,
344
+ )
345
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
346
+ with gr.Tab(label="T2I-Adapter-Doodle (Optional)") as doodle_space:
347
+ enable_doodle = gr.Checkbox(
348
  label="Enable Drawing Doodle for Control", value=enable_doodle_arg,
349
  info="After enabling this option, PhotoMaker will generate content based on your doodle on the canvas, driven by the T2I-Adapter (Quality may be decreased)",
350
  )
351
+ with gr.Row():
352
+ sketch_image = gr.Sketchpad(
353
+ label="Canvas",
354
+ type="pil",
355
+ crop_size=[1024,1024],
356
+ layers=False,
357
+ canvas_size=(350, 350),
358
+ brush=gr.Brush(default_size=5, colors=["#000000"], color_mode="fixed")
359
+ )
 
360
  with gr.Group():
361
  adapter_conditioning_scale = gr.Slider(
362
  label="Adapter conditioning scale",
 
373
  step=0.1,
374
  value=0.8,
375
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  with gr.Column():
377
  gallery = gr.Gallery(label="Generated Images")
378
  usage_tips = gr.Markdown(label="Usage tips of PhotoMaker", value=tips ,visible=False)
 
413
  outputs=[gallery, usage_tips]
414
  )
415
 
416
+ # gr.Examples(
417
+ # examples=get_example(),
418
+ # inputs=[files, prompt, style, negative_prompt],
419
+ # run_on_click=True,
420
+ # fn=upload_example_to_gallery,
421
+ # outputs=[uploaded_files, clear_button, files],
422
+ # )
423
 
424
+ #gr.Markdown(article)
425
 
426
  demo.launch()