Python API

bob.db.swan.SWAN_FRAME_SHAPE = (3, 1280, 720)

Shape of the video frames in the swan database.

class bob.db.swan.Database(original_directory=None, bio_file_class=<class 'bob.db.swan.SwanAudioBioFile'>, annotation_directory=None, annotation_extension='.json', annotation_type='json', name='swan', **kwargs)

Bases: bob.bio.base_legacy.database.FileListBioDatabase, bob.db.swan.common.SwanVideoDatabase

Wrapper class for the SWAN database for speaker recognition (http://www.idiap.ch/dataset/swan). This class defines a simple protocol for training, dev and and by splitting the audio files of the database in three main parts.

objects(groups=None, protocol=None, purposes=None, model_ids=None, classes=None, filter_samples=None, **kwargs)[source]

Returns a set of bob.bio.base_legacy.database.BioFile objects for the specific query by the user.

Parameters
  • protocol (str or None) – The protocol to consider

  • purposes (str or [str] or None) – The purposes required to be retrieved ('enroll', 'probe') or a tuple with several of them. If None is given (this is the default), it is considered the same as a tuple with all possible values. This field is ignored for the data from the 'world', 'optional_world_1', 'optional_world_2' groups.

  • model_ids (str or [str] or None) – Only retrieves the files for the provided list of model ids (claimed client id). If None is given (this is the default), no filter over the model_ids is performed.

  • groups (str or [str] or None) – One of the groups ('dev', 'eval', 'world', 'optional_world_1', 'optional_world_2') or a tuple with several of them. If None is given (this is the default), it is considered to be the existing subset of ('world', 'dev', 'eval').

  • classes (str or [str] or None) –

    The classes (types of accesses) to be retrieved ('client', 'impostor') or a tuple with several of them. If None is given (this is the default), it is considered the same as a tuple with all possible values.

    Note

    Classes are not allowed to be specified when ‘probes_filename’ is used in the constructor.

Returns

A list of BioFile objects considering all the filtering criteria.

Return type

[BioFile]

class bob.db.swan.SwanAudioBioFile(new_rate=None, **kwargs)

Bases: bob.db.swan.common.SwanAudioFile, bob.bio.spear_legacy.database.AudioBioFile

SwanAudioBioFile are video files actually

class bob.db.swan.SwanVideoBioFile(client_id, path, file_id, **kwargs)

Bases: bob.db.swan.common.SwanVideoFile

SwanVideoBioFile are video files actually

bob.db.swan.get_config()[source]

Returns a string containing the configuration information.

bob.db.swan.common.read_audio(video_path, new_rate=None)[source]
class bob.db.swan.common.Client(site, id_in_site, gender, **kwargs)[source]

Bases: object

A base class for SWAN clients

property id
bob.db.swan.common.swan_file_metadata(path)[source]

Returns the metadata associated with a SWAN file recorded during the biometric recognition phase.

Parameters

path (str) – The path of the SWAN file.

Returns

  • client (Client)

  • session (str)

  • nrecording (str)

  • device (str)

  • modality (str)

class bob.db.swan.common.SwanFile(**kwargs)[source]

Bases: object

A base class for SWAN bio files which can handle the metadata.

class bob.db.swan.common.SwanVideoFile(client_id, path, file_id, **kwargs)[source]

Bases: bob.bio.video_legacy.database.VideoBioFile, bob.db.swan.common.SwanFile

A base class for SWAN video files

swap(data)[source]
load(directory=None, extension=None, frame_selector=<bob.bio.video_legacy.utils.FrameSelector.FrameSelector object>)[source]

Loads the data at the specified location and using the given extension. Override it if you need to load differently.

Parameters
  • directory (str, optional) – If not empty or None, this directory is prefixed to the final file destination

  • extension (str, optional) – If not empty or None, this extension is suffixed to the final file destination

Returns

The loaded data (normally numpy.ndarray).

Return type

object

property frames

Yields the frames of the padfile one by one.

Parameters

padfile (SwanVideoFile) – The high-level pad file

Yields

numpy.array – A frame of the video. The size is (3, 1280, 720).

property number_of_frames

Returns the number of frames in a video file.

Parameters

padfile (SwanVideoFile) – The high-level pad file

Returns

The number of frames.

Return type

int

property frame_shape

Returns the size of each frame in this database.

Returns

The (#Channels, Height, Width) which is (3, 1920, 1080).

Return type

(int, int, int)

property annotations

Returns the annotations of the current file

Returns

The annotations as a dictionary, e.g.: {'0': {'reye':(re_y,re_x), 'leye':(le_y,le_x)}, ...}

Return type

dict

class bob.db.swan.common.SwanAudioFile(new_rate=None, **kwargs)[source]

Bases: bob.db.swan.common.SwanVideoFile

A base class that extracts audio from SWAN video files

load(directory=None, extension=None)[source]

Loads the data at the specified location and using the given extension. Override it if you need to load differently.

Parameters
  • directory (str, optional) – If not empty or None, this directory is prefixed to the final file destination

  • extension (str, optional) – If not empty or None, this extension is suffixed to the final file destination

Returns

The loaded data (normally numpy.ndarray).

Return type

object

class bob.db.swan.common.SwanVideoDatabase(new_rate=None, **kwargs)[source]

Bases: object

frames(padfile)[source]
number_of_frames(padfile)[source]
property frame_shape
update_files(files)[source]
class bob.db.swan.query_pad.SwanAudioPadFile(new_rate=None, **kwargs)[source]

Bases: bob.db.swan.common.SwanAudioFile, bob.pad.voice.database.PadVoiceFile

SwanAudioPadFile are video files actually

class bob.db.swan.query_pad.SwanVideoPadFile(client_id, path, file_id, **kwargs)[source]

Bases: bob.db.swan.common.SwanVideoFile, bob.pad.face.database.VideoPadFile

SwanVideoPadFile are video files actually

class bob.db.swan.query_pad.Database(original_directory=None, pad_file_class=<class 'bob.db.swan.query_pad.SwanAudioPadFile'>, annotation_directory=None, annotation_extension='.json', annotation_type='json', name='swan', **kwargs)[source]

Bases: bob.pad.base.database.FileListPadDatabase, bob.db.swan.common.SwanVideoDatabase

Wrapper class for the SWAN database for PAD (http://www.idiap.ch/dataset/swan).

objects(groups=None, protocol=None, purposes=None, model_ids=None, classes=None, filter_samples=None, **kwargs)[source]

Returns a set of PadFile objects for the specific query by the user.

Keyword Parameters:

groupsstr or [str] or None

One of the groups (“dev”, “eval”, “train”) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.

protocolstr or None

The protocol to consider

purposesstr or [str] or None

The purposes required to be retrieved (“real”, “attack”) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.

model_ids[various type]

This parameter is not supported in PAD databases yet

Returns: A list of PadFile objects considering all the filtering criteria.