def __init__(self, images, group=None, verbose=False, reference_shape=None, holistic_features=no_op, transform=DifferentiablePiecewiseAffine, diagonal=None, scales=(0.5, 1.0), max_shape_components=None, max_appearance_components=None, batch_size=None): checks.check_diagonal(diagonal) scales = checks.check_scales(scales) n_scales = len(scales) holistic_features = checks.check_features(holistic_features, n_scales) max_shape_components = checks.check_max_components( max_shape_components, n_scales, 'max_shape_components') max_appearance_components = checks.check_max_components( max_appearance_components, n_scales, 'max_appearance_components') self.holistic_features = holistic_features self.transform = transform self.diagonal = diagonal self.scales = scales self.max_shape_components = max_shape_components self.max_appearance_components = max_appearance_components self.reference_shape = reference_shape self.shape_models = [] self.appearance_models = [] # Train AAM self._train(images, increment=False, group=group, verbose=verbose, batch_size=batch_size)
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
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
def __init__(self, images, group=None, verbose=False, reference_shape=None, holistic_features=no_op, transform=DifferentiablePiecewiseAffine, diagonal=None, scales=(0.5, 1.0), shape_model_cls=OrthoPDM, max_shape_components=None, max_appearance_components=None, batch_size=None): checks.check_diagonal(diagonal) scales = checks.check_scales(scales) n_scales = len(scales) holistic_features = checks.check_callable(holistic_features, n_scales) shape_model_cls = checks.check_callable(shape_model_cls, n_scales) max_shape_components = checks.check_max_components( max_shape_components, n_scales, 'max_shape_components') max_appearance_components = checks.check_max_components( max_appearance_components, n_scales, 'max_appearance_components') self.holistic_features = holistic_features self.transform = transform self.diagonal = diagonal self.scales = scales self.max_shape_components = max_shape_components self.max_appearance_components = max_appearance_components self.reference_shape = reference_shape self._shape_model_cls = shape_model_cls self.shape_models = [] self.appearance_models = [] # Train AAM self._train(images, increment=False, group=group, verbose=verbose, batch_size=batch_size)
def __init__(self, images, group=None, holistic_features=no_op, reference_shape=None, diagonal=None, scales=(0.5, 1.0), expert_ensemble_cls=CorrelationFilterExpertEnsemble, patch_shape=(17, 17), context_shape=(34, 34), sample_offsets=None, transform=DifferentiablePiecewiseAffine, shape_model_cls=OrthoPDM, max_shape_components=None, max_appearance_components=None, sigma=None, boundary=3, response_covariance=2, patch_normalisation=no_op, cosine_mask=True, verbose=False): # Check parameters checks.check_diagonal(diagonal) scales = checks.check_scales(scales) n_scales = len(scales) holistic_features = checks.check_callable(holistic_features, n_scales) shape_model_cls = checks.check_callable(shape_model_cls, n_scales) max_shape_components = checks.check_max_components( max_shape_components, n_scales, 'max_shape_components') max_appearance_components = checks.check_max_components( max_appearance_components, n_scales, 'max_appearance_components') # Assign attributes self.expert_ensemble_cls = checks.check_callable( expert_ensemble_cls, n_scales) self.expert_ensembles = [] self.patch_shape = checks.check_patch_shape(patch_shape, n_scales) self.context_shape = checks.check_patch_shape(context_shape, n_scales) self.holistic_features = holistic_features self.transform = transform self.diagonal = diagonal self.scales = scales self.max_shape_components = max_shape_components self.max_appearance_components = max_appearance_components self.reference_shape = reference_shape self.shape_model_cls = shape_model_cls self.sigma = sigma self.boundary = boundary self.sample_offsets = sample_offsets self.response_covariance = response_covariance self.patch_normalisation = patch_normalisation self.cosine_mask = cosine_mask self.shape_models = [] self.appearance_models = [] self.expert_ensembles = [] self._train(images=images, group=group, verbose=verbose)
def __init__(self, images, group=None, appearance_graph=None, shape_graph=None, deformation_graph=None, holistic_features=no_op, reference_shape=None, diagonal=None, scales=(0.5, 1.0), patch_shape=(17, 17), patch_normalisation=no_op, use_procrustes=True, precision_dtype=np.float32, max_shape_components=None, n_appearance_components=None, can_be_incremented=False, verbose=False, batch_size=None): # Check parameters checks.check_diagonal(diagonal) scales = checks.check_scales(scales) n_scales = len(scales) holistic_features = checks.check_callable(holistic_features, n_scales) patch_shape = checks.check_patch_shape(patch_shape, n_scales) patch_normalisation = checks.check_callable(patch_normalisation, n_scales) max_shape_components = checks.check_max_components( max_shape_components, n_scales, 'max_shape_components') n_appearance_components = checks.check_max_components( n_appearance_components, n_scales, 'n_appearance_components') # Assign attributes self.diagonal = diagonal self.scales = scales self.holistic_features = holistic_features self.patch_shape = patch_shape self.patch_normalisation = patch_normalisation self.reference_shape = reference_shape self.use_procrustes = use_procrustes self.is_incremental = can_be_incremented self.precision_dtype = precision_dtype self.max_shape_components = max_shape_components self.n_appearance_components = n_appearance_components # Check provided graphs self.appearance_graph = checks.check_graph( appearance_graph, UndirectedGraph, 'appearance_graph', n_scales) self.shape_graph = checks.check_graph(shape_graph, UndirectedGraph, 'shape_graph', n_scales) self.deformation_graph = checks.check_graph( deformation_graph, [DirectedGraph, Tree], 'deformation_graph', n_scales) # Initialize models' lists self.shape_models = [] self.appearance_models = [] self.deformation_models = [] # Train APS self._train(images, increment=False, group=group, batch_size=batch_size, verbose=verbose)
def __init__(self, images, group=None, verbose=False, batch_size=None, diagonal=None, scales=(0.5, 1), holistic_features=no_op, shape_model_cls=OrthoPDM, expert_ensemble_cls=CorrelationFilterExpertEnsemble, max_shape_components=None, reference_shape=None): scales = checks.check_scales(scales) n_scales = len(scales) self.diagonal = checks.check_diagonal(diagonal) self.scales = scales self.holistic_features = checks.check_callable(holistic_features, self.n_scales) self.expert_ensemble_cls = checks.check_algorithm_cls( expert_ensemble_cls, self.n_scales, ExpertEnsemble) shape_model_cls = checks.check_callable(shape_model_cls, n_scales) self.max_shape_components = checks.check_max_components( max_shape_components, self.n_scales, 'max_shape_components') self.reference_shape = reference_shape self.shape_models = [] self._shape_model_cls = shape_model_cls self.expert_ensembles = [] # Train CLM self._train(images, increment=False, group=group, verbose=verbose, batch_size=batch_size)
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
def __init__(self, images, group=None, verbose=False, batch_size=None, diagonal=None, scales=(0.5, 1), holistic_features=no_op, # shape_model_cls=build_normalised_pca_shape_model, expert_ensemble_cls=CorrelationFilterExpertEnsemble, max_shape_components=None, reference_shape=None, shape_forgetting_factor=1.0): self.diagonal = checks.check_diagonal(diagonal) self.scales = checks.check_scales(scales) self.holistic_features = checks.check_features(holistic_features, self.n_scales) # self.shape_model_cls = checks.check_algorithm_cls( # shape_model_cls, self.n_scales, ShapeModel) self.expert_ensemble_cls = checks.check_algorithm_cls( expert_ensemble_cls, self.n_scales, ExpertEnsemble) self.max_shape_components = checks.check_max_components( max_shape_components, self.n_scales, 'max_shape_components') self.shape_forgetting_factor = shape_forgetting_factor self.reference_shape = reference_shape self.shape_models = [] self.expert_ensembles = [] # Train CLM self._train(images, increment=False, group=group, verbose=verbose, batch_size=batch_size)
def __init__(self, template, shapes, group=None, holistic_features=no_op, reference_shape=None, diagonal=None, scales=(0.5, 1.0), transform=DifferentiablePiecewiseAffine, shape_model_cls=OrthoPDM, max_shape_components=None, verbose=False, batch_size=None): # Check arguments checks.check_diagonal(diagonal) n_scales = len(scales) scales = checks.check_scales(scales) holistic_features = checks.check_callable(holistic_features, n_scales) max_shape_components = checks.check_max_components( max_shape_components, n_scales, 'max_shape_components') shape_model_cls = checks.check_callable(shape_model_cls, n_scales) # Assign attributes self.holistic_features = holistic_features self.transform = transform self.diagonal = diagonal self.scales = scales self.max_shape_components = max_shape_components self.reference_shape = reference_shape self.shape_models = [] self.warped_templates = [] self._shape_model_cls = shape_model_cls # Train ATM self._train(template, shapes, increment=False, group=group, verbose=verbose, batch_size=batch_size)
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
def __init__( self, template, shapes, group=None, verbose=False, reference_shape=None, holistic_features=no_op, shape_model_cls=OrthoPDM, transform=DifferentiablePiecewiseAffine, diagonal=None, scales=(0.5, 1.0), max_shape_components=None, batch_size=None, ): checks.check_diagonal(diagonal) n_scales = len(scales) scales = checks.check_scales(scales) holistic_features = checks.check_callable(holistic_features, n_scales) max_shape_components = checks.check_max_components(max_shape_components, n_scales, "max_shape_components") shape_model_cls = checks.check_callable(shape_model_cls, n_scales) self.holistic_features = holistic_features self.transform = transform self.diagonal = diagonal self.scales = scales self.max_shape_components = max_shape_components self.reference_shape = reference_shape self.shape_models = [] self.warped_templates = [] self._shape_model_cls = shape_model_cls # Train ATM self._train(template, shapes, increment=False, group=group, verbose=verbose, batch_size=batch_size)
def __init__(self, images, group=None, holistic_features=no_op, reference_shape=None, diagonal=None, scales=(0.5, 1), patch_shape=(17, 17), patch_normalisation=no_op, context_shape=(34, 34), cosine_mask=True, sample_offsets=None, shape_model_cls=OrthoPDM, expert_ensemble_cls=CorrelationFilterExpertEnsemble, max_shape_components=None, verbose=False, batch_size=None): self.scales = checks.check_scales(scales) n_scales = len(scales) self.diagonal = checks.check_diagonal(diagonal) self.holistic_features = checks.check_callable(holistic_features, n_scales) self.expert_ensemble_cls = checks.check_callable(expert_ensemble_cls, n_scales) self._shape_model_cls = checks.check_callable(shape_model_cls, n_scales) self.max_shape_components = checks.check_max_components( max_shape_components, n_scales, 'max_shape_components') self.reference_shape = reference_shape self.patch_shape = checks.check_patch_shape(patch_shape, n_scales) self.patch_normalisation = patch_normalisation self.context_shape = checks.check_patch_shape(context_shape, n_scales) self.cosine_mask = cosine_mask self.sample_offsets = sample_offsets self.shape_models = [] self.expert_ensembles = [] # Train CLM self._train(images, increment=False, group=group, verbose=verbose, batch_size=batch_size)
def __init__(self, images, group=None, holistic_features=no_op, reference_shape=None, diagonal=None, scales=(0.5, 1.0), expert_ensemble_cls=CorrelationFilterExpertEnsemble, patch_shape=(17, 17), context_shape=(34, 34), sample_offsets=None, transform=DifferentiablePiecewiseAffine, shape_model_cls=OrthoPDM, max_shape_components=None, max_appearance_components=None, sigma=None, boundary=3, response_covariance=2, patch_normalisation=no_op, cosine_mask=True, verbose=False): # Check parameters checks.check_diagonal(diagonal) scales = checks.check_scales(scales) n_scales = len(scales) holistic_features = checks.check_callable(holistic_features, n_scales) shape_model_cls = checks.check_callable(shape_model_cls, n_scales) max_shape_components = checks.check_max_components( max_shape_components, n_scales, 'max_shape_components') max_appearance_components = checks.check_max_components( max_appearance_components, n_scales, 'max_appearance_components') # Assign attributes self.expert_ensemble_cls = checks.check_callable(expert_ensemble_cls, n_scales) self.expert_ensembles = [] self.patch_shape = checks.check_patch_shape(patch_shape, n_scales) self.context_shape = checks.check_patch_shape(context_shape, n_scales) self.holistic_features = holistic_features self.transform = transform self.diagonal = diagonal self.scales = scales self.max_shape_components = max_shape_components self.max_appearance_components = max_appearance_components self.reference_shape = reference_shape self.shape_model_cls = shape_model_cls self.sigma = sigma self.boundary = boundary self.sample_offsets = sample_offsets self.response_covariance = response_covariance self.patch_normalisation = patch_normalisation self.cosine_mask = cosine_mask self.shape_models = [] self.appearance_models = [] self.expert_ensembles = [] self._train(images=images, group=group, verbose=verbose)
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
def __init__( self, images, group=None, holistic_features=no_op, reference_shape=None, diagonal=None, scales=(1, ), # scales=(0.5, 1) patch_shape=(8, 8), patch_normalisation=no_op, context_shape=(8, 8), cosine_mask=True, sample_offsets=None, shape_model_cls=OrthoPDM, expert_ensemble_cls=CorrelationFilterExpertEnsemble, max_shape_components=None, verbose=False, batch_size=None): self.scales = checks.check_scales(scales) n_scales = len(scales) self.diagonal = checks.check_diagonal(diagonal) self.holistic_features = checks.check_callable(holistic_features, n_scales) self.expert_ensemble_cls = checks.check_callable( expert_ensemble_cls, n_scales) self._shape_model_cls = checks.check_callable(shape_model_cls, n_scales) self.max_shape_components = checks.check_max_components( max_shape_components, n_scales, 'max_shape_components') self.reference_shape = reference_shape self.patch_shape = checks.check_patch_shape(patch_shape, n_scales) self.patch_normalisation = patch_normalisation self.context_shape = checks.check_patch_shape(context_shape, n_scales) self.cosine_mask = cosine_mask self.sample_offsets = sample_offsets self.shape_models = [] self.expert_ensembles = [] # Train CLM self._train(images, increment=False, group=group, verbose=verbose, batch_size=batch_size)
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