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 |
---|---|---|
probe_image | system/array_2d_uint8/1 | Input |
template_images | system/array_3d_uint8/1 | Input |
score | system/float/1 | Output |
Endpoint Name | Data Format | Nature |
---|---|---|
linear_model | tutorial/linear_machine/1 | Input |
xxxxxxxxxx
import numpy as np
import scipy.spatial
def project(image, weights, biases, input_subtract, input_divide):
image = (image.flatten() - input_subtract) / input_divide
image = np.dot(image, weights.T) + biases
return image
class Algorithm:
def __init__(self):
self.projections = []
def prepare(self, data_loaders):
# Loads the model at the beginning
loader = data_loaders.loaderOf("linear_model")
for i in range(loader.count()):
view = loader.view("linear_model", i)
data, _, _ = view[0]
data = data["linear_model"]
self.weights = data.weights
self.biases = data.biases
self.input_subtract = data.input_subtract
self.input_divide = data.input_divide
return True
def process(self, inputs, data_loaders, outputs):
# collect all the image projections for the current template
probe_image = inputs["probe_image"].data.value.astype("float64")
probe_image = project(
probe_image,
self.weights,
self.biases,
self.input_subtract,
self.input_divide,
)
template_images = inputs["template_images"].data.value.astype("float64")
template_images = [
project(
img,
self.weights,
self.biases,
self.input_subtract,
self.input_divide,
)
for img in template_images
]
score = -np.min(
[
scipy.spatial.distance.euclidean(template_img, probe_image)
for template_img in template_images
]
)
outputs["score"].write({"value": score})
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
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.
Updated | Name | Databases/Protocols | Analyzers | |||
---|---|---|---|---|---|---|
amohammadi/amohammadi/atnt_eigenfaces/1/atnt1 | atnt/6@idiap | amohammadi/eer_analyzer/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.