Commit e396992b authored by Olegs NIKISINS's avatar Olegs NIKISINS
Browse files

Added a CelebA file-list based HLDI and entry points

parent 0e3a9d70
Pipeline #20482 passed with stage
in 15 minutes and 49 seconds
#!/usr/bin/env python
"""`CELEBA`_ is a face makeup spoofing database adapted for face PAD experiments.
You can download the raw data of the `CELEBA`_ database by following
the link.
.. include:: links.rst
"""
from bob.pad.face.database.celeb_a import CELEBAPadDatabase
# Directory where the data files are stored.
# This directory is given in the .bob_bio_databases.txt file located in your home directory
original_directory = "[YOUR_CELEB_A_DATABASE_DIRECTORY]"
"""Value of ``~/.bob_bio_databases.txt`` for this database"""
original_extension = "" # extension of the data files
database = CELEBAPadDatabase(
protocol='grandtest',
original_directory=original_directory,
original_extension=original_extension,
training_depends_on_protocol=True,
)
"""The :py:class:`bob.pad.base.database.PadDatabase` derivative with CELEBA
database settings.
.. warning::
This class only provides a programmatic interface to load data in an orderly
manner, respecting usage protocols. It does **not** contain the raw
data files. You should procure those yourself.
Notice that ``original_directory`` is set to ``[YOUR_CELEBA_DATABASE_DIRECTORY]``.
You must make sure to create ``${HOME}/.bob_bio_databases.txt`` setting this
value to the place where you actually installed the CELEBA Database, as
explained in the section :ref:`bob.pad.face.baselines`.
"""
protocol = 'grandtest'
"""The default protocol to use for reproducing the baselines.
You may modify this at runtime by specifying the option ``--protocol`` on the
command-line of ``spoof.py`` or using the keyword ``protocol`` on a
configuration file that is loaded **after** this configuration resource.
"""
groups = ["train", "dev", "eval"]
"""The default groups to use for reproducing the baselines.
You may modify this at runtime by specifying the option ``--groups`` on the
command-line of ``spoof.py`` or using the keyword ``groups`` on a
configuration file that is loaded **after** this configuration resource.
"""
......@@ -5,6 +5,7 @@ from .msu_mfsd import MsuMfsdPadDatabase
from .aggregated_db import AggregatedDbPadDatabase
from .mifs import MIFSPadDatabase
from .batl import BatlPadDatabase
from .celeb_a import CELEBAPadDatabase
# gets sphinx autodoc done right - don't remove it
......@@ -31,6 +32,7 @@ __appropriate__(
AggregatedDbPadDatabase,
MIFSPadDatabase,
BatlPadDatabase,
CELEBAPadDatabase
)
__all__ = [_ for _ in dir() if not _.startswith('_')]
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#!/usr/bin/env python
#==============================================================================
import bob.bio.video # Used in CELEBAPadFile class
import bob.io.base
import numpy as np
from bob.pad.base.database import PadFile # Used in ReplayPadFile class
from bob.pad.base.database import FileListPadDatabase
#==============================================================================
class CELEBAPadFile(PadFile):
"""
A high level implementation of the File class for the CELEBA database.
"""
def __init__(self, client_id, path, attack_type=None, file_id=None):
super(CELEBAPadFile, self).__init__(client_id, path, attack_type, file_id)
#==========================================================================
def load(self, directory=None, extension=None):
"""
Overridden version of the load method defined in the ``PadFile``.
**Parameters:**
``directory`` : :py:class:`str`
String containing the path to the CELEBA database.
Default: None
``extension`` : :py:class:`str`
Extension of the video files in the CELEBA database.
Default: None
**Returns:**
``video_data`` : FrameContainer
Video data stored in the FrameContainer, see ``bob.bio.video.utils.FrameContainer``
for further details.
"""
path = self.make_path(directory=directory, extension=extension) # path to the file
frame_selector = bob.bio.video.FrameSelector(selection_style = 'all') # this frame_selector will select all frames from the video file
data = bob.io.base.load(path)
data = np.expand_dims(data, axis=0) # upgrade to 4D (video)
video_data = frame_selector(data) # video data
return video_data # video data
#==============================================================================
class CELEBAPadDatabase(FileListPadDatabase):
"""
A high level implementation of the Database class for the CELEBA database.
"""
def __init__(
self,
protocol='grandtest', # grandtest is the default protocol for this database
original_directory='[YOUR_CELEB_A_DATABASE_DIRECTORY]',
original_extension='.jpg',
**kwargs):
from pkg_resources import resource_filename
folder = resource_filename(__name__, '../lists/celeb_a/')
super(CELEBAPadDatabase, self).__init__(folder, 'celeb_a',
pad_file_class=CELEBAPadFile,
protocol = protocol,
original_directory=original_directory,
original_extension=original_extension)
#==========================================================================
def annotations(self, f):
"""
Return annotations for a given file object ``f``, which is an instance
of ``CELEBAPadFile``.
**Parameters:**
``f`` : :py:class:`object`
An instance of ``CELEBAPadFile`` defined above.
**Returns:**
``annotations`` : :py:class:`dict`
A dictionary containing the annotations for each frame in the video.
Dictionary structure: ``annotations = {'1': frame1_dict, '2': frame1_dict, ...}``.
Where ``frameN_dict = {'topleft': (row, col), 'bottomright': (row, col)}``
is the dictionary defining the coordinates of the face bounding box in frame N.
"""
annotations = {} # dictionary to return
return annotations
\ No newline at end of file
027/027360.jpg 027/027360 attack
027/027360.jpg 027/027360 attack
027/027360.jpg 027/027360 attack
027/027360.jpg 027/027360 attack
This diff is collapsed.
061/061710.jpg 061/061710 attack
102/102612.jpg 102/102612 attack
094/094016.jpg 094/094016 attack
027/027360.jpg 027/027360 attack
This diff is collapsed.
061/061710.jpg 061/061710 attack
102/102612.jpg 102/102612 attack
094/094016.jpg 094/094016 attack
027/027360.jpg 027/027360 attack
This diff is collapsed.
......@@ -14,3 +14,4 @@
.. _dependencies: https://gitlab.idiap.ch/bob/bob/wikis/Dependencies
.. _MSU MFSD: http://biometrics.cse.msu.edu/Publications/Databases/MSUMobileFaceSpoofing/index.htm
.. _MIFS: http://www.antitza.com/makeup-datasets.html
.. _CELEBA: http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html
......@@ -67,6 +67,7 @@ setup(
'batl-db-infrared = bob.pad.face.config.batl_db_infrared:database',
'batl-db-depth = bob.pad.face.config.batl_db_depth:database',
'batl-db-thermal = bob.pad.face.config.batl_db_thermal:database',
'celeb-a = bob.pad.face.config.celeb_a:database',
],
# registered configurations:
......@@ -81,6 +82,7 @@ setup(
'batl-db-infrared = bob.pad.face.config.batl_db_infrared',
'batl-db-depth = bob.pad.face.config.batl_db_depth',
'batl-db-thermal = bob.pad.face.config.batl_db_thermal',
'celeb-a = bob.pad.face.config.celeb_a',
# baselines using SVM:
'lbp-svm = bob.pad.face.config.lbp_svm',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment