Skip to content
Snippets Groups Projects
Commit e7722c0c authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Merge branch 'issue-8-remove-database-configuration' of...

Merge branch 'issue-8-remove-database-configuration' of gitlab.idiap.ch:bob/bob.bio.base into issue-8-remove-database-configuration
parents 0df3423e 4a1731f6
No related branches found
No related tags found
1 merge request!38Issue 8 remove database configuration
Pipeline #
......@@ -22,7 +22,7 @@ class Preprocessor:
A list of keyword arguments to be written in the :py:meth:`__str__` function.
"""
def __init__(self, writes_data = True, read_original_data = lambda biofile,directory,extension : biofile.load(directory,extension), **kwargs):
def __init__(self, writes_data = True, read_original_data = utils.read_original_data, **kwargs):
# Each class needs to have a constructor taking
# all the parameters that are required for the preprocessing as arguments
self.writes_data = writes_data
......
......@@ -4,6 +4,7 @@ import tempfile, tarfile
import logging
logger = logging.getLogger("bob.bio.base")
from .. import database
import bob.io.base
def filter_missing_files(file_names, split_by_client=False, allow_missing_files=True):
......@@ -51,6 +52,33 @@ def check_file(filename, force, expected_file_size = 1):
return False
def read_original_data(biofile, directory, extension):
"""read_original_data(biofile, directory, extension) -> data
This function reads the original data using the given ``biofile`` instance.
It simply calls ``load(directory, extension)`` from :py:class:`bob.bio.base.database.BioFile` or one of its derivatives.
**Parameters:**
``biofile`` : :py:class:`bob.bio.base.database.BioFile` or one of its derivatives
The file to read the original data.
``directory`` : str
The base directory of the database.
``extension`` : str or ``None``
The extension of the original data.
Might be ``None`` if the ``biofile`` itself has the extension stored.
**Returns**
``data`` : object
Whatver ``biofile.load`` returns; usually a :py:class:`numpy.ndarray`
"""
assert isinstance(biofile, database.BioFile)
return biofile.load(directory, extension)
def load(file):
"""Loads data from file. The given file might be an HDF5 file open for reading or a string."""
if isinstance(file, bob.io.base.HDF5File):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment