Beispiel #1
0
    def __init__(self, classifier_trainers=linear_svm_lr, patch_shape=(5, 5),
                 features=sparse_hog, normalization_diagonal=None,
                 n_levels=3, downscale=1.1, scaled_shape_models=True,
                 max_shape_components=None, boundary=3):

        # general deformable model checks
        checks.check_n_levels(n_levels)
        checks.check_downscale(downscale)
        checks.check_normalization_diagonal(normalization_diagonal)
        checks.check_boundary(boundary)
        max_shape_components = checks.check_max_components(
            max_shape_components, n_levels, 'max_shape_components')
        features = checks.check_features(features, n_levels)

        # CLM specific checks
        classifier_trainers = check_classifier_trainers(classifier_trainers, n_levels)
        patch_shape = check_patch_shape(patch_shape)

        # store parameters
        self.classifier_trainers = classifier_trainers
        self.patch_shape = patch_shape
        self.features = features
        self.normalization_diagonal = normalization_diagonal
        self.n_levels = n_levels
        self.downscale = downscale
        self.scaled_shape_models = scaled_shape_models
        self.max_shape_components = max_shape_components
        self.boundary = boundary
Beispiel #2
0
    def __init__(self, regression_type=mlr, regression_features=None,
                 features=no_op, n_levels=3, downscale=1.2, noise_std=0.04,
                 rotation=False, n_perturbations=10):
        features = checks.check_features(features, n_levels)
        DeformableModel.__init__(self, features)

        # general deformable model checks
        checks.check_n_levels(n_levels)
        checks.check_downscale(downscale)

        # SDM specific checks
        regression_type_list = check_regression_type(regression_type,
                                                     n_levels)
        regression_features = check_regression_features(regression_features,
                                                        n_levels)
        check_n_permutations(n_perturbations)

        # store parameters
        self.regression_type = regression_type_list
        self.regression_features = regression_features
        self.n_levels = n_levels
        self.downscale = downscale
        self.noise_std = noise_std
        self.rotation = rotation
        self.n_perturbations = n_perturbations
Beispiel #3
0
    def __init__(self, features=igo, patch_shape=(16, 16),
                 normalization_diagonal=None, n_levels=3, downscale=2,
                 scaled_shape_models=True, max_shape_components=None,
                 boundary=3):
        # check parameters
        checks.check_n_levels(n_levels)
        checks.check_downscale(downscale)
        checks.check_normalization_diagonal(normalization_diagonal)
        checks.check_boundary(boundary)
        max_shape_components = checks.check_max_components(
            max_shape_components, n_levels, 'max_shape_components')
        features = checks.check_features(features, n_levels)

        # store parameters
        self.features = features
        self.patch_shape = patch_shape
        self.normalization_diagonal = normalization_diagonal
        self.n_levels = n_levels
        self.downscale = downscale
        self.scaled_shape_models = scaled_shape_models
        self.max_shape_components = max_shape_components
        self.boundary = boundary

        # patch-based AAMs can only work with TPS transform
        self.transform = ThinPlateSplines
Beispiel #4
0
    def __init__(self, features=igo, patch_shape=(16, 16),
                 normalization_diagonal=None, n_levels=3, downscale=2,
                 scaled_shape_models=True, max_shape_components=None,
                 max_appearance_components=None, boundary=3):
        # check parameters
        checks.check_n_levels(n_levels)
        checks.check_downscale(downscale)
        checks.check_normalization_diagonal(normalization_diagonal)
        checks.check_boundary(boundary)
        max_shape_components = checks.check_max_components(
            max_shape_components, n_levels, 'max_shape_components')
        max_appearance_components = checks.check_max_components(
            max_appearance_components, n_levels, 'max_appearance_components')
        features = checks.check_features(features, n_levels)

        # store parameters
        self.features = features
        self.patch_shape = patch_shape
        self.normalization_diagonal = normalization_diagonal
        self.n_levels = n_levels
        self.downscale = downscale
        self.scaled_shape_models = scaled_shape_models
        self.max_shape_components = max_shape_components
        self.max_appearance_components = max_appearance_components
        self.boundary = boundary

        # patch-based AAMs can only work with TPS transform
        self.transform = DifferentiableThinPlateSplines
Beispiel #5
0
 def __init__(self, features=igo, transform=DifferentiablePiecewiseAffine,
              trilist=None, normalization_diagonal=None, n_levels=3,
              downscale=2, scaled_shape_models=True,
              max_shape_components=None, max_appearance_components=None,
              boundary=3):
     # check parameters
     checks.check_n_levels(n_levels)
     checks.check_downscale(downscale)
     checks.check_normalization_diagonal(normalization_diagonal)
     checks.check_boundary(boundary)
     max_shape_components = checks.check_max_components(
         max_shape_components, n_levels, 'max_shape_components')
     max_appearance_components = checks.check_max_components(
         max_appearance_components, n_levels, 'max_appearance_components')
     features = checks.check_features(features, n_levels)
     # store parameters
     self.features = features
     self.transform = transform
     self.trilist = trilist
     self.normalization_diagonal = normalization_diagonal
     self.n_levels = n_levels
     self.downscale = downscale
     self.scaled_shape_models = scaled_shape_models
     self.max_shape_components = max_shape_components
     self.max_appearance_components = max_appearance_components
     self.boundary = boundary
Beispiel #6
0
    def __init__(self,
                 regression_type=mlr,
                 regression_features=None,
                 features=no_op,
                 n_levels=3,
                 downscale=1.2,
                 noise_std=0.04,
                 rotation=False,
                 n_perturbations=10):
        features = checks.check_features(features, n_levels)
        DeformableModel.__init__(self, features)

        # general deformable model checks
        checks.check_n_levels(n_levels)
        checks.check_downscale(downscale)

        # SDM specific checks
        regression_type_list = check_regression_type(regression_type, n_levels)
        regression_features = check_regression_features(
            regression_features, n_levels)
        check_n_permutations(n_perturbations)

        # store parameters
        self.regression_type = regression_type_list
        self.regression_features = regression_features
        self.n_levels = n_levels
        self.downscale = downscale
        self.noise_std = noise_std
        self.rotation = rotation
        self.n_perturbations = n_perturbations
Beispiel #7
0
 def __init__(self,
              features=igo,
              transform=DifferentiablePiecewiseAffine,
              trilist=None,
              normalization_diagonal=None,
              n_levels=3,
              downscale=2,
              scaled_shape_models=True,
              max_shape_components=None,
              max_appearance_components=None,
              boundary=3):
     # check parameters
     checks.check_n_levels(n_levels)
     checks.check_downscale(downscale)
     checks.check_normalization_diagonal(normalization_diagonal)
     checks.check_boundary(boundary)
     max_shape_components = checks.check_max_components(
         max_shape_components, n_levels, 'max_shape_components')
     max_appearance_components = checks.check_max_components(
         max_appearance_components, n_levels, 'max_appearance_components')
     features = checks.check_features(features, n_levels)
     # store parameters
     self.features = features
     self.transform = transform
     self.trilist = trilist
     self.normalization_diagonal = normalization_diagonal
     self.n_levels = n_levels
     self.downscale = downscale
     self.scaled_shape_models = scaled_shape_models
     self.max_shape_components = max_shape_components
     self.max_appearance_components = max_appearance_components
     self.boundary = boundary
Beispiel #8
0
    def __init__(self,
                 classifier_trainers=linear_svm_lr,
                 patch_shape=(5, 5),
                 features=sparse_hog,
                 normalization_diagonal=None,
                 n_levels=3,
                 downscale=1.1,
                 scaled_shape_models=True,
                 max_shape_components=None,
                 boundary=3):

        # general deformable model checks
        checks.check_n_levels(n_levels)
        checks.check_downscale(downscale)
        checks.check_normalization_diagonal(normalization_diagonal)
        checks.check_boundary(boundary)
        max_shape_components = checks.check_max_components(
            max_shape_components, n_levels, 'max_shape_components')
        features = checks.check_features(features, n_levels)

        # CLM specific checks
        classifier_trainers = check_classifier_trainers(
            classifier_trainers, n_levels)
        patch_shape = check_patch_shape(patch_shape)

        # store parameters
        self.classifier_trainers = classifier_trainers
        self.patch_shape = patch_shape
        self.features = features
        self.normalization_diagonal = normalization_diagonal
        self.n_levels = n_levels
        self.downscale = downscale
        self.scaled_shape_models = scaled_shape_models
        self.max_shape_components = max_shape_components
        self.boundary = boundary
Beispiel #9
0
    def __init__(self, adjacency_array_appearance=None, gaussian_per_patch=True,
                 adjacency_array_deformation=None, root_vertex_deformation=None,
                 adjacency_array_shape=None, features=no_op,
                 patch_shape=(17, 17), normalization_diagonal=None, n_levels=2,
                 downscale=2, scaled_shape_models=False, use_procrustes=True,
                 max_shape_components=None, n_appearance_parameters=None):
        # check parameters
        checks.check_n_levels(n_levels)
        checks.check_downscale(downscale)
        checks.check_normalization_diagonal(normalization_diagonal)
        max_shape_components = checks.check_max_components(
            max_shape_components, n_levels, 'max_shape_components')
        features = checks.check_features(features, n_levels)
        n_appearance_parameters = _check_n_parameters(
            n_appearance_parameters, n_levels, 'n_appearance_parameters')

        # appearance graph
        if adjacency_array_appearance is None:
            self.graph_appearance = None
        elif adjacency_array_appearance == 'yorgos':
            self.graph_appearance = 'yorgos'
        else:
            self.graph_appearance = UndirectedGraph(adjacency_array_appearance)

        # shape graph
        if adjacency_array_shape is None:
            self.graph_shape = None
        else:
            self.graph_shape = UndirectedGraph(adjacency_array_shape)

        # check adjacency_array_deformation, root_vertex_deformation
        if adjacency_array_deformation is None:
            self.graph_deformation = None
            if root_vertex_deformation is None:
                self.root_vertex = 0
        else:
            if root_vertex_deformation is None:
                self.graph_deformation = DirectedGraph(adjacency_array_deformation)
            else:
                self.graph_deformation = Tree(adjacency_array_deformation,
                                              root_vertex_deformation)

        # store parameters
        self.features = features
        self.patch_shape = patch_shape
        self.normalization_diagonal = normalization_diagonal
        self.n_levels = n_levels
        self.downscale = downscale
        self.scaled_shape_models = scaled_shape_models
        self.max_shape_components = max_shape_components
        self.n_appearance_parameters = n_appearance_parameters
        self.use_procrustes = use_procrustes
        self.gaussian_per_patch = gaussian_per_patch
Beispiel #10
0
    def __init__(self,
                 adjacency_array_appearance=None,
                 gaussian_per_patch=True,
                 adjacency_array_deformation=None,
                 root_vertex_deformation=None,
                 adjacency_array_shape=None,
                 features=no_op,
                 patch_shape=(17, 17),
                 normalization_diagonal=None,
                 n_levels=2,
                 downscale=2,
                 scaled_shape_models=False,
                 use_procrustes=True,
                 max_shape_components=None,
                 n_appearance_parameters=None):
        # check parameters
        checks.check_n_levels(n_levels)
        checks.check_downscale(downscale)
        checks.check_normalization_diagonal(normalization_diagonal)
        max_shape_components = checks.check_max_components(
            max_shape_components, n_levels, 'max_shape_components')
        features = checks.check_features(features, n_levels)
        n_appearance_parameters = _check_n_parameters(
            n_appearance_parameters, n_levels, 'n_appearance_parameters')

        # appearance graph
        if adjacency_array_appearance is None:
            self.graph_appearance = None
        elif adjacency_array_appearance == 'yorgos':
            self.graph_appearance = 'yorgos'
        else:
            self.graph_appearance = UndirectedGraph(adjacency_array_appearance)

        # shape graph
        if adjacency_array_shape is None:
            self.graph_shape = None
        else:
            self.graph_shape = UndirectedGraph(adjacency_array_shape)

        # check adjacency_array_deformation, root_vertex_deformation
        if adjacency_array_deformation is None:
            self.graph_deformation = None
            if root_vertex_deformation is None:
                self.root_vertex = 0
        else:
            if root_vertex_deformation is None:
                self.graph_deformation = DirectedGraph(
                    adjacency_array_deformation)
            else:
                self.graph_deformation = Tree(adjacency_array_deformation,
                                              root_vertex_deformation)

        # store parameters
        self.features = features
        self.patch_shape = patch_shape
        self.normalization_diagonal = normalization_diagonal
        self.n_levels = n_levels
        self.downscale = downscale
        self.scaled_shape_models = scaled_shape_models
        self.max_shape_components = max_shape_components
        self.n_appearance_parameters = n_appearance_parameters
        self.use_procrustes = use_procrustes
        self.gaussian_per_patch = gaussian_per_patch