SemiParametricClassifierBasedRegressorTrainer

class menpo.fit.regression.trainer.SemiParametricClassifierBasedRegressorTrainer(classifiers, transform, reference_shape, regression_type=<function mlr at 0x7f5c2da62cf8>, patch_shape=(16, 16), update='compositional', noise_std=0.04, rotation=False, n_perturbations=10)[source]

Bases: SemiParametricRegressorTrainer

Class for training a Semi-Parametric Classifier-Based Regressor. This means that the classifiers are used instead of features.

Parameters:

classifiers : list of Classifier Functions

List of classifiers.

transform : Affine

The transform used for warping.

reference_shape : PointCloud

The reference shape that will be used.

regression_type : function, optional

A function that defines the regression technique to be used. Examples of such closures can be found in Functions

patch_shape : tuple, optional

The shape of the patches that will be extracted.

noise_std : float, optional

The standard deviation of the gaussian noise used to produce the training shapes.

rotation : boolean, optional

Specifies whether ground truth in-plane rotation is to be used to produce the training shapes.

n_perturbations : int, optional

Defines the number of perturbations that will be applied to the training shapes.

interpolator : string

Specifies the interpolator used in warping.

delta_ps(gt_shape, perturbed_shape)

Method to generate the delta_ps for the regression.

Parameters:

gt_shape : PointCloud

The ground truth shape.

perturbed_shape : PointCloud

The perturbed shape.

features(image, shape)[source]

Method that extracts the features for the regression, which in this case are patch based.

Parameters:

image : MaskedImage

The current image.

shape : PointCloud

The current shape.

perturb_shapes(gt_shape)

Perturbs the given shapes. The number of perturbations is defined by n_perturbations.

Parameters:

gt_shape : PointCloud list

List of the shapes that correspond to the images. will be perturbed.

Returns:

perturbed_shapes : PointCloud list

List of the perturbed shapes.

train(images, shapes, perturbed_shapes=None, verbose=False, **kwargs)

Trains a Regressor given a list of landmarked images.

Parameters:

images : list of MaskedImage

The set of landmarked images from which to train the regressor.

shapes : PointCloud list

List of the shapes that correspond to the images.

perturbed_shapes : PointCloud list, optional

List of the perturbed shapes used for the regressor training.

verbose : boolean, optional

Flag that controls information and progress printing.

Returns:

regressor : :map:`Regressor`

A regressor object.

Raises:

ValueError :

The number of shapes must be equal to the number of images.

ValueError :

The number of perturbed shapes must be equal or multiple to the number of images.

algorithm

Returns the algorithm name.