CorrelationFilterExpertEnsemble

class menpofit.clm.CorrelationFilterExpertEnsemble(images, shapes, icf_cls=<class 'menpofit.clm.expert.base.IncrementalCorrelationFilterThinWrapper'>, patch_shape=(17, 17), context_shape=(34, 34), response_covariance=3, patch_normalisation=<functools.partial object>, cosine_mask=True, sample_offsets=None, prefix='', verbose=False)

Bases: ConvolutionBasedExpertEnsemble

Class for defining an ensemble of correlation filter experts.

Parameters:
  • images (list of menpo.image.Image) – The list of training images.
  • shapes (list of menpo.shape.PointCloud) – The list of training shapes that correspond to the images.
  • icf_cls (class, optional) – The incremental correlation filter class. For example IncrementalCorrelationFilterThinWrapper.
  • patch_shape ((int, int), optional) – The shape of the patches that will be extracted around the landmarks. Those patches are used to train the experts.
  • context_shape ((int, int), optional) – The context shape for the convolution.
  • response_covariance (int, optional) – The covariance of the generated Gaussian response.
  • patch_normalisation (callable, optional) – A normalisation function that will be applied on the extracted patches.
  • cosine_mask (bool, optional) – If True, then a cosine mask (Hanning function) will be applied on the extracted patches.
  • sample_offsets ((n_offsets, n_dims) ndarray or None, optional) – The offsets to sample from within a patch. So (0, 0) is the centre of the patch (no offset) and (1, 0) would be sampling the patch from 1 pixel up the first axis away from the centre. If None, then no offsets are applied.
  • prefix (str, optional) – The prefix of the printed progress information.
  • verbose (bool, optional) – If True, then information will be printed regarding the training progress.
increment(images, shapes, prefix='', verbose=False)

Increments the learned ensemble of convolution-based experts given a new set of training data.

Parameters:
  • images (list of menpo.image.Image) – The list of training images.
  • shapes (list of menpo.shape.PointCloud) – The list of training shapes that correspond to the images.
  • prefix (str, optional) – The prefix of the printed training progress.
  • verbose (bool, optional) – If True, then information about the training progress will be printed.
predict_probability(image, shape)

Method for predicting the probability map of the response experts on a given image. Note that the provided shape must have the same number of points as the number of experts.

Parameters:
  • image (menpo.image.Image or subclass) – The test image.
  • shape (menpo.shape.PointCloud) – The shape that corresponds to the image from which the patches will be extracted.
Returns:

probability_map ((n_experts, 1, height, width) ndarray) – The probability map of the response of each expert.

predict_response(image, shape)

Method for predicting the response of the experts on a given image. Note that the provided shape must have the same number of points as the number of experts.

Parameters:
  • image (menpo.image.Image or subclass) – The test image.
  • shape (menpo.shape.PointCloud) – The shape that corresponds to the image from which the patches will be extracted.
Returns:

response ((n_experts, 1, height, width) ndarray) – The response of each expert.

view_frequency_filter_images_widget(figure_size=(10, 8), style='coloured', browser_style='buttons')

Visualizes the filters on the frequency domain using an interactive widget.

Parameters:
  • figure_size ((int, int), optional) – The initial size of the rendered figure.
  • style ({'coloured', 'minimal'}, optional) – If 'coloured', then the style of the widget will be coloured. If minimal, then the style is simple using black and white colours.
  • browser_style ({'buttons', 'slider'}, optional) – It defines whether the selector of the objects will have the form of plus/minus buttons or a slider.
view_spatial_filter_images_widget(figure_size=(10, 8), style='coloured', browser_style='buttons')

Visualizes the filters on the spatial domain using an interactive widget.

Parameters:
  • figure_size ((int, int), optional) – The initial size of the rendered figure.
  • style ({'coloured', 'minimal'}, optional) – If 'coloured', then the style of the widget will be coloured. If minimal, then the style is simple using black and white colours.
  • browser_style ({'buttons', 'slider'}, optional) – It defines whether the selector of the objects will have the form of plus/minus buttons or a slider.
frequency_filter_images

Returns a list of n_experts filter images on the frequency domain.

Type:list of menpo.image.Image
n_experts

Returns the number of experts.

Type:int
n_sample_offsets

Returns the number of offsets that are sampled within a patch.

Type:int
padded_size

Returns the convolution pad size, i.e. floor(1.5 * patch_shape - 1).

Type:(int, int)
search_shape

Returns the search shape (patch_shape).

Type:(int, int)
spatial_filter_images

Returns a list of n_experts filter images on the spatial domain.

Type:list of menpo.image.Image