hysts HF staff commited on
Commit
53b4ee2
1 Parent(s): a6dde31
Files changed (3) hide show
  1. README.md +4 -1
  2. app.py +7 -15
  3. requirements.txt +5 -5
README.md CHANGED
@@ -4,9 +4,12 @@ emoji: 🏢
4
  colorFrom: blue
5
  colorTo: gray
6
  sdk: gradio
7
- sdk_version: 3.19.1
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: blue
5
  colorTo: gray
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,18 +15,11 @@ from huggingface_hub import hf_hub_download
16
  sys.path.insert(0, 'StyleGAN-Human')
17
 
18
  TITLE = 'StyleGAN-Human (Interpolation)'
19
- DESCRIPTION = '''This is an unofficial demo for https://github.com/stylegan-human/StyleGAN-Human.
20
-
21
- Related App: [StyleGAN-Human](https://huggingface.co/spaces/hysts/StyleGAN-Human)
22
- '''
23
-
24
- HF_TOKEN = os.getenv('HF_TOKEN')
25
 
26
 
27
  def load_model(file_name: str, device: torch.device) -> nn.Module:
28
- path = hf_hub_download('hysts/StyleGAN-Human',
29
- f'models/{file_name}',
30
- use_auth_token=HF_TOKEN)
31
  with open(path, 'rb') as f:
32
  model = pickle.load(f)['G_ema']
33
  model.eval()
@@ -74,12 +66,12 @@ def generate_interpolated_images(seed0: int, psi0: float, seed1: int,
74
 
75
  device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
76
  model = load_model('stylegan_human_v2_1024.pkl', device)
77
- func = functools.partial(generate_interpolated_images,
78
- model=model,
79
- device=device)
80
 
81
  gr.Interface(
82
- fn=func,
83
  inputs=[
84
  gr.Slider(label='Seed 1',
85
  minimum=0,
@@ -112,4 +104,4 @@ gr.Interface(
112
  outputs=gr.Gallery(label='Output Images', type='numpy'),
113
  title=TITLE,
114
  description=DESCRIPTION,
115
- ).launch(show_api=False)
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 (Interpolation)'
18
+ DESCRIPTION = 'https://github.com/stylegan-human/StyleGAN-Human'
 
 
 
 
 
19
 
20
 
21
  def load_model(file_name: str, device: torch.device) -> nn.Module:
22
+ path = hf_hub_download('public-data/StyleGAN-Human', f'models/{file_name}')
 
 
23
  with open(path, 'rb') as f:
24
  model = pickle.load(f)['G_ema']
25
  model.eval()
66
 
67
  device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
68
  model = load_model('stylegan_human_v2_1024.pkl', device)
69
+ fn = functools.partial(generate_interpolated_images,
70
+ model=model,
71
+ device=device)
72
 
73
  gr.Interface(
74
+ fn=fn,
75
  inputs=[
76
  gr.Slider(label='Seed 1',
77
  minimum=0,
104
  outputs=gr.Gallery(label='Output Images', type='numpy'),
105
  title=TITLE,
106
  description=DESCRIPTION,
107
+ ).queue(max_size=10).launch()
requirements.txt CHANGED
@@ -1,5 +1,5 @@
1
- numpy==1.22.3
2
- Pillow==9.1.0
3
- scipy==1.8.0
4
- torch==1.11.0
5
- torchvision==0.12.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