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

Included metadata durint the feature extraction. Ongoing with cd workspace_HTFace/

Included metadata durint the feature extraction. Ongoing with cd workspace_HTFace/
parent 9d8ee935
......@@ -25,3 +25,14 @@ class DummyExtractor (Extractor):
return data.astype(numpy.float).flatten()
extractor = DummyExtractor()
class DummyExtractorMetadata (DummyExtractor):
def __call__(self, data, metadata=None):
"""Does nothing, simply converts the data type of the data, ignoring any annotation."""
assert metadata is not None
assert self.model
return data.astype(numpy.float).flatten()
extractor_metadata = DummyExtractorMetadata()
......@@ -143,6 +143,25 @@ def test_verify_resources():
_verify(parameters, test_dir, 'test_resource')
def test_verify_resources_metadata():
test_dir = tempfile.mkdtemp(prefix='bobtest_')
# define dummy parameters
parameters = [
'-d', 'dummy',
'-p', 'dummy',
'-e', 'dummy_metadata',
'-a', 'dummy',
'--zt-norm',
'--allow-missing-files',
'-vs', 'test_resource',
'--temp-directory', test_dir,
'--result-directory', test_dir,
'--preferred-package', 'bob.bio.base'
]
_verify(parameters, test_dir, 'test_resource')
def test_verify_commandline():
test_dir = tempfile.mkdtemp(prefix='bobtest_')
# define dummy parameters
......
......@@ -2,6 +2,7 @@ import bob.io.base
import os
import logging
import inspect
logger = logging.getLogger("bob.bio.base")
from .FileSelector import FileSelector
......@@ -90,6 +91,7 @@ def extract(extractor, preprocessor, groups=None, indices = None, allow_missing_
extractor.load(fs.extractor_file)
data_files = fs.preprocessed_data_list(groups=groups)
feature_files = fs.feature_list(groups=groups)
metadata = fs.original_data_list(groups=groups)
# select a subset of indices to iterate
if indices is not None:
......@@ -119,7 +121,10 @@ def extract(extractor, preprocessor, groups=None, indices = None, allow_missing_
# load data
data = preprocessor.read_data(data_file)
# extract feature
feature = extractor(data)
if "metadata" in inspect.getargspec(extractor.__call__).args:
feature = extractor(data, metadata=metadata[i])
else:
feature = extractor(data)
if feature is None:
if allow_missing_files:
......
......@@ -99,6 +99,7 @@ setup(
'bob.bio.extractor': [
'dummy = bob.bio.base.test.dummy.extractor:extractor', # for test purposes only
'dummy_metadata = bob.bio.base.test.dummy.extractor:extractor_metadata', # for test purposes only
'linearize = bob.bio.base.config.extractor.linearize: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