Compute the GMM Scores

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
comparison_ids system/array_1d_uint64/1 Input
probe_statistics tutorial/gmm_statistics/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/gmm/1 Input

Unnamed group

Endpoint Name Data Format Nature
ubm tutorial/gmm/1 Input
xxxxxxxxxx
81
 
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 stats_from_data(data):
17
    """Unmangles a bob.machine.GMMStats from a BEAT Data object"""
18
19
    dim_c, dim_d = data.sum_px.shape
20
    stat = bob.machine.GMMStats(dim_c, dim_d)
21
    stat.t = long(data.t)
22
    stat.n = data.n
23
    stat.sum_px = data.sum_px
24
    stat.sum_pxx = data.sum_pxx
25
    return stat
26
27
28
class Algorithm:
29
30
    def __init__(self):
31
        self.ubm       = None
32
        self.templates = None
33
34
35
    def process(self, inputs, outputs):
36
37
        # retrieve the UBM once
38
        if self.ubm is None:
39
            inputs['ubm'].next()
40
            self.ubm = gmm_from_data(inputs['ubm'].data)
41
42
43
        # retrieve all the templates once
44
        if self.templates is None:
45
            self.templates = {}
46
            group = inputs.groupOf('template_model')
47
48
            while group.hasMoreData():
49
                group.next()
50
51
                template_id = group['template_id'].data.value
52
53
                self.templates[template_id] = dict(
54
                    client_id = group['template_client_id'].data.value,
55
                    model = gmm_from_data(group['template_model'].data),
56
                )
57
58
59
        # process the probe
60
        comparison_ids = inputs['comparison_ids'].data.value
61
        statistics = stats_from_data(inputs['probe_statistics'].data)
62
63
        scores = []
64
        for comparison_id in comparison_ids:
65
            template_client_identity = self.templates[comparison_id]['client_id']
66
67
            score = bob.machine.linear_scoring([self.templates[comparison_id]['model']],
68
                                               self.ubm, [statistics])[0,0]
69
70
            scores.append({
71
                'template_identity': template_client_identity,
72
                'score': score,
73
            })
74
75
        outputs['scores'].write({
76
                'client_identity': inputs['probe_client_id'].data.value,
77
                'scores': scores
78
            },
79
        )
80
81
        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

For a given set of feature vectors, a Gaussian Mixture Model (GMM) of the target client and an UBM-GMM, this algorithm computes the scoring using the linear scoring implemented on the Bob <https://www.idiap.ch/software/bob/docs/releases/last/sphinx/html/machine/generated/bob.machine.linear_scoring.html?highlight=linear%20scoring#bob.machine.linear_scoring>

This algorithm relies on the Bob library.

The inputs are:

  • probe_statistics: A set of GMM Statistics of a probe.
  • probe_id: A set of probe (class/subject) identifier as an unsigned 64 bits integer.
  • ubm: A GMM corresponding to the Universal Background Model.
  • template_id: Client (class/subject) identifier as an unsigned 64 bits integer.
  • template_model: The GMM of the client

The output are the scores.

No experiments are using this algorithm.
Created with Raphaël 2.1.2[compare]tutorial/gmm_scoring/1tutorial/gmm_scoring/3Jun27tutorial/gmm_scoring/42014Nov112015Sep3
This algorithm was never executed.
Terms of Service | Contact Information | BEAT platform version 2.2.1b0 | © Idiap Research Institute - 2013-2025