RegressorTrainer

class menpo.fit.regression.trainer.RegressorTrainer(reference_shape, regression_type=<function mlr at 0x7f5c2da62cf8>, regression_features=None, noise_std=0.04, rotation=False, n_perturbations=10)[source]

Bases: object

An abstract base class for training regressors.

Parameters:

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

regression_features : None or string or function, optional

The features that are used during the regression.

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.

delta_ps(gt_shape, perturbed_shape)[source]

Abstract 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]

Abstract method to generate the features for the regression.

Parameters:

image : MaskedImage

The current image.

shape : PointCloud

The current shape.

perturb_shapes(gt_shape)[source]

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)[source]

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.