diff --git a/bob/pad/face/config/brsu.py b/bob/pad/face/config/brsu.py deleted file mode 100644 index b49a7ea9f5ed9a2c9d618ac7ea5ffaef43ddd09d..0000000000000000000000000000000000000000 --- a/bob/pad/face/config/brsu.py +++ /dev/null @@ -1,4 +0,0 @@ -from bob.pad.face.database import BRSUPadDatabase -from bob.pad.base.pipelines.vanilla_pad import DatabaseConnector - -database = DatabaseConnector(BRSUPadDatabase()) diff --git a/bob/pad/face/database/__init__.py b/bob/pad/face/database/__init__.py index 1c0fe2e1268122bc884391dcd50108b19c562947..8bd8f5e2d70e2abbf6cd69fbf00f4b5d403921d3 100644 --- a/bob/pad/face/database/__init__.py +++ b/bob/pad/face/database/__init__.py @@ -6,7 +6,6 @@ from .celeb_a import CELEBAPadDatabase from .maskattack import MaskAttackPadDatabase from .casiasurf import CasiaSurfPadDatabase from .casiafasd import CasiaFasdPadDatabase -from .brsu import BRSUPadDatabase # gets sphinx autodoc done right - don't remove it @@ -34,7 +33,6 @@ __appropriate__( MaskAttackPadDatabase, CasiaSurfPadDatabase, CasiaFasdPadDatabase, - BRSUPadDatabase ) __all__ = [_ for _ in dir() if not _.startswith('_')] diff --git a/bob/pad/face/database/brsu.py b/bob/pad/face/database/brsu.py deleted file mode 100644 index 294ed59540856b89d2bd3b7f57245012a9e786c0..0000000000000000000000000000000000000000 --- a/bob/pad/face/database/brsu.py +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - - -from bob.pad.face.database import VideoPadFile -from bob.pad.base.database import PadDatabase - -from bob.extension import rc - -class BRSUPadFile(VideoPadFile): - """ - A high level implementation of the File class for the BRSU database. - - Note that this does not represent a file per se, but rather a sample - that may contain more than one file. - - Attributes - ---------- - f : :py:class:`object` - An instance of the Sample class defined in the low level db interface - of the BRSU database, in the bob.db.brsu.models.py file. - - """ - - def __init__(self, s): - """ Init - - Parameters - ---------- - s : :py:class:`object` - An instance of the Sample class defined in the low level db interface - of the BRSU database, in the bob.db.brsu.models.py file. - """ - self.s = s - attack_type = str(s.attack_type) - - if attack_type == '0': - attack_type = None - - super(BRSUPadFile, self).__init__( - client_id=s.id, - file_id=s.id, - attack_type=attack_type, - path=s.id) - - - def load(self, directory=rc['bob.db.brsu.directory'], extension=None): - """Overloaded version of the load method defined in ``VideoPadFile``. - - Parameters - ---------- - directory : :py:class:`str` - String containing the path to the BRSU database - extension : :py:class:`str` - Not used here, since a sample contains more than one file, - possibly with different extensions - - Returns - ------- - dict: - image data for multiple streams stored in the dictionary. - The structure of the dictionary: ``data={"stream1_name" : numpy array, "stream2_name" : numpy array}`` - """ - return self.s.load(directory) - - -class BRSUPadDatabase(PadDatabase): - """High level implementation of the Database class for the BRSU database. - - Attributes - ---------- - db : :py:class:`bob.db.brsu.Database` - the low-level database interface - - """ - - def __init__(self, protocol='test', original_directory=rc['bob.db.brsu.directory'], original_extension=None, **kwargs): - """Init function - - Parameters - ---------- - protocol : :py:class:`str` - The name of the protocol that defines the default experimental setup for this database. - original_directory : :py:class:`str` - The directory where the original data of the database are stored. - original_extension : :py:class:`str` - The file name extension of the original data. - - """ - - from bob.db.brsu import Database as LowLevelDatabase - self.db = LowLevelDatabase() - - super(BRSUPadDatabase, self).__init__( - name='brsu', - protocol=protocol, - original_directory=original_directory, - original_extension=original_extension, - **kwargs) - - @property - def original_directory(self): - return self.db.original_directory - - - @original_directory.setter - def original_directory(self, value): - self.db.original_directory = value - - def objects(self, - groups=None, - protocol='test', - purposes=None, - model_ids=None, - **kwargs): - """Returns a list of BRSUPadFile objects, which fulfill the given restrictions. - - Parameters - ---------- - groups : list of :py:class:`str` - The groups of which the clients should be returned. - Usually, groups are one or more elements of ('train', 'dev', 'eval') - protocol : :py:class:`str` - The protocol for which the samples should be retrieved. - purposes : :py:class:`str` - The purposes for which Sample objects should be retrieved. - Usually it is either 'real' or 'attack' - model_ids - This parameter is not supported in PAD databases yet. - - Returns - ------- - samples : :py:class:`BRSUPadFile` - A list of BRSUPadFile objects. - """ - lowlevel_purposes = None - if groups is not None and purposes is not None: - - # for training - lowlevel_purposes = [] - if 'train' in groups and 'real' in purposes: - lowlevel_purposes.append('real') - if 'train' in groups and 'attack' in purposes: - lowlevel_purposes.append('attack') - - # for eval - if 'test' in groups and 'real' in purposes: - lowlevel_purposes.append('real') - if 'test' in groups and 'attack' in purposes: - lowlevel_purposes.append('attack') - - if groups is None and purposes is not None: - lowlevel_purposes = [] - if 'real' in purposes: - lowlevel_purposes.append('real') - if 'attack' in purposes: - lowlevel_purposes.append('attack') - - samples = self.db.objects(groups=groups, purposes=lowlevel_purposes, **kwargs) - samples = [BRSUPadFile(s) for s in samples] - return samples - - - def annotations(self, file): - """No annotations are provided with this DB - """ - return None diff --git a/bob/pad/face/test/dummy/database.py b/bob/pad/face/test/dummy/database.py index 7960da4185ffcfda94f1626e94b1f7c5abb0b0ee..f74eb0b6841da72d17453bb3d54a681d933674b3 100644 --- a/bob/pad/face/test/dummy/database.py +++ b/bob/pad/face/test/dummy/database.py @@ -5,19 +5,21 @@ from bob.pad.face.database import VideoPadFile from bob.pad.base.database import PadDatabase from bob.db.base.utils import ( check_parameters_for_validity, convert_names_to_lowlevel) +from bob.bio.video import VideoLikeContainer class DummyPadFile(VideoPadFile): def load(self, directory=None, extension='.pgm', frame_selector=None): file_name = self.make_path(directory, extension) - fc = FrameContainer() - fc.add(os.path.basename(file_name), bob.io.base.load(file_name)) + data = bob.io.base.load(file_name)[None, ...] + indices = [os.path.basename(file_name)] + fc = VideoLikeContainer(data, indices) return fc @property def frames(self): fc = self.load(self.original_directory) - for _, frame, _ in fc: + for frame in fc: yield frame @property diff --git a/bob/pad/face/test/test_databases.py b/bob/pad/face/test/test_databases.py index 3d99cf80027b4f3ad6e505b47d8325f442ee8eca..fe50809d11f606c62d01829a8c36b8027b4a8d57 100644 --- a/bob/pad/face/test/test_databases.py +++ b/bob/pad/face/test/test_databases.py @@ -139,23 +139,6 @@ def test_casiasurf(): % e) -@db_available('brsu') -def test_brsu(): - brsu = bob.bio.base.load_resource( - 'brsu', - 'database', - preferred_package='bob.pad.face', - package_prefix='bob.pad.').database - try: - assert len(brsu.objects()) == 276 - assert len(brsu.objects(purposes=('real',))) == 192 - assert len(brsu.objects(purposes=('attack',))) == 84 - - except IOError as e: - raise SkipTest( - "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" - % e) - @db_available('casia_fasd') def test_casia_fasd(): casia_fasd = bob.bio.base.load_resource( diff --git a/bob/pad/face/test/test_utils.py b/bob/pad/face/test/test_utils.py index e9b87030d418628159393ff6ff7238ed9fc059e8..779581731dbfd348b5b2c41ac7dfaa83039244c9 100644 --- a/bob/pad/face/test/test_utils.py +++ b/bob/pad/face/test/test_utils.py @@ -5,7 +5,7 @@ import numpy padfile = Database().all_files(('train', 'dev'))[0][0] image = padfile.load(Database().original_directory, - Database().original_extension)[0][1] + Database().original_extension)[0] def dummy_cropper(frame, annotations=None): diff --git a/setup.py b/setup.py index aaa0c1167716d62916ae376b6e82710e4f253b00..39ab520a25b607ed36bb17cca39ef38ade4c6843 100644 --- a/setup.py +++ b/setup.py @@ -76,7 +76,6 @@ setup( 'maskattack = bob.pad.face.config.maskattack:database', 'casiasurf-color = bob.pad.face.config.casiasurf_color:database', 'casiasurf = bob.pad.face.config.casiasurf:database', - 'brsu = bob.pad.face.config.brsu:database', ], # registered configurations: