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

BInding PLDA

parent e1939456
......@@ -11,7 +11,6 @@
#ifndef BOB_LEARN_MISC_PLDAMACHINE_H
#define BOB_LEARN_MISC_PLDAMACHINE_H
#include <bob.learn.misc/Machine.h>
#include <blitz/array.h>
#include <bob.io.base/HDF5File.h>
#include <map>
......@@ -432,7 +431,7 @@ class PLDABase
* 3. 'Probabilistic Models for Inference about Identity', Li, Fu, Mohammed,
* Elder and Prince, TPAMI'2012
*/
class PLDAMachine: public Machine<blitz::Array<double,1>, double>
class PLDAMachine
{
public:
/**
......
......@@ -31,7 +31,7 @@ static auto IVectorMachine_doc = bob::extension::ClassDoc(
.add_parameter("ubm", ":py:class:`bob.learn.misc.GMMMachine`", "The Universal Background Model.")
.add_parameter("rt", "int", "Size of the Total Variability matrix (CD x rt).")
.add_parameter("variance_threshold", "double", "Variance flooring threshold for the Sigma (diagonal) matrix")
.add_parameter("variance_threshold", "double", "Variance flooring threshold for the :math:`\\Sigma` (diagonal) matrix")
.add_parameter("other", ":py:class:`bob.learn.misc.IVectorMachine`", "A IVectorMachine object to be copied.")
.add_parameter("hdf5", ":py:class:`bob.io.base.HDF5File`", "An HDF5 file open for reading")
......@@ -450,6 +450,39 @@ static PyObject* PyBobLearnMiscIVectorMachine_Forward(PyBobLearnMiscIVectorMachi
}
/*** resize ***/
static auto resize = bob::extension::FunctionDoc(
"resize",
"Resets the dimensionality of the subspace T. ",
0,
true
)
.add_prototype("rT")
.add_parameter("rT", "int", "Size of T (Total variability matrix)");
static PyObject* PyBobLearnMiscIVectorMachine_resize(PyBobLearnMiscIVectorMachineObject* self, PyObject* args, PyObject* kwargs) {
BOB_TRY
/* Parses input arguments in a single shot */
char** kwlist = resize.kwlist(0);
int rT = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &rT)) Py_RETURN_NONE;
if (rT < 1){
PyErr_Format(PyExc_TypeError, "rU must be greater than one");
resize.print_usage();
return 0;
}
self->cxx->resize(rT);
BOB_CATCH_MEMBER("cannot perform the resize method", 0)
Py_RETURN_NONE;
}
static PyMethodDef PyBobLearnMiscIVectorMachine_methods[] = {
{
......@@ -470,6 +503,12 @@ static PyMethodDef PyBobLearnMiscIVectorMachine_methods[] = {
METH_VARARGS|METH_KEYWORDS,
is_similar_to.doc()
},
{
resize.name(),
(PyCFunction)PyBobLearnMiscIVectorMachine_resize,
METH_VARARGS|METH_KEYWORDS,
resize.doc()
},
/*
{
......
......@@ -53,7 +53,9 @@ static PyObject* create_module (void) {
if (!init_BobLearnMiscJFAMachine(module)) return 0;
if (!init_BobLearnMiscISVMachine(module)) return 0;
if (!init_BobLearnMiscIVectorMachine(module)) return 0;
if (!init_BobLearnMiscIVectorMachine(module)) return 0;
if (!init_BobLearnMiscPLDABase(module)) return 0;
if (!init_BobLearnMiscPLDAMachine(module)) return 0;
static void* PyBobLearnMisc_API[PyBobLearnMisc_API_pointers];
......
......@@ -33,6 +33,7 @@
#include <bob.learn.misc/JFAMachine.h>
#include <bob.learn.misc/ISVMachine.h>
#include <bob.learn.misc/IVectorMachine.h>
#include <bob.learn.misc/PLDAMachine.h>
#if PY_VERSION_HEX >= 0x03000000
......@@ -216,5 +217,27 @@ bool init_BobLearnMiscIVectorMachine(PyObject* module);
int PyBobLearnMiscIVectorMachine_Check(PyObject* o);
// PLDABase
typedef struct {
PyObject_HEAD
boost::shared_ptr<bob::learn::misc::PLDABase> cxx;
} PyBobLearnMiscPLDABaseObject;
extern PyTypeObject PyBobLearnMiscPLDABase_Type;
bool init_BobLearnMiscPLDABase(PyObject* module);
int PyBobLearnMiscPLDABase_Check(PyObject* o);
// PLDAMachine
typedef struct {
PyObject_HEAD
boost::shared_ptr<bob::learn::misc::PLDAMachine> cxx;
} PyBobLearnMiscPLDAMachineObject;
extern PyTypeObject PyBobLearnMiscPLDAMachine_Type;
bool init_BobLearnMiscPLDAMachine(PyObject* module);
int PyBobLearnMiscPLDAMachine_Check(PyObject* o);
#endif // BOB_LEARN_EM_MAIN_H
This diff is collapsed.
This diff is collapsed.
......@@ -31,6 +31,10 @@ References
.. [Vogt2008] *R. Vogt, S. Sridharan*. **'Explicit Modelling of Session Variability for Speaker Verification'**, Computer Speech & Language, 2008, vol. 22, no. 1, pp. 17-38
.. [McCool2013] *C. McCool, R. Wallace, M. McLaren, L. El Shafey, S. Marcel*. **'Session Variability Modelling for Face Authentication'**, IET Biometrics, 2013
.. [Dehak2010] *N. Dehak, P. Kenny, R. Dehak, P. Dumouchel, P. Ouellet*, **'Front End Factor Analysis for Speaker Verification'**, IEEE Transactions on Audio, Speech and Language Processing, 2010, vol. 19, issue 4, pp. 788-798
.. [ElShafey2014] *Laurent El Shafey, Chris McCool, Roy Wallace, Sebastien Marcel*. **'A Scalable Formulation of Probabilistic Linear Discriminant Analysis: Applied to Face Recognition'**, TPAMI'2014
.. [PrinceElder2007] *Prince and Elder*. **'Probabilistic Linear Discriminant Analysis for Inference About Identity'**, ICCV'2007
.. [LiFu2012] *Li, Fu, Mohammed, Elder and Prince*. **'Probabilistic Models for Inference about Identity'**, TPAMI'2012
Indices and tables
......
......@@ -119,6 +119,8 @@ setup(
"bob/learn/misc/isv_machine.cpp",
"bob/learn/misc/ivector_machine.cpp",
"bob/learn/misc/plda_base.cpp",
"bob/learn/misc/plda_machine.cpp",
"bob/learn/misc/main.cpp",
],
......
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