Skip to content

Instantly share code, notes, and snippets.

@johndpope
Last active August 26, 2021 12:12
Show Gist options
  • Save johndpope/c5b77f8cc7d7d008be7f15079a9378bf to your computer and use it in GitHub Desktop.
Save johndpope/c5b77f8cc7d7d008be7f15079a9378bf to your computer and use it in GitHub Desktop.
UPDATE 2 -
when I print out the generator - I get this. presumably to get this to plug into other repo - I have to rewire it......
```shell
new_G: Generator(
(synthesis): SynthesisNetwork(
(b4): SynthesisBlock(
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b8): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b16): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b32): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b64): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b128): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b256): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b512): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b1024): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
)
(mapping): MappingNetwork(
(fc0): FullyConnectedLayer()
(fc1): FullyConnectedLayer()
(fc2): FullyConnectedLayer()
(fc3): FullyConnectedLayer()
(fc4): FullyConnectedLayer()
(fc5): FullyConnectedLayer()
(fc6): FullyConnectedLayer()
(fc7): FullyConnectedLayer()
)
```
with stylegan2-ada-pytorch
**python projector.py --outdir=out --target=1.jpg --network=ffhq.pkl**
the file npz contains the dictionary array with 'w' key.
```shell
(torch) ➜ out git:(main) ✗ npz projected_w.npz
<numpy.lib.npyio.NpzFile object at 0x7f27905b8280>
['w']
(torch) ➜ out git:(main) ✗ python
Python 3.8.5 (default, Sep 4 2020, 07:30:14)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import numpy as np
>>> d = np.load("projected_w.npz")
>>> d['w']
array([[[-0.75353324, 0.55418384, 0.47273687, ..., -0.5179746 ,
-1.0065545 , 1.383011 ],
[-0.75353324, 0.55418384, 0.47273687, ..., -0.5179746 ,
-1.0065545 , 1.383011 ],
[-0.75353324, 0.55418384, 0.47273687, ..., -0.5179746 ,
-1.0065545 , 1.383011 ],
...,
[-0.75353324, 0.55418384, 0.47273687, ..., -0.5179746 ,
-1.0065545 , 1.383011 ],
[-0.75353324, 0.55418384, 0.47273687, ..., -0.5179746 ,
-1.0065545 , 1.383011 ],
[-0.75353324, 0.55418384, 0.47273687, ..., -0.5179746 ,
-1.0065545 , 1.383011 ]]], dtype=float32)
>>> d['w'].shape
(1, 18, 512)
```
FFHQ - pkl
{'G': Generator(
(synthesis): SynthesisNetwork(
(b4): SynthesisBlock(
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b8): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b16): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b32): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b64): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b128): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b256): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b512): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b1024): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
)
(mapping): MappingNetwork(
(fc0): FullyConnectedLayer()
(fc1): FullyConnectedLayer()
(fc2): FullyConnectedLayer()
(fc3): FullyConnectedLayer()
(fc4): FullyConnectedLayer()
(fc5): FullyConnectedLayer()
(fc6): FullyConnectedLayer()
(fc7): FullyConnectedLayer()
)
), 'D': Discriminator(
(b1024): DiscriminatorBlock(
(fromrgb): Conv2dLayer()
(conv0): Conv2dLayer()
(conv1): Conv2dLayer()
(skip): Conv2dLayer()
)
(b512): DiscriminatorBlock(
(conv0): Conv2dLayer()
(conv1): Conv2dLayer()
(skip): Conv2dLayer()
)
(b256): DiscriminatorBlock(
(conv0): Conv2dLayer()
(conv1): Conv2dLayer()
(skip): Conv2dLayer()
)
(b128): DiscriminatorBlock(
(conv0): Conv2dLayer()
(conv1): Conv2dLayer()
(skip): Conv2dLayer()
)
(b64): DiscriminatorBlock(
(conv0): Conv2dLayer()
(conv1): Conv2dLayer()
(skip): Conv2dLayer()
)
(b32): DiscriminatorBlock(
(conv0): Conv2dLayer()
(conv1): Conv2dLayer()
(skip): Conv2dLayer()
)
(b16): DiscriminatorBlock(
(conv0): Conv2dLayer()
(conv1): Conv2dLayer()
(skip): Conv2dLayer()
)
(b8): DiscriminatorBlock(
(conv0): Conv2dLayer()
(conv1): Conv2dLayer()
(skip): Conv2dLayer()
)
(b4): DiscriminatorEpilogue(
(mbstd): MinibatchStdLayer()
(conv): Conv2dLayer()
(fc): FullyConnectedLayer()
(out): FullyConnectedLayer()
)
), 'G_ema': Generator(
(synthesis): SynthesisNetwork(
(b4): SynthesisBlock(
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b8): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b16): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b32): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b64): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b128): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b256): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b512): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
(b1024): SynthesisBlock(
(conv0): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(conv1): SynthesisLayer(
(affine): FullyConnectedLayer()
)
(torgb): ToRGBLayer(
(affine): FullyConnectedLayer()
)
)
)
(mapping): MappingNetwork(
(fc0): FullyConnectedLayer()
(fc1): FullyConnectedLayer()
(fc2): FullyConnectedLayer()
(fc3): FullyConnectedLayer()
(fc4): FullyConnectedLayer()
(fc5): FullyConnectedLayer()
(fc6): FullyConnectedLayer()
(fc7): FullyConnectedLayer()
)
), 'training_set_kwargs': None, 'augment_pipe': None}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment