Spaces:
Running
Running
Add examples
Browse files- .gitattributes +1 -0
- README.md +1 -1
- app.py +30 -2
- images/95UF6LXe-Lo.jpg +3 -0
- images/ILip77SbmOE.jpg +3 -0
- images/README.md +7 -0
- images/et_78QkMMQs.jpg +3 -0
- images/rDEOVtE7vOs.jpg +3 -0
.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.
|
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
|
images/ILip77SbmOE.jpg
ADDED
Git LFS Details
|
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
|
images/rDEOVtE7vOs.jpg
ADDED
Git LFS Details
|