From 212d30aaec13de1ffaa751b36e8d07d5733f0dfd Mon Sep 17 00:00:00 2001 From: Philip ABBET Date: Mon, 6 Nov 2017 14:12:32 +0100 Subject: [PATCH] Various fixes (detected on the platform) --- advanced/databases/atnt/4.json | 10 +- advanced/databases/atnt/4.py | 456 +++++++++++++++++- advanced/databases/banca/3.py | 2 +- advanced/databases/banca/3.rst | 2 +- advanced/databases/biosecurid_face/2.py | 2 +- advanced/databases/biosecurid_face/2.rst | 2 +- advanced/databases/casme2/3.py | 12 +- advanced/databases/cbsr_nir_vis_2/3.py | 4 +- advanced/databases/frgc/3.py | 22 +- advanced/databases/gbu/3.py | 2 +- advanced/databases/kboc16/3.json | 4 +- advanced/databases/kboc16/3.py | 8 +- advanced/databases/lfw/3.py | 2 +- advanced/databases/mnist/3.py | 15 +- advanced/databases/mobio/3.py | 2 +- advanced/databases/utfvp/3.py | 2 +- advanced/databases/voxforge/3.py | 2 +- advanced/databases/xm2vts/3.py | 2 +- .../system_username}/kboc16_keystroke/1.json | 2 +- 19 files changed, 485 insertions(+), 68 deletions(-) rename {advanced/dataformats/username => system/dataformats/system_username}/kboc16_keystroke/1.json (72%) diff --git a/advanced/databases/atnt/4.json b/advanced/databases/atnt/4.json index ad6a0ae..25459fc 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 fd7b6d8..8888d4b 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 0eb8029..49f65df 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 228d85b..1897c89 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 05430f6..eadad1e 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 ebe17e0..9597be6 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 4e9380f..7da6700 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 b63952e..7dc7b86 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 e24f7ea..3fcf8b6 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 9b6c849..debd736 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 cf37377..3c4fb3c 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 34c0dd0..25206a7 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 bb8b864..18c48c6 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 571c07e..ac09898 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 84967e2..b0db0be 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 b1fdb84..601fc85 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 085e4ff..54f5003 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 b334183..98ee684 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 2c48552..d4d1106 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"] } -- 2.21.0