File size: 1,203 Bytes
9ea56c1
 
e61f0c9
9ea56c1
e61f0c9
9ea56c1
 
 
 
 
 
 
 
1c499ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Self-Distilled StyleGAN

- https://arxiv.org/abs/2202.12211
- https://github.com/self-distilled-stylegan/self-distilled-internet-photos
- weights
    - https://storage.googleapis.com/self-distilled-stylegan/dogs_1024_pytorch.pkl
    - https://storage.googleapis.com/self-distilled-stylegan/elephants_512_pytorch.pkl
    - https://storage.googleapis.com/self-distilled-stylegan/horses_256_pytorch.pkl
    - https://storage.googleapis.com/self-distilled-stylegan/bicycles_256_pytorch.pkl
    - https://storage.googleapis.com/self-distilled-stylegan/lions_512_pytorch.pkl
    - https://storage.googleapis.com/self-distilled-stylegan/giraffes_512_pytorch.pkl
    - https://storage.googleapis.com/self-distilled-stylegan/parrots_512_pytorch.pkl

```python
import pathlib
import pickle

sys.path.insert(0, '~/codes/clones/stylegan3')

paths = sorted(pathlib.Path('orig/').glob('*'))

out_dir = pathlib.Path('models')
out_dir.mkdir()

for path in paths:
    with open(path, 'rb') as f:
        ckpt = pickle.load(f)
    for key in list(ckpt.keys()):
        if key != 'G_ema':
            del ckpt[key]
    out_path = out_dir / path.name
    with open(out_path, 'wb') as f:
        pickle.dump(ckpt, f)
```