This algorithm is a sequential one. The platform will call its process() method once per data incoming on its inputs.
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: main

Endpoint Name Data Format Nature
image system/array_2d_uint8/1 Input
id system/uint64/1 Input
projections system/array_2d_floats/1 Output

Unnamed group

Endpoint Name Data Format Nature
subspace tutorial/linear_machine/1 Input
xxxxxxxxxx
45
 
1
import numpy as np
2
3
def project(image, weights, biases, input_subtract, input_divide):
4
    image = (image - input_subtract) / input_divide
5
    image = np.dot(image, weights.T) + biases
6
    return image
7
8
9
class Algorithm:
10
11
    def __init__(self):
12
        self.projections        = []
13
14
    def prepare(self, data_loaders):
15
        # Loads the model at the beginning
16
        loader = data_loaders.loaderOf("subspace")
17
        for i in range(loader.count()):
18
            view = loader.view("subspace", i)
19
            data, _, _ = view[0]
20
            data = data["subspace"]
21
            self.weights = data.weights
22
            self.biases = data.biases
23
            self.input_subtract = data.input_subtract
24
            self.input_divide = data.input_divide
25
        return True
26
27
    def process(self, inputs, data_loaders, outputs):
28
29
        # collect all the image projections for the current template
30
        image = inputs['image'].data.value.astype('float64').flatten()
31
        projection = project(image, self.weights, self.biases, self.input_subtract, self.input_divide)
32
33
        self.projections.append(projection)
34
35
        # generate the results (when all the images of the current template have been
36
        # projected)
37
        if inputs["id"].isDataUnitDone():
38
            outputs['projections'].write({
39
                'value': np.array(self.projections, dtype=np.float64)
40
            })
41
42
            self.projections = []
43
44
        return True
45

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

This algorithm linearizes and accumulates images into a buffer, before applying a linear transformation (e.g. using a projection matrix computed by principal component analysis). The linear transformation relies on the Bob library.

The inputs are:

  • image: an image as a two-dimensional arrays of floats (64 bits)
  • id: an identifier which is used as follows: all images with the
    same identifier are accumulated into the same buffer
  • subspace: a linear transformation as a collection of weights,
    biases, input subtraction and input division factors.

The output projections is a two-dimensional array of floats (64 bits), the number of rows corresponding to the number of accumulated images (with the same identifier), and the number of columns to the output dimensionality after applying the linear transformation.

Experiments

Updated Name Databases/Protocols Analyzers
amohammadi/tutorial/eigenface/1/atnt-eigenfaces-66-comp atnt/5@idiap tutorial/postperf_iso/1
amohammadi/tutorial/eigenface/1/atnt-eigenfaces-67-comp atnt/5@idiap tutorial/postperf_iso/1
Created with Raphaël 2.1.2[compare]tutorial/linear_machine_projection/1tutorial/linear_machine_projection/3Jun29tutorial/linear_machine_projection/42014Nov5anjos/lda_projection/13sbhatta/iqm_project_lda/4Sep17chichan/comp_linear_machine_projection/3718amohammadi/linear_machine_projection/12015Nov252020Jul21

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