update title
Browse files- README.md +2 -2
- visualizer_drag_gradio.py +16 -21
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title: DragGan
|
3 |
-
emoji:
|
4 |
colorFrom: purple
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
+
title: DragGan - Drag Your GAN
|
3 |
+
emoji: ππ
|
4 |
colorFrom: purple
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
visualizer_drag_gradio.py
CHANGED
@@ -2,7 +2,6 @@ import os
|
|
2 |
import os.path as osp
|
3 |
from argparse import ArgumentParser
|
4 |
from functools import partial
|
5 |
-
from huggingface_hub import snapshot_download
|
6 |
from pathlib import Path
|
7 |
|
8 |
import gradio as gr
|
@@ -17,7 +16,9 @@ from gradio_utils import (ImageMask, draw_mask_on_image, draw_points_on_image,
|
|
17 |
from viz.renderer import Renderer, add_watermark_np
|
18 |
|
19 |
|
20 |
-
# download models from hub
|
|
|
|
|
21 |
model_dir = Path('./checkpoints')
|
22 |
snapshot_download('radames/DragGan', repo_type='model', local_dir=model_dir)
|
23 |
|
@@ -166,6 +167,14 @@ print(valid_checkpoints_dict)
|
|
166 |
init_pkl = 'stylegan_human_v2_512'
|
167 |
|
168 |
with gr.Blocks() as app:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
# renderer = Renderer()
|
171 |
global_state = gr.State({
|
@@ -330,25 +339,11 @@ with gr.Blocks() as app:
|
|
330 |
mask (this has the same effect as `Reset Image` button).
|
331 |
3. Click `Edit Flexible Area` to create a mask and constrain the
|
332 |
unmasked region to remain unchanged.
|
333 |
-
""")
|
334 |
-
gr.HTML("""
|
335 |
-
<style>
|
336 |
-
.container {
|
337 |
-
position: absolute;
|
338 |
-
height: 50px;
|
339 |
-
text-align: center;
|
340 |
-
line-height: 50px;
|
341 |
-
width: 100%;
|
342 |
-
}
|
343 |
-
</style>
|
344 |
-
<div class="container">
|
345 |
-
Gradio demo supported by
|
346 |
-
<img src="https://avatars.githubusercontent.com/u/10245193?s=200&v=4" height="20" width="20" style="display:inline;">
|
347 |
-
<a href="https://github.com/open-mmlab/mmagic">OpenMMLab MMagic</a>
|
348 |
-
</div>
|
349 |
-
""")
|
350 |
|
|
|
|
|
351 |
# Network & latents tab listeners
|
|
|
352 |
def on_change_pretrained_dropdown(pretrained_value, global_state):
|
353 |
"""Function to handle model change.
|
354 |
1. Set pretrained value to global_state
|
@@ -869,5 +864,5 @@ with gr.Blocks() as app:
|
|
869 |
)
|
870 |
|
871 |
gr.close_all()
|
872 |
-
app.queue(concurrency_count=5, max_size=20)
|
873 |
-
app.launch(
|
|
|
2 |
import os.path as osp
|
3 |
from argparse import ArgumentParser
|
4 |
from functools import partial
|
|
|
5 |
from pathlib import Path
|
6 |
|
7 |
import gradio as gr
|
|
|
16 |
from viz.renderer import Renderer, add_watermark_np
|
17 |
|
18 |
|
19 |
+
# download models from Hugging Face hub
|
20 |
+
from huggingface_hub import snapshot_download
|
21 |
+
|
22 |
model_dir = Path('./checkpoints')
|
23 |
snapshot_download('radames/DragGan', repo_type='model', local_dir=model_dir)
|
24 |
|
|
|
167 |
init_pkl = 'stylegan_human_v2_512'
|
168 |
|
169 |
with gr.Blocks() as app:
|
170 |
+
gr.Markdown("""
|
171 |
+
# DragGAN - Drag Your GAN: Interactive Point-based Manipulation on the Generative Image Manifold
|
172 |
+
## Unofficial Gradio Demo
|
173 |
+
<small>
|
174 |
+
* Official Repo: [XingangPan][https://github.com/XingangPan/DragGAN]
|
175 |
+
* Gradio Demo by: [LeoXing1996](https://github.com/LeoXing1996) with [OpenMMLab MMagic](https://github.com/open-mmlab/mmagic)
|
176 |
+
</small>
|
177 |
+
""")
|
178 |
|
179 |
# renderer = Renderer()
|
180 |
global_state = gr.State({
|
|
|
339 |
mask (this has the same effect as `Reset Image` button).
|
340 |
3. Click `Edit Flexible Area` to create a mask and constrain the
|
341 |
unmasked region to remain unchanged.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
|
343 |
+
|
344 |
+
""")
|
345 |
# Network & latents tab listeners
|
346 |
+
|
347 |
def on_change_pretrained_dropdown(pretrained_value, global_state):
|
348 |
"""Function to handle model change.
|
349 |
1. Set pretrained value to global_state
|
|
|
864 |
)
|
865 |
|
866 |
gr.close_all()
|
867 |
+
app.queue(concurrency_count=5, max_size=20, api_open=False)
|
868 |
+
app.launch(show_api=False)
|