tfsnippet.applications

class tfsnippet.applications.InceptionV3(cache_dir=None)

Bases: object

Inception V3 model from TensorFlow tutorial.

This class directly loads the persisted TensorFlow graph, instead of assembling the model using TensorFlow or Keras APIs. If you do need a freshly assembled model, you should turn to Keras instead.

The major purpose of this class is to compute the same Inception score as “Improved techniques for training gans”, Salimans, T. et al. 2016.

N_CLASSES = 1008
__init__(cache_dir=None)

Construct a new InceptionV3 instance.

Parameters:cache_dir (CacheDir) – The cache directory instance. If not specified, use a default one.
get_labels(classes)

Get the labels for specified classes.

Parameters:classes (Iterable[int]) – The IDs of the classes.
Returns:The class labels.
Return type:list[str]
inception_score(images)

Compute the Inception score (“Improved techniques for training gans”, Salimans, T. et al. 2016.) for specified images, using InceptionV3.

Parameters:images (list[bytes] or np.ndarray) – List of JPEG image data (each image as bytes), or numpy array of shape (?, ?, ?, 3), the pixels of images. Note the pixels should be 256-colors.
Returns:The Inception score for images.
Return type:float
predict(images)

Predict the class classes for images.

Parameters:images (list[bytes] or np.ndarray) – List of JPEG image data (each image as bytes), or numpy array of shape (?, ?, ?, 3), the pixels of images. Note the pixels should be 256-colors.
Returns:The predicted classes.
Return type:np.ndarray
predict_log_proba(images)

Predict the class log-probabilities for images.

Parameters:images (list[bytes] or np.ndarray) – List of JPEG image data (each image as bytes), or numpy array of shape (?, ?, ?, 3), the pixels of images. Note the pixels should be 256-colors.
Returns:The predicted class log-probabilities.
Return type:np.ndarray
predict_logits(images)

Predict the softmax logits (un-normalized log-proba) for images.

Parameters:images (list[bytes] or np.ndarray) – List of JPEG image data (each image as bytes), or numpy array of shape (?, ?, ?, 3), the pixels of images. Note the pixels should be 256-colors.
Returns:The predicted softmax logits probabilities.
Return type:np.ndarray
predict_proba(images)

Predict the class probabilities for images.

Parameters:images (list[bytes] or np.ndarray) – List of JPEG image data (each image as bytes), or numpy array of shape (?, ?, ?, 3), the pixels of images. Note the pixels should be 256-colors.
Returns:The predicted class probabilities.
Return type:np.ndarray