This algorithm is a sequential one. The platform will call its process() method once per data incoming on its inputs.

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: main

Endpoint Name Data Format Nature
probe_image system/array_2d_uint8/1 Input
template_images system/array_3d_uint8/1 Input
score system/float/1 Output

Group: model

Endpoint Name Data Format Nature
linear_model tutorial/linear_machine/1 Input
xxxxxxxxxx
62
 
1
import numpy as np
2
import scipy.spatial
3
4
5
def project(image, weights, biases, input_subtract, input_divide):
6
    image = (image.flatten() - input_subtract) / input_divide
7
    image = np.dot(image, weights.T) + biases
8
    return image
9
10
11
class Algorithm:
12
    def __init__(self):
13
        self.projections = []
14
15
    def prepare(self, data_loaders):
16
        # Loads the model at the beginning
17
        loader = data_loaders.loaderOf("linear_model")
18
        for i in range(loader.count()):
19
            view = loader.view("linear_model", i)
20
            data, _, _ = view[0]
21
            data = data["linear_model"]
22
            self.weights = data.weights
23
            self.biases = data.biases
24
            self.input_subtract = data.input_subtract
25
            self.input_divide = data.input_divide
26
        return True
27
28
    def process(self, inputs, data_loaders, outputs):
29
30
        # collect all the image projections for the current template
31
        probe_image = inputs["probe_image"].data.value.astype("float64")
32
        probe_image = project(
33
            probe_image,
34
            self.weights,
35
            self.biases,
36
            self.input_subtract,
37
            self.input_divide,
38
        )
39
40
        template_images = inputs["template_images"].data.value.astype("float64")
41
        template_images = [
42
            project(
43
                img,
44
                self.weights,
45
                self.biases,
46
                self.input_subtract,
47
                self.input_divide,
48
            )
49
            for img in template_images
50
        ]
51
52
        score = -np.min(
53
            [
54
                scipy.spatial.distance.euclidean(template_img, probe_image)
55
                for template_img in template_images
56
            ]
57
        )
58
59
        outputs["score"].write({"value": score})
60
61
        return True
62

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

A biometrics algorithm that compares a probe image to a set of template images and outputs a comparison score. This algorithm was trained on the ATNT database and reproduces the EigenFaces face recognition baseline. The input images must be gray-scale and of the size of 92x92.

Experiments

Updated Name Databases/Protocols Analyzers
amohammadi/amohammadi/atnt_eigenfaces/1/atnt1 atnt/6@idiap amohammadi/eer_analyzer/1
Created with Raphaël 2.1.2[compare]amohammadi/linear_machine_projection_and_comparison/12021Jan28

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