From db30eca87489c8470b529e29b2ba44c9fee22afb Mon Sep 17 00:00:00 2001 From: Tiago Freitas Pereira Date: Fri, 20 Aug 2021 16:58:33 +0200 Subject: [PATCH 1/3] Removed old GBU tests [pytest] --- bob/bio/face/test/test_databases.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/bob/bio/face/test/test_databases.py b/bob/bio/face/test/test_databases.py index c4d488c..15ed168 100644 --- a/bob/bio/face/test/test_databases.py +++ b/bob/bio/face/test/test_databases.py @@ -98,29 +98,6 @@ def test_atnt(): ) -@db_available("gbu") -def test_gbu(): - database = bob.bio.base.load_resource( - "gbu", "database", preferred_package="bob.bio.face" - ) - try: - check_database(database, models_depend=True) - check_database(database, protocol="Bad", models_depend=True) - check_database(database, protocol="Ugly", models_depend=True) - except IOError as e: - pytest.skip( - "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" - % e - ) - try: - _check_annotations(database, limit_files=1000) - except IOError as e: - pytest.skip( - "The annotations could not be queried; probably the annotation files are missing. Here is the error: '%s'" - % e - ) - - @db_available("lfw") def test_lfw(): database = bob.bio.base.load_resource( -- GitLab From 5b32149c45a1d7b6ec7e8f639874c56cb181b1d8 Mon Sep 17 00:00:00 2001 From: Tiago Freitas Pereira Date: Fri, 20 Aug 2021 17:10:43 +0200 Subject: [PATCH 2/3] Implemented the CASPEAL protcols --- bob/bio/face/database/__init__.py | 2 + bob/bio/face/database/caspeal.py | 97 +++++++++++++++++++++++++++++ bob/bio/face/test/test_databases.py | 40 ++++++++++++ doc/implemented.rst | 1 + 4 files changed, 140 insertions(+) create mode 100644 bob/bio/face/database/caspeal.py diff --git a/bob/bio/face/database/__init__.py b/bob/bio/face/database/__init__.py index 6f9f519..3a0141b 100644 --- a/bob/bio/face/database/__init__.py +++ b/bob/bio/face/database/__init__.py @@ -20,6 +20,7 @@ from .pola_thermal import PolaThermalDatabase from .cbsr_nir_vis_2 import CBSRNirVis2Database from .rfw import RFWDatabase from .scface import SCFaceDatabase +from .caspeal import CaspealDatabase # gets sphinx autodoc done right - don't remove it @@ -58,5 +59,6 @@ __appropriate__( FRGCDatabase, RFWDatabase, SCFaceDatabase, + CaspealDatabase, ) __all__ = [_ for _ in dir() if not _.startswith("_")] diff --git a/bob/bio/face/database/caspeal.py b/bob/bio/face/database/caspeal.py new file mode 100644 index 0000000..b29f6d3 --- /dev/null +++ b/bob/bio/face/database/caspeal.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python +# vim: set fileencoding=utf-8 : +# Tiago de Freitas Pereira + +""" + Multipie database implementation +""" + +from bob.bio.base.database import CSVDataset +from bob.bio.base.database import CSVToSampleLoaderBiometrics +from bob.bio.face.database.sample_loaders import EyesAnnotations +from bob.extension import rc +from bob.extension.download import get_file +import bob.io.base +from sklearn.pipeline import make_pipeline + + +class CaspealDatabase(CSVDataset): + """ + The CAS-PEAL database consists of several ten thousand images of Chinese people (CAS = Chinese Academy of Science). + Overall, there are 1040 identities contained in the database. + For these identities, images with different Pose, Expression, Aging and Lighting (PEAL) conditions, as well as accessories, image backgrounds and camera distances are provided. + + Included in the database, there are file lists defining identification experiments. + All the experiments rely on a gallery that consists of the frontal and frontally illuminated images with neutral expression and no accessories. + For each of the variations, probe sets including exactly that variation are available. + + The training set consists of a subset of the frontal images (some images are both in the training and in the development set). + This also means that there is no training set defined for the pose images. + Additionally, the database defines only a development set, but no evaluation set. + + This package only contains the Bob_ accessor methods to use the DB directly from python, with our certified protocols. + We have implemented the default face identification protocols ``'accessory'``, ``'aging'``, ``'background'``, ``'distance'``, ``'expression'`` and ``'lighting'``. + We do not provide the ``'pose'`` protocol (yet) since the training set of the `CAS-PEAL`_ database does not contain pose images: + + + .. code-block:: latex + + @article{gao2007cas, + title={The CAS-PEAL large-scale Chinese face database and baseline evaluations}, + author={Gao, Wen and Cao, Bo and Shan, Shiguang and Chen, Xilin and Zhou, Delong and Zhang, Xiaohua and Zhao, Debin}, + journal={IEEE Transactions on Systems, Man, and Cybernetics-Part A: Systems and Humans}, + volume={38}, + number={1}, + pages={149--161}, + year={2007}, + publisher={IEEE} + } + + """ + + def __init__(self, protocol, annotation_type="eyes-center", fixed_positions=None): + + # Downloading model if not exists + urls = CaspealDatabase.urls() + filename = get_file( + "caspeal-f2479a0b.tar.gz", + urls, + file_hash="c747f2810f5373e556c43f979b00dd06", + ) + + super().__init__( + name="caspeal", + dataset_protocol_path=filename, + protocol=protocol, + csv_to_sample_loader=make_pipeline( + CSVToSampleLoaderBiometrics( + data_loader=bob.io.base.load, + dataset_original_directory=rc["bob.bio.face.caspeal.directory"] + if rc["bob.bio.face.caspeal.directory"] + else "", + extension=".png", + ), + EyesAnnotations(), + ), + annotation_type="eyes-center", + fixed_positions=None, + ) + + @staticmethod + def protocols(): + # TODO: Until we have (if we have) a function that dumps the protocols, let's use this one. + protocols = [ + "accessory", + "aging", + "background", + "distance", + "expression", + "lighting", + ] + + @staticmethod + def urls(): + return [ + "https://www.idiap.ch/software/bob/databases/latest/caspeal-f2479a0b.tar.gz", + "http://www.idiap.ch/software/bob/databases/latest/caspeal-f2479a0b.tar.gz", + ] diff --git a/bob/bio/face/test/test_databases.py b/bob/bio/face/test/test_databases.py index 15ed168..65fbe9c 100644 --- a/bob/bio/face/test/test_databases.py +++ b/bob/bio/face/test/test_databases.py @@ -551,3 +551,43 @@ def test_gbu(): assert len(database.probes()) == 1085 assert len(database.background_model_samples()) == 3910 + + +def test_caspeal(): + + from bob.bio.face.database import CaspealDatabase + + # protocols = ['accessory', 'aging', 'background', 'distance', 'expression', 'lighting', 'pose'] + + database = CaspealDatabase("accessory") + assert len(database.references()) == 1040 + assert len(database.probes()) == 2285 + assert len(database.background_model_samples()) == 1200 + + database = CaspealDatabase("aging") + assert len(database.references()) == 1040 + assert len(database.probes()) == 66 + assert len(database.background_model_samples()) == 1200 + + database = CaspealDatabase("background") + assert len(database.references()) == 1040 + assert len(database.probes()) == 553 + assert len(database.background_model_samples()) == 1200 + + database = CaspealDatabase("distance") + assert len(database.references()) == 1040 + assert len(database.probes()) == 275 + assert len(database.background_model_samples()) == 1200 + + database = CaspealDatabase("expression") + assert len(database.references()) == 1040 + assert len(database.probes()) == 1570 + assert len(database.background_model_samples()) == 1200 + + database = CaspealDatabase("lighting") + assert len(database.references()) == 1040 + assert len(database.probes()) == 2243 + assert len(database.background_model_samples()) == 1200 + + ### There's no pose protocol + diff --git a/doc/implemented.rst b/doc/implemented.rst index 4fe5ffe..a8cb9a4 100644 --- a/doc/implemented.rst +++ b/doc/implemented.rst @@ -26,6 +26,7 @@ Databases bob.bio.face.database.PolaThermalDatabase bob.bio.face.database.CBSRNirVis2Database bob.bio.face.database.SCFaceDatabase + bob.bio.face.database.CaspealDatabase Deep Learning Extractors -- GitLab From bc99af4d162ec9170a2758155b8001ad8bf0b2a7 Mon Sep 17 00:00:00 2001 From: Tiago Freitas Pereira Date: Mon, 23 Aug 2021 08:30:31 +0200 Subject: [PATCH 3/3] [sphinx] Adjustments --- bob/bio/face/database/caspeal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bob/bio/face/database/caspeal.py b/bob/bio/face/database/caspeal.py index b29f6d3..d7f58c3 100644 --- a/bob/bio/face/database/caspeal.py +++ b/bob/bio/face/database/caspeal.py @@ -31,7 +31,8 @@ class CaspealDatabase(CSVDataset): This package only contains the Bob_ accessor methods to use the DB directly from python, with our certified protocols. We have implemented the default face identification protocols ``'accessory'``, ``'aging'``, ``'background'``, ``'distance'``, ``'expression'`` and ``'lighting'``. - We do not provide the ``'pose'`` protocol (yet) since the training set of the `CAS-PEAL`_ database does not contain pose images: + We do not provide the ``'pose'`` protocol (yet) since the training set of the `CAS-PEAL `_ + database does not contain pose images: .. code-block:: latex -- GitLab