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(<function normalize_norm>, mode='per_channel', error_on_divide_by_zero=False), cosine_mask=True, sample_offsets=None, prefix='', verbose=False)[source]

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.

property frequency_filter_images

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

Type

list of menpo.image.Image

property n_experts

Returns the number of experts.

Type

int

property n_sample_offsets

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

Type

int

property padded_size

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

Type

(int, int)

property search_shape

Returns the search shape (patch_shape).

Type

(int, int)

property spatial_filter_images

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

Type

list of menpo.image.Image