diff --git a/advanced/databases/atnt/4.json b/advanced/databases/atnt/4.json index ad6a0ae12e521a00526c37ea8a6f5d3081483aa0..25459fc0a60660a3f0c72e71ec970f8a733e94b5 100644 --- a/advanced/databases/atnt/4.json +++ b/advanced/databases/atnt/4.json @@ -48,7 +48,7 @@ { "name": "train", "template": "train", - "view": "Train", + "view": "TrainEyePositions", "outputs": { "file_id": "{{ system_user.username }}/uint64/1", "client_id": "{{ system_user.username }}/uint64/1", @@ -59,7 +59,7 @@ { "name": "dev_templates", "template": "templates", - "view": "Templates", + "view": "TemplatesEyePositions", "parameters": { "group": "dev" }, @@ -74,7 +74,7 @@ { "name": "dev_probes", "template": "probes", - "view": "Probes", + "view": "ProbesEyePositions", "parameters": { "group": "dev" }, @@ -90,7 +90,7 @@ { "name": "test_templates", "template": "templates", - "view": "Templates", + "view": "TemplatesEyePositions", "parameters": { "group": "eval" }, @@ -105,7 +105,7 @@ { "name": "test_probes", "template": "probes", - "view": "Probes", + "view": "ProbesEyePositions", "parameters": { "group": "eval" }, diff --git a/advanced/databases/atnt/4.py b/advanced/databases/atnt/4.py index fd7b6d80d97cc81f54ff465e52e62780b8503c50..8888d4be75ef1802823ec0e68806c2eeb54b3d22 100644 --- a/advanced/databases/atnt/4.py +++ b/advanced/databases/atnt/4.py @@ -25,6 +25,7 @@ import numpy as np import bob.io.base import bob.io.image +import bob.ip.color import bob.db.atnt @@ -75,10 +76,8 @@ class Train: - image: "{{ system_user.username }}/array_2d_uint8/1" - file_id: "{{ system_user.username }}/uint64/1" - client_id: "{{ system_user.username }}/uint64/1" - - (optional) eye_centers: "{{ system_user.username }}/eye_positions/1" One "file_id" is associated with a given "image". - One "eye_centers" is associated with a given "image". Several "image" are associated with a given "client_id". --------------- --------------- --------------- --------------- --------------- --------------- @@ -87,9 +86,6 @@ class Train: --------------- --------------- --------------- --------------- --------------- --------------- | file_id | | file_id | | file_id | | file_id | | file_id | | file_id | --------------- --------------- --------------- --------------- --------------- --------------- - --------------- --------------- --------------- --------------- --------------- --------------- - | eye_centers | | eye_centers | | eye_centers | | eye_centers | | eye_centers | | eye_centers | - --------------- --------------- --------------- --------------- --------------- --------------- ----------------------------------------------- ----------------------------------------------- | client_id | | client_id | ----------------------------------------------- ----------------------------------------------- @@ -191,10 +187,8 @@ class Templates: - file_id: "{{ system_user.username }}/uint64/1" - template_id: "{{ system_user.username }}/uint64/1" - client_id: "{{ system_user.username }}/uint64/1" - - (optional) eye_centers: "{{ system_user.username }}/eye_positions/1" One "file_id" is associated with a given "image". - One "eye_centers" is associated with a given "image". Several "image" are associated with a given "template_id". Several "template_id" are associated with a given "client_id". @@ -204,9 +198,6 @@ class Templates: --------------- --------------- --------------- --------------- --------------- --------------- | file_id | | file_id | | file_id | | file_id | | file_id | | file_id | --------------- --------------- --------------- --------------- --------------- --------------- - --------------- --------------- --------------- --------------- --------------- --------------- - | eye_centers | | eye_centers | | eye_centers | | eye_centers | | eye_centers | | eye_centers | - --------------- --------------- --------------- --------------- --------------- --------------- ----------------------------------------------- ----------------------------------------------- | template_id | | template_id | ----------------------------------------------- ----------------------------------------------- @@ -346,7 +337,424 @@ class Probes: - client_id: "{{ system_user.username }}/uint64/1" - probe_id: "{{ system_user.username }}/uint64/1" - template_ids: "{{ system_user.username }}/array_1d_uint64/1" - - (optional) eye_centers: "{{ system_user.username }}/eye_positions/1" + + One "file_id" is associated with a given "image". + One "probe_id" is associated with a given "image". + Several "image" are associated with a given "client_id". + Several "client_id" are associated with a given "template_ids". + + --------------- --------------- --------------- --------------- --------------- --------------- + | image | | image | | image | | image | | image | | image | + --------------- --------------- --------------- --------------- --------------- --------------- + --------------- --------------- --------------- --------------- --------------- --------------- + | file_id | | file_id | | file_id | | file_id | | file_id | | file_id | + --------------- --------------- --------------- --------------- --------------- --------------- + --------------- --------------- --------------- --------------- --------------- --------------- + | probe_id | | probe_id | | probe_id | | probe_id | | probe_id | | probe_id | + --------------- --------------- --------------- --------------- --------------- --------------- + ----------------------------------------------- ----------------------------------------------- + | client_id | | client_id | + ----------------------------------------------- ----------------------------------------------- + ----------------------------------------------------------------------------------------------- + | template_ids | + ----------------------------------------------------------------------------------------------- + """ + + def setup(self, root_folder, outputs, parameters, force_start_index=None, + force_end_index=None): + + # Initialisations + self.root_folder = root_folder + self.outputs = outputs + + # Open the database and load the objects to provide via the outputs + self.db = bob.db.atnt.Database() + self.objs = sorted(self.db.objects(groups='dev', purposes='probe'), + key=lambda x: (x.client_id, x.id)) + + # Determine the range of indices that must be provided + self.start_index = force_start_index if force_start_index is not None else 0 + self.end_index = force_end_index if force_end_index is not None else len(self.objs) - 1 + + self.objs = self.objs[self.start_index : self.end_index + 1] + + self.next_index = self.start_index + + return True + + + def done(self, last_data_index): + return last_data_index >= self.end_index + + + def next(self): + obj = self.objs[self.next_index - self.start_index] + + # Output: template_ids (only provide data when the template_ids change) + if self.outputs['template_ids'].isConnected() and \ + self.outputs['template_ids'].last_written_data_index < self.next_index: + + self.outputs['template_ids'].write( + { + 'value': np.array(sorted(self.db.model_ids(groups='dev'), + key=lambda x: int(x)), + dtype='uint64') + }, + self.end_index + ) + + + # Output: client_id (only provide data when the client_id change) + if self.outputs['client_id'].isConnected() and \ + self.outputs['client_id'].last_written_data_index < self.next_index: + + client_end_index = get_client_end_index(self.objs, obj.client_id, + self.next_index, + self.start_index, + self.end_index) + + self.outputs['client_id'].write( + { + 'value': np.uint64(obj.client_id) + }, + client_end_index + ) + + + # Output: probe_id (provide data at each iteration) + if self.outputs['probe_id'].isConnected(): + self.outputs['probe_id'].write( + { + 'value': np.uint64(obj.id) + }, + self.next_index + ) + + + # Output: file_id (provide data at each iteration) + if self.outputs['file_id'].isConnected(): + self.outputs['file_id'].write( + { + 'value': np.uint64(obj.id) + }, + self.next_index + ) + + + # Output: image (provide data at each iteration) + if self.outputs['image'].isConnected(): + self.outputs['image'].write( + { + 'value': bob.io.base.load(obj.make_path(self.root_folder, '.pgm')) + }, + self.next_index + ) + + + # Optional output: eye_centers (provide data at each iteration) + if (self.outputs['eye_centers'] is not None) and self.outputs['eye_centers'].isConnected(): + self.outputs['eye_centers'].write({ + 'left': { + 'y': np.int32(48), + 'x': np.int32(63), + }, + 'right': { + 'y': np.int32(48), + 'x': np.int32(27), + } + }, + self.next_index + ) + + + # Determine the next data index that must be provided + self.next_index = 1 + min([ x.last_written_data_index for x in self.outputs + if x.isConnected() ] + ) + + return True + + +#---------------------------------------------------------- + + +class TrainEyePositions: + """Outputs: + - image: "{{ system_user.username }}/array_3d_uint8/1" + - file_id: "{{ system_user.username }}/uint64/1" + - eye_centers: "{{ system_user.username }}/eye_positions/1" + - client_id: "{{ system_user.username }}/uint64/1" + + One "file_id" is associated with a given "image". + One "eye_centers" is associated with a given "image". + Several "image" are associated with a given "client_id". + + --------------- --------------- --------------- --------------- --------------- --------------- + | image | | image | | image | | image | | image | | image | + --------------- --------------- --------------- --------------- --------------- --------------- + --------------- --------------- --------------- --------------- --------------- --------------- + | file_id | | file_id | | file_id | | file_id | | file_id | | file_id | + --------------- --------------- --------------- --------------- --------------- --------------- + --------------- --------------- --------------- --------------- --------------- --------------- + | eye_centers | | eye_centers | | eye_centers | | eye_centers | | eye_centers | | eye_centers | + --------------- --------------- --------------- --------------- --------------- --------------- + ----------------------------------------------- ----------------------------------------------- + | client_id | | client_id | + ----------------------------------------------- ----------------------------------------------- + """ + + def setup(self, root_folder, outputs, parameters, force_start_index=None, + force_end_index=None): + + # Initialisations + self.root_folder = root_folder + self.outputs = outputs + + # Open the database and load the objects to provide via the outputs + self.db = bob.db.atnt.Database() + self.objs = sorted(self.db.objects(groups='world', purposes=None), + key=lambda x: (x.client_id, x.id)) + + # Determine the range of indices that must be provided + self.start_index = force_start_index if force_start_index is not None else 0 + self.end_index = force_end_index if force_end_index is not None else len(self.objs) - 1 + + self.objs = self.objs[self.start_index : self.end_index + 1] + + self.next_index = self.start_index + + return True + + + def done(self, last_data_index): + return last_data_index >= self.end_index + + + def next(self): + obj = self.objs[self.next_index - self.start_index] + + # Output: client_id (only provide data when the client_id change) + if self.outputs['client_id'].isConnected() and \ + self.outputs['client_id'].last_written_data_index < self.next_index: + + client_end_index = get_client_end_index(self.objs, obj.client_id, + self.next_index, + self.start_index, + self.end_index) + + self.outputs['client_id'].write( + { + 'value': np.uint64(obj.client_id) + }, + client_end_index + ) + + # Output: file_id (provide data at each iteration) + if self.outputs['file_id'].isConnected(): + self.outputs['file_id'].write( + { + 'value': np.uint64(obj.id) + }, + self.next_index + ) + + # Output: image (provide data at each iteration) + if self.outputs['image'].isConnected(): + self.outputs['image'].write( + { + 'value': bob.ip.color.gray_to_rgb(bob.io.base.load(obj.make_path(self.root_folder, '.pgm'))) + }, + self.next_index + ) + + # Output: eye_centers (provide data at each iteration) + if self.outputs['eye_centers'].isConnected(): + self.outputs['eye_centers'].write({ + 'left': { + 'y': np.int32(48), + 'x': np.int32(63), + }, + 'right': { + 'y': np.int32(48), + 'x': np.int32(27), + } + }, + self.next_index + ) + + # Determine the next data index that must be provided + self.next_index = 1 + min([ x.last_written_data_index for x in self.outputs + if x.isConnected() ] + ) + + return True + + +#---------------------------------------------------------- + + +class TemplatesEyePositions: + """Outputs: + - image: "{{ system_user.username }}/array_3d_uint8/1" + - file_id: "{{ system_user.username }}/uint64/1" + - eye_centers: "{{ system_user.username }}/eye_positions/1" + - template_id: "{{ system_user.username }}/uint64/1" + - client_id: "{{ system_user.username }}/uint64/1" + + One "file_id" is associated with a given "image". + One "eye_centers" is associated with a given "image". + Several "image" are associated with a given "template_id". + Several "template_id" are associated with a given "client_id". + + --------------- --------------- --------------- --------------- --------------- --------------- + | image | | image | | image | | image | | image | | image | + --------------- --------------- --------------- --------------- --------------- --------------- + --------------- --------------- --------------- --------------- --------------- --------------- + | file_id | | file_id | | file_id | | file_id | | file_id | | file_id | + --------------- --------------- --------------- --------------- --------------- --------------- + --------------- --------------- --------------- --------------- --------------- --------------- + | eye_centers | | eye_centers | | eye_centers | | eye_centers | | eye_centers | | eye_centers | + --------------- --------------- --------------- --------------- --------------- --------------- + ----------------------------------------------- ----------------------------------------------- + | template_id | | template_id | + ----------------------------------------------- ----------------------------------------------- + ----------------------------------------------------------------------------------------------- + | client_id | + ----------------------------------------------------------------------------------------------- + + Note: for this particular database, there is only one "template_id" + per "client_id". + """ + + def setup(self, root_folder, outputs, parameters, force_start_index=None, + force_end_index=None): + + # Initialisations + self.root_folder = root_folder + self.outputs = outputs + + # Open the database and load the objects to provide via the outputs + self.db = bob.db.atnt.Database() + + template_ids = self.db.model_ids(groups='dev') + + self.objs = [] + + for template_id in template_ids: + objs = self.db.objects(groups='dev', purposes='enroll', + model_ids=[template_id]) + + self.objs.extend([ (template_id, obj) for obj in objs ]) + + self.objs = sorted(self.objs, key=lambda x: (x[1].client_id, x[0], x[1].id)) + + # Determine the range of indices that must be provided + self.start_index = force_start_index if force_start_index is not None else 0 + self.end_index = force_end_index if force_end_index is not None else len(self.objs) - 1 + + self.objs = self.objs[self.start_index : self.end_index + 1] + + self.next_index = self.start_index + + return True + + + def done(self, last_data_index): + return last_data_index >= self.end_index + + + def next(self): + (template_id, obj) = self.objs[self.next_index - self.start_index] + + # Output: template_id (only provide data when the template_id change) + if self.outputs['template_id'].isConnected() and \ + self.outputs['template_id'].last_written_data_index < self.next_index: + + template_end_index = get_template_end_index(self.objs, template_id, + self.next_index, + self.start_index, + self.end_index) + + self.outputs['template_id'].write( + { + 'value': np.uint64(template_id) + }, + template_end_index + ) + + + # Output: client_id (only provide data when the client_id change) + if self.outputs['client_id'].isConnected() and \ + self.outputs['client_id'].last_written_data_index < self.next_index: + + client_end_index = get_client_end_index(self.objs, obj.client_id, + self.next_index, + self.start_index, + self.end_index) + + self.outputs['client_id'].write( + { + 'value': np.uint64(obj.client_id) + }, + client_end_index + ) + + + # Output: file_id (provide data at each iteration) + if self.outputs['file_id'].isConnected(): + self.outputs['file_id'].write( + { + 'value': np.uint64(obj.id) + }, + self.next_index + ) + + + # Output: image (provide data at each iteration) + if self.outputs['image'].isConnected(): + self.outputs['image'].write( + { + 'value': bob.ip.color.gray_to_rgb(bob.io.base.load(obj.make_path(self.root_folder, '.pgm'))) + }, + self.next_index + ) + + + # Output: eye_centers (provide data at each iteration) + if self.outputs['eye_centers'].isConnected(): + self.outputs['eye_centers'].write({ + 'left': { + 'y': np.int32(48), + 'x': np.int32(63), + }, + 'right': { + 'y': np.int32(48), + 'x': np.int32(27), + } + }, + self.next_index + ) + + + # Determine the next data index that must be provided + self.next_index = 1 + min([ x.last_written_data_index for x in self.outputs + if x.isConnected() ] + ) + + return True + + +#---------------------------------------------------------- + + +class ProbesEyePositions: + """Outputs: + - image: "{{ system_user.username }}/array_3d_uint8/1" + - file_id: "{{ system_user.username }}/uint64/1" + - eye_centers: "{{ system_user.username }}/eye_positions/1" + - client_id: "{{ system_user.username }}/uint64/1" + - probe_id: "{{ system_user.username }}/uint64/1" + - template_ids: "{{ system_user.username }}/array_1d_uint64/1" One "file_id" is associated with a given "image". One "eye_centers" is associated with a given "image". @@ -459,14 +867,14 @@ class Probes: if self.outputs['image'].isConnected(): self.outputs['image'].write( { - 'value': bob.io.base.load(obj.make_path(self.root_folder, '.pgm')) + 'value': bob.ip.color.gray_to_rgb(bob.io.base.load(obj.make_path(self.root_folder, '.pgm'))) }, self.next_index ) - # Optional output: eye_centers (provide data at each iteration) - if (self.outputs['eye_centers'] is not None) and self.outputs['eye_centers'].isConnected(): + # Output: eye_centers (provide data at each iteration) + if self.outputs['eye_centers'].isConnected(): self.outputs['eye_centers'].write({ 'left': { 'y': np.int32(48), @@ -519,30 +927,30 @@ if __name__ == '__main__': parameters=dict(), ) - DatabaseTester('Train (with eye centers)', Train, + DatabaseTester('Templates', Templates, [ 'client_id', + 'template_id', 'file_id', - 'eye_centers', 'image', ], parameters=dict(), ) - DatabaseTester('Templates', Templates, + DatabaseTester('Probes', Probes, [ + 'template_ids', 'client_id', - 'template_id', + 'probe_id', 'file_id', 'image', ], parameters=dict(), ) - DatabaseTester('Templates (with eye centers)', Templates, + DatabaseTester('TrainEyePositions', TrainEyePositions, [ 'client_id', - 'template_id', 'file_id', 'eye_centers', 'image', @@ -550,18 +958,18 @@ if __name__ == '__main__': parameters=dict(), ) - DatabaseTester('Probes', Probes, + DatabaseTester('TemplatesEyePositions', TemplatesEyePositions, [ - 'template_ids', 'client_id', - 'probe_id', + 'template_id', 'file_id', + 'eye_centers', 'image', ], parameters=dict(), ) - DatabaseTester('Probes (with eye centers)', Probes, + DatabaseTester('ProbesEyePositions', ProbesEyePositions, [ 'template_ids', 'client_id', diff --git a/advanced/databases/banca/3.py b/advanced/databases/banca/3.py index 0eb8029c7624d391fc4a9dd325a91834b146c132..49f65df769ad3ab0c52d631a378c2b3941143c66 100644 --- a/advanced/databases/banca/3.py +++ b/advanced/databases/banca/3.py @@ -445,7 +445,7 @@ class Probes: self.outputs['template_ids'].write( { - 'value': template_ids + 'value': np.uint64(template_ids) }, template_ids_end_index ) diff --git a/advanced/databases/banca/3.rst b/advanced/databases/banca/3.rst index 228d85bc950a6ad18326784384de9cfd3250681a..1897c89039afc91f0553a1cf3a0ff9366c25c65d 100644 --- a/advanced/databases/banca/3.rst +++ b/advanced/databases/banca/3.rst @@ -1,4 +1,4 @@ -.. Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/ .. +.. Copyright (c) 2017 Idiap Research Institute, http://www.idiap.ch/ .. .. Contact: beat.support@idiap.ch .. .. .. .. This file is part of the beat.examples module of the BEAT platform. .. diff --git a/advanced/databases/biosecurid_face/2.py b/advanced/databases/biosecurid_face/2.py index 05430f618c618479b67e16c93d8ecc3b21020262..eadad1ea03cf3505c479b3e3f28d2b652d6c30fc 100644 --- a/advanced/databases/biosecurid_face/2.py +++ b/advanced/databases/biosecurid_face/2.py @@ -397,7 +397,7 @@ class Probes: self.outputs['template_ids'].write( { - 'value': template_ids + 'value': np.uint64(template_ids) }, template_ids_end_index ) diff --git a/advanced/databases/biosecurid_face/2.rst b/advanced/databases/biosecurid_face/2.rst index ebe17e00728e8da6c979b08dbe83c3ccdf7a0fcd..9597be6e4b9e7c98d1e216951243178944a6dc29 100644 --- a/advanced/databases/biosecurid_face/2.rst +++ b/advanced/databases/biosecurid_face/2.rst @@ -1,4 +1,4 @@ -.. Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/ .. +.. Copyright (c) 2017 Idiap Research Institute, http://www.idiap.ch/ .. .. Contact: beat.support@idiap.ch .. .. .. .. This file is part of the beat.examples module of the BEAT platform. .. diff --git a/advanced/databases/casme2/3.py b/advanced/databases/casme2/3.py index 4e9380f4d421f49cf70eb26425456ab7ed912834..7da670051aff12fb24b579dc599223bb450b2a54 100644 --- a/advanced/databases/casme2/3.py +++ b/advanced/databases/casme2/3.py @@ -104,7 +104,7 @@ class View: # Open the database and load the objects to provide via the outputs self.db = bob.db.casme2.Database() - self.objs = sorted(self.db.objects(protocol=parameters['protocol'], + self.objs = sorted(self.db.objects(protocol=str(parameters['protocol']), groups=parameters['group']), key=lambda x: (x.emotion, x.client_id, x.id)) @@ -171,7 +171,11 @@ class View: if self.outputs['image'].isConnected(): frames = obj.frames - filename = str(os.path.join(obj.make_path(self.root_folder), frames[0].filename)) + filename = str(os.path.join(obj.make_path(), frames[0].filename)) + + # Bugfix: the database returns invalid paths... + filename = filename.replace('/idiap/resource/database/CASME2/Cropped', self.root_folder) + frame = bob.io.base.load(filename) data = np.zeros(shape=(len(frames), frame.shape[0], frame.shape[1], frame.shape[2]), dtype="uint8") @@ -179,6 +183,10 @@ class View: for i in range(1, len(frames)): filename = str(os.path.join(obj.make_path(self.root_folder), frames[i].filename)) + + # Bugfix: the database returns invalid paths... + filename = filename.replace('/idiap/resource/database/CASME2/Cropped', self.root_folder) + data[i] = bob.io.base.load(filename) self.outputs['image'].write( diff --git a/advanced/databases/cbsr_nir_vis_2/3.py b/advanced/databases/cbsr_nir_vis_2/3.py index b63952e8f561b86160ada44e9a5a0aa2d91e3c6f..7dc7b864a4963eb416a6d410e4a201a9558dc28a 100644 --- a/advanced/databases/cbsr_nir_vis_2/3.py +++ b/advanced/databases/cbsr_nir_vis_2/3.py @@ -23,7 +23,7 @@ ############################################################################### import os -import numpy +import numpy as np import bob.io.base import bob.io.image import bob.db.cbsr_nir_vis_2 @@ -459,7 +459,7 @@ class Probes: self.outputs['template_ids'].write( { - 'value': template_ids + 'text': template_ids }, template_ids_end_index ) diff --git a/advanced/databases/frgc/3.py b/advanced/databases/frgc/3.py index e24f7ea32437322cd6b34810981b7041107ffb92..3fcf8b6dc8fc4c0b116b56f484a01cb44c41fa31 100644 --- a/advanced/databases/frgc/3.py +++ b/advanced/databases/frgc/3.py @@ -23,7 +23,7 @@ ############################################################################### import os -import numpy +import numpy as np import bob.io.base import bob.io.image import bob.db.frgc @@ -104,7 +104,7 @@ class Train: self.outputs = outputs # Open the database and load the objects to provide via the outputs - self.db = bob.db.frgc.Database() + self.db = bob.db.frgc.Database(original_directory=root_folder) self.objs = sorted(self.db.objects(protocol=parameters['protocol'], groups='world', @@ -157,7 +157,7 @@ class Train: # Output: image (provide data at each iteration) if self.outputs['image'].isConnected(): filename = obj.make_path(self.root_folder, '.jpg') - if not os.path.exists(path): + if not os.path.exists(filename): path = obj.make_path(self.root_folder, '.JPG') self.outputs['image'].write( @@ -200,7 +200,7 @@ class Templates: - image: "{{ system_user.username }}/array_3d_uint8/1" - file_id: "{{ system_user.username }}/text/1" - eye_centers: "{{ system_user.username }}/eye_positions/1" - - template_id: "{{ system_user.username }}/text/1" + - template_id: "{{ system_user.username }}/uint64/1" - client_id: "{{ system_user.username }}/text/1" One "file_id" is associated with a given "image". @@ -234,7 +234,7 @@ class Templates: self.parameters = parameters # Open the database and load the objects to provide via the outputs - self.db = bob.db.frgc.Database() + self.db = bob.db.frgc.Database(original_directory=root_folder) template_ids = self.db.model_ids(protocol=parameters['protocol'], groups='dev', @@ -282,7 +282,7 @@ class Templates: self.outputs['template_id'].write( { - 'text': template_id + 'value': np.uint64(template_id) }, template_end_index ) @@ -315,7 +315,7 @@ class Templates: # Output: image (provide data at each iteration) if self.outputs['image'].isConnected(): filename = obj.make_path(self.root_folder, '.jpg') - if not os.path.exists(path): + if not os.path.exists(filename): path = obj.make_path(self.root_folder, '.JPG') self.outputs['image'].write( @@ -360,7 +360,7 @@ class Probes: - eye_centers: "{{ system_user.username }}/eye_positions/1" - probe_id: "{{ system_user.username }}/text/1" - client_id: "{{ system_user.username }}/text/1" - - template_ids: "{{ system_user.username }}/array_1d_text/1" + - template_ids: "{{ system_user.username }}/array_1d_uint64/1" One "file_id" is associated with a given "image". One "eye_centers" is associated with a given "image". @@ -397,7 +397,7 @@ class Probes: self.parameters = parameters # Open the database and load the objects to provide via the outputs - self.db = bob.db.frgc.Database() + self.db = bob.db.frgc.Database(original_directory=root_folder) template_ids = sorted(self.db.model_ids(protocol=parameters['protocol'], groups='dev', @@ -457,7 +457,7 @@ class Probes: self.outputs['template_ids'].write( { - 'value': template_ids + 'value': np.uint64(template_ids) }, template_ids_end_index ) @@ -499,7 +499,7 @@ class Probes: # Output: image (provide data at each iteration) if self.outputs['image'].isConnected(): filename = obj.make_path(self.root_folder, '.jpg') - if not os.path.exists(path): + if not os.path.exists(filename): path = obj.make_path(self.root_folder, '.JPG') self.outputs['image'].write( diff --git a/advanced/databases/gbu/3.py b/advanced/databases/gbu/3.py index 9b6c84958e831f4e031a025dd92d669f70bde6e5..debd736ca8a336da0b876e174a688c142aed1d36 100644 --- a/advanced/databases/gbu/3.py +++ b/advanced/databases/gbu/3.py @@ -447,7 +447,7 @@ class Probes: self.outputs['template_ids'].write( { - 'value': template_ids + 'value': np.uint64(template_ids) }, template_ids_end_index ) diff --git a/advanced/databases/kboc16/3.json b/advanced/databases/kboc16/3.json index cf37377c702ba199a8e1308207d108d3a4739f65..3c4fb3c3d5387020698d50a3809f0e2236824d9d 100644 --- a/advanced/databases/kboc16/3.json +++ b/advanced/databases/kboc16/3.json @@ -17,7 +17,7 @@ "file_id": "{{ system_user.username }}/uint64/1", "client_id": "{{ system_user.username }}/text/1", "template_id": "{{ system_user.username }}/text/1", - "keystroke": "{{ user.username }}/kboc16_keystroke/1" + "keystroke": "{{ system_user.username }}/kboc16_keystroke/1" } }, { @@ -32,7 +32,7 @@ "probe_id": "{{ system_user.username }}/uint64/1", "client_id": "{{ system_user.username }}/text/1", "template_ids": "{{ system_user.username }}/array_1d_text/1", - "keystroke": "{{ user.username }}/kboc16_keystroke/1" + "keystroke": "{{ system_user.username }}/kboc16_keystroke/1" } } ] diff --git a/advanced/databases/kboc16/3.py b/advanced/databases/kboc16/3.py index 34c0dd02c92973bdb76652112e3e3b9b0b6127c8..25206a7399c33f39ad33b155434c1e92c6d6a77e 100644 --- a/advanced/databases/kboc16/3.py +++ b/advanced/databases/kboc16/3.py @@ -36,11 +36,11 @@ def keystroke_reader(filename): for line in open(filename, 'r').readlines(): parts = string.split(line) - times.append(numpy.int32(parts[1])) + times.append(np.int32(parts[1])) keys.append(parts[0]) return dict( - holdtime = times, + timestamps = times, key_events = keys, ) @@ -89,7 +89,7 @@ def get_value_end_index(objs, value, index_in_tuple, value_start_index, class Templates: """Outputs: - - keystroke: "{{ user.username }}/kboc16_keystroke/1 + - keystroke: "{{ system_user.username }}/kboc16_keystroke/1 - file_id: "{{ system_user.username }}/uint64/1" - template_id: "{{ system_user.username }}/text/1" - client_id: "{{ system_user.username }}/text/1" @@ -225,7 +225,7 @@ class Templates: class Probes: """Outputs: - - keystroke: "{{ user.username }}/kboc16_keystroke/1 + - keystroke: "{{ system_user.username }}/kboc16_keystroke/1 - file_id: "{{ system_user.username }}/uint64/1" - client_id: "{{ system_user.username }}/text/1" - probe_id: "{{ system_user.username }}/uint64/1", diff --git a/advanced/databases/lfw/3.py b/advanced/databases/lfw/3.py index bb8b864a9d10d77892d9236c7347bdddc10530b6..18c48c6dd9db1e58f37698bdb60c590aa5d34fbf 100644 --- a/advanced/databases/lfw/3.py +++ b/advanced/databases/lfw/3.py @@ -395,7 +395,7 @@ class Probes: self.outputs['template_ids'].write( { - 'value': template_ids + 'value': np.uint64(template_ids) }, template_ids_end_index ) diff --git a/advanced/databases/mnist/3.py b/advanced/databases/mnist/3.py index 571c07e57f7541a7df1633aa5bb92032496124a8..ac09898a1aa052d04216bdf6fd8025252e2ef358 100644 --- a/advanced/databases/mnist/3.py +++ b/advanced/databases/mnist/3.py @@ -29,12 +29,12 @@ import bob.db.mnist #---------------------------------------------------------- -def get_label_end_index(labels, label, label_start_index, +def get_label_end_index(objs, label, label_start_index, start_index, end_index): label_end_index = label_start_index while label_end_index + 1 <= end_index: - label_ = labels[label_end_index + 1 - start_index] + label_ = objs[label_end_index + 1 - start_index][1] if label_ != label: return label_end_index @@ -78,8 +78,10 @@ class View: # Open the database and load the objects to provide via the outputs self.db = bob.db.mnist.Database(data_dir=self.root_folder) - self.features, self.labels = sorted(self.db.data(groups=parameters['group']), - key=lambda x: x[1]) + features, labels = self.db.data(groups=parameters['group']) + + self.objs = sorted([ (features[i], labels[i]) for i in range(len(features)) ], + key=lambda x: x[1]) # Determine the range of indices that must be provided self.start_index = force_start_index if force_start_index is not None else 0 @@ -97,14 +99,13 @@ class View: def next(self): - features = self.features[self.next_index - self.start_index, :] - label = self.labels[self.next_index - self.start_index] + features, label = self.objs[self.next_index - self.start_index] # Output: class_id (only provide data when the class_id change) if self.outputs['class_id'].isConnected() and \ self.outputs['class_id'].last_written_data_index < self.next_index: - label_end_index = get_label_end_index(self.labels, label, + label_end_index = get_label_end_index(self.objs, label, self.next_index, self.start_index, self.end_index) diff --git a/advanced/databases/mobio/3.py b/advanced/databases/mobio/3.py index 84967e2b8cc831b9d26197835fd6d227ac0e8598..b0db0bed9f1ff7b52fe5e807f8d77794482f30e2 100644 --- a/advanced/databases/mobio/3.py +++ b/advanced/databases/mobio/3.py @@ -459,7 +459,7 @@ class Probes: self.outputs['template_ids'].write( { - 'value': template_ids + 'value': np.uint64(template_ids) }, template_ids_end_index ) diff --git a/advanced/databases/utfvp/3.py b/advanced/databases/utfvp/3.py index b1fdb84704cb42a10e71b23a9403a8924a8d2b60..601fc853f80814bea5a5b8be11885f5bd19018f0 100644 --- a/advanced/databases/utfvp/3.py +++ b/advanced/databases/utfvp/3.py @@ -379,7 +379,7 @@ class Probes: self.outputs['template_ids'].write( { - 'value': template_ids + 'text': template_ids }, end_index ) diff --git a/advanced/databases/voxforge/3.py b/advanced/databases/voxforge/3.py index 085e4ff86f93d4b8bdf9ca685b2df2d555d759fd..54f50039481729894e221b63195a868aee8ef65c 100644 --- a/advanced/databases/voxforge/3.py +++ b/advanced/databases/voxforge/3.py @@ -401,7 +401,7 @@ class Probes: self.outputs['template_ids'].write( { - 'value': template_ids + 'text': template_ids }, template_ids_end_index ) diff --git a/advanced/databases/xm2vts/3.py b/advanced/databases/xm2vts/3.py index b3341839d2369ad175b0425e8330fd85f8363fd1..98ee684d3b178bc5bcc90fcfeb33770ffc3ad979 100644 --- a/advanced/databases/xm2vts/3.py +++ b/advanced/databases/xm2vts/3.py @@ -449,7 +449,7 @@ class Probes: self.outputs['template_ids'].write( { - 'value': template_ids + 'value': np.uint64(template_ids) }, template_ids_end_index ) diff --git a/advanced/dataformats/username/kboc16_keystroke/1.json b/system/dataformats/system_username/kboc16_keystroke/1.json similarity index 72% rename from advanced/dataformats/username/kboc16_keystroke/1.json rename to system/dataformats/system_username/kboc16_keystroke/1.json index 2c48552b78af75349f32a635d38ffa443e463333..d4d1106e9dc191163aa248be70a608b7d0656d70 100644 --- a/advanced/dataformats/username/kboc16_keystroke/1.json +++ b/system/dataformats/system_username/kboc16_keystroke/1.json @@ -1,5 +1,5 @@ { "#description": "Raw KBOC16 keystroke data", - "holdtime": [0, "int32"], + "timestamps": [0, "int32"], "key_events": [0, "string"] }