Computes the ISV scoring.

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

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.

Group: probes

Endpoint Name Data Format Nature
probe_isv_offset system/array_1d_floats/1 Input
probe_statistics tutorial/gmm_statistics/1 Input
template_ids system/array_1d_uint64/1 Input
probe_id system/uint64/1 Input
probe_client_id system/uint64/1 Input
scores tutorial/probe_scores/1 Output

Group: templates

Endpoint Name Data Format Nature
template_client_id system/uint64/1 Input
template_id system/uint64/1 Input
template_model tutorial/isvmachine/1 Input

Unnamed group

Endpoint Name Data Format Nature
ubm tutorial/gmm/1 Input
isvbase tutorial/isvbase/1 Input
xxxxxxxxxx
108
 
1
import bob
2
3
4
def gmm_from_data(data):
5
    """Unmangles a bob.machine.GMMMachine from a BEAT Data object"""
6
7
    dim_c, dim_d = data.means.shape
8
    gmm = bob.machine.GMMMachine(dim_c, dim_d)
9
    gmm.weights = data.weights
10
    gmm.means = data.means
11
    gmm.variances = data.variances
12
    gmm.variance_thresholds = data.variance_thresholds
13
    return gmm
14
15
16
def isvbase_from_data(data, ubm):
17
    """Unmangles a bob.machine.ISVBase from a BEAT Data object"""
18
19
    dim_cd, dim_u = data.subspace_u.shape
20
    isvbase = bob.machine.ISVBase(ubm, dim_u)
21
    isvbase.u = data.subspace_u
22
    isvbase.d = data.subspace_d
23
    return isvbase
24
25
26
def stats_from_data(data):
27
    """Unmangles a bob.machine.GMMStats from a BEAT Data object"""
28
29
    dim_c, dim_d = data.sum_px.shape
30
    stat = bob.machine.GMMStats(dim_c, dim_d)
31
    stat.t = long(data.t)
32
    stat.n = data.n
33
    stat.sum_px = data.sum_px
34
    stat.sum_pxx = data.sum_pxx
35
    return stat
36
37
38
def isvmachine_from_data(data, isvbase):
39
    """Unmangles a bob.machine.ISVBase from a BEAT Data object"""
40
41
    isvmachine = bob.machine.ISVMachine(isvbase)
42
    isvmachine.z = data.latent_z
43
    return isvmachine
44
45
46
47
48
class Algorithm:
49
50
    def __init__(self):
51
        self.ubm       = None
52
        self.isvbase   = None
53
        self.templates = None
54
55
56
    def process(self, inputs, outputs):
57
58
        # retrieve the UBM once
59
        if self.ubm is None:
60
            inputs['ubm'].next()
61
            self.ubm = gmm_from_data(inputs['ubm'].data)
62
63
        # retrieve the ISVBase once
64
        if self.isvbase is None:
65
            inputs['isvbase'].next()
66
            self.isvbase = isvbase_from_data(inputs['isvbase'].data, self.ubm)
67
68
69
        # retrieve all the templates once
70
        if self.templates is None:
71
            self.templates = {}
72
            group = inputs.groupOf('template_model')
73
74
            while group.hasMoreData():
75
                group.next()
76
77
                template_id = group['template_id'].data.value
78
79
                self.templates[template_id] = dict(
80
                    client_id = group['template_client_id'].data.value,
81
                    model = isvmachine_from_data(group['template_model'].data, self.isvbase),
82
                )
83
84
        # process the probe
85
        template_ids = inputs['template_ids'].data.value
86
        statistics = stats_from_data(inputs['probe_statistics'].data)
87
        ux = inputs['probe_isv_offset'].data.value
88
89
        scores = []
90
        for template_id in template_ids:
91
            template_client_identity = self.templates[template_id]['client_id']
92
            model = self.templates[template_id]['model']
93
94
95
            score = model.forward_ux(statistics, ux)
96
97
            scores.append({
98
                'template_identity': template_client_identity,
99
                'score': score,
100
            })
101
102
        outputs['scores'].write({
103
                'client_identity': inputs['probe_client_id'].data.value,
104
                'scores': scores
105
            },
106
        )
107
108
        return True

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

Could not find any documentation for this object.
No experiments are using this algorithm.
Created with Raphaël 2.1.2[compare]tutorial/isv_scoring/3tutorial/isv_scoring/42014Nov112015Sep3

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