Spaces:
Runtime error
Runtime error
Update
Browse files- README.md +4 -1
- app.py +5 -13
- requirements.txt +5 -5
README.md
CHANGED
@@ -4,9 +4,12 @@ emoji: 🌍
|
|
4 |
colorFrom: purple
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 3.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
|
|
|
|
|
4 |
colorFrom: purple
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.35.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
+
suggested_hardware: t4-small
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
14 |
+
|
15 |
+
https://arxiv.org/abs/2204.11823
|
app.py
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
from __future__ import annotations
|
4 |
|
5 |
import functools
|
6 |
-
import os
|
7 |
import pickle
|
8 |
import sys
|
9 |
|
@@ -16,12 +15,7 @@ from huggingface_hub import hf_hub_download
|
|
16 |
sys.path.insert(0, 'StyleGAN-Human')
|
17 |
|
18 |
TITLE = 'StyleGAN-Human'
|
19 |
-
DESCRIPTION = '
|
20 |
-
|
21 |
-
Related App: [StyleGAN-Human (Interpolation)](https://huggingface.co/spaces/hysts/StyleGAN-Human-Interpolation)
|
22 |
-
'''
|
23 |
-
|
24 |
-
HF_TOKEN = os.getenv('HF_TOKEN')
|
25 |
|
26 |
|
27 |
def generate_z(z_dim: int, seed: int, device: torch.device) -> torch.Tensor:
|
@@ -43,9 +37,7 @@ def generate_image(seed: int, truncation_psi: float, model: nn.Module,
|
|
43 |
|
44 |
|
45 |
def load_model(file_name: str, device: torch.device) -> nn.Module:
|
46 |
-
path = hf_hub_download('
|
47 |
-
f'models/{file_name}',
|
48 |
-
use_auth_token=HF_TOKEN)
|
49 |
with open(path, 'rb') as f:
|
50 |
model = pickle.load(f)['G_ema']
|
51 |
model.eval()
|
@@ -59,10 +51,10 @@ def load_model(file_name: str, device: torch.device) -> nn.Module:
|
|
59 |
|
60 |
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
61 |
model = load_model('stylegan_human_v2_1024.pkl', device)
|
62 |
-
|
63 |
|
64 |
gr.Interface(
|
65 |
-
fn=
|
66 |
inputs=[
|
67 |
gr.Slider(label='Seed', minimum=0, maximum=100000, step=1, value=0),
|
68 |
gr.Slider(label='Truncation psi',
|
@@ -74,4 +66,4 @@ gr.Interface(
|
|
74 |
outputs=gr.Image(label='Output', type='numpy'),
|
75 |
title=TITLE,
|
76 |
description=DESCRIPTION,
|
77 |
-
).
|
|
|
3 |
from __future__ import annotations
|
4 |
|
5 |
import functools
|
|
|
6 |
import pickle
|
7 |
import sys
|
8 |
|
|
|
15 |
sys.path.insert(0, 'StyleGAN-Human')
|
16 |
|
17 |
TITLE = 'StyleGAN-Human'
|
18 |
+
DESCRIPTION = 'https://github.com/stylegan-human/StyleGAN-Human'
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
|
21 |
def generate_z(z_dim: int, seed: int, device: torch.device) -> torch.Tensor:
|
|
|
37 |
|
38 |
|
39 |
def load_model(file_name: str, device: torch.device) -> nn.Module:
|
40 |
+
path = hf_hub_download('public-data/StyleGAN-Human', f'models/{file_name}')
|
|
|
|
|
41 |
with open(path, 'rb') as f:
|
42 |
model = pickle.load(f)['G_ema']
|
43 |
model.eval()
|
|
|
51 |
|
52 |
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
53 |
model = load_model('stylegan_human_v2_1024.pkl', device)
|
54 |
+
fn = functools.partial(generate_image, model=model, device=device)
|
55 |
|
56 |
gr.Interface(
|
57 |
+
fn=fn,
|
58 |
inputs=[
|
59 |
gr.Slider(label='Seed', minimum=0, maximum=100000, step=1, value=0),
|
60 |
gr.Slider(label='Truncation psi',
|
|
|
66 |
outputs=gr.Image(label='Output', type='numpy'),
|
67 |
title=TITLE,
|
68 |
description=DESCRIPTION,
|
69 |
+
).queue(max_size=10).launch()
|
requirements.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
numpy==1.
|
2 |
-
Pillow==
|
3 |
-
scipy==1.
|
4 |
-
torch==
|
5 |
-
torchvision==0.
|
|
|
1 |
+
numpy==1.23.5
|
2 |
+
Pillow==10.0.0
|
3 |
+
scipy==1.10.1
|
4 |
+
torch==2.0.1
|
5 |
+
torchvision==0.15.2
|