Commit 212d30aa authored by Philip ABBET's avatar Philip ABBET

Various fixes (detected on the platform)

parent a81d1638
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
{ {
"name": "train", "name": "train",
"template": "train", "template": "train",
"view": "Train", "view": "TrainEyePositions",
"outputs": { "outputs": {
"file_id": "{{ system_user.username }}/uint64/1", "file_id": "{{ system_user.username }}/uint64/1",
"client_id": "{{ system_user.username }}/uint64/1", "client_id": "{{ system_user.username }}/uint64/1",
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
{ {
"name": "dev_templates", "name": "dev_templates",
"template": "templates", "template": "templates",
"view": "Templates", "view": "TemplatesEyePositions",
"parameters": { "parameters": {
"group": "dev" "group": "dev"
}, },
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
{ {
"name": "dev_probes", "name": "dev_probes",
"template": "probes", "template": "probes",
"view": "Probes", "view": "ProbesEyePositions",
"parameters": { "parameters": {
"group": "dev" "group": "dev"
}, },
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
{ {
"name": "test_templates", "name": "test_templates",
"template": "templates", "template": "templates",
"view": "Templates", "view": "TemplatesEyePositions",
"parameters": { "parameters": {
"group": "eval" "group": "eval"
}, },
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
{ {
"name": "test_probes", "name": "test_probes",
"template": "probes", "template": "probes",
"view": "Probes", "view": "ProbesEyePositions",
"parameters": { "parameters": {
"group": "eval" "group": "eval"
}, },
......
This diff is collapsed.
...@@ -445,7 +445,7 @@ class Probes: ...@@ -445,7 +445,7 @@ class Probes:
self.outputs['template_ids'].write( self.outputs['template_ids'].write(
{ {
'value': template_ids 'value': np.uint64(template_ids)
}, },
template_ids_end_index template_ids_end_index
) )
......
.. 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 .. .. Contact: beat.support@idiap.ch ..
.. .. .. ..
.. This file is part of the beat.examples module of the BEAT platform. .. .. This file is part of the beat.examples module of the BEAT platform. ..
......
...@@ -397,7 +397,7 @@ class Probes: ...@@ -397,7 +397,7 @@ class Probes:
self.outputs['template_ids'].write( self.outputs['template_ids'].write(
{ {
'value': template_ids 'value': np.uint64(template_ids)
}, },
template_ids_end_index template_ids_end_index
) )
......
.. 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 .. .. Contact: beat.support@idiap.ch ..
.. .. .. ..
.. This file is part of the beat.examples module of the BEAT platform. .. .. This file is part of the beat.examples module of the BEAT platform. ..
......
...@@ -104,7 +104,7 @@ class View: ...@@ -104,7 +104,7 @@ class View:
# Open the database and load the objects to provide via the outputs # Open the database and load the objects to provide via the outputs
self.db = bob.db.casme2.Database() 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']), groups=parameters['group']),
key=lambda x: (x.emotion, x.client_id, x.id)) key=lambda x: (x.emotion, x.client_id, x.id))
...@@ -171,7 +171,11 @@ class View: ...@@ -171,7 +171,11 @@ class View:
if self.outputs['image'].isConnected(): if self.outputs['image'].isConnected():
frames = obj.frames 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) frame = bob.io.base.load(filename)
data = np.zeros(shape=(len(frames), frame.shape[0], frame.shape[1], frame.shape[2]), dtype="uint8") data = np.zeros(shape=(len(frames), frame.shape[0], frame.shape[1], frame.shape[2]), dtype="uint8")
...@@ -179,6 +183,10 @@ class View: ...@@ -179,6 +183,10 @@ class View:
for i in range(1, len(frames)): for i in range(1, len(frames)):
filename = str(os.path.join(obj.make_path(self.root_folder), frames[i].filename)) 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) data[i] = bob.io.base.load(filename)
self.outputs['image'].write( self.outputs['image'].write(
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
############################################################################### ###############################################################################
import os import os
import numpy import numpy as np
import bob.io.base import bob.io.base
import bob.io.image import bob.io.image
import bob.db.cbsr_nir_vis_2 import bob.db.cbsr_nir_vis_2
...@@ -459,7 +459,7 @@ class Probes: ...@@ -459,7 +459,7 @@ class Probes:
self.outputs['template_ids'].write( self.outputs['template_ids'].write(
{ {
'value': template_ids 'text': template_ids
}, },
template_ids_end_index template_ids_end_index
) )
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
############################################################################### ###############################################################################
import os import os
import numpy import numpy as np
import bob.io.base import bob.io.base
import bob.io.image import bob.io.image
import bob.db.frgc import bob.db.frgc
...@@ -104,7 +104,7 @@ class Train: ...@@ -104,7 +104,7 @@ class Train:
self.outputs = outputs self.outputs = outputs
# Open the database and load the objects to provide via the 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'], self.objs = sorted(self.db.objects(protocol=parameters['protocol'],
groups='world', groups='world',
...@@ -157,7 +157,7 @@ class Train: ...@@ -157,7 +157,7 @@ class Train:
# Output: image (provide data at each iteration) # Output: image (provide data at each iteration)
if self.outputs['image'].isConnected(): if self.outputs['image'].isConnected():
filename = obj.make_path(self.root_folder, '.jpg') 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') path = obj.make_path(self.root_folder, '.JPG')
self.outputs['image'].write( self.outputs['image'].write(
...@@ -200,7 +200,7 @@ class Templates: ...@@ -200,7 +200,7 @@ class Templates:
- image: "{{ system_user.username }}/array_3d_uint8/1" - image: "{{ system_user.username }}/array_3d_uint8/1"
- file_id: "{{ system_user.username }}/text/1" - file_id: "{{ system_user.username }}/text/1"
- eye_centers: "{{ system_user.username }}/eye_positions/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" - client_id: "{{ system_user.username }}/text/1"
One "file_id" is associated with a given "image". One "file_id" is associated with a given "image".
...@@ -234,7 +234,7 @@ class Templates: ...@@ -234,7 +234,7 @@ class Templates:
self.parameters = parameters self.parameters = parameters
# Open the database and load the objects to provide via the 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)
template_ids = self.db.model_ids(protocol=parameters['protocol'], template_ids = self.db.model_ids(protocol=parameters['protocol'],
groups='dev', groups='dev',
...@@ -282,7 +282,7 @@ class Templates: ...@@ -282,7 +282,7 @@ class Templates:
self.outputs['template_id'].write( self.outputs['template_id'].write(
{ {
'text': template_id 'value': np.uint64(template_id)
}, },
template_end_index template_end_index
) )
...@@ -315,7 +315,7 @@ class Templates: ...@@ -315,7 +315,7 @@ class Templates:
# Output: image (provide data at each iteration) # Output: image (provide data at each iteration)
if self.outputs['image'].isConnected(): if self.outputs['image'].isConnected():
filename = obj.make_path(self.root_folder, '.jpg') 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') path = obj.make_path(self.root_folder, '.JPG')
self.outputs['image'].write( self.outputs['image'].write(
...@@ -360,7 +360,7 @@ class Probes: ...@@ -360,7 +360,7 @@ class Probes:
- eye_centers: "{{ system_user.username }}/eye_positions/1" - eye_centers: "{{ system_user.username }}/eye_positions/1"
- probe_id: "{{ system_user.username }}/text/1" - probe_id: "{{ system_user.username }}/text/1"
- client_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 "file_id" is associated with a given "image".
One "eye_centers" is associated with a given "image". One "eye_centers" is associated with a given "image".
...@@ -397,7 +397,7 @@ class Probes: ...@@ -397,7 +397,7 @@ class Probes:
self.parameters = parameters self.parameters = parameters
# Open the database and load the objects to provide via the 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)
template_ids = sorted(self.db.model_ids(protocol=parameters['protocol'], template_ids = sorted(self.db.model_ids(protocol=parameters['protocol'],
groups='dev', groups='dev',
...@@ -457,7 +457,7 @@ class Probes: ...@@ -457,7 +457,7 @@ class Probes:
self.outputs['template_ids'].write( self.outputs['template_ids'].write(
{ {
'value': template_ids 'value': np.uint64(template_ids)
}, },
template_ids_end_index template_ids_end_index
) )
...@@ -499,7 +499,7 @@ class Probes: ...@@ -499,7 +499,7 @@ class Probes:
# Output: image (provide data at each iteration) # Output: image (provide data at each iteration)
if self.outputs['image'].isConnected(): if self.outputs['image'].isConnected():
filename = obj.make_path(self.root_folder, '.jpg') 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') path = obj.make_path(self.root_folder, '.JPG')
self.outputs['image'].write( self.outputs['image'].write(
......
...@@ -447,7 +447,7 @@ class Probes: ...@@ -447,7 +447,7 @@ class Probes:
self.outputs['template_ids'].write( self.outputs['template_ids'].write(
{ {
'value': template_ids 'value': np.uint64(template_ids)
}, },
template_ids_end_index template_ids_end_index
) )
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
"file_id": "{{ system_user.username }}/uint64/1", "file_id": "{{ system_user.username }}/uint64/1",
"client_id": "{{ system_user.username }}/text/1", "client_id": "{{ system_user.username }}/text/1",
"template_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 @@ ...@@ -32,7 +32,7 @@
"probe_id": "{{ system_user.username }}/uint64/1", "probe_id": "{{ system_user.username }}/uint64/1",
"client_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_text/1",
"keystroke": "{{ user.username }}/kboc16_keystroke/1" "keystroke": "{{ system_user.username }}/kboc16_keystroke/1"
} }
} }
] ]
......
...@@ -36,11 +36,11 @@ def keystroke_reader(filename): ...@@ -36,11 +36,11 @@ def keystroke_reader(filename):
for line in open(filename, 'r').readlines(): for line in open(filename, 'r').readlines():
parts = string.split(line) parts = string.split(line)
times.append(numpy.int32(parts[1])) times.append(np.int32(parts[1]))
keys.append(parts[0]) keys.append(parts[0])
return dict( return dict(
holdtime = times, timestamps = times,
key_events = keys, key_events = keys,
) )
...@@ -89,7 +89,7 @@ def get_value_end_index(objs, value, index_in_tuple, value_start_index, ...@@ -89,7 +89,7 @@ def get_value_end_index(objs, value, index_in_tuple, value_start_index,
class Templates: class Templates:
"""Outputs: """Outputs:
- keystroke: "{{ user.username }}/kboc16_keystroke/1 - keystroke: "{{ system_user.username }}/kboc16_keystroke/1
- file_id: "{{ system_user.username }}/uint64/1" - file_id: "{{ system_user.username }}/uint64/1"
- template_id: "{{ system_user.username }}/text/1" - template_id: "{{ system_user.username }}/text/1"
- client_id: "{{ system_user.username }}/text/1" - client_id: "{{ system_user.username }}/text/1"
...@@ -225,7 +225,7 @@ class Templates: ...@@ -225,7 +225,7 @@ class Templates:
class Probes: class Probes:
"""Outputs: """Outputs:
- keystroke: "{{ user.username }}/kboc16_keystroke/1 - keystroke: "{{ system_user.username }}/kboc16_keystroke/1
- file_id: "{{ system_user.username }}/uint64/1" - file_id: "{{ system_user.username }}/uint64/1"
- client_id: "{{ system_user.username }}/text/1" - client_id: "{{ system_user.username }}/text/1"
- probe_id: "{{ system_user.username }}/uint64/1", - probe_id: "{{ system_user.username }}/uint64/1",
......
...@@ -395,7 +395,7 @@ class Probes: ...@@ -395,7 +395,7 @@ class Probes:
self.outputs['template_ids'].write( self.outputs['template_ids'].write(
{ {
'value': template_ids 'value': np.uint64(template_ids)
}, },
template_ids_end_index template_ids_end_index
) )
......
...@@ -29,12 +29,12 @@ import bob.db.mnist ...@@ -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): start_index, end_index):
label_end_index = label_start_index label_end_index = label_start_index
while label_end_index + 1 <= end_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: if label_ != label:
return label_end_index return label_end_index
...@@ -78,8 +78,10 @@ class View: ...@@ -78,8 +78,10 @@ class View:
# Open the database and load the objects to provide via the outputs # Open the database and load the objects to provide via the outputs
self.db = bob.db.mnist.Database(data_dir=self.root_folder) self.db = bob.db.mnist.Database(data_dir=self.root_folder)
self.features, self.labels = sorted(self.db.data(groups=parameters['group']), features, labels = self.db.data(groups=parameters['group'])
key=lambda x: x[1])
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 # 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.start_index = force_start_index if force_start_index is not None else 0
...@@ -97,14 +99,13 @@ class View: ...@@ -97,14 +99,13 @@ class View:
def next(self): def next(self):
features = self.features[self.next_index - self.start_index, :] features, label = self.objs[self.next_index - self.start_index]
label = self.labels[self.next_index - self.start_index]
# Output: class_id (only provide data when the class_id change) # Output: class_id (only provide data when the class_id change)
if self.outputs['class_id'].isConnected() and \ if self.outputs['class_id'].isConnected() and \
self.outputs['class_id'].last_written_data_index < self.next_index: 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.next_index,
self.start_index, self.start_index,
self.end_index) self.end_index)
......
...@@ -459,7 +459,7 @@ class Probes: ...@@ -459,7 +459,7 @@ class Probes:
self.outputs['template_ids'].write( self.outputs['template_ids'].write(
{ {
'value': template_ids 'value': np.uint64(template_ids)
}, },
template_ids_end_index template_ids_end_index
) )
......
...@@ -379,7 +379,7 @@ class Probes: ...@@ -379,7 +379,7 @@ class Probes:
self.outputs['template_ids'].write( self.outputs['template_ids'].write(
{ {
'value': template_ids 'text': template_ids
}, },
end_index end_index
) )
......
...@@ -401,7 +401,7 @@ class Probes: ...@@ -401,7 +401,7 @@ class Probes:
self.outputs['template_ids'].write( self.outputs['template_ids'].write(
{ {
'value': template_ids 'text': template_ids
}, },
template_ids_end_index template_ids_end_index
) )
......
...@@ -449,7 +449,7 @@ class Probes: ...@@ -449,7 +449,7 @@ class Probes:
self.outputs['template_ids'].write( self.outputs['template_ids'].write(
{ {
'value': template_ids 'value': np.uint64(template_ids)
}, },
template_ids_end_index template_ids_end_index
) )
......
{ {
"#description": "Raw KBOC16 keystroke data", "#description": "Raw KBOC16 keystroke data",
"holdtime": [0, "int32"], "timestamps": [0, "int32"],
"key_events": [0, "string"] "key_events": [0, "string"]
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment