diff --git a/bob/bio/face/database/replaymobile.py b/bob/bio/face/database/replaymobile.py index 2ebac35662bca566733437057f1ef2e82d040a23..1cb4f1acce08a95b80b104470bf0050c232fd8f1 100644 --- a/bob/bio/face/database/replaymobile.py +++ b/bob/bio/face/database/replaymobile.py @@ -75,7 +75,6 @@ class ReplayMobileCSVFrameSampleLoader(CSVToSampleLoaderBiometrics): dataset_original_directory=dataset_original_directory, ) self.reference_id_equal_subject_id = reference_id_equal_subject_id - self.references_list = [] def convert_row_to_sample(self, row, header): """Creates a sample given a row of the CSV protocol definition.""" @@ -88,25 +87,10 @@ class ReplayMobileCSVFrameSampleLoader(CSVToSampleLoaderBiometrics): raise ValueError(f"`subject_id` not available in {header}") if "should_flip" not in fields: raise ValueError(f"`should_flip` not available in {header}") - if "purpose" not in fields: - raise ValueError(f"`purpose` not available in {header}") kwargs = {k: fields[k] for k in fields.keys() - {"id", "should_flip"}} - # Retrieve the references list - if ( - fields["purpose"].lower() == "enroll" - and fields["reference_id"] not in self.references_list - ): - self.references_list.append(fields["reference_id"]) - # Set the references list in the probes for vanilla-biometrics - if fields["purpose"].lower() != "enroll": - if fields["attack_type"]: - # Attacks are only compare to their target (no `spoof_neg`) - kwargs["references"] = [fields["reference_id"]] - else: - kwargs["references"] = self.references_list - # One row leads to multiple samples (different frames) + # One row creates one samples (=> one comparison because of `is_sparse`) return DelayedSample( functools.partial( load_frame_from_file_replaymobile, @@ -246,7 +230,10 @@ class ReplayMobileBioDatabase(CSVDataset): ): if protocol_definition_path is None: # Downloading database description files if it is not specified - proto_def_name = "bio-face-replaymobile-img-3a584a97.tar.gz" + proto_def_hash = "6cd66a5e" + proto_def_name = ( + f"database-protocols-replaymobile-img-{proto_def_hash}.tar.gz" + ) proto_def_urls = [ f"https://www.idiap.ch/software/bob/data/bob/bob.bio.face/{proto_def_name}", f"http://www.idiap.ch/software/bob/data/bob/bob.bio.face/{proto_def_name}", @@ -255,7 +242,7 @@ class ReplayMobileBioDatabase(CSVDataset): filename=proto_def_name, urls=proto_def_urls, cache_subdir="datasets", - file_hash="3a584a97", + file_hash=proto_def_hash, ) if data_path is None: @@ -268,7 +255,10 @@ class ReplayMobileBioDatabase(CSVDataset): ) if annotations_path is None: - annot_name = "annotations-replaymobile-mtcnn-9cd6e452.tar.xz" + annot_hash = "9cd6e452" + annot_name = ( + f"annotations-replaymobile-mtcnn-{annot_hash}.tar.xz" + ) annot_urls = [ f"https://www.idiap.ch/software/bob/data/bob/bob.pad.face/{annot_name}", f"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/{annot_name}", @@ -277,7 +267,7 @@ class ReplayMobileBioDatabase(CSVDataset): filename=annot_name, urls=annot_urls, cache_subdir="annotations", - file_hash="9cd6e452", + file_hash=annot_hash, ) logger.info( @@ -299,7 +289,7 @@ class ReplayMobileBioDatabase(CSVDataset): annotation_extension=annotations_extension, ), ), - fetch_probes=False, + is_sparse=True, **kwargs, ) self.annotation_type = "eyes-center" diff --git a/bob/bio/face/test/test_databases.py b/bob/bio/face/test/test_databases.py index cd937af4a41fe1c277590044b2d69b5d967c5caf..59d10423c6e7389ba138ad93f3090b7ec21d8e10 100644 --- a/bob/bio/face/test/test_databases.py +++ b/bob/bio/face/test/test_databases.py @@ -26,7 +26,6 @@ from bob.bio.base.test.utils import db_available from bob.bio.base.test.test_database_implementations import check_database import bob.core from bob.extension.download import get_file -from nose.plugins.skip import SkipTest from bob.extension import rc logger = bob.core.log.setup("bob.bio.face") @@ -277,9 +276,7 @@ def test_replaymobile(): database = bob.bio.base.load_resource( "replaymobile-img", "database", preferred_package="bob.bio.face" ) - samples = database.all_samples(groups=("dev", "eval")) - assert len(samples) == 8300, len(samples) - sample = samples[0] + sample = database.probes()[0][0] assert hasattr(sample, "annotations") assert "reye" in sample.annotations assert "leye" in sample.annotations @@ -289,20 +286,19 @@ def test_replaymobile(): assert len(database.references(group="eval")) == 12 assert len(database.probes()) == 4160 assert len(database.probes(group="eval")) == 3020 - try: + # Only if data is available + if rc.get("bob.db.replaymobile.directory", None): assert sample.annotations == { - "bottomright": [785, 395], - "topleft": [475, 167], - "leye": [587, 336], - "reye": [588, 238], - "mouthleft": [705, 252], - "mouthright": [706, 326], - "nose": [643, 295], + "bottomright": [734, 407], + "topleft": [436, 182], + "leye": [541, 350], + "reye": [540, 245], + "mouthleft": [655, 254], + "mouthright": [657, 338], + "nose": [591, 299], } assert sample.data.shape == (3, 1280, 720) - assert sample.data[0, 0, 0] == 87 - except RuntimeError as e: - raise SkipTest(e) + assert sample.data[0, 0, 0] == 110 @pytest.mark.skipif(