Tools implemented in bob.pad.base¶
Please not that some parts of the code in this package are dependent on and reused from bob.bio.base package.
Summary¶
Base Classes¶
Most of the base classes are reused from bob.bio.base.
Only one base class that is presentation attack detection specific, Algorithm
is implemented in this package.
Implementations¶
|
Base class for Vanilla PAD pipeline |
|
Wraps a bob.pad.base database and generates conforming samples |
|
This class represents the basic API for database access. |
|
A simple base class that defines basic properties of File object for the use in PAD experiments |
Preprocessors and Extractors¶
Preprocessors and Extractors from the bob.bio.base package can also be used in this package.
Databases¶
-
class
bob.pad.base.database.
FileListPadDatabase
(dataset_protocols_path, protocol, transformer=None, **kwargs)¶ Bases:
bob.pad.base.pipelines.vanilla_pad.Database
,bob.pipelines.datasets.FileListDatabase
A PAD database interface from CSV files.
-
fit_samples
()[source]¶ Returns
Sample
’s to train a PAD model- Returns
samples – List of samples for model training.
- Return type
-
-
class
bob.pad.base.database.
HighBioDatabase
(filelists_directory=None, original_directory='[DB_DATA_DIRECTORY]', original_extension='.wav', db_name='', file_class=None, **kwargs)¶ Bases:
bob.bio.base.database.filelist.FileListBioDatabase
Implements verification API for querying High database.
-
annotations
(file)[source]¶ Reads the annotations for the given file id from file and returns them in a dictionary.
- Parameters
file (BioFile) – The BioFile object for which the annotations should be read.
- Returns
The annotations as a dictionary, e.g.:
{'reye':(re_y,re_x), 'leye':(le_y,le_x)}
- Return type
-
arrange_by_client
(files) → files_by_client[source]¶ Arranges the given list of files by client id. This function returns a list of lists of File’s.
Parameters:
- files
bob.bio.base.database.BioFile
A list of files that should be split up by BioFile.client_id.
Returns:
- files_by_client[[
bob.bio.base.database.BioFile
]] The list of lists of files, where each sub-list groups the files with the same BioFile.client_id
- files
-
client_id_from_model_id
(model_id, group='dev')[source]¶ This wrapper around PAD database does not have a knowledge of model ids used in verification experiments, so we just assume that the client_id is the same as model_id, which is actually true for most of the verification databases as well.
-
model_ids_with_protocol
(groups=None, protocol=None, **kwargs)[source]¶ This wrapper around PAD database does not have a knowledge of model ids used in verification experiments, so we just assume that the model_ids are the same as client ids, which is actually true for most of the verification databases as well.
-
objects
(protocol=None, purposes=None, model_ids=None, groups=None, **kwargs)[source]¶ Maps objects method of PAD databases into objects method of Verification database
- Parameters
protocol (str) – To distinguish two vulnerability scenarios, protocol name should have either ‘-licit’ or ‘-spoof’ appended to it. For instance, if DB has protocol ‘general’, the named passed to this method should be ‘general-licit’, if we want to run verification experiments on bona fide data only, but it should be ‘general-spoof’, if we want to run it for spoof scenario (the probes are attacks).
purposes ([str]) – This parameter is passed by the
bob.bio.base
verification experimentmodel_ids ([object]) – This parameter is passed by the
bob.bio.base
verification experimentgroups ([str]) – We map the groups from (‘world’, ‘dev’, ‘eval’) used in verification experiments to (‘train’, ‘dev’, ‘eval’)
**kwargs – The rest of the parameters valid for a given database
- Returns
Set of BioFiles that verification experiments expect.
- Return type
[object]
-
-
class
bob.pad.base.database.
HighPadDatabase
(filelists_directory=None, original_directory='[DB_DATA_DIRECTORY]', original_extension='.wav', file_class=None, db_name='', **kwargs)¶
-
class
bob.pad.base.database.
PadDatabase
(name, protocol='Default', original_directory=None, original_extension=None, **kwargs)¶ Bases:
bob.bio.base.database.BioDatabase
This class represents the basic API for database access. Please use this class as a base class for your database access classes. Do not forget to call the constructor of this base class in your derived class.
Parameters:
name : str A unique name for the database.
protocol : str or
None
The name of the protocol that defines the default experimental setup for this database.original_directory : str The directory where the original data of the database are stored.
original_extension : str The file name extension of the original data.
kwargs :
key=value
pairs The arguments of thebob.bio.base.database.BioDatabase
base class constructor.-
all_files
(groups='train', 'dev', 'eval', flat=False)[source]¶ Returns all files of the database, respecting the current protocol. The files can be limited using the
all_files_options
in the constructor.- Parameters
- Returns
files – The sorted and unique list of all files of the database.
- Return type
-
annotations
(file)[source]¶ Returns the annotations for the given File object, if available. You need to override this method in your high-level implementation. If your database does not have annotations, it should return
None
.Parameters:
- file
bob.pad.base.database.PadFile
The file for which annotations should be returned.
Returns:
- annotsdict or None
The annotations for the file, if available.
- file
-
model_ids_with_protocol
(groups=None, protocol=None, **kwargs) → ids[source]¶ Client-based PAD is not implemented.
-
abstract
objects
(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]¶ This function returns lists of File objects, which fulfill the given restrictions.
Keyword parameters:
- groupsstr or [str]
The groups of which the clients should be returned. Usually, groups are one or more elements of (‘train’, ‘dev’, ‘eval’)
- protocol
The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.
- purposesstr or [str]
The purposes for which File objects should be retrieved. Usually it is either ‘real’ or ‘attack’.
- model_ids[various type]
This parameter is not supported in PAD databases yet
-
original_file_names
(files) → paths[source]¶ Returns the full paths of the real and attack data of the given PadFile objects.
Parameters:
- files[[
bob.pad.base.database.PadFile
], [bob.pad.base.database.PadFile
] The list of lists ([real, attack]) of file object to retrieve the original data file names for.
Returns:
- paths[str] or [[str]]
The paths extracted for the concatenated real+attack files, in the preserved order.
- files[[
-
training_files
(step=None, arrange_by_client=False) → files[source]¶ Returns all training File objects This function needs to be implemented in derived class implementations.
- Parameters:
The parameters are not applicable in this version of anti-spoofing experiments
Returns:
- files[
bob.pad.base.database.PadFile
] or [[bob.pad.base.database.PadFile
]] The (arranged) list of files used for the training.
-
-
class
bob.pad.base.database.
PadFile
(client_id, path, attack_type=None, file_id=None, original_directory=None, original_extension=None, annotation_directory=None, annotation_extension=None, annotation_type=None)¶ Bases:
bob.bio.base.database.BioFile
A simple base class that defines basic properties of File object for the use in PAD experiments
Grid Configuration¶
Code related to grid is reused from bob.bio.base package. Please see the corresponding documentation.