コード例 #1
0
ファイル: fitter.py プロジェクト: Millczc/menpofit
    def __init__(self, images, aam, group=None, bounding_box_group_glob=None,
                 n_shape=None, n_appearance=None, sampling=None,
                 sd_algorithm_cls=ProjectOutNewton,
                 n_iterations=6, n_perturbations=30,
                 perturb_from_gt_bounding_box=noisy_shape_from_bounding_box,
                 batch_size=None, verbose=False):
        self.aam = aam
        # Check parameters
        checks.set_models_components(aam.shape_models, n_shape)
        checks.set_models_components(aam.appearance_models, n_appearance)
        self._sampling = checks.check_sampling(sampling, aam.n_scales)

        # patch_feature and patch_shape are not actually
        # used because they are fully defined by the AAM already. Therefore,
        # we just leave them as their 'defaults' because they won't be used.
        super(SupervisedDescentAAMFitter, self).__init__(
            images, group=group, bounding_box_group_glob=bounding_box_group_glob,
            reference_shape=self.aam.reference_shape,
            sd_algorithm_cls=sd_algorithm_cls,
            holistic_features=self.aam.holistic_features,
            diagonal=self.aam.diagonal,
            scales=self.aam.scales, n_iterations=n_iterations,
            n_perturbations=n_perturbations,
            perturb_from_gt_bounding_box=perturb_from_gt_bounding_box,
            batch_size=batch_size, verbose=verbose)
コード例 #2
0
ファイル: fitter.py プロジェクト: KeeganRen/menpofit
    def __init__(self, aps, gn_algorithm_cls=Inverse, n_shape=None,
                 weight=200., sampling=None):
        # Check parameters
        checks.set_models_components(aps.shape_models, n_shape)
        self._sampling = checks.check_sampling(sampling, aps.n_scales)
        self.weight = checks.check_multi_scale_param(
            aps.n_scales, (float, int), 'weight', weight)

        # Get list of algorithm objects per scale
        algorithms = []
        for j in list(range(aps.n_scales)):
            # create the interface object
            interface = GaussNewtonBaseInterface(
                appearance_model=aps.appearance_models[j],
                deformation_model=aps.deformation_models[j],
                transform=aps.shape_models[j], weight=self.weight[j],
                use_procrustes=aps.use_procrustes,
                template=aps.appearance_models[j].mean(),
                sampling=self._sampling[j], patch_shape=aps.patch_shape[j],
                patch_normalisation=aps.patch_normalisation[j])

            # create the algorithm object and append it
            algorithms.append(gn_algorithm_cls(interface))

        # Call superclass
        super(GaussNewtonAPSFitter, self).__init__(aps=aps,
                                                   algorithms=algorithms)
コード例 #3
0
    def __init__(self,
                 aps,
                 gn_algorithm_cls=Inverse,
                 n_shape=None,
                 weight=200.,
                 sampling=None):
        # Check parameters
        checks.set_models_components(aps.shape_models, n_shape)
        self._sampling = checks.check_sampling(sampling, aps.n_scales)
        self.weight = checks.check_multi_scale_param(aps.n_scales,
                                                     (float, int), 'weight',
                                                     weight)

        # Get list of algorithm objects per scale
        algorithms = []
        for j in list(range(aps.n_scales)):
            # create the interface object
            interface = GaussNewtonBaseInterface(
                appearance_model=aps.appearance_models[j],
                deformation_model=aps.deformation_models[j],
                transform=aps.shape_models[j],
                weight=self.weight[j],
                use_procrustes=aps.use_procrustes,
                template=aps.appearance_models[j].mean(),
                sampling=self._sampling[j],
                patch_shape=aps.patch_shape[j],
                patch_normalisation=aps.patch_normalisation[j])

            # create the algorithm object and append it
            algorithms.append(gn_algorithm_cls(interface))

        # Call superclass
        super(GaussNewtonAPSFitter, self).__init__(aps=aps,
                                                   algorithms=algorithms)
コード例 #4
0
ファイル: fitter.py プロジェクト: Millczc/menpofit
 def __init__(self, atm, lk_algorithm_cls=InverseCompositional,
              n_shape=None, sampling=None):
     self._model = atm
     # Check parameters
     checks.set_models_components(atm.shape_models, n_shape)
     self._sampling = checks.check_sampling(sampling, atm.n_scales)
     # Set up algorithm
     self._set_up(lk_algorithm_cls)
コード例 #5
0
ファイル: fitter.py プロジェクト: lydonchandra/menpofit
 def __init__(self,
              atm,
              lk_algorithm_cls=InverseCompositional,
              n_shape=None,
              sampling=None):
     self._model = atm
     checks.set_models_components(atm.shape_models, n_shape)
     self._sampling = checks.check_sampling(sampling, atm.n_scales)
     self._set_up(lk_algorithm_cls)
コード例 #6
0
ファイル: fitter.py プロジェクト: jabooth/menpofit
    def __init__(self, aam, lk_algorithm_cls=WibergInverseCompositional,
                 n_shape=None, n_appearance=None, sampling=None):
        # Check parameters
        checks.set_models_components(aam.shape_models, n_shape)
        checks.set_models_components(aam.appearance_models, n_appearance)
        self._sampling = checks.check_sampling(sampling, aam.n_scales)

        # Get list of algorithm objects per scale
        interfaces = aam.build_fitter_interfaces(self._sampling)
        algorithms = [lk_algorithm_cls(interface) for interface in interfaces]

        # Call superclass
        super(LucasKanadeAAMFitter, self).__init__(aam=aam,
                                                   algorithms=algorithms)
コード例 #7
0
ファイル: fitter.py プロジェクト: dykestra/menpofit
    def __init__(self, clm, gd_algorithm_cls=RegularisedLandmarkMeanShift,
                 n_shape=None):
        # Store CLM trained model
        self._model = clm

        # Check parameter
        checks.set_models_components(clm.shape_models, n_shape)

        # Get list of algorithm objects per scale
        algorithms = [gd_algorithm_cls(clm.expert_ensembles[i],
                                       clm.shape_models[i])
                      for i in range(clm.n_scales)]

        # Call superclass
        super(GradientDescentCLMFitter, self).__init__(clm=clm,
                                                       algorithms=algorithms)
コード例 #8
0
ファイル: fitter.py プロジェクト: KeeganRen/menpofit
    def __init__(self, atm, lk_algorithm_cls=InverseCompositional,
                 n_shape=None, sampling=None):
        # Store model
        self._model = atm

        # Check parameters
        checks.set_models_components(atm.shape_models, n_shape)
        self._sampling = checks.check_sampling(sampling, atm.n_scales)

        # Get list of algorithm objects per scale
        interfaces = atm.build_fitter_interfaces(self._sampling)
        algorithms = [lk_algorithm_cls(interface) for interface in interfaces]

        # Call superclass
        super(LucasKanadeATMFitter, self).__init__(
            scales=atm.scales, reference_shape=atm.reference_shape,
            holistic_features=atm.holistic_features, algorithms=algorithms)
コード例 #9
0
ファイル: fitter.py プロジェクト: zk496007331/menpofit
    def __init__(self,
                 aam,
                 lk_algorithm_cls=WibergInverseCompositional,
                 n_shape=None,
                 n_appearance=None,
                 sampling=None):
        # Check parameters
        checks.set_models_components(aam.shape_models, n_shape)
        checks.set_models_components(aam.appearance_models, n_appearance)
        self._sampling = checks.check_sampling(sampling, aam.n_scales)

        # Get list of algorithm objects per scale
        interfaces = aam.build_fitter_interfaces(self._sampling)
        algorithms = [lk_algorithm_cls(interface) for interface in interfaces]

        # Call superclass
        super(LucasKanadeAAMFitter, self).__init__(aam=aam,
                                                   algorithms=algorithms)
コード例 #10
0
ファイル: fitter.py プロジェクト: zk496007331/menpofit
    def __init__(self,
                 clm,
                 gd_algorithm_cls=RegularisedLandmarkMeanShift,
                 n_shape=None):
        # Store CLM trained model
        self._model = clm

        # Check parameter
        checks.set_models_components(clm.shape_models, n_shape)

        # Get list of algorithm objects per scale
        algorithms = [
            gd_algorithm_cls(clm.expert_ensembles[i], clm.shape_models[i])
            for i in range(clm.n_scales)
        ]

        # Call superclass
        super(GradientDescentCLMFitter, self).__init__(clm=clm,
                                                       algorithms=algorithms)
コード例 #11
0
    def __init__(self, clm, gd_algorithm_cls=RegularisedLandmarkMeanShift,
                 n_shape=None):
        # Store CLM trained model
        self._model = clm

        # Check parameter
        checks.set_models_components(clm.shape_models, n_shape)

        # Get list of algorithm objects per scale
        algorithms = [gd_algorithm_cls(clm.expert_ensembles[i],
                                       clm.shape_models[i],
                                       kernel_covariance=clm.opt['kernel_covariance'],
                                       kernel_idealmap=clm.opt['sigOffset'],
                                       confidence_gama=clm.opt['sigRate'],
                                       opt=clm.opt)
                      for i in range(clm.n_scales)]

        # Call superclass
        super(GradientDescentCLMFitter, self).__init__(clm=clm,
                                                       algorithms=algorithms)
コード例 #12
0
    def __init__(self,
                 atm,
                 lk_algorithm_cls=InverseCompositional,
                 n_shape=None,
                 sampling=None):
        # Store model
        self._model = atm

        # Check parameters
        checks.set_models_components(atm.shape_models, n_shape)
        self._sampling = checks.check_sampling(sampling, atm.n_scales)

        # Get list of algorithm objects per scale
        interfaces = atm.build_fitter_interfaces(self._sampling)
        algorithms = [lk_algorithm_cls(interface) for interface in interfaces]

        # Call superclass
        super(LucasKanadeATMFitter,
              self).__init__(scales=atm.scales,
                             reference_shape=atm.reference_shape,
                             holistic_features=atm.holistic_features,
                             algorithms=algorithms)
コード例 #13
0
ファイル: fitter.py プロジェクト: zk496007331/menpofit
    def __init__(self,
                 images,
                 aam,
                 group=None,
                 bounding_box_group_glob=None,
                 n_shape=None,
                 n_appearance=None,
                 sampling=None,
                 sd_algorithm_cls=ProjectOutNewton,
                 n_iterations=6,
                 n_perturbations=30,
                 perturb_from_gt_bounding_box=noisy_shape_from_bounding_box,
                 batch_size=None,
                 verbose=False):
        self.aam = aam
        # Check parameters
        checks.set_models_components(aam.shape_models, n_shape)
        checks.set_models_components(aam.appearance_models, n_appearance)
        self._sampling = checks.check_sampling(sampling, aam.n_scales)

        # patch_feature and patch_shape are not actually
        # used because they are fully defined by the AAM already. Therefore,
        # we just leave them as their 'defaults' because they won't be used.
        super(SupervisedDescentAAMFitter, self).__init__(
            images,
            group=group,
            bounding_box_group_glob=bounding_box_group_glob,
            reference_shape=self.aam.reference_shape,
            sd_algorithm_cls=sd_algorithm_cls,
            holistic_features=self.aam.holistic_features,
            diagonal=self.aam.diagonal,
            scales=self.aam.scales,
            n_iterations=n_iterations,
            n_perturbations=n_perturbations,
            perturb_from_gt_bounding_box=perturb_from_gt_bounding_box,
            batch_size=batch_size,
            verbose=verbose)
コード例 #14
0
ファイル: fitter.py プロジェクト: zk496007331/menpofit
    def __init__(self, unified_aam_clm,
                 algorithm_cls=AlternatingRegularisedLandmarkMeanShift,
                 n_shape=None, n_appearance=None, sampling=None):
        self._model = unified_aam_clm
        # Check parameters
        checks.set_models_components(self._model.shape_models, n_shape)
        checks.set_models_components(self._model.appearance_models,
                                     n_appearance)
        self._sampling = checks.check_sampling(sampling, self._model.n_scales)

        # Get list of algorithm objects per scale
        interfaces = unified_aam_clm.build_fitter_interfaces(self._sampling)
        algorithms = [algorithm_cls(interface,
                                    self._model.expert_ensembles[k],
                                    self._model.patch_shape[k],
                                    self._model.response_covariance)
                      for k, interface in enumerate(interfaces)]

        # Call superclass
        super(UnifiedAAMCLMFitter, self).__init__(
            scales=self._model.scales,
            reference_shape=self._model.reference_shape,
            holistic_features=self._model.holistic_features,
            algorithms=algorithms)
コード例 #15
0
ファイル: fitter.py プロジェクト: lydonchandra/menpofit
 def _check_n_appearance(self, n_appearance):
     checks.set_models_components(self.aam.appearance_models, n_appearance)
コード例 #16
0
ファイル: fitter.py プロジェクト: HaoyangWang/menpofit
 def _check_n_shape(self, n_shape):
     checks.set_models_components(self._model.shape_models, n_shape)
コード例 #17
0
ファイル: fitter.py プロジェクト: HaoyangWang/menpofit
 def __init__(self, atm, algorithm_cls=InverseCompositional,
              n_shape=None, sampling=None):
     self._model = atm
     checks.set_models_components(atm.shape_models, n_shape)
     self._sampling = checks.check_sampling(sampling, atm.n_scales)
     self._set_up(algorithm_cls)
コード例 #18
0
ファイル: fitter.py プロジェクト: Millczc/menpofit
 def __init__(self, clm, gd_algorithm_cls=RegularisedLandmarkMeanShift,
              n_shape=None):
     self._model = clm
     checks.set_models_components(clm.shape_models, n_shape)
     self._set_up(gd_algorithm_cls)
コード例 #19
0
ファイル: fitter.py プロジェクト: lydonchandra/menpofit
 def _check_n_appearance(self, n_appearance):
     checks.set_models_components(self.aam.appearance_models, n_appearance)
コード例 #20
0
ファイル: fitter.py プロジェクト: lydonchandra/menpofit
 def _check_n_shape(self, n_shape):
     checks.set_models_components(self._model.shape_models, n_shape)