hysts HF staff commited on
Commit
dbbdaef
1 Parent(s): 160d1e3

Add examples

Browse files
.gitattributes CHANGED
@@ -1,3 +1,4 @@
 
1
  *.7z filter=lfs diff=lfs merge=lfs -text
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
 
1
+ *.jpg filter=lfs diff=lfs merge=lfs -text
2
  *.7z filter=lfs diff=lfs merge=lfs -text
3
  *.arrow filter=lfs diff=lfs merge=lfs -text
4
  *.bin filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 😻
4
  colorFrom: purple
5
  colorTo: red
6
  sdk: gradio
7
- sdk_version: 3.0.2
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: purple
5
  colorTo: red
6
  sdk: gradio
7
+ sdk_version: 3.0.3
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py CHANGED
@@ -4,6 +4,7 @@ from __future__ import annotations
4
 
5
  import argparse
6
  import os
 
7
  import sys
8
  from typing import Callable
9
 
@@ -219,6 +220,17 @@ def update_style_image(style_name: str) -> dict:
219
  return gr.Markdown.update(value=text)
220
 
221
 
 
 
 
 
 
 
 
 
 
 
 
222
  def main():
223
  args = parse_args()
224
  app = App(device=torch.device(args.device))
@@ -245,12 +257,12 @@ This is an unofficial demo app for [https://github.com/williamyang1991/DualStyle
245
 
246
  <center><img id="overview" src="https://raw.githubusercontent.com/williamyang1991/DualStyleGAN/main/doc_images/overview.jpg" alt="overview"></center>
247
  ''')
248
-
249
  with gr.Box():
250
  gr.Markdown('''## Step 1 (Preprocess Input Image)
251
 
252
  - Drop an image containing a near-frontal face to the **Input Image**.
253
  - If there are multiple faces in the image, hit the Edit button in the upper right corner and crop the input image beforehand.
 
254
  - Hit the **Detect & Align Face** button.
255
  - Hit the **Reconstruct Face** button.
256
  - The final result will be based on this **Reconstructed Face**. So, if the reconstructed image is not satisfactory, you may want to change the input image.
@@ -320,12 +332,28 @@ This is an unofficial demo app for [https://github.com/williamyang1991/DualStyle
320
  with gr.Column():
321
  output_image = gr.Image(label='Output Image')
322
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  gr.Markdown(
324
- 'Related App: [https://huggingface.co/spaces/hysts/DualStyleGAN](https://huggingface.co/spaces/hysts/DualStyleGAN)')
 
325
  gr.Markdown(
326
  '<center><img src="https://visitor-badge.glitch.me/badge?page_id=gradio-blocks.dualstylegan" alt="visitor badge"/></center>'
327
  )
328
 
 
 
 
329
  detect_button.click(fn=app.detect_and_align_face,
330
  inputs=input_image,
331
  outputs=face_image)
 
4
 
5
  import argparse
6
  import os
7
+ import pathlib
8
  import sys
9
  from typing import Callable
10
 
 
220
  return gr.Markdown.update(value=text)
221
 
222
 
223
+ def set_example(example: list) -> list[dict]:
224
+ return [
225
+ gr.Image.update(value=example[0]),
226
+ gr.Radio.update(value=example[1]),
227
+ gr.Slider.update(value=example[2]),
228
+ gr.Slider.update(value=example[3]),
229
+ gr.Slider.update(value=example[4]),
230
+ gr.Checkbox.update(value=example[5]),
231
+ ]
232
+
233
+
234
  def main():
235
  args = parse_args()
236
  app = App(device=torch.device(args.device))
 
257
 
258
  <center><img id="overview" src="https://raw.githubusercontent.com/williamyang1991/DualStyleGAN/main/doc_images/overview.jpg" alt="overview"></center>
259
  ''')
 
260
  with gr.Box():
261
  gr.Markdown('''## Step 1 (Preprocess Input Image)
262
 
263
  - Drop an image containing a near-frontal face to the **Input Image**.
264
  - If there are multiple faces in the image, hit the Edit button in the upper right corner and crop the input image beforehand.
265
+ - You can also load example inputs from the **Examples** section at the bottom of this page.
266
  - Hit the **Detect & Align Face** button.
267
  - Hit the **Reconstruct Face** button.
268
  - The final result will be based on this **Reconstructed Face**. So, if the reconstructed image is not satisfactory, you may want to change the input image.
 
332
  with gr.Column():
333
  output_image = gr.Image(label='Output Image')
334
 
335
+ with gr.Box():
336
+ gr.Markdown('## Examples')
337
+
338
+ paths = sorted(pathlib.Path('images').glob('*.jpg'))
339
+ samples = [[path.as_posix(), 'cartoon', 26, 0.6, 1.0, False]
340
+ for path in paths]
341
+ examples = gr.Dataset(components=[
342
+ input_image, style_type, style_index, structure_weight,
343
+ color_weight, structure_only
344
+ ],
345
+ samples=samples)
346
+
347
  gr.Markdown(
348
+ 'Related App: [https://huggingface.co/spaces/hysts/DualStyleGAN](https://huggingface.co/spaces/hysts/DualStyleGAN)'
349
+ )
350
  gr.Markdown(
351
  '<center><img src="https://visitor-badge.glitch.me/badge?page_id=gradio-blocks.dualstylegan" alt="visitor badge"/></center>'
352
  )
353
 
354
+ examples.click(fn=set_example,
355
+ inputs=examples,
356
+ outputs=examples.components)
357
  detect_button.click(fn=app.detect_and_align_face,
358
  inputs=input_image,
359
  outputs=face_image)
images/95UF6LXe-Lo.jpg ADDED

Git LFS Details

  • SHA256: 9ba751a6519822fa683e062ee3a383e748f15b41d4ca87d14c4fa73f9beed845
  • Pointer size: 131 Bytes
  • Size of remote file: 503 kB
images/ILip77SbmOE.jpg ADDED

Git LFS Details

  • SHA256: 3eed82923bc76a90f067415f148d56239fdfa4a1aca9eef1d459bc6050c9dde8
  • Pointer size: 131 Bytes
  • Size of remote file: 939 kB
images/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ These images are freely-usable ones from [Unsplash](https://unsplash.com/).
2
+
3
+ - https://unsplash.com/photos/rDEOVtE7vOs
4
+ - https://unsplash.com/photos/et_78QkMMQs
5
+ - https://unsplash.com/photos/ILip77SbmOE
6
+ - https://unsplash.com/photos/95UF6LXe-Lo
7
+
images/et_78QkMMQs.jpg ADDED

Git LFS Details

  • SHA256: c63a2e9de5eda3cb28012cfc8e4ba9384daeda8cca7a8989ad90b21a1293cc6f
  • Pointer size: 131 Bytes
  • Size of remote file: 371 kB
images/rDEOVtE7vOs.jpg ADDED

Git LFS Details

  • SHA256: b136bf195fef5599f277a563f0eef79af5301d9352d4ebf82bd7a0a061b7bdc0
  • Pointer size: 131 Bytes
  • Size of remote file: 155 kB