Skip to content
Snippets Groups Projects
Commit cec5e5cb authored by Manuel Günther's avatar Manuel Günther
Browse files

Merge branch 'missing-files-db' into 'master'

Created a dummy db that dump some fake missing files

See merge request !104
parents 700d7a48 53cd7d12
No related branches found
No related tags found
1 merge request!104Created a dummy db that dump some fake missing files
Pipeline #
from bob.bio.base.preprocessor import Preprocessor from bob.bio.base.preprocessor import Preprocessor
import numpy
numpy.random.seed(10)
class DummyPreprocessor (Preprocessor): class DummyPreprocessor (Preprocessor):
def __init__(self, return_none=False, **kwargs): def __init__(self, return_none=False, probability_of_none=1, **kwargs):
Preprocessor.__init__(self) Preprocessor.__init__(self)
self.return_none = return_none self.return_none = return_none
self.probability_of_none = probability_of_none
def __call__(self, data, annotation): def __call__(self, data, annotation):
"""Does nothing, simply converts the data type of the data, ignoring any annotation.""" """Does nothing, simply converts the data type of the data, ignoring any annotation."""
if self.return_none: if self.return_none:
return None return numpy.random.choice([None, data], p=[self.probability_of_none, 1-self.probability_of_none])
return data return data
......
...@@ -68,6 +68,7 @@ def preprocess(preprocessor, groups = None, indices = None, allow_missing_files ...@@ -68,6 +68,7 @@ def preprocess(preprocessor, groups = None, indices = None, allow_missing_files
if not utils.check_file(preprocessed_data_file, force, if not utils.check_file(preprocessed_data_file, force,
preprocessor.min_preprocessed_file_size): preprocessor.min_preprocessed_file_size):
logger.debug("... Processing original data file '%s'", file_name) logger.debug("... Processing original data file '%s'", file_name)
data = preprocessor.read_original_data(file_object, original_directory, original_extension) data = preprocessor.read_original_data(file_object, original_directory, original_extension)
# create output directory before reading the data file (is sometimes required, when relative directories are specified, especially, including a .. somewhere) # create output directory before reading the data file (is sometimes required, when relative directories are specified, especially, including a .. somewhere)
bob.io.base.create_directories_safe(os.path.dirname(preprocessed_data_file)) bob.io.base.create_directories_safe(os.path.dirname(preprocessed_data_file))
......
...@@ -124,7 +124,7 @@ setup( ...@@ -124,7 +124,7 @@ setup(
], ],
# declare database to bob # declare database to bob
'bob.db': [ 'bob.db': [
'bio_filelist = bob.bio.base.database.filelist.driver:Interface', 'bio_filelist = bob.bio.base.database.filelist.driver:Interface',
], ],
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment