Chainer implementation of the inception score module presented in Improved Techniques for Training GANs. The code is derived from the official OpenAI implementation at https://github.com/openai/improved-gan.
A method proposed by Tim Salimans et al. (2016) in the above mentioned paper to evaluate generated image quality for generative models such as VAEs and GANs.
It is based on the fact that good samples (images generated from a generative model) are expected to give
- Low entropy p(y|x), i.e. high prediction confidence
- High entropy p(y), i.e. highly varied predictions
to the inception network, where x is an image generated by the generative model and y is the class prediction.
The inception score is thus defined as exp(E_x[KL(p(y|x) || p(y))])
Download the pretrained TensorFlow model and create a Chainer copy named inception_score.model.
python download.py --outfile inception_score.model
Load the pretrained Chainer model and compute the inception score for the CIFAR-10 dataset including both train and test images. To limit the number of images, use the --samples
option.
python example.py --model inception_score.model
...
Batch size: 100
Total number of images: 60000
Total number of batches: 600
Running batch 1 / 600 ...
Running batch 2 / 600 ...
...
Running batch 600 / 600 ...
Inception score mean: 12.003619194030762
Inception score std: 0.10357429087162018
import numpy as np
from chainer import serializers, datasets
from inception_score import Inception, inception_score
model = Inception()
serializers.load_hdf5('inception_score.model', model)
train, test = datasets.get_cifar10(ndim=3, withlabel=False, scale=255.0)
mean, std = inception_score(model, np.concatenate(train, test))
print('Inception score mean:', mean)
print('Inception score std:', std)
This implementation seems to yield slightly higher scores than the original implementation looking at the inception scores based on CIFAR-10, upsampled from (32, 32) to (299, 299) using bilinear interpolation.
Ours | Original | |
---|---|---|
Mean | 12.00 | 11.24 |
Std | 0.10 | 0.12 |