pliers.extractors.TensorFlowKerasApplicationExtractor

class pliers.extractors.TensorFlowKerasApplicationExtractor(architecture='inceptionv3', weights=None, num_predictions=5)[source]

Bases: ImageExtractor

Labels objects in images using a pretrained Inception V3 architecture implemented in TensorFlow / Keras.

Images must be RGB and be a certain shape. Different model architectures may require different shapes, and images will be resized (with some distortion) if the shape of the image is different.

Parameters
  • architecture (str) – model architecture to use. One of ‘vgg16’, ‘vgg19’, ‘resnet50’, ‘inception_resnetv2’, ‘inceptionv3’, ‘xception’, ‘densenet121’, ‘densenet169’, ‘nasnetlarge’, or ‘nasnetmobile’.

  • weights (str) – URL to download pre-trained weights. If None (default), uses the pre-trained weights trained on ImageNet used in Keras Applications.

  • num_predictions (int) – Number of top predicted labels to retain for each image.

__init__(architecture='inceptionv3', weights=None, num_predictions=5)[source]
transform(stim, *args, **kwargs)

Executes the transformation on the passed stim(s).

Parameters
  • stims (str, Stim, list) –

    One or more stimuli to process. Must be one of:

    • A string giving the path to a file that can be read in as a Stim (e.g., a .txt file, .jpg image, etc.)

    • A Stim instance of any type.

    • An iterable of stims, where each element is either a string or a Stim.

  • validation (str) –

    String specifying how validation errors should be handled. Must be one of:

    • ’strict’: Raise an exception on any validation error

    • ’warn’: Issue a warning for all validation errors

    • ’loose’: Silently ignore all validation errors

  • args – Optional positional arguments to pass onto the internal _transform call.

  • kwargs – Optional positional arguments to pass onto the internal _transform call.