Implements ISV subspaces training
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.
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
import bob
import numpy
def gmm_from_data(data):
"""Unmangles a bob.machine.GMMMachine from a BEAT Data object"""
dim_c, dim_d = data.means.shape
gmm = bob.machine.GMMMachine(dim_c, dim_d)
gmm.weights = data.weights
gmm.means = data.means
gmm.variances = data.variances
gmm.variance_thresholds = data.variance_thresholds
return gmm
def stats_from_data(data):
"""Unmangles a bob.machine.GMMStats from a BEAT Data object"""
dim_c, dim_d = data.sum_px.shape
stat = bob.machine.GMMStats(dim_c, dim_d)
stat.t = long(data.t)
stat.n = data.n
stat.sum_px = data.sum_px
stat.sum_pxx = data.sum_pxx
return stat
class Algorithm:
def __init__(self):
self.isv_training_iterations = 10
self.relevance_factor = 4.
self.subspace_dimension_of_u = 50
self.init_seed = 0
self.data = {}
self.ubm = None
def setup(self, parameters):
self.isv_training_iterations = parameters.get('isv-training-iterations', self.isv_training_iterations)
self.relevance_factor = parameters.get('relevance-factor', self.relevance_factor)
self.subspace_dimension_of_u = parameters.get('subspace-dimension-of-u', self.subspace_dimension_of_u)
self.init_seed = parameters.get('init-seed', self.init_seed)
return True
def process(self, inputs, outputs):
# retrieve the UBM once
if self.ubm is None:
self.ubm = gmm_from_data(inputs['ubm'].data)
stats = stats_from_data(inputs["statistics"].data)
c_id = inputs["client_id"].data.value
if c_id in self.data.keys(): self.data[c_id].append(stats)
else: self.data[c_id] = [stats]
if not(inputs.hasMoreData()):
# create array set used for training
training_set = [v for k,v in self.data.iteritems()]
isvbase = bob.machine.ISVBase(self.ubm, int(self.subspace_dimension_of_u))
trainer = bob.trainer.ISVTrainer(int(self.isv_training_iterations), self.relevance_factor)
trainer.rng = bob.core.random.mt19937(int(self.init_seed))
trainer.train(isvbase, training_set)
# outputs data
outputs["isvbase"].write({
'subspace_u': isvbase.u,
'subspace_d': isvbase.d,
})
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 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:
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. |
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 |
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.