ParametricRegressorTrainer

class menpo.fit.regression.trainer.ParametricRegressorTrainer(appearance_model, transform, reference_shape, regression_type=<function mlr at 0x7f5c2da62cf8>, regression_features=<function weights at 0x7f5c2da628c0>, update='compositional', noise_std=0.04, rotation=False, n_perturbations=10, interpolator='scipy')[source]

Bases: RegressorTrainer

Class for training a Parametric Regressor.

Parameters:

appearance_model : PCAModel

The appearance model to be used.

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

regression_features : None or function, optional

The parametric features that are used during the regression.

If None, the reconstruction appearance weights will be used as feature.

If string or function, the feature representation will be computed using one of the function in:

If string, the feature representation will be extracted by executing a parametric feature function.

Note that this feature type can only be one of the parametric feature functions defined Parametric Features.

patch_shape : tuple, optional

The shape of the patches that will be extracted.

update : ‘compositional’ or ‘additive’

Defines the way to update the warp.

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

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

Returns the algorithm name.