Update
Browse files
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: π
|
|
4 |
colorFrom: blue
|
5 |
colorTo: red
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 3.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
4 |
colorFrom: blue
|
5 |
colorTo: red
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.34.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
app.py
CHANGED
@@ -7,10 +7,7 @@ import numpy as np
|
|
7 |
|
8 |
from model import Model
|
9 |
|
10 |
-
DESCRIPTION = '
|
11 |
-
|
12 |
-
This is an unofficial demo for [https://github.com/microsoft/StyleSwin](https://github.com/microsoft/StyleSwin).
|
13 |
-
'''
|
14 |
|
15 |
|
16 |
def get_sample_image_url(name: str) -> str:
|
@@ -69,15 +66,12 @@ with gr.Blocks(css='style.css') as demo:
|
|
69 |
text = get_sample_image_markdown(model_name2.value)
|
70 |
sample_images = gr.Markdown(text)
|
71 |
|
72 |
-
model_name.change(fn=model.set_model, inputs=model_name, outputs=None)
|
73 |
run_button.click(fn=model.set_model_and_generate_image,
|
74 |
-
inputs=[
|
75 |
-
|
76 |
-
|
77 |
-
],
|
78 |
-
outputs=result)
|
79 |
model_name2.change(fn=get_sample_image_markdown,
|
80 |
inputs=model_name2,
|
81 |
outputs=sample_images)
|
82 |
|
83 |
-
demo.queue().launch(
|
|
|
7 |
|
8 |
from model import Model
|
9 |
|
10 |
+
DESCRIPTION = '# [StyleSwin](https://github.com/microsoft/StyleSwin)'
|
|
|
|
|
|
|
11 |
|
12 |
|
13 |
def get_sample_image_url(name: str) -> str:
|
|
|
66 |
text = get_sample_image_markdown(model_name2.value)
|
67 |
sample_images = gr.Markdown(text)
|
68 |
|
|
|
69 |
run_button.click(fn=model.set_model_and_generate_image,
|
70 |
+
inputs=[model_name, seed],
|
71 |
+
outputs=result,
|
72 |
+
api_name='run')
|
|
|
|
|
73 |
model_name2.change(fn=get_sample_image_markdown,
|
74 |
inputs=model_name2,
|
75 |
outputs=sample_images)
|
76 |
|
77 |
+
demo.queue(max_size=15).launch()
|
model.py
CHANGED
@@ -19,8 +19,6 @@ sys.path.insert(0, submodule_dir.as_posix())
|
|
19 |
|
20 |
from models.generator import Generator
|
21 |
|
22 |
-
HF_TOKEN = os.getenv('HF_TOKEN')
|
23 |
-
|
24 |
|
25 |
class Model:
|
26 |
MODEL_NAMES = [
|
@@ -52,9 +50,8 @@ class Model:
|
|
52 |
style_dim=512,
|
53 |
n_mlp=8,
|
54 |
channel_multiplier=channel_multiplier)
|
55 |
-
ckpt_path = huggingface_hub.hf_hub_download('
|
56 |
-
f'models/{model_name}.pt'
|
57 |
-
use_auth_token=HF_TOKEN)
|
58 |
ckpt = torch.load(ckpt_path)
|
59 |
model.load_state_dict(ckpt['g_ema'])
|
60 |
model.to(self.device)
|
|
|
19 |
|
20 |
from models.generator import Generator
|
21 |
|
|
|
|
|
22 |
|
23 |
class Model:
|
24 |
MODEL_NAMES = [
|
|
|
50 |
style_dim=512,
|
51 |
n_mlp=8,
|
52 |
channel_multiplier=channel_multiplier)
|
53 |
+
ckpt_path = huggingface_hub.hf_hub_download('public-data/StyleSwin',
|
54 |
+
f'models/{model_name}.pt')
|
|
|
55 |
ckpt = torch.load(ckpt_path)
|
56 |
model.load_state_dict(ckpt['g_ema'])
|
57 |
model.to(self.device)
|