Commit 9f413d92 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

Initial commit

parents
*~
*.swp
*.pyc
bin
eggs
parts
.installed.cfg
.mr.developer.cfg
*.egg-info
src
develop-eggs
sphinx
dist
This diff is collapsed.
include README.rst bootstrap-buildout.py buildout.cfg COPYING version.txt requirements.txt
recursive-include doc *.py *.rst *.ico *.png
.. vim: set fileencoding=utf-8 :
.. Mon 03 Jul 2017 11:50:06 CEST
.. image:: http://img.shields.io/badge/docs-stable-yellow.svg
:target: https://www.idiap.ch/software/bob/docs/bob/bob.db.oulunpu/stable/index.html
.. image:: http://img.shields.io/badge/docs-latest-orange.svg
:target: https://www.idiap.ch/software/bob/docs/bob/bob.db.oulunpu/master/index.html
.. image:: https://gitlab.idiap.ch/bob/bob.db.oulunpu/badges/master/build.svg
:target: https://gitlab.idiap.ch/bob/bob.db.oulunpu/commits/master
.. image:: https://gitlab.idiap.ch/bob/bob.db.oulunpu/badges/master/coverage.svg
:target: https://gitlab.idiap.ch/bob/bob.db.oulunpu/commits/master
.. image:: https://img.shields.io/badge/gitlab-project-0000c0.svg
:target: https://gitlab.idiap.ch/bob/bob.db.oulunpu
.. image:: http://img.shields.io/pypi/v/bob.db.oulunpu.svg
:target: https://pypi.python.org/pypi/bob.db.oulunpu
============================
Example buildout environment
============================
This package is part of the signal-processing and machine learning toolbox
Bob_. This simple example demonstrates how to wrap Bob-based scripts on buildout
environments. This may be useful for homework assignments, tests or as a way to
distribute code to reproduce your publication. In summary, if you need to give
out code to others, we recommend you do it following this template so your code
can be tested, documented and run in an orderly fashion.
Installation
------------
Follow our `installation`_ instructions. Then, using the Python interpreter
provided by the distribution, build this package with::
$ buildout
Documentation and Further Information
-------------------------------------
Refer to the latest Bob_ documentation for details. In particular, the
guide `Bob Package Development`_ contains details on how to setup, build and
roll out your own code.
Contact
-------
For questions or reporting issues to this software package, contact our
development `mailing list`_.
.. Place your references here:
.. _bob: https://www.idiap.ch/software/bob
.. _installation: https://www.idiap.ch/software/bob/install
.. _mailing list: https://www.idiap.ch/software/bob/discuss
.. _bob package development: https://www.idiap.ch/software/bob/docs/bob/bob.extension/master/
# see https://docs.python.org/3/library/pkgutil.html
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
# see https://docs.python.org/3/library/pkgutil.html
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
from .query import Database, File
def __appropriate__(*args):
"""Says object was actually declared here, and not in the import module.
Fixing sphinx warnings of not being able to find classes, when path is
shortened. Parameters:
*args: An iterable of objects to modify
Resolves `Sphinx referencing issues
<https://github.com/sphinx-doc/sphinx/issues/3048>`
"""
for obj in args:
obj.__module__ = __name__
__appropriate__(
Database,
File,
)
def get_config():
"""Returns a string containing the configuration information.
"""
import bob.extension
return bob.extension.get_config(__name__)
# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
"""OULU-NPU - a mobile face presentation attack database with real-world
variations
"""
import os
import sys
import pkg_resources
from bob.db.base.driver import Interface as BaseInterface
from bob.io.base import create_directories_safe
def dumplist(args):
"""Dumps lists of files based on your criteria"""
from .query import Database
db = Database()
r = db.objects(
purposes=args.purpose,
groups=args.group,
)
output = sys.stdout
if args.selftest:
from bob.db.base.utils import null
output = null()
for f in r:
output.write('%s\n' % f.make_path(
directory=args.directory, extension=args.extension))
return 0
def checkfiles(args):
"""Checks existence of files based on your criteria"""
from .query import Database
db = Database()
r = db.objects()
# go through all files, check if they are available on the filesystem
good = []
bad = []
for f in r:
if os.path.exists(f.make_path(args.directory, args.extension)):
good.append(f)
else:
bad.append(f)
# report
output = sys.stdout
if args.selftest:
from bob.db.base.utils import null
output = null()
if bad:
for f in bad:
output.write('Cannot find file "%s"\n' %
f.make_path(args.directory, args.extension))
output.write('%d files (out of %d) were not found at "%s"\n' %
(len(bad), len(r), args.directory))
return 0
def convert_filelist_pad(path, outfolder, append, test, group):
outfolder = os.path.join(outfolder, group)
realpath = os.path.join(outfolder, 'for_real.lst')
attackpath = os.path.join(outfolder, 'for_attack.lst')
create_directories_safe(os.path.dirname(realpath))
conv = {'1': 'real', '2': 'print1', '3': 'print2',
'4': 'video_replay1', '5': 'video_replay2'}
with open(path) as f, \
open(realpath, 'w') as rf, \
open(attackpath, 'w') as af:
for line in f:
if test:
isreal = True
if line[0] == '+':
isreal = True
elif line[0] == '-':
isreal = False
elif not test:
print('ignoring line: ' + line)
continue
if test:
filename = line.strip()
client_id = 'test'
else:
_, filename = line.strip().split(',')
_, _, client_id, attack_type = filename.split('_')
attack_type = conv[attack_type]
filename = append + os.sep + filename
if isreal:
rf.write('{} {}\n'.format(filename, client_id))
else:
af.write('{} {} {}\n'.format(
filename, client_id, attack_type))
def convert_filelist_dap(path, outfolder, append, test, group):
if group == 'world':
outpath = os.path.join(outfolder, 'norm', 'train_world.lst')
else:
outpath = os.path.join(outfolder, group, 'for_scores.lst')
# create the empty 'for_models.lst' file.
with open(os.path.join(outfolder, group, 'for_models.lst'), 'w') as f:
pass
create_directories_safe(os.path.dirname(outpath))
conv = {'1': 'real', '2': 'print1', '3': 'print2',
'4': 'video_replay1', '5': 'video_replay2'}
with open(path) as f, \
open(outpath, 'w') as wf:
for line in f:
if test:
isreal = True
if line[0] == '+':
isreal = True
elif line[0] == '-':
isreal = False
elif not test:
print('ignoring line: ' + line)
continue
if test:
filename = line.strip()
client_id = 'test'
else:
_, filename = line.strip().split(',')
_, _, client_id, attack_type = filename.split('_')
attack_type = conv[attack_type]
filename = os.path.join(append, filename)
if not isreal:
client_id = 'attack/{}/{}'.format(attack_type, client_id)
if group == 'world':
wf.write('{} {}\n'.format(filename, client_id))
else:
wf.write('{} model model {}\n'.format(filename, client_id))
def create(args):
"""Creates the file-lists to be used in Bob based on original file lists.
"""
root_dir = args.root_dir
output_dir = args.output_dir
groups2 = ['world', 'dev', 'eval']
convert_filelist = convert_filelist_dap
for grp1, grp2 in zip(['Train', 'Dev', 'Test'],
groups2):
if grp1 == 'Test':
part = 'OULU_NPU_Part_2'
append = 'OULU_NPU_Part_2/Files_2'
test = True
else:
part = 'OULU_NPU_Part_1'
append = 'OULU_NPU_Part_1/Files_1'
test = False
for protocol in ('Protocol_1', 'Protocol_2', 'Protocol_3',
'Protocol_4'):
for i in range(1, 7):
if protocol in ('Protocol_1', 'Protocol_2'):
textfile = '{}.txt'.format(grp1)
new_protocol = protocol
else:
textfile = '{}_{}.txt'.format(grp1, i)
new_protocol = '{}_{}'.format(protocol, i)
convert_filelist(
os.path.join(root_dir, part, protocol, textfile),
os.path.join(output_dir, new_protocol),
append, test, grp2)
if protocol in ('Protocol_1', 'Protocol_2'):
break
class Interface(BaseInterface):
def name(self):
return 'oulunpu'
def version(self):
return pkg_resources.require('bob.db.%s' % self.name())[0].version
def files(self):
return ()
def type(self):
return 'text'
def add_commands(self, parser):
from . import __doc__ as docs
subparsers = self.setup_parser(parser,
"OULU-NPU database", docs)
import argparse
# the "dumplist" action
parser = subparsers.add_parser('dumplist', help=dumplist.__doc__)
parser.add_argument(
'-d', '--directory', default='',
help="if given, this path will be prepended to every entry "
"returned.")
parser.add_argument(
'-e', '--extension', default='',
help="if given, this extension will be appended to every entry "
"returned.")
parser.add_argument(
'-u', '--purpose', help="if given, this value will limit the "
"output files to those designed for the given purposes.",
choices=('enroll', 'probe', ''))
parser.add_argument(
'-g', '--group',
help="if given, this value will limit the output files to those "
"belonging to a particular protocolar group.",
choices=('dev', 'eval', 'world', ''))
parser.add_argument('--self-test', dest="selftest",
action='store_true', help=argparse.SUPPRESS)
parser.set_defaults(func=dumplist) # action
# the "checkfiles" action
parser = subparsers.add_parser('checkfiles', help=checkfiles.__doc__)
parser.add_argument(
'-l', '--list-directory', required=True,
help="The directory which contains the file lists.")
parser.add_argument(
'-d', '--directory', dest="directory", default='',
help="if given, this path will be prepended to every entry "
"returned.")
parser.add_argument(
'-e', '--extension', dest="extension", default='',
help="if given, this extension will be appended to every entry "
"returned.")
parser.add_argument('--self-test', dest="selftest",
action='store_true', help=argparse.SUPPRESS)
parser.set_defaults(func=checkfiles) # action
# the "create" action
parser = subparsers.add_parser('create', help=create.__doc__)
parser.add_argument(
'-d', '--root-dir',
help='The directory where the original database is.')
default_output = pkg_resources.resource_filename(__name__, 'lists')
parser.add_argument(
'-o', '--output-dir', default=default_output,
help='The directory where the new list files will be saved into.')
parser.set_defaults(func=create) # action
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
OULU_NPU_Part_2/Files_2/02C48 model model test
OULU_NPU_Part_2/Files_2/03418 model model test
OULU_NPU_Part_2/Files_2/03BE8 model model test
OULU_NPU_Part_2/Files_2/02C49 model model test
OULU_NPU_Part_2/Files_2/03419 model model test
OULU_NPU_Part_2/Files_2/03BE9 model model test
OULU_NPU_Part_2/Files_2/02C4A model model test
OULU_NPU_Part_2/Files_2/0341A model model test
OULU_NPU_Part_2/Files_2/03BEA model model test
OULU_NPU_Part_2/Files_2/02C4B model model test
OULU_NPU_Part_2/Files_2/0341B model model test
OULU_NPU_Part_2/Files_2/03BEB model model test
OULU_NPU_Part_2/Files_2/02C4C model model test
OULU_NPU_Part_2/Files_2/0341C model model test
OULU_NPU_Part_2/Files_2/03BEC model model test
OULU_NPU_Part_2/Files_2/02C4D model model test
OULU_NPU_Part_2/Files_2/0341D model model test
OULU_NPU_Part_2/Files_2/03BED model model test
OULU_NPU_Part_2/Files_2/02C4E model model test
OULU_NPU_Part_2/Files_2/0341E model model test
OULU_NPU_Part_2/Files_2/03BEE model model test
OULU_NPU_Part_2/Files_2/02C4F model model test
OULU_NPU_Part_2/Files_2/0341F model model test
OULU_NPU_Part_2/Files_2/03BEF model model test
OULU_NPU_Part_2/Files_2/02C50 model model test
OULU_NPU_Part_2/Files_2/03420 model model test
OULU_NPU_Part_2/Files_2/03BF0 model model test
OULU_NPU_Part_2/Files_2/02C51 model model test
OULU_NPU_Part_2/Files_2/03421 model model test
OULU_NPU_Part_2/Files_2/03BF1 model model test
OULU_NPU_Part_2/Files_2/02C52 model model test
OULU_NPU_Part_2/Files_2/03422 model model test
OULU_NPU_Part_2/Files_2/03BF2 model model test
OULU_NPU_Part_2/Files_2/02C53 model model test
OULU_NPU_Part_2/Files_2/03423 model model test
OULU_NPU_Part_2/Files_2/03BF3 model model test
OULU_NPU_Part_2/Files_2/02C54 model model test
OULU_NPU_Part_2/Files_2/03424 model model test
OULU_NPU_Part_2/Files_2/03BF4 model model test
OULU_NPU_Part_2/Files_2/02C55 model model test
OULU_NPU_Part_2/Files_2/03425 model model test
OULU_NPU_Part_2/Files_2/03BF5 model model test
OULU_NPU_Part_2/Files_2/02C56 model model test
OULU_NPU_Part_2/Files_2/03426 model model test
OULU_NPU_Part_2/Files_2/03BF6 model model test
OULU_NPU_Part_2/Files_2/02C57 model model test
OULU_NPU_Part_2/Files_2/03427 model model test
OULU_NPU_Part_2/Files_2/03BF7 model model test
OULU_NPU_Part_2/Files_2/02C58 model model test
OULU_NPU_Part_2/Files_2/03428 model model test
OULU_NPU_Part_2/Files_2/03BF8 model model test
OULU_NPU_Part_2/Files_2/02C59 model model test
OULU_NPU_Part_2/Files_2/03429 model model test
OULU_NPU_Part_2/Files_2/03BF9 model model test
OULU_NPU_Part_2/Files_2/02C5A model model test
OULU_NPU_Part_2/Files_2/0342A model model test
OULU_NPU_Part_2/Files_2/03BFA model model test
OULU_NPU_Part_2/Files_2/02C5B model model test
OULU_NPU_Part_2/Files_2/0342B model model test
OULU_NPU_Part_2/Files_2/03BFB model model test
This diff is collapsed.
This diff is collapsed.
OULU_NPU_Part_2/Files_2/05358 model model test
OULU_NPU_Part_2/Files_2/05B28 model model test
OULU_NPU_Part_2/Files_2/062F8 model model test
OULU_NPU_Part_2/Files_2/05359 model model test
OULU_NPU_Part_2/Files_2/05B29 model model test
OULU_NPU_Part_2/Files_2/062F9 model model test
OULU_NPU_Part_2/Files_2/0535A model model test
OULU_NPU_Part_2/Files_2/05B2A model model test
OULU_NPU_Part_2/Files_2/062FA model model test
OULU_NPU_Part_2/Files_2/0535B model model test
OULU_NPU_Part_2/Files_2/05B2B model model test
OULU_NPU_Part_2/Files_2/062FB model model test
OULU_NPU_Part_2/Files_2/0535C model model test
OULU_NPU_Part_2/Files_2/05B2C model model test
OULU_NPU_Part_2/Files_2/062FC model model test
OULU_NPU_Part_2/Files_2/0535D model model test
OULU_NPU_Part_2/Files_2/05B2D model model test
OULU_NPU_Part_2/Files_2/062FD model model test
OULU_NPU_Part_2/Files_2/0535E model model test
OULU_NPU_Part_2/Files_2/05B2E model model test
OULU_NPU_Part_2/Files_2/062FE model model test
OULU_NPU_Part_2/Files_2/0535F model model test
OULU_NPU_Part_2/Files_2/05B2F model model test
OULU_NPU_Part_2/Files_2/062FF model model test
OULU_NPU_Part_2/Files_2/05360 model model test
OULU_NPU_Part_2/Files_2/05B30 model model test
OULU_NPU_Part_2/Files_2/06300 model model test
OULU_NPU_Part_2/Files_2/05361 model model test
OULU_NPU_Part_2/Files_2/05B31 model model test
OULU_NPU_Part_2/Files_2/06301 model model test
OULU_NPU_Part_2/Files_2/05362 model model test
OULU_NPU_Part_2/Files_2/05B32 model model test
OULU_NPU_Part_2/Files_2/06302 model model test
OULU_NPU_Part_2/Files_2/05363 model model test
OULU_NPU_Part_2/Files_2/05B33 model model test
OULU_NPU_Part_2/Files_2/06303 model model test
OULU_NPU_Part_2/Files_2/05364 model model test
OULU_NPU_Part_2/Files_2/05B34 model model test
OULU_NPU_Part_2/Files_2/06304 model model test
OULU_NPU_Part_2/Files_2/05365 model model test
OULU_NPU_Part_2/Files_2/05B35 model model test
OULU_NPU_Part_2/Files_2/06305 model model test
OULU_NPU_Part_2/Files_2/05366 model model test
OULU_NPU_Part_2/Files_2/05B36 model model test
OULU_NPU_Part_2/Files_2/06306 model model test
OULU_NPU_Part_2/Files_2/05367 model model test
OULU_NPU_Part_2/Files_2/05B37 model model test
OULU_NPU_Part_2/Files_2/06307 model model test
OULU_NPU_Part_2/Files_2/05368 model model test
OULU_NPU_Part_2/Files_2/05B38 model model test
OULU_NPU_Part_2/Files_2/06308 model model test
OULU_NPU_Part_2/Files_2/05369 model model test
OULU_NPU_Part_2/Files_2/05B39 model model test
OULU_NPU_Part_2/Files_2/06309 model model test
OULU_NPU_Part_2/Files_2/0536A model model test
OULU_NPU_Part_2/Files_2/05B3A model model test
OULU_NPU_Part_2/Files_2/0630A model model test
OULU_NPU_Part_2/Files_2/0536B model model test
OULU_NPU_Part_2/Files_2/05B3B model model test
OULU_NPU_Part_2/Files_2/0630B model model test
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
from pkg_resources import resource_filename
from bob.dap.base.database import FileListPadDatabase, FileListPadFile
from bob.dap.face.database import VideoPadFile
class File(FileListPadFile, VideoPadFile):
"""The file objects of the OULU-NPU dataset."""
pass
class Database(FileListPadDatabase):
"""The database interface for the OULU-NPU dataset."""
def __init__(self, original_directory=None,
bio_file_class=None, name='oulunpu', **kwargs):
if bio_file_class is None:
bio_file_class = File
filelists_directory = resource_filename(__name__, 'lists')
super(Database, self).__init__(
filelists_directory=filelists_directory, name=name,
original_directory=original_directory,
bio_file_class=bio_file_class,
**kwargs)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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