def clm_build_benchmark(training_images, training_options=None, verbose=False): r""" Builds an CLM model. Parameters ---------- training_images: list of :class:MaskedImage objects A list of the training images. training_options: dictionary, optional A dictionary with the parameters that will be passed in the CLMBuilder (:class:menpo.fitmultilevel.clm.CLMBuilder). If None, the default options will be used. This is an example of the dictionary with the default options: training_options = {'group': 'PTS', 'classifier_type': linear_svm_lr, 'patch_shape': (5, 5), 'feature_type': sparse_hog, 'normalization_diagonal': None, 'n_levels': 3, 'downscale': 1.1, 'scaled_shape_models': True, 'pyramid_on_features': True, 'max_shape_components': None, 'boundary': 3, 'interpolator': 'scipy' } For an explanation of the options, please refer to the CLMBuilder documentation. Default: None verbose: boolean, optional If True, it prints information regarding the CLM training. Default: False Returns ------- clm: :class:menpo.fitmultilevel.clm.CLM object The trained CLM model. """ if verbose: print('CLM Training:') # parse options if training_options is None: training_options = {} # group option group = training_options.pop('group', None) # build aam aam = CLMBuilder(**training_options).build(training_images, group=group, verbose=verbose) return aam
regression_features=weights, noise_std=0.04, rotation=False, n_perturbations=1, update='compositional', md_transform=OrthoMDTransform, global_transform=AlignmentSimilarity, n_shape=25, n_appearance=None).train(training_images, group='PTS') clm = CLMBuilder(classifier_type=linear_svm_lr, feature_type=[sparse_hog], normalization_diagonal=100, patch_shape=(5, 5), n_levels=1, downscale=1.1, scaled_shape_models=True, pyramid_on_features=True, max_shape_components=25, boundary=3, interpolator='scipy').build(training_images, group='PTS') sdm3 = SDCLMTrainer(clm, regression_type=mlr, noise_std=0.04, rotation=False, n_perturbations=1, pdm_transform=OrthoPDM, global_transform=AlignmentSimilarity, n_shape=None).train(training_images, group='PTS')
def test_feature_type_with_pyramid_on_features_exception(): clm = CLMBuilder(feature_type=['igo', sparse_hog]).build(training_images, group='PTS')
def test_classifier_type_2_exception(): clm = CLMBuilder(classifier_type=['linear_svm_lr']).build( training_images, group='PTS')
def test_patch_shape_2_exception(): clm = CLMBuilder(patch_shape=(5, 6, 7)).build(training_images, group='PTS')
def test_boundary_exception(): clm = CLMBuilder(boundary=-1).build(training_images, group='PTS')
def test_verbose_mock(mock_stdout): clm = CLMBuilder().build(training_images, group='PTS', verbose=True)
def test_max_shape_components_2_exception(): clm = CLMBuilder(max_shape_components=[1, 2]).build(training_images, group='PTS')
def test_normalization_diagonal_exception(): clm = CLMBuilder(normalization_diagonal=10).build(training_images, group='PTS')
def test_downscale_exception(): clm = CLMBuilder(downscale=1).build(training_images, group='PTS') assert (clm.downscale == 1) clm = CLMBuilder(downscale=0).build(training_images, group='PTS')
def test_n_levels_exception(): clm = CLMBuilder(n_levels=0).build(training_images, group='PTS')
training_images = [] for i in range(4): im = mio.import_builtin_asset(filenames[i]) im.crop_to_landmarks_proportion_inplace(0.1) labeller(im, 'PTS', ibug_68_trimesh) if im.n_channels == 3: im = im.as_greyscale(mode='luminosity') training_images.append(im) # build clms clm1 = CLMBuilder(classifier_type=[linear_svm_lr], patch_shape=(5, 5), feature_type=['igo', sparse_hog, None], normalization_diagonal=150, n_levels=3, downscale=2, scaled_shape_models=False, pyramid_on_features=False, max_shape_components=[1, 2, 3], boundary=3, interpolator='scipy').build(training_images, group='PTS') clm2 = CLMBuilder(classifier_type=[random_forest, linear_svm_lr], patch_shape=(3, 10), feature_type=None, normalization_diagonal=None, n_levels=2, downscale=1.2, scaled_shape_models=True, pyramid_on_features=False, max_shape_components=None,