Commit ce35fbfa authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Hacked the spoofing layer to deal with the anonymous test set

parent 45cf50d4
......@@ -8,35 +8,60 @@
from . import __doc__ as long_description
from . import Database as ReplayDatabase
from antispoofing.utils.db import File as FileBase, Database as DatabaseBase
import os
class File(FileBase):
def __init__(self, f):
"""Initializes this File object with our own File equivalent"""
def __init__(self, f, icb2013=False):
Initializes this File object with our own File equivalent
icb2013: Flag selecting the icb2013 anonymous test set
self.__f = f
self.__icb2013 = icb2013
def videofile(self, directory=None):
return self.__f.videofile(directory=os.path.join(directory,"anonymized_test_set","videos"))
return self.__f.videofile(directory=directory)
videofile.__doc__ = FileBase.videofile.__doc__
def facefile(self, directory=None):
return self.__f.facefile(directory=os.path.join(directory,"anonymized_test_set"))
return self.__f.facefile(directory=directory)
facefile.__doc__ = FileBase.facefile.__doc__
def bbx(self, directory=None):
return self.__f.bbx(directory=os.path.join(directory,"anonymized_test_set"))
return self.__f.bbx(directory=directory)
bbx.__doc__ = FileBase.bbx.__doc__
def load(self, directory=None, extension='.hdf5'):
return self.__f.load(directory=os.path.join(directory,"anonymized_test_set","videos"), extension=extension)
return self.__f.load(directory=directory, extension=extension)
load.__doc__ = FileBase.bbx.__doc__
def save(self, data, directory=None, extension='.hdf5'):
return, directory=os.path.join(directory,"anonymized_test_set","videos"), extension=extension)
return, directory=directory, extension=extension)
save.__doc__ =
def make_path(self, directory=None, extension=None):
return self.__f.make_path(directory=os.path.join(directory,"anonymized_test_set","videos"), extension=extension)
return self.__f.make_path(directory=directory, extension=extension)
make_path.__doc__ = FileBase.make_path.__doc__
......@@ -55,7 +80,10 @@ class Database(DatabaseBase):
self.__db = ReplayDatabase()
self.__kwargs = {}
self.__icb2013 = False
if args is not None:
self.__icb2013 = args.icb2013
self.__kwargs = {
'protocol': args.replay_protocol,
......@@ -91,7 +119,9 @@ class Database(DatabaseBase):
identities = [ for k in self.__db.clients()]
p.add_argument('--client', type=int, action='append', choices=identities, dest='replay_client', help="Client identifier (if unset, the default, use all)")
p.add_argument('--ICB-2013', default=False, action='store_true', dest='icb2013', help="Retrieve the File list of the ICB 2013 competition anonymized test set (The 2nd competition on counter measures to 2D facial spoofing attacks).")
......@@ -129,7 +159,6 @@ class Database(DatabaseBase):
def get_data(self, group):
"""Returns either all objects or objects for a specific group"""
real = dict(self.__kwargs)
real.update({'groups': group, 'cls': 'real'})
attack = dict(self.__kwargs)
......@@ -146,12 +175,31 @@ class Database(DatabaseBase):
get_devel_data.__doc__ = DatabaseBase.get_devel_data.__doc__
def get_test_data(self):
return get_ICB2013_test_data()
return self.get_data('test')
get_test_data.__doc__ = DatabaseBase.get_test_data.__doc__
def get_test_filters(self):
return ('device', 'support', 'light')
def get_ICB2013_test_data(self):
Return a list of File objects containing the ICB 2013 test set
icb2013_test_data = []
#There are 480 files
import xbob
icb2013_test_data = [File(
xbob.db.replay.models.File(None,"test_sequence_" + str(i).zfill(3),None),
self.__icb2013) for i in range(1,481)]
return icb2013_test_data,[]
def get_filtered_test_data(self, filter):
def device_filter(obj, filter):
......@@ -187,5 +235,12 @@ class Database(DatabaseBase):
def get_all_data(self):
train_real,train_attack = self.get_train_data()
devel_real,devel_attack = self.get_devel_data()
anonymous_data,_ = self.get_ICB2013_test_data()
return train_real + devel_real + anonymous_data, train_attack + devel_attack
#return anonymous_data,[]
return self.get_data(None)
get_all_data.__doc__ = DatabaseBase.get_all_data.__doc__
Supports Markdown
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