Skip to content
Snippets Groups Projects
Commit caf9f93e authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

remove support for legacy databases

parent ebb608e9
No related branches found
No related tags found
1 merge request!94remove support for legacy databases
Pipeline #60825 passed
from .abstract_classes import Database
from .legacy import DatabaseConnector
# gets sphinx autodoc done right - don't remove it
......@@ -20,6 +19,5 @@ def __appropriate__(*args):
__appropriate__(
Database,
DatabaseConnector,
)
__all__ = [_ for _ in dir() if not _.startswith("_")]
"""Re-usable blocks for legacy bob.pad.base databases"""
import logging
from bob.pipelines.sample import DelayedSample
from .abstract_classes import Database
logger = logging.getLogger(__name__)
def _padfile_to_delayed_sample(padfile, database):
return DelayedSample(
load=padfile.load,
subject=str(padfile.client_id),
attack_type=padfile.attack_type,
key=padfile.path,
delayed_attributes=dict(annotations=lambda: padfile.annotations),
is_bonafide=padfile.attack_type is None,
)
class DatabaseConnector(Database):
"""Wraps a bob.pad.base database and generates conforming samples
This connector allows wrapping generic bob.pad.base datasets and generate samples
that conform to the specifications of pad pipelines defined in this package.
Parameters
----------
database : object
An instantiated version of a bob.pad.base.Database object
"""
def __init__(
self,
database,
annotation_type="eyes-center",
fixed_positions=None,
**kwargs,
):
super().__init__(**kwargs)
self.database = database
self.annotation_type = annotation_type
self.fixed_positions = fixed_positions
def fit_samples(self):
objects = self.database.training_files(flat=True)
return [_padfile_to_delayed_sample(k, self.database) for k in objects]
def predict_samples(self, group="dev"):
objects = self.database.all_files(groups=group, flat=True)
return [_padfile_to_delayed_sample(k, self.database) for k in objects]
def __repr__(self) -> str:
return f"""{self.__class__.__name__}(
database={self.database},
annotation_type={self.annotation_type},
fixed_positions={self.fixed_positions}
)"""
......@@ -20,7 +20,6 @@ Implementations
.. autosummary::
bob.pad.base.pipelines.vanilla_pad.Database
bob.pad.base.pipelines.vanilla_pad.DatabaseConnector
bob.pad.base.database.FileListPadDatabase
Preprocessors and Extractors
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment