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

streamline name of databases and fix tests

parent ad534b35
No related branches found
No related tags found
1 merge request!128Several changes
Pipeline #62109 passed
Showing
with 92 additions and 84 deletions
"""The `CASIA-SURF`_ database for face anti-spoofing
After downloading, you can tell the bob library where the files are located
using::
$ bob config set bob.db.casia_surf.directory /path/to/database/CASIA-SURF/
"""
from bob.pad.face.database import CasiaSurfPadDatabase
database = CasiaSurfPadDatabase()
from bob.pad.face.database import CasiaSurfPadDatabase
database = CasiaSurfPadDatabase()
......@@ -54,7 +54,7 @@ preprocessor = mario.wrap(
)
# Classifier #
classifier = DeepPixBisClassifier(model_file="oulunpu-p1")
classifier = DeepPixBisClassifier(model_file="oulu-npu-p1")
classifier = mario.wrap(["sample"], classifier)
# change the decision_function
decision_function = "predict_proba"
......
......@@ -17,7 +17,7 @@ your references:
After downloading, you can tell the bob library where the files are located
using::
$ bob config set bob.db.maskattack.directory /path/to/database/3dmad/Data/
$ bob config set bob.db.mask_attack.directory /path/to/database/3dmad/Data/
"""
from bob.pad.face.database import MaskAttackPadDatabase
......
......@@ -3,7 +3,7 @@ A mobile face presentation attack database with real-world variations database.
To configure the location of the database on your computer, run::
bob config set bob.db.oulunpu.directory /path/to/database/oulu-npu
bob config set bob.db.oulu_npu.directory /path/to/database/oulu-npu
If you use this database, please cite the following publication::
......@@ -17,6 +17,6 @@ If you use this database, please cite the following publication::
year = {2017},
}
"""
from bob.pad.face.database import OulunpuPadDatabase
from bob.pad.face.database import OuluNpuPadDatabase
database = OulunpuPadDatabase()
database = OuluNpuPadDatabase()
......@@ -9,7 +9,7 @@ You can download the raw data of the `Replay-Attack`_ database by following the
link. After downloading, you can tell the bob library where the files are
located using::
$ bob config set bob.db.replayattack.directory /path/to/database/replay/protocols/replayattack-database/
$ bob config set bob.db.replay_attack.directory /path/to/database/replay/protocols/replayattack-database/
"""
from bob.pad.face.database import ReplayAttackPadDatabase
......
......@@ -11,7 +11,7 @@ You can download the raw data of the `Replay-Mobile`_ database by following
the link. After downloading, you can tell the bob library where the files are
located using::
$ bob config set bob.db.replaymobile.directory /path/to/database/replay-mobile/database/
$ bob config set bob.db.replay_mobile.directory /path/to/database/replay-mobile/database/
"""
from bob.pad.face.database import ReplayMobilePadDatabase
......
# isort: skip_file
from .database import VideoPadSample # noqa: F401
from .casiafasd import CasiaFasdPadDatabase
from .casiasurf import CasiaSurfPadDatabase
from .maskattack import MaskAttackPadDatabase
from .database import VideoPadSample
from .casia_fasd import CasiaFasdPadDatabase
from .casia_surf import CasiaSurfPadDatabase
from .mask_attack import MaskAttackPadDatabase
from .replay_attack import ReplayAttackPadDatabase
from .replay_mobile import ReplayMobilePadDatabase
from .swan import SwanPadDatabase
from .oulunpu import OulunpuPadDatabase
from .oulu_npu import OuluNpuPadDatabase
# gets sphinx autodoc done right - don't remove it
......@@ -26,13 +26,14 @@ def __appropriate__(*args):
__appropriate__(
VideoPadSample,
ReplayAttackPadDatabase,
ReplayMobilePadDatabase,
MaskAttackPadDatabase,
CasiaSurfPadDatabase,
CasiaFasdPadDatabase,
SwanPadDatabase,
OulunpuPadDatabase,
OuluNpuPadDatabase,
)
__all__ = [_ for _ in dir() if not _.startswith("_")]
......@@ -79,10 +79,10 @@ class CasiaSurfPadDatabase(FileListPadDatabase):
self,
**kwargs,
):
original_directory = rc.get("bob.db.casiasurf.directory")
original_directory = rc.get("bob.db.casia_surf.directory")
if original_directory is None or not os.path.isdir(original_directory):
raise FileNotFoundError(
"The original_directory is not set. Please set it in the terminal using `bob config set bob.db.casiasurf.directory /path/to/database/CASIA-SURF/`."
"The original_directory is not set. Please set it in the terminal using `bob config set bob.db.casia_surf.directory /path/to/database/CASIA-SURF/`."
)
transformer = CasiaSurfMultiStreamSample(
original_directory=original_directory,
......
......@@ -128,17 +128,16 @@ def MaskAttackPadDatabase(
step_size=None,
**kwargs,
):
name = "pad-face-mask-attack-211bd751.tar.gz"
name = "pad-face-mask-attack-2ab2032c.tar.gz"
dataset_protocols_path = get_file(
name,
[f"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/{name}"],
cache_subdir="protocols",
file_hash="211bd751",
file_hash="2ab2032c",
)
dataset_protocols_path = "/idiap/home/amohammadi/bob_data/protocols/pad-face-mask-attack-211bd751/"
transformer = MaskAttackPadSample(
original_directory=rc.get("bob.db.maskattack.directory"),
original_directory=rc.get("bob.db.mask_attack.directory"),
selection_style=selection_style,
max_number_of_frames=max_number_of_frames,
step_size=step_size,
......
......@@ -8,7 +8,7 @@ from bob.pad.face.database import VideoPadSample
logger = logging.getLogger(__name__)
def OulunpuPadDatabase(
def OuluNpuPadDatabase(
protocol="Protocol_1",
selection_style=None,
max_number_of_frames=None,
......@@ -37,7 +37,7 @@ def OulunpuPadDatabase(
annotation_type = "eyes-center"
transformer = VideoPadSample(
original_directory=rc.get("bob.db.oulunpu.directory"),
original_directory=rc.get("bob.db.oulu_npu.directory"),
annotation_directory=annotation_directory,
selection_style=selection_style,
max_number_of_frames=max_number_of_frames,
......
......@@ -37,7 +37,7 @@ def ReplayAttackPadDatabase(
annotation_type = "eyes-center"
transformer = VideoPadSample(
original_directory=rc.get("bob.db.replayattack.directory"),
original_directory=rc.get("bob.db.replay_attack.directory"),
annotation_directory=annotation_directory,
selection_style=selection_style,
max_number_of_frames=max_number_of_frames,
......
......@@ -54,7 +54,7 @@ def ReplayMobilePadDatabase(
transformer = make_pipeline(
Str_To_Types(fieldtypes=dict(should_flip=str_to_bool)),
VideoPadSample(
original_directory=rc.get("bob.db.replaymobile.directory"),
original_directory=rc.get("bob.db.replay_mobile.directory"),
annotation_directory=annotation_directory,
selection_style=selection_style,
max_number_of_frames=max_number_of_frames,
......
......@@ -15,49 +15,49 @@ logger = logging.getLogger(__name__)
DEEP_PIX_BIS_PRETRAINED_MODELS = {
"oulunpu-p1": [
"oulu-npu-p1": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_1_model_0_0-24844429.pth"
],
"oulunpu-p2": [
"oulu-npu-p2": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_2_model_0_0-4aae2f3a.pth"
],
"oulunpu-p3-1": [
"oulu-npu-p3-1": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_3_1_model_0_0-f0e70cf3.pth"
],
"oulunpu-p3-2": [
"oulu-npu-p3-2": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_3_2_model_0_0-92594797.pth"
],
"oulunpu-p3-3": [
"oulu-npu-p3-3": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_3_3_model_0_0-71e18149.pth"
],
"oulunpu-p3-4": [
"oulu-npu-p3-4": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_3_4_model_0_0-d7f666e5.pth"
],
"oulunpu-p3-5": [
"oulu-npu-p3-5": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_3_5_model_0_0-fc40ba69.pth"
],
"oulunpu-p3-6": [
"oulu-npu-p3-6": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_3_6_model_0_0-123a6c92.pth"
],
"oulunpu-p4-1": [
"oulu-npu-p4-1": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_4_1_model_0_0-5f8dc7cf.pth"
],
"oulunpu-p4-2": [
"oulu-npu-p4-2": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_4_2_model_0_0-168f2644.pth"
],
"oulunpu-p4-3": [
"oulu-npu-p4-3": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_4_3_model_0_0-db57e3b5.pth"
],
"oulunpu-p4-4": [
"oulu-npu-p4-4": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_4_4_model_0_0-e999b7e8.pth"
],
"oulunpu-p4-5": [
"oulu-npu-p4-5": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_4_5_model_0_0-dcd13b8b.pth"
],
"oulunpu-p4-6": [
"oulu-npu-p4-6": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_OULU_Protocol_4_6_model_0_0-96a1ab92.pth"
],
"replaymobile": [
"replay-mobile": [
"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/deep_pix_bis_RM_grandtest_model_0_0-6761ca7e.pth"
],
}
......
......@@ -9,7 +9,7 @@ import numpy as np
import bob.bio.base
def test_replayattack():
def test_replay_attack():
database = bob.bio.base.load_resource(
"replay-attack",
"database",
......@@ -61,7 +61,7 @@ def test_replayattack():
raise SkipTest(e)
def test_replaymobile():
def test_replay_mobile():
database = bob.bio.base.load_resource(
"replay-mobile",
"database",
......@@ -131,10 +131,10 @@ def test_replaymobile():
raise SkipTest(e)
# Test the maskattack database
def test_maskattack():
maskattack = bob.bio.base.load_resource(
"maskattack",
# Test the mask_attack database
def test_mask_attack():
mask_attack = bob.bio.base.load_resource(
"mask-attack",
"database",
preferred_package="bob.pad.face",
package_prefix="bob.pad.",
......@@ -142,14 +142,16 @@ def test_maskattack():
# all real sequences: 2 sessions, 5 recordings for 17 individuals
assert (
len(
maskattack.samples(groups=["train", "dev", "eval"], purposes="real")
mask_attack.samples(
groups=["train", "dev", "eval"], purposes="real"
)
)
== 170
)
# all attacks: 1 session, 5 recordings for 17 individuals
assert (
len(
maskattack.samples(
mask_attack.samples(
groups=["train", "dev", "eval"], purposes="attack"
)
)
......@@ -157,19 +159,19 @@ def test_maskattack():
)
# training real: 7 subjects, 2 sessions, 5 recordings
assert len(maskattack.samples(groups=["train"], purposes="real")) == 70
assert len(mask_attack.samples(groups=["train"], purposes="real")) == 70
# training real: 7 subjects, 1 session, 5 recordings
assert len(maskattack.samples(groups=["train"], purposes="attack")) == 35
assert len(mask_attack.samples(groups=["train"], purposes="attack")) == 35
# dev and test contains the same number of sequences:
# real: 5 subjects, 2 sessions, 5 recordings
# attack: 5 subjects, 1 sessions, 5 recordings
assert len(maskattack.samples(groups=["dev"], purposes="real")) == 50
assert len(maskattack.samples(groups=["eval"], purposes="real")) == 50
assert len(maskattack.samples(groups=["dev"], purposes="attack")) == 25
assert len(maskattack.samples(groups=["eval"], purposes="attack")) == 25
assert len(mask_attack.samples(groups=["dev"], purposes="real")) == 50
assert len(mask_attack.samples(groups=["eval"], purposes="real")) == 50
assert len(mask_attack.samples(groups=["dev"], purposes="attack")) == 25
assert len(mask_attack.samples(groups=["eval"], purposes="attack")) == 25
sample = maskattack.samples()[0]
sample = mask_attack.samples()[0]
try:
assert sample.data.shape == (20, 3, 480, 640)
np.testing.assert_equal(sample.data[0][:, 0, 0], [185, 166, 167])
......@@ -186,7 +188,7 @@ def test_maskattack():
def test_casia_fasd():
casia_fasd = bob.bio.base.load_resource(
"casiafasd",
"casia-fasd",
"database",
preferred_package="bob.pad.face",
package_prefix="bob.pad.",
......@@ -208,14 +210,14 @@ def test_casia_fasd():
def test_casia_surf():
casia_surf = bob.bio.base.load_resource(
"casiasurf",
"database",
preferred_package="bob.pad.face",
package_prefix="bob.pad.",
)
try:
casia_surf = bob.bio.base.load_resource(
"casia-surf",
"database",
preferred_package="bob.pad.face",
package_prefix="bob.pad.",
)
assert len(casia_surf.samples()) == 96584
assert len(casia_surf.samples(purposes="real")) == 29394
assert len(casia_surf.samples(purposes="attack")) == 67190
......@@ -281,9 +283,9 @@ def test_swan():
raise SkipTest(e)
def test_oulunpu():
def test_oulu_npu():
database = bob.bio.base.load_resource(
"oulunpu",
"oulu-npu",
"database",
preferred_package="bob.pad.face",
package_prefix="bob.pad.",
......
......@@ -60,7 +60,7 @@ Documentation for each resource is available on the section
.. code-block:: sh
$ bob config set bob.db.replaymobile.directory /path/to/replaymobile-database/
$ bob config set bob.db.replay_mobile.directory /path/to/replaymobile-database/
Notice it is rather important to correctly configure the database as
described above, otherwise ``bob.pad.base`` will not be able to correctly
......@@ -79,7 +79,7 @@ Baselines on REPLAY-ATTACK database
This section summarizes the results of baseline face PAD experiments on the
REPLAY-ATTACK (`replay-attack`_) database. The description of the
database-related settings, which are used to run face PAD baselines on the
Replay-Attack is given here :ref:`bob.pad.face.resources.databases.replay`. To
Replay-Attack is given here :ref:`bob.pad.face.resources.databases.replay_attack`. To
understand the settings in more detail you can check the corresponding
configuration file: ``bob/pad/face/config/replay_attack.py``.
......@@ -176,7 +176,7 @@ which should give you::
=================== ============== ==============
.. _bob.pad.face.baselines.oulunpu:
.. _bob.pad.face.baselines.oulu_npu:
Baselines on OULU-NPU database
--------------------------------------
......@@ -184,9 +184,9 @@ Baselines on OULU-NPU database
This section summarizes the results of baseline face PAD experiments on the
`OULU-NPU`_ database. The description of the database-related settings,
which are used to run face PAD baselines on the OULU-NPU is given here
:ref:`bob.pad.face.resources.databases.oulunpu`. To understand the
:ref:`bob.pad.face.resources.databases.oulu_npu`. To understand the
settings in more detail you can check the corresponding configuration file :
``bob/pad/face/config/oulunpu.py``.
``bob/pad/face/config/oulu_npu.py``.
Deep-Pix-BiS Baseline
......@@ -194,7 +194,7 @@ Deep-Pix-BiS Baseline
.. code-block:: sh
$ bob pad run-pipeline -vv oulunpu deep-pix-bis --output <OUTPUT> --dask-client <CLIENT>
$ bob pad run-pipeline -vv oulu-npu deep-pix-bis --output <OUTPUT> --dask-client <CLIENT>
This baseline reports scores per frame. To obtain scores per video, you can run::
......
......@@ -26,7 +26,7 @@ The configuration files contain at least the following arguments of the
* ``groups``
.. _bob.pad.face.resources.databases.replay:
.. _bob.pad.face.resources.databases.replay_attack:
Replay-Attack Database
================================================================================
......@@ -45,12 +45,12 @@ Replay-Mobile Database
.. _bob.pad.face.resources.databases.oulunpu:
.. _bob.pad.face.resources.databases.oulu_npu:
OULU-NPU Database
================================================================================
.. automodule:: bob.pad.face.config.oulunpu
.. automodule:: bob.pad.face.config.oulu_npu
:members:
......
......@@ -55,14 +55,13 @@ setup(
"console_scripts": [],
# registered databases:
"bob.pad.database": [
"casia-fasd = bob.pad.face.config.casia_fasd:database",
"casia-surf = bob.pad.face.config.casia_surf:database",
"mask-attack = bob.pad.face.config.mask_attack:database",
"oulu-npu = bob.pad.face.config.oulu_npu:database",
"replay-attack = bob.pad.face.config.replay_attack:database",
"replay-mobile = bob.pad.face.config.replay_mobile:database",
"casiafasd = bob.pad.face.config.casiafasd:database",
"maskattack = bob.pad.face.config.maskattack:database",
"casiasurf-color = bob.pad.face.config.casiasurf_color:database",
"casiasurf = bob.pad.face.config.casiasurf:database",
"swan = bob.pad.face.config.swan:database",
"oulunpu = bob.pad.face.config.oulunpu:database",
],
# registered pipelines:
"bob.pad.pipeline": [
......@@ -72,13 +71,13 @@ setup(
# registered configurations:
"bob.pad.config": [
# databases
"casia-fasd = bob.pad.face.config.casia_fasd",
"casia-surf = bob.pad.face.config.casia_surf",
"mask-attack = bob.pad.face.config.mask_attack",
"oulu-npu = bob.pad.face.config.oulu_npu",
"replay-attack = bob.pad.face.config.replay_attack",
"replay-mobile = bob.pad.face.config.replay_mobile",
"casiafasd = bob.pad.face.config.casiafasd",
"maskattack = bob.pad.face.config.maskattack",
"casiasurf = bob.pad.face.config.casiasurf",
"swan = bob.pad.face.config.swan",
"oulunpu = bob.pad.face.config.oulunpu",
# pipelines
"svm-frames = bob.pad.face.config.svm_frames",
"deep-pix-bis = bob.pad.face.config.deep_pix_bis",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment