Commit 75451c07 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Appended the metadata during preprocessing

parent ca797325
......@@ -16,5 +16,14 @@ class DummyPreprocessor (Preprocessor):
return data
preprocessor = DummyPreprocessor()
class DummyPreprocessorMetadata (DummyPreprocessor):
def __call__(self, data, annotation, metadata=None):
"""Does nothing, simply converts the data type of the data, ignoring any annotation."""
assert metadata is not None
return super(DummyPreprocessorMetadata, self).__call__(data, annotation)
preprocessor_metadata = DummyPreprocessorMetadata()
......@@ -148,7 +148,7 @@ def test_verify_resources_metadata():
# define dummy parameters
parameters = [
'-d', 'dummy',
'-p', 'dummy',
'-p', 'dummy_metadata',
'-e', 'dummy_metadata',
'-a', 'dummy',
'--zt-norm',
......
......@@ -2,6 +2,7 @@ import bob.io.base
import os
import logging
import inspect
logger = logging.getLogger("bob.bio.base")
from .FileSelector import FileSelector
......@@ -45,6 +46,7 @@ def preprocess(preprocessor, groups = None, indices = None, allow_missing_files
data_files = fs.original_data_list(groups=groups)
original_directory, original_extension = fs.original_directory_and_extension()
preprocessed_data_files = fs.preprocessed_data_list(groups=groups)
metadata = fs.original_data_list(groups=groups)
# select a subset of keys to iterate
if indices is not None:
......@@ -78,7 +80,11 @@ def preprocess(preprocessor, groups = None, indices = None, allow_missing_files
annotations = fs.get_annotations(annotation_list[i])
# call the preprocessor
if "metadata" in inspect.getargspec(preprocessor.__call__).args:
preprocessed_data = preprocessor(data, annotations, metadata=metadata[i])
else:
preprocessed_data = preprocessor(data, annotations)
if preprocessed_data is None:
if allow_missing_files:
logger.debug("... Processing original data file '%s' was not successful", file_name)
......@@ -93,7 +99,6 @@ def preprocess(preprocessor, groups = None, indices = None, allow_missing_files
logger.debug("... Skipping original data file '%s' since preprocessed data '%s' exists", file_name, preprocessed_data_file)
def read_preprocessed_data(file_names, preprocessor, split_by_client = False, allow_missing_files = False):
"""read_preprocessed_data(file_names, preprocessor, split_by_client = False) -> preprocessed
......
......@@ -95,6 +95,7 @@ setup(
'bob.bio.preprocessor': [
'dummy = bob.bio.base.test.dummy.preprocessor:preprocessor', # for test purposes only
'filename = bob.bio.base.config.preprocessor.filename:preprocessor',
'dummy_metadata = bob.bio.base.test.dummy.preprocessor:preprocessor_metadata',
],
'bob.bio.extractor': [
......
Supports Markdown
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