GlobalSimilarityModel

class menpofit.modelinstance.GlobalSimilarityModel(data, **kwargs)[source]

Bases: Targetable, Vectorizable

Class for creating a model that represents a global similarity transform (in-plane rotation, scaling, translation).

Parameters:data (list of menpo.shape.PointCloud) – The list of shapes to use as training data.
as_vector(**kwargs)

Returns a flattened representation of the object as a single vector.

Returns:vector ((N,) ndarray) – The core representation of the object, flattened into a single vector. Note that this is always a view back on to the original object, but is not writable.
copy()

Generate an efficient copy of this object.

Note that Numpy arrays and other Copyable objects on self will be deeply copied. Dictionaries and sets will be shallow copied, and everything else will be assigned (no copy will be made).

Classes that store state other than numpy arrays and immutable types should overwrite this method to ensure all state is copied.

Returns:type(self) – A copy of this object
d_dp(_)[source]

Returns the Jacobian of the similarity model reshaped in order to have the standard Jacobian shape, i.e. (n_points, n_weights, n_dims) which maps to (n_features, n_components, n_dims) on the linear model.

Returns:jacobian ((n_features, n_components, n_dims) ndarray) – The Jacobian of the model in the standard Jacobian shape.
from_vector(vector)

Build a new instance of the object from it’s vectorized state.

self is used to fill out the missing state required to rebuild a full object from it’s standardized flattened state. This is the default implementation, which is which is a deepcopy of the object followed by a call to from_vector_inplace(). This method can be overridden for a performance benefit if desired.

Parameters:vector ((n_parameters,) ndarray) – Flattened representation of the object.
Returns:object (type(self)) – An new instance of this class.
from_vector_inplace(vector)

Deprecated. Use the non-mutating API, from_vector.

For internal usage in performance-sensitive spots, see _from_vector_inplace()

Parameters:vector ((n_parameters,) ndarray) – Flattened representation of this object
has_nan_values()

Tests if the vectorized form of the object contains nan values or not. This is particularly useful for objects with unknown values that have been mapped to nan values.

Returns:has_nan_values (bool) – If the vectorized object contains nan values.
set_target(new_target)[source]

Update this object so that it attempts to recreate the new_target.

Parameters:new_target (menpo.shape.PointCloud) – The new target that this object should try and regenerate.
n_dims

The number of dimensions of the spatial instance of the model.

Type:int
n_parameters

The length of the vector that this object produces.

Type:int
n_points

The number of points on the target.

Type:int
n_weights

The number of parameters in the linear model.

Type:int
target

The current menpo.shape.PointCloud that this object produces.

Type:menpo.shape.PointCloud
weights

The weights of the model.

Type:(n_weights,) ndarray