Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yxlao/reverse-gan.pytorch
Precise Recovery of Latent Vectors from Generative Adversarial Networks in PyTorch
https://github.com/yxlao/reverse-gan.pytorch
Last synced: 21 days ago
JSON representation
Precise Recovery of Latent Vectors from Generative Adversarial Networks in PyTorch
- Host: GitHub
- URL: https://github.com/yxlao/reverse-gan.pytorch
- Owner: yxlao
- License: bsd-3-clause
- Created: 2017-05-14T08:14:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-21T04:32:13.000Z (over 7 years ago)
- Last Synced: 2024-10-03T12:42:08.298Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 12.4 MB
- Stars: 32
- Watchers: 5
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PyTorch-ReverseGAN
PyTorch implementation of
"Precise Recovery of Latent Vectors from Generative Adversarial Networks"
[https://arxiv.org/abs/1702.04782](https://arxiv.org/abs/1702.04782).Given the generated image `G(z)` with `z` unknown, the goal of ReverseGAN is to
find `z_approx` that approximates `z`. To achieve this, one can find `z_approx`
that minimizes `MSE(G(z_approx), G(z))` through gradient descent.## Setups
### Dataset
Download the "Align&Cropped Images" from
[http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html](http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html)
and unzip.### Training
```bash
python dcgan.py --dataset=folder --dataroot=/path/to/dataset --cuda
```
By default, the generated images and saved models will be saved in `dcgan_out`
directory.### Reverse
After training, run
```bash
python dcgan_reverse.py --clip=stochastic --netG=pre_trained/netG_epoch_10.pth --cuda
```
where `--netG` points to the model saved during training.### Example results
The following example uses the pre-trained model `pre_trained/netG_epoch_10.pth`
on CelebA aligned dataset.`G(z)`: the generated image with `z`
![result](pre_trained/g_z.png)
`G(z_approx)`: the generated image with the estimated `z_approx`
![result](pre_trained/g_z_approx.png)
## References
- DCGAN's implementation from
[PyTorch examples](https://github.com/pytorch/examples/tree/master/dcgan).
- Author's [TF implementation](https://github.com/SubarnaTripathi/ReverseGAN).