NonParametricNewton¶
-
class
menpofit.sdm.
NonParametricNewton
(patch_features=<function no_op>, patch_shape=(17, 17), n_iterations=3, compute_error=<function euclidean_bb_normalised_error>, alpha=0, bias=True)[source]¶ Bases:
NonParametricSDAlgorithm
Class for training a non-parametric cascaded-regression algorithm using Incremental Regularized Linear Regression (
IRLRegression
).Parameters: - patch_features (callable, optional) – The features to be extracted from the patches of an image.
- patch_shape ((int, int), optional) – The shape of the extracted patches.
- n_iterations (int, optional) – The number of iterations (cascades).
- compute_error (callable, optional) – The function to be used for computing the fitting error when training each cascade.
- alpha (float, optional) – The regularization parameter.
- bias (bool, optional) – Flag that controls whether to use a bias term.
-
increment
(images, gt_shapes, current_shapes, prefix='', verbose=False)¶ Method to increment the model with the set of current shapes.
Parameters: - images (list of menpo.image.Image) – The list of training images.
- gt_shapes (list of menpo.shape.PointCloud) – The list of ground truth shapes that correspond to the images.
- current_shapes (list of menpo.shape.PointCloud) – The list of current shapes that correspond to the images.
- prefix (str, optional) – The prefix to use when printing information.
- verbose (bool, optional) – If
True
, then information is printed during training.
Returns: current_shapes (list of menpo.shape.PointCloud) – The list of current shapes that correspond to the images.
-
run
(image, initial_shape, gt_shape=None, return_costs=False, **kwargs)¶ Run the algorithm to an image given an initial shape.
Parameters: - image (menpo.image.Image or subclass) – The image to be fitted.
- initial_shape (menpo.shape.PointCloud) – The initial shape from which the fitting procedure will start.
- gt_shape (class : menpo.shape.PointCloud or
None
, optional) – The ground truth shape associated to the image. - return_costs (bool, optional) – If
True
, then the cost function values will be computed during the fitting procedure. Then these cost values will be assigned to the returned fitting_result. Note that this argument currently has no effect and will raise a warning if set to ``True``. This is because it is not possible to evaluate the cost function of this algorithm.
Returns: fitting_result (
NonParametricIterativeResult
) – The result of the fitting procedure.
-
train
(images, gt_shapes, current_shapes, prefix='', verbose=False)¶ Method to train the model given a set of initial shapes.
Parameters: - images (list of menpo.image.Image) – The list of training images.
- gt_shapes (list of menpo.shape.PointCloud) – The list of ground truth shapes that correspond to the images.
- current_shapes (list of menpo.shape.PointCloud) – The list of current shapes that correspond to the images, which will be used as initial shapes.
- prefix (str, optional) – The prefix to use when printing information.
- verbose (bool, optional) – If
True
, then information is printed during training.
Returns: current_shapes (list of menpo.shape.PointCloud) – The list of current shapes that correspond to the images.