Skip to content
Snippets Groups Projects
Commit 6588233b authored by Amir Mohammadi's avatar Amir Mohammadi
Browse files

Initial commit

Adds basic fusion implementations and an example of usage in
bob/fusion/base/fusion.py
This is not complete yet. It needs a command line interface,
documentation, and test cases.
parents
No related branches found
No related tags found
No related merge requests found
Showing
with 966 additions and 0 deletions
*~
*.swp
*.pyc
bin
eggs
parts
.installed.cfg
.mr.developer.cfg
*.egg-info
src
develop-eggs
sphinx
dist
# 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__)
#!/usr/bin/env python
from __future__ import division
from __future__ import absolute_import
from ..utils import grouping
import numpy as np
class Algorithm(object):
"""docstring for Algorithm"""
def __init__(self,
scores=None,
normalizer=None,
performs_training=False,
trainer_scores=None,
trainer=None,
machine=None,
*args,
**kwargs
):
super(Algorithm, self).__init__()
self.scores = scores
self.performs_training = performs_training
self.trainer_scores = trainer_scores
self.trainer = trainer
self.machine = machine
self.normalizer = normalizer
def normalize(self, scores):
if self.normalizer is None:
return scores
else:
if not self.normalizer.trained:
train_scores = np.vstack(self.trainer_scores)
self.normalizer.train(train_scores)
return self.normalizer(scores)
def train(self):
negatives, positives = self.trainer_scores
negatives = self.normalize(negatives)
positives = self.normalize(positives)
self.trainer_scores = (negatives, positives)
def __call__(self):
self.scores = self.normalize(self.scores)
def plot_boundary_decision(self, score_labels, threshold,
label_system1='',
label_system2='',
thres_system1=None,
thres_system2=None,
do_grouping=False,
resolution=100,
x_pad=0.5,
y_pad=0.5,
alpha=0.75,
legends=None,
**kwargs
):
'''
Plots the boundary decision of the Algorithm
@param score_labels numpy.array A (self.scores.shape[0]) array containing
the true labels of self.scores.
@param threshold float threshold of the decision boundary
'''
if legends is None:
legends = ['Impostor', 'Genuine']
import matplotlib.pyplot as plt
plt.gca() # this is necessary for subplots to work.
X = self.scores
Y = score_labels
x_min, x_max = X[:, 0].min() - x_pad, X[:, 0].max() + x_pad
y_min, y_max = X[:, 1].min() - y_pad, X[:, 1].max() + y_pad
h1 = abs(x_max - x_min) / resolution
h2 = abs(y_max - y_min) / resolution
xx, yy = np.meshgrid(
np.arange(x_min, x_max, h1), np.arange(y_min, y_max, h2))
self.scores = np.c_[xx.ravel(), yy.ravel()]
Z = (self() > threshold).reshape(xx.shape)
self.scores = X
contourf = plt.contour(xx, yy, Z, 1, alpha=1, cmap=plt.cm.viridis)
if do_grouping:
positives, negatives = X[Y], X[np.logical_not(Y)]
negatives, positives = grouping(negatives, positives, **kwargs)
X = np.concatenate((negatives, positives), axis=0)
Y = np.concatenate(
(np.zeros(negatives.shape[0], dtype=np.bool8),
np.ones(positives.shape[0], dtype=np.bool8)),
axis=0)
plt.scatter(
X[:, 0], X[:, 1], c=Y, alpha=alpha, cmap=plt.cm.viridis)
# plt.legend(legends)
if thres_system1 is not None:
plt.axvline(thres_system1, color='red')
plt.axhline(thres_system2, color='red')
return contourf
#!/usr/bin/env python
from __future__ import division
from __future__ import absolute_import
import bob.learn.linear
from .Algorithm import Algorithm
import logging
logger = logging.getLogger("bob.fusion.base")
class LLR(Algorithm):
"""docstring for LLR"""
def __init__(self,
*args, **kwargs):
super(LLR, self).__init__(
performs_training=True, *args, **kwargs)
self.trainer = self.trainer if self.trainer else \
bob.learn.linear.CGLogRegTrainer()
def train(self):
super(LLR, self).train()
(negatives, positives) = self.trainer_scores
# Trainning the LLR machine
self.machine = self.trainer.train(negatives, positives)
def __call__(self):
super(LLR, self).__call__()
# Applying the LLR in the input data
return self.machine(self.scores).flatten()
#!/usr/bin/env python
from __future__ import division
from __future__ import absolute_import
import bob.learn.mlp
import bob.core.random
import numpy
from .Algorithm import Algorithm
import logging
logger = logging.getLogger("bob.fusion.base")
class MLP(Algorithm):
"""docstring for MLP"""
def __init__(self,
mlp_shape=None,
trainer_devel=None,
seed=None,
*args, **kwargs):
super(MLP, self).__init__(
performs_training=True, *args, **kwargs)
if mlp_shape is not None:
self.mlp_shape = mlp_shape
elif self.scores is not None:
self.mlp_shape = (numpy.asarray(self.scores).shape[1], 3, 1)
else:
self.mlp_shape = (2, 3, 1)
self.machine = self.machine if self.machine else \
bob.learn.mlp.Machine(self.mlp_shape)
if seed is not None:
self.rng = bob.core.random.mt19937(seed)
self.machine.randomize(rng=self.rng)
else:
self.machine.randomize()
self.trainer = self.trainer if self.trainer else \
bob.learn.mlp.RProp(1, bob.learn.mlp.SquareError(
self.machine.output_activation), machine=self.machine,
train_biases=False)
self.trainer_devel = trainer_devel if trainer_devel else \
self.trainer_scores
self.train_helper = bob.learn.mlp.MLPTrainer(
train=self.trainer_scores[::-1],
devel=self.trainer_devel[::-1],
mlp_shape=self.mlp_shape,
machine=self.machine,
trainer=self.trainer,
**kwargs)
def train(self):
super(MLP, self).train()
self.machine, self.analyzer = self.train_helper()
def __call__(self):
super(MLP, self).__call__()
return self.machine(self.scores).flatten()
#!/usr/bin/env python
from __future__ import division
from __future__ import absolute_import
import numpy
from .Algorithm import Algorithm
import logging
logger = logging.getLogger("bob.fusion.base")
class Weighted_Sum(Algorithm):
"""docstring for Weighted_Sum weighted sum (default: mean)"""
def __init__(self, weights=None, *args, **kwargs):
super(Weighted_Sum, self).__init__(
performs_training=False, *args, **kwargs)
self.weights = weights
def __call__(self):
super(Weighted_Sum, self).__call__()
if self.weights is None:
return numpy.mean(self.scores, axis=1)
else:
return numpy.sum(self.scores * self.weights, axis=1)
from .Algorithm import Algorithm
from .Weighted_Sum import Weighted_Sum
from .LLR import LLR
from .MLP import MLP
# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
#!/usr/bin/env python
import os
import numpy
import matplotlib.pyplot as plt
from bob.measure.load import load_score, get_all_scores,\
get_negatives_positives_all
from bob.fusion.base.algorithm import LLR, Weighted_Sum, MLP
from bob.fusion.base.normalizer import ZNorm
def main():
'''
/home/amir/idiap/remote/user/mobio-male/baselines/gmm/male/nonorm/scores-dev
/home/amir/idiap/remote/user/mobio-male/baselines/gmm/male/nonorm/scores-eval
/home/amir/idiap/remote/user/mobio-male/baselines/gmm/male/ztnorm/scores-dev
/home/amir/idiap/remote/user/mobio-male/baselines/gmm/male/ztnorm/scores-eval
/home/amir/idiap/remote/user/mobio-male/baselines/gabor-graph/male/nonorm/scores-dev
/home/amir/idiap/remote/user/mobio-male/baselines/gabor-graph/male/nonorm/scores-eval
/home/amir/idiap/remote/user/mobio-male/baselines/gabor-graph/male/ztnorm/scores-dev
/home/amir/idiap/remote/user/mobio-male/baselines/gabor-graph/male/ztnorm/scores-eval
/home/amir/idiap/remote/user/mobio-male/voice/gmm/male/nonorm/scores-dev
/home/amir/idiap/remote/user/mobio-male/voice/gmm/male/nonorm/scores-eval
/home/amir/idiap/remote/user/mobio-male/voice/gmm/male/ztnorm/scores-dev
/home/amir/idiap/remote/user/mobio-male/voice/gmm/male/ztnorm/scores-eval
/home/amir/idiap/remote/user/mobio-male/voice/isv/male/nonorm/scores-dev
/home/amir/idiap/remote/user/mobio-male/voice/isv/male/nonorm/scores-eval
/home/amir/idiap/remote/user/mobio-male/voice/isv/male/ztnorm/scores-dev
/home/amir/idiap/remote/user/mobio-male/voice/isv/male/ztnorm/scores-eval
# = ['/home/amir/idiap/remote/scores-dev_gmm',
# '/home/amir/idiap/remote/scores-dev_isv']
# s_eval_paths = ['/home/amir/idiap/remote/scores-eval_gmm',
# '/home/amir/idiap/remote/scores-eval_isv']
'''
score_path_mask = '/home/amir/idiap/remote/user/mobio-male/{}/male/{}/scores-{}'
fusion_lists = [
(('baselines/gmm', 'voice/isv'), 'face-voice/F-gmm-S-isv{}'),
(('baselines/gmm', 'baselines/gabor-graph'), 'baselines/gmm-gabor-graph{}'),
(('voice/gmm', 'voice/isv'), 'voice/gmm-isv{}'),
# (('baselines/gmm', 'baselines/gabor-graph', 'voice/gmm', 'voice/isv'), 'face-voice/F-gmm-gabor-graph-S-gmm-isv{}'),
]
for norm in ['ztnorm']:
for scores_paths_param, save_path_param in fusion_lists:
save_path_dev = score_path_mask.format(save_path_param, norm, 'dev')
save_path_eval = score_path_mask.format(save_path_param, norm, 'eval')
# for path in [save_path_dev, save_path_eval]:
# for tag in [
# '_Weighted_Sum',
# '_LLR',
# '_MLP'
# ]:
# try:
# os.makedirs(os.path.split(path.format(tag))[0])
# except Exception:
# pass
s_dev_paths = [
score_path_mask.format(a, norm, 'dev') for a in scores_paths_param]
s_eval_paths = [
score_path_mask.format(a, norm, 'eval') for a in scores_paths_param]
score_lines_list = [load_score(path) for path in s_dev_paths]
scores = get_all_scores(score_lines_list)
trainer_scores = get_negatives_positives_all(score_lines_list)
score_lines_list_eval = [load_score(path) for path in s_eval_paths]
scores_eval = get_all_scores(score_lines_list_eval)
plt.figure()
for i, (fuse, tag) in enumerate([
(Weighted_Sum(normalizer=ZNorm(), scores=numpy.array(scores), trainer_scores=trainer_scores), '_Weighted_Sum'),
(LLR(normalizer=ZNorm(), scores=numpy.array(scores), trainer_scores=trainer_scores), '_LLR'),
(MLP(normalizer=ZNorm(), scores=numpy.array(scores), trainer_scores=trainer_scores, verbose=True,
mlp_shape=(2, 3, 1), batch_size=1, seed=0), '_MLP'),
]):
plt.subplot(2,2,i+1)
fuse.train()
# import ipdb; ipdb.set_trace()
fused_scores_dev = fuse()
score_lines = numpy.array(score_lines_list[0])
score_lines['score'] = fused_scores_dev
# import ipdb
# ipdb.set_trace()
# numpy.savetxt(save_path_dev.format(tag), score_lines, fmt='%s %s %s %.6f')
fuse.scores = numpy.array(scores_eval)
fused_scores_eval = fuse()
fuse.scores = numpy.array(scores_eval)
score_lines = numpy.array(score_lines_list_eval[0])
score_lines['score'] = fused_scores_eval
# numpy.savetxt(save_path_eval.format(tag), score_lines, fmt='%s %s %s %.6f')
# plot the decision boundary
from bob.measure import eer_threshold, min_hter_threshold
from bob.measure.load import get_negatives_positives
score_labels = score_lines['claimed_id'] == score_lines['real_id']
threshold = eer_threshold(*get_negatives_positives(score_lines))
thres_system1 = min_hter_threshold(
*get_negatives_positives(score_lines_list[0]))
thres_system2 = min_hter_threshold(
*get_negatives_positives(score_lines_list[1]))
fuse.plot_boundary_decision(
score_labels, threshold,
scores_paths_param[0], scores_paths_param[1],
thres_system1, thres_system2,
True,
seed=0
)
plt.title(tag[1:])
# print(thres_system1, thres_system2)
# thres_system1, thres_system2 = (3.51670052, 3.19892205)
# plt.axvline(thres_system1, color='red')
# plt.axhline(thres_system2, color='red')
# plt.show()
plt.savefig('scatter_{}_{}.pdf'.format(norm, '_'.join([a.replace('/','-') for a in scores_paths_param])))
plt.close()
# return
# fuse = LLR(scores=scores, trainer_scores=trainer_scores)
# fuse.train()
# print('LLR', fuse()[:10])
# fuse = Weighted_Sum(scores=scores)
# print('Weighted_Sum', fuse()[:10])
# fuse = MEAN(scores=scores)
# print('MEAN', fuse()[:10])
# fuse = MLP(scores=scores, trainer_scores=trainer_scores,
# verbose=True, max_iter=0, batch_size=1)
# fuse.train()
# print('MLP', fuse()[:10])
if __name__ == '__main__':
main()
#!/usr/bin/env python
from __future__ import division
from __future__ import absolute_import
import numpy
from .Normalizer import Normalizer
import logging
logger = logging.getLogger("bob.fusion.base")
class MinMaxNorm(Normalizer):
"""
the MinMaxNorm score normalization
Normalize the score in an specific interval
@param lowBound The lower bound
@param upperBound The upper bound
"""
def __init__(self,
lowerBound=-1,
upperBound=1,
*args,
**kwargs
):
super(MinMaxNorm, self).__init__(performs_training=True)
self.lowerBound = lowerBound
self.upperBound = upperBound
def train(self, scores):
super(MinMaxNorm, self).train(scores)
self.mins = numpy.min(scores, axis=0)
self.maxs = numpy.max(scores, axis=0)
def __call__(self, scores):
scores = super(MinMaxNorm, self).__call__(scores)
denom = self.maxs - self.mins
normalizedScores = (self.upperBound - self.lowerBound) * \
(scores - self.mins) / denom + self.lowerBound
return normalizedScores
#!/usr/bin/env python
from __future__ import division
from __future__ import absolute_import
class Normalizer(object):
"""docstring for Normalizer"""
def __init__(self,
performs_training=False,
trained=False,
*args,
**kwargs
):
super(Normalizer, self).__init__()
self.performs_training = performs_training
if not self.performs_training:
trained = True
self.trained = trained
def train(self, scores):
"""
Trains the Normalizer
calls to this function changes the self.trained to True
@param scores numpy.array of scores to be used for training
"""
self.trained = True
def __call__(self, scores):
"""
Normalizes the scores
@param scores numpy.array to be normalized
@return numpy.array with the normalized scores.
"""
return scores
#!/usr/bin/env python
from __future__ import division
from __future__ import absolute_import
import numpy
from .Normalizer import Normalizer
import logging
logger = logging.getLogger("bob.fusion.base")
class ZNorm(Normalizer):
"""the ZNorm score normalization"""
def __init__(self,
*args,
**kwargs
):
super(ZNorm, self).__init__(performs_training=True)
def train(self, scores):
super(ZNorm, self).train(scores)
self.avg = numpy.average(scores, axis=0)
self.std = numpy.std(scores, axis=0)
def __call__(self, scores):
scores = super(ZNorm, self).__call__(scores)
return (scores - self.avg) / self.std
from .Normalizer import Normalizer
from .ZNorm import ZNorm
from .MinMaxNorm import MinMaxNorm
# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
#!/usr/bin/env python
import bob.learn.em
import numpy
def grouping(negatives, positives,
gformat='random', npoints=500, seed=None, **kwargs):
negatives = numpy.asarray(negatives)
positives = numpy.asarray(positives)
if(gformat == "kmeans"):
kmeans_negatives = bob.learn.em.KMeansMachine(npoints, 2)
kmeans_positives = bob.learn.em.KMeansMachine(npoints, 2)
kmeansTrainer = bob.learn.em.KMeansTrainer()
bob.learn.em.train(
kmeansTrainer, kmeans_negatives, negatives, max_iterations=500,
convergence_threshold=0.1)
bob.learn.em.train(
kmeansTrainer, kmeans_positives, positives, max_iterations=500,
convergence_threshold=0.1)
negatives = kmeans_negatives.means
positives = kmeans_positives.means
elif(gformat == "random"):
if seed is not None:
numpy.random.seed(seed)
negatives_indexes = numpy.array(
numpy.random.rand(npoints) * negatives.shape[0], dtype=int)
positives_indexes = numpy.array(
numpy.random.rand(npoints) * positives.shape[0], dtype=int)
negatives = negatives[negatives_indexes]
positives = positives[positives_indexes]
return negatives, positives
##############################################################################
#
# Copyright (c) 2006 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Bootstrap a buildout-based project
Simply run this script in a directory containing a buildout.cfg.
The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
"""
import os
import shutil
import sys
import tempfile
from optparse import OptionParser
__version__ = '2015-07-01'
# See zc.buildout's changelog if this version is up to date.
tmpeggs = tempfile.mkdtemp(prefix='bootstrap-')
usage = '''\
[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
Bootstraps a buildout-based project.
Simply run this script in a directory containing a buildout.cfg, using the
Python that you want bin/buildout to use.
Note that by using --find-links to point to local resources, you can keep
this script from going over the network.
'''
parser = OptionParser(usage=usage)
parser.add_option("--version",
action="store_true", default=False,
help=("Return bootstrap.py version."))
parser.add_option("-t", "--accept-buildout-test-releases",
dest='accept_buildout_test_releases',
action="store_true", default=False,
help=("Normally, if you do not specify a --version, the "
"bootstrap script and buildout gets the newest "
"*final* versions of zc.buildout and its recipes and "
"extensions for you. If you use this flag, "
"bootstrap and buildout will get the newest releases "
"even if they are alphas or betas."))
parser.add_option("-c", "--config-file",
help=("Specify the path to the buildout configuration "
"file to be used."))
parser.add_option("-f", "--find-links",
help=("Specify a URL to search for buildout releases"))
parser.add_option("--allow-site-packages",
action="store_true", default=False,
help=("Let bootstrap.py use existing site packages"))
parser.add_option("--buildout-version",
help="Use a specific zc.buildout version")
parser.add_option("--setuptools-version",
help="Use a specific setuptools version")
parser.add_option("--setuptools-to-dir",
help=("Allow for re-use of existing directory of "
"setuptools versions"))
options, args = parser.parse_args()
if options.version:
print("bootstrap.py version %s" % __version__)
sys.exit(0)
######################################################################
# load/install setuptools
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
ez = {}
if os.path.exists('ez_setup.py'):
exec(open('ez_setup.py').read(), ez)
else:
exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
if not options.allow_site_packages:
# ez_setup imports site, which adds site packages
# this will remove them from the path to ensure that incompatible versions
# of setuptools are not in the path
import site
# inside a virtualenv, there is no 'getsitepackages'.
# We can't remove these reliably
if hasattr(site, 'getsitepackages'):
for sitepackage_path in site.getsitepackages():
# Strip all site-packages directories from sys.path that
# are not sys.prefix; this is because on Windows
# sys.prefix is a site-package directory.
if sitepackage_path != sys.prefix:
sys.path[:] = [x for x in sys.path
if sitepackage_path not in x]
setup_args = dict(to_dir=tmpeggs, download_delay=0)
if options.setuptools_version is not None:
setup_args['version'] = options.setuptools_version
if options.setuptools_to_dir is not None:
setup_args['to_dir'] = options.setuptools_to_dir
ez['use_setuptools'](**setup_args)
import setuptools
import pkg_resources
# This does not (always?) update the default working set. We will
# do it.
for path in sys.path:
if path not in pkg_resources.working_set.entries:
pkg_resources.working_set.add_entry(path)
######################################################################
# Install buildout
ws = pkg_resources.working_set
setuptools_path = ws.find(
pkg_resources.Requirement.parse('setuptools')).location
# Fix sys.path here as easy_install.pth added before PYTHONPATH
cmd = [sys.executable, '-c',
'import sys; sys.path[0:0] = [%r]; ' % setuptools_path +
'from setuptools.command.easy_install import main; main()',
'-mZqNxd', tmpeggs]
find_links = os.environ.get(
'bootstrap-testing-find-links',
options.find_links or
('http://downloads.buildout.org/'
if options.accept_buildout_test_releases else None)
)
if find_links:
cmd.extend(['-f', find_links])
requirement = 'zc.buildout'
version = options.buildout_version
if version is None and not options.accept_buildout_test_releases:
# Figure out the most recent final version of zc.buildout.
import setuptools.package_index
_final_parts = '*final-', '*final'
def _final_version(parsed_version):
try:
return not parsed_version.is_prerelease
except AttributeError:
# Older setuptools
for part in parsed_version:
if (part[:1] == '*') and (part not in _final_parts):
return False
return True
index = setuptools.package_index.PackageIndex(
search_path=[setuptools_path])
if find_links:
index.add_find_links((find_links,))
req = pkg_resources.Requirement.parse(requirement)
if index.obtain(req) is not None:
best = []
bestv = None
for dist in index[req.project_name]:
distv = dist.parsed_version
if _final_version(distv):
if bestv is None or distv > bestv:
best = [dist]
bestv = distv
elif distv == bestv:
best.append(dist)
if best:
best.sort()
version = best[-1].version
if version:
requirement = '=='.join((requirement, version))
cmd.append(requirement)
import subprocess
if subprocess.call(cmd) != 0:
raise Exception(
"Failed to execute command:\n%s" % repr(cmd)[1:-1])
######################################################################
# Import and run buildout
ws.add_entry(tmpeggs)
ws.require(requirement)
import zc.buildout.buildout
if not [a for a in args if '=' not in a]:
args.append('bootstrap')
# if -c was provided, we push it back into args for buildout' main function
if options.config_file is not None:
args[0:0] = ['-c', options.config_file]
zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
; vim: set fileencoding=utf-8 :
; Amir Mohammadi <amir.mohammadi@idiap.ch>
; Mon Mar 21 16:51:06 CEST 2016
[buildout]
parts = scripts
eggs = bob.fusion.base
ipython
extensions = bob.buildout
mr.developer
auto-checkout = *
develop = ../bob.extension
../bob.learn.linear
../bob.learn.activation
../bob.learn.mlp
../bob.measure
.
; options for bob.buildout
debug = true
verbose = true
newest = false
[sources]
bob.extension = git https://github.com/bioidiap/bob.extension
bob.learn.linear = git https://github.com/bioidiap/bob.learn.linear
bob.learn.activation = git https://github.com/bioidiap/bob.learn.activation
bob.learn.mlp = git https://github.com/bioidiap/bob.learn.mlp
bob.measure = git https://github.com/bioidiap/bob.measure
[scripts]
recipe = bob.buildout:scripts
dependent-scripts = true
setup.py 0 → 100644
#!/usr/bin/env python
# Amir Mohammadi <amir.mohammadi@idiap.ch>
# Mon 21 Mar 08:18:08 2016 CEST
#
# Copyright (C) Idiap Research Institute, Martigny, Switzerland
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file contains the python (distutils/setuptools) instructions so your
# package can be installed on **any** host system. It defines some basic
# information like the package name for instance, or its homepage.
#
# It also defines which other packages this python package depends on and that
# are required for this package's operation. The python subsystem will make
# sure all dependent packages are installed or will install them for you upon
# the installation of this package.
#
# The 'buildout' system we use here will go further and wrap this package in
# such a way to create an isolated python working environment. Buildout will
# make sure that dependencies which are not yet installed do get installed, but
# **without** requiring administrative privileges on the host system. This
# allows you to test your package with new python dependencies w/o requiring
# administrative interventions.
from setuptools import setup, dist
dist.Distribution(dict(setup_requires=['bob.extension']))
from bob.extension.utils import load_requirements, find_packages
install_requires = load_requirements()
# The only thing we do in this file is to call the setup() function with all
# parameters that define our package.
setup(
# This is the basic information about your project. Modify all this
# information before releasing code publicly.
name='bob.fusion.base',
version=open("version.txt").read().rstrip(),
description='Basic fusion implementations',
url='https://www.github.com/bioidiap/bob.fusion.base',
license='GPLv3',
author='Amir Mohammadi',
author_email='amir.mohammadi@idiap.ch',
keywords='bob, fusion',
# If you have a better, long description of your package, place it on the
# 'doc' directory and then hook it here
long_description=open('README.rst').read(),
# This line is required for any distutils based packaging.
packages=find_packages(),
include_package_data=True,
zip_safe=False,
# This line defines which packages should be installed when you "install"
# this package. All packages that are mentioned here, but are not installed
# on the current system will be installed locally and only visible to the
# scripts of this package. Don't worry - You won't need administrative
# privileges when using buildout.
install_requires=install_requires,
# Your project should be called something like 'bob.<foo>' or
# 'bob.<foo>.<bar>'. To implement this correctly and still get all your
# packages to be imported w/o problems, you need to implement namespaces
# on the various levels of the package and declare them here. See more
# about this here:
# http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
#
# Our database packages are good examples of namespace implementations
# using several layers. You can check them out here:
# https://github.com/idiap/bob/wiki/Satellite-Packages
# This entry defines which scripts you will have inside the 'bin' directory
# once you install the package (or run 'bin/buildout'). The order of each
# entry under 'console_scripts' is like this:
# script-name-at-bin-directory = module.at.your.library:function
#
# The module.at.your.library is the python file within your library, using
# the python syntax for directories (i.e., a '.' instead of '/' or '\').
# This syntax also omits the '.py' extension of the filename. So, a file
# installed under 'example/foo.py' that contains a function which
# implements the 'main()' function of particular script you want to have
# should be referred as 'example.foo:main'.
#
# In this simple example we will create a single program that will print
# the version of bob.
# entry_points={
# # scripts should be declared using this entry:
# 'console_scripts': [
# 'verify.py = bob.fusion.base.script.verify:main',
# 'resources.py = bob.fusion.base.script.resources:resources',
# 'databases.py = bob.fusion.base.script.resources:databases',
# 'evaluate.py = bob.fusion.base.script.evaluate:main',
# 'collect_results.py = bob.fusion.base.script.collect_results:main',
# 'grid_search.py = bob.fusion.base.script.grid_search:main',
# 'preprocess.py = bob.fusion.base.script.preprocess:main',
# 'extract.py = bob.fusion.base.script.extract:main',
# 'enroll.py = bob.fusion.base.script.enroll:main',
# 'score.py = bob.fusion.base.script.score:main',
# 'fusion_llr.py = bob.fusion.base.script.fusion_llr:main',
# ],
# 'bob.bio.database': [
# # for test purposes only
# 'dummy = bob.fusion.base.test.dummy.database:database',
# ],
# 'bob.bio.preprocessor': [
# # for test purposes only
# 'dummy = bob.fusion.base.test.dummy.preprocessor:preprocessor',
# ],
# 'bob.bio.extractor': [
# # for test purposes only
# 'dummy = bob.fusion.base.test.dummy.extractor:extractor',
# 'linearize = bob.fusion.base.config.extractor.linearize:extractor',
# ],
# 'bob.bio.algorithm': [
# # for test purposes only
# 'dummy = bob.fusion.base.test.dummy.algorithm:algorithm',
# 'distance-euclidean = bob.fusion.base.config.algorithm.distance_euclidean:algorithm',
# 'distance-cosine = bob.fusion.base.config.algorithm.distance_cosine:algorithm',
# 'pca = bob.fusion.base.config.algorithm.pca:algorithm',
# 'lda = bob.fusion.base.config.algorithm.lda:algorithm',
# 'pca+lda = bob.fusion.base.config.algorithm.pca_lda:algorithm',
# 'plda = bob.fusion.base.config.algorithm.plda:algorithm',
# 'pca+plda = bob.fusion.base.config.algorithm.pca_plda:algorithm',
# 'bic = bob.fusion.base.config.algorithm.bic:algorithm',
# ],
# 'bob.bio.grid': [
# 'local-p4 = bob.fusion.base.config.grid.local:grid',
# 'local-p8 = bob.fusion.base.config.grid.local:grid_p8',
# 'local-p16 = bob.fusion.base.config.grid.local:grid_p16',
# 'grid = bob.fusion.base.config.grid.grid:grid',
# 'demanding = bob.fusion.base.config.grid.demanding:grid',
# ],
# },
# Classifiers are important if you plan to distribute this package through
# PyPI. You can find the complete list of classifiers that are valid and
# useful here (http://pypi.python.org/pypi?%3Aaction=list_classifiers).
classifiers=[
'Framework :: Bob',
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Natural Language :: English',
'Programming Language :: Python',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
],
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment