Implements ISV subspaces training

This algorithm is a legacy one. The API has changed since its implementation. New versions and forks will need to be updated.

Algorithms have at least one input and one output. All algorithm endpoints are organized in groups. Groups are used by the platform to indicate which inputs and outputs are synchronized together. The first group is automatically synchronized with the channel defined by the block in which the algorithm is deployed.

Unnamed group

Endpoint Name Data Format Nature
ubm tutorial/gmm/1 Input
statistics tutorial/gmm_statistics/1 Input
client_id system/uint64/1 Input
isvbase tutorial/isvbase/1 Output

Parameters allow users to change the configuration of an algorithm when scheduling an experiment

Name Description Type Default Range/Choices
isv-training-iterations uint32 10
relevance-factor float64 4.0
subspace-dimension-of-u uint32 50
init-seed uint32 0
xxxxxxxxxx
75
 
1
import bob
2
import numpy
3
4
5
def gmm_from_data(data):
6
    """Unmangles a bob.machine.GMMMachine from a BEAT Data object"""
7
8
    dim_c, dim_d = data.means.shape
9
    gmm = bob.machine.GMMMachine(dim_c, dim_d)
10
    gmm.weights = data.weights
11
    gmm.means = data.means
12
    gmm.variances = data.variances
13
    gmm.variance_thresholds = data.variance_thresholds
14
    return gmm
15
16
17
18
def stats_from_data(data):
19
    """Unmangles a bob.machine.GMMStats from a BEAT Data object"""
20
21
    dim_c, dim_d = data.sum_px.shape
22
    stat = bob.machine.GMMStats(dim_c, dim_d)
23
    stat.t = long(data.t)
24
    stat.n = data.n
25
    stat.sum_px = data.sum_px
26
    stat.sum_pxx = data.sum_pxx
27
    return stat
28
29
30
class Algorithm:
31
32
    def __init__(self):
33
        self.isv_training_iterations = 10
34
        self.relevance_factor = 4.
35
        self.subspace_dimension_of_u = 50
36
        self.init_seed = 0
37
        self.data = {}
38
        self.ubm = None
39
40
    def setup(self, parameters):
41
        self.isv_training_iterations = parameters.get('isv-training-iterations', self.isv_training_iterations)
42
        self.relevance_factor = parameters.get('relevance-factor', self.relevance_factor)
43
        self.subspace_dimension_of_u = parameters.get('subspace-dimension-of-u', self.subspace_dimension_of_u)
44
        self.init_seed = parameters.get('init-seed', self.init_seed)
45
        return True
46
47
48
    def process(self, inputs, outputs):
49
50
        # retrieve the UBM once
51
        if self.ubm is None:
52
            self.ubm = gmm_from_data(inputs['ubm'].data)
53
54
        stats = stats_from_data(inputs["statistics"].data)
55
        c_id = inputs["client_id"].data.value
56
        if c_id in self.data.keys(): self.data[c_id].append(stats)
57
        else: self.data[c_id] = [stats]
58
59
        if not(inputs.hasMoreData()):
60
            # create array set used for training
61
            training_set = [v for k,v in self.data.iteritems()]
62
63
            isvbase = bob.machine.ISVBase(self.ubm, int(self.subspace_dimension_of_u))
64
            trainer = bob.trainer.ISVTrainer(int(self.isv_training_iterations), self.relevance_factor)
65
            trainer.rng = bob.core.random.mt19937(int(self.init_seed))
66
            trainer.train(isvbase, training_set)
67
68
            # outputs data
69
            outputs["isvbase"].write({
70
                'subspace_u':              isvbase.u,
71
                'subspace_d':              isvbase.d,
72
            })
73
74
        return True
75

The code for this algorithm in Python
The ruler at 80 columns indicate suggested POSIX line breaks (for readability).
The editor will automatically enlarge to accomodate the entirety of your input
Use keyboard shortcuts for search/replace and faster editing. For example, use Ctrl-F (PC) or Cmd-F (Mac) to search through this box

For a Gaussian Mixture Models (GMM) mean supervector space, computes the within-class variability subspace (U subspace) described in [McCool2013]:

This algorithm relies on the Bob library.

The inputs are:

  • statistics: A training set of GMM Statistics.
  • ubm: A GMM corresponding to the Universal Background Model.
  • client_id: Client (class/subject) identifier as an unsigned 64 bits integer.

The outputs are subspace_u and subspace_d for the session and the client offset respectivelly.

[McCool2013]McCool, Christopher, et al. "Session variability modelling for face authentication." IET biometrics 2.3 (2013): 117-129.

Experiments

Updated Name Databases/Protocols Analyzers
smarcel/tutorial/full_isv/2/mobio_male-gmm_100Gx10I-isv_50Ux10Ix4R-dct_12Bx8Ox45C-seed101 mobio/1@male tutorial/eerhter_postperf_iso/1
tutorial/tutorial/full_isv/2/bancaMc_isv_DCT12x8_100G_U50 banca/1@Mc tutorial/eerhter_postperf_iso/1
tutorial/tutorial/full_isv/2/xm2vtsLp1_isv_DCT12x8_100G_U50 xm2vts/1@lp1 tutorial/eerhter_postperf_iso/1
tutorial/tutorial/full_isv/2/mobioMale_isv_DCT12x8_100G_U50 mobio/1@male tutorial/eerhter_postperf_iso/1
tutorial/tutorial/full_isv/2/bancaP_isv_DCT12x8_100G_U50 banca/1@P tutorial/eerhter_postperf_iso/1
tutorial/tutorial/full_isv/2/atnt_isv_DCT12x8_100G_U50 atnt/1@idiap_test_eyepos tutorial/eerhter_postperf_iso/1
Created with Raphaël 2.1.2[compare]tutorial/isv/22014Sep7

This table shows the number of times this algorithm has been successfully run using the given environment. Note this does not provide sufficient information to evaluate if the algorithm will run when submitted to different conditions.

Terms of Service | Contact Information | BEAT platform version 2.2.1b0 | © Idiap Research Institute - 2013-2025