Computes the similarity between a grid graph template and a grid graph probe

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 siebenkopf/graph/1 Input
scores system/array_1d_floats/1 Output

Group: models

Endpoint Name Data Format Nature
model siebenkopf/graph_model/3 Input

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

Name Description Type Default Range/Choices
gabor_jet_similarity The Gabor jet similarity function to be used string Canberra ScalarProduct, Canberra, Disparity, PhaseDiff, PhaseDiffPlusCanberra
xxxxxxxxxx
56
 
1
import bob
2
import numpy
3
4
class Algorithm:
5
6
  def __init__(self):
7
    self.models = None
8
    
9
  def setup(self, parameters):
10
    self.similarity = bob.machine.GaborJetSimilarity({
11
      'ScalarProduct' : bob.machine.gabor_jet_similarity_type.SCALAR_PRODUCT,
12
      'Canberra' : bob.machine.gabor_jet_similarity_type.CANBERRA,
13
      'Disparity' : bob.machine.gabor_jet_similarity_type.DISPARITY,
14
      'PhaseDiff' : bob.machine.gabor_jet_similarity_type.PHASE_DIFF,
15
      'PhaseDiffPlusCanberra' : bob.machine.gabor_jet_similarity_type.PHASE_DIFF_PLUS_CANBERRA,
16
    } [parameters.get('gabor_jet_similarity', "Canberra")])
17
  
18
    return True
19
       
20
  def process(self, inputs, outputs):
21
    # retrieve all the models once
22
    if self.models is None:
23
      self.models = {}
24
      input = inputs['model']
25
      while input.hasMoreData(): 
26
        input.next()
27
        self.models[input.data.id] = (
28
           input.data.graphs
29
        )
30
31
    # process the probe
32
    comparison_ids = inputs['comparison_ids'].data.value
33
    probe = inputs['probe'].data
34
    probe_jets = [numpy.array([probe.jet[j].abs, probe.jet[j].phase]) for j in range(len(probe.jet))]
35
36
    scores = []
37
    for comparison_id in comparison_ids:
38
      graphs = self.models[comparison_id]
39
      similarities = [[] for j in range(len(probe.jet))]
40
      # compute similarities between model graphs and probe graph
41
      for graph in graphs:
42
        for j in range(len(graph.jet)):
43
           model_jet = numpy.array([graph.jet[j].abs, graph.jet[j].phase])
44
           similarities[j].append(self.similarity(model_jet, probe_jets[j]))
45
      # for each jet location, get the maximum similarity, and average those
46
      scores.append(sum([max(sims) for sims in similarities]) / len(probe.jet))
47
48
    # finally, write all scores
49
    outputs['scores'].write(
50
      {
51
        'value': scores
52
      }
53
    )
54
55
    return True
56

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

In this algorithm, the similarity between a template graph T (which is a concatenation of several enrollment graphs) and a probe sample P is computed. The similarities of all node positions n is simply averaged:

simtotal(T, P) = (1)/(N)nsimnode(Tn, Pn)

In each node, the similarity of all enrollment jets tm with the probe jet p is computed, and the maximum value is taken:

simnode(t, p) = maxmS(tm, p)

Where S is a Gabor jet similarity function, which can be chosen accordingg to [Guenther12].

[Guenther12]Manuel Günther, Denis Haufe, Rolf P. Würtz. Face recognition with disparity corrected Gabor phase differences. Artificial Neural Networks and Machine Learning, pp. 411-418, 2012.

Experiments

Updated Name Databases/Protocols Analyzers
siebenkopf/siebenkopf/FaceRec-WithOut-Training/2/XM2VTS-PhaseDiff xm2vts/1@darkened-lp1 siebenkopf/ROC/15,siebenkopf/EER_HTER/8
siebenkopf/siebenkopf/FaceRec-WithOut-Training/2/XM2VTS-ScalarProduct xm2vts/1@darkened-lp1 siebenkopf/ROC/15,siebenkopf/EER_HTER/8
siebenkopf/siebenkopf/FaceRec-WithOut-Training/2/XM2VTS-Canberra xm2vts/1@darkened-lp1 siebenkopf/ROC/15,siebenkopf/EER_HTER/8
siebenkopf/siebenkopf/FaceRec-WithOut-Training/2/Banca_P-ScalarProduct banca/1@P siebenkopf/ROC/15,siebenkopf/EER_HTER/8
siebenkopf/siebenkopf/FaceRec-WithOut-Training/2/Banca_P-Canberra banca/1@P siebenkopf/EER_HTER/8,siebenkopf/ROC/14
siebenkopf/siebenkopf/FaceRec-WithOut-Training/2/Banca_P-PhaseDiff banca/1@P siebenkopf/EER_HTER/8,siebenkopf/ROC/14
Created with Raphaël 2.1.2[compare]siebenkopf/GaborGraphSimilarity/122015May6

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