Skip to content
Snippets Groups Projects
Commit 49e720ba authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[all] add files as in bob.db.voxforge

parent e4b500e9
Branches
Tags
No related merge requests found
# see https://docs.python.org/3/library/pkgutil.html #!/usr/bin/env python
from pkgutil import extend_path # encoding: utf-8
__path__ = extend_path(__path__, __name__) # Guillaume HEUSCH <guillaume.heusch@idiap.ch>
# Thu 22 Dec 16:16:15 CET 2016
from .query import Database
from bob.db.bio_filelist.models import File, Client
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('_')]
#!/usr/bin/env python
# encoding: utf-8
# Guillaume HEUSCH <guillaume.heusch@idiap.ch>
# Thu 22 Dec 16:23:51 CET 2016
"""Commands the FARGO database can respond to.
"""
import os
import sys
from bob.db.base.driver import Interface as BaseInterface
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
class Interface(BaseInterface):
def name(self):
return 'fargo'
def version(self):
import pkg_resources # part of setuptools
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,
"FARGO 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', 'optional_world_1', 'optional_world_2', ''))
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
#!/usr/bin/env python
# encoding: utf-8
# Guillaume HEUSCH <guillaume.heusch@idiap.ch>
# Thu 22 Dec 16:20:02 CET 2016
import bob.db.bio_filelist
class Database(bob.db.bio_filelist.Database):
"""Wrapper class for the FARGO database for face verification
"""
def __init__(self, original_directory = None, original_extension = None):
# call base class constructor
from pkg_resources import resource_filename
lists = resource_filename(__name__, 'lists')
bob.db.bio_filelist.Database.__init__(self, lists, original_directory = original_directory, original_extension = original_extension)
...@@ -11,4 +11,4 @@ verbose = true ...@@ -11,4 +11,4 @@ verbose = true
[scripts] [scripts]
recipe = bob.buildout:scripts recipe = bob.buildout:scripts
dependent-scripts = true dependent-scripts = true
\ No newline at end of file
...@@ -27,11 +27,11 @@ setup( ...@@ -27,11 +27,11 @@ setup(
entry_points = { entry_points = {
#'bob.db': [ 'bob.db': [
# 'fargo = bob.db.fargo.driver:Interface', 'fargo = bob.db.fargo.driver:Interface',
# ], ],
'console_scripts': [ 'console_scripts': [
'extract_images.py = bob.db.fargo.scripts.extract_images:main' 'extract_images.py = bob.db.fargo.scripts.extract_images:main',
'make_file_lists.py = bob.db.fargo.scripts.make_file_lists:main' 'make_file_lists.py = bob.db.fargo.scripts.make_file_lists:main'
], ],
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment