problems running antispoofing.lbp-top in combination with bob

333 views
Skip to first unread message

Jeroen Fokkema

unread,
Apr 21, 2016, 4:49:05 AM4/21/16
to bob-devel

Hello guys,


For my graduation research into spoofing detection techniques I am trying to use the source code of https://pypi.python.org/pypi/antispoofing.lbptop/. Unfortunately, I am running into some errors that I am not able to solve myself (neither after asking help of some people who are more skilled in using python than I am). Maybe you can provide some help.

 

The errors I am running into are these:

1.       While running lbptop_calculate_parameters.py on the MSU-MSFD or CASIA_FASD databases I get the following error:

 

Traceback (most recent call last):

  File "./bin/lbptop_calculate_parameters.py", line 24, in <module>

    sys.exit(antispoofing.lbptop.script.lbptop_calculate_parameters.main())

  File "/home/jeroen/Documents/detection/antispoofing.lbptop/antispoofing/lbptop/script/lbptop_calculate_parameters.py", line 183, in main

    locations = preprocess_detections(facefile, len(input), facesize_filter=args.min_face_size)

AttributeError: 'Namespace' object has no attribute 'min_face_size'

 

                However, running lbptop_calculate_parameters.py on MSU-MSFD with the --bbx parameter does allow me to run this algorithm.

 

2.       While running lbptop_make_scores.py on the files that are generates while running lbptop_calculate_parameters.py on MSU-MSFD with –bbx, I get the following error:

 

Traceback (most recent call last):

  File "./bin/lbptop_make_scores.py", line 24, in <module>

    sys.exit(antispoofing.lbptop.script.lbptop_make_scores.main())

  File "/home/jeroen/Documents/detection/antispoofing.lbptop/antispoofing/lbptop/script/lbptop_make_scores.py", line 122, in main

    dataset = calclbptop.create_full_dataset([obj],featuresDir,retrieveNanLines=True)

  File "/home/jeroen/Documents/detection/antispoofing.lbptop/antispoofing/lbptop/spoof/calclbptop.py", line 303, in create_full_dataset

    from bob.io import load

ImportError: cannot import name load

 

I have tried to import bob.io directly before this function, but even then, this code does not work.

 

I hope you can help me out with this problem, maybe it is something that occurs more frequently.

 

Kind regards,

 

Jeroen Fokkema

 

Operating system: Ubuntu 14.04.4

Installation of antispoofing.lbptop performed using zc.buildout

Installed packages according to pip:

Jinja2==2.7.2

MarkupSafe==0.18

MySQL-python==1.2.3

PAM==0.4.2

Pillow==3.2.0

Pygments==1.6

SQLAlchemy==0.8.4

Sphinx==1.2.2

Twisted-Core==13.2.0

Twisted-Web==13.2.0

adium-theme-ubuntu==0.3.4

antispoofing.lbptop==2.0.3

antispoofing.utils==2.0.7

apt-xapian-index==0.45

argparse==1.2.1

beautifulsoup4==4.2.1

bob==2.1.0

bob.ap==2.0.4

bob.blitz==2.0.8

bob.core==2.1.0

bob.db.atnt==2.0.3

bob.db.base==2.0.5

bob.db.casia-fasd==2.0.5

bob.db.iris==2.0.4

bob.db.mnist==2.0.3

bob.db.replay==2.0.5

bob.db.verification.utils==2.0.3

bob.db.wine==2.0.3

bob.extension==2.0.11

bob.io.base==2.0.7

bob.io.image==2.0.4

bob.io.matlab==2.0.4

bob.io.video==2.0.5

bob.ip.base==2.0.7

bob.ip.color==2.0.4

bob.ip.draw==2.0.3

bob.ip.facedetect==2.0.3

bob.ip.gabor==2.0.4

bob.ip.optflow.hornschunck==2.0.6

bob.ip.optflow.liu==2.0.5

bob.learn.activation==2.0.4

bob.learn.boosting==2.0.4

bob.learn.em==2.0.7

bob.learn.libsvm==2.0.3

bob.learn.linear==2.0.7

bob.learn.mlp==2.0.6

bob.math==2.0.3

bob.measure==2.1.0

bob.sp==2.0.4

chardet==2.0.1

colorama==0.2.5

command-not-found==0.3

cvxopt==1.1.4

cycler==0.10.0

debtagshw==0.1

decorator==3.4.0

defer==1.0.6

dirspec==13.10

docutils==0.11

duplicity==0.6.23

html5lib==0.999

httplib2==0.8

ipdb==0.8

ipython==1.2.1

joblib==0.7.1

lockfile==0.8

lxml==3.3.3

matplotlib==1.5.1

mercurial==2.8.2

nose==1.3.1

numexpr==2.2.2

numpy==1.11.0

oauthlib==0.6.1

oneconf==0.3.7.14.04.1

openpyxl==1.7.0

pandas==0.13.1

patsy==0.2.1

pexpect==3.1

piston-mini-client==0.7.5

pyOpenSSL==0.13

pycrypto==2.6.1

pycups==1.9.66

pycurl==7.19.3

pygobject==3.12.0

pyparsing==2.1.1

pyserial==2.6

pysmbc==1.0.14.1

python-apt==0.9.3.5ubuntu2

python-dateutil==2.5.2

python-debian==0.1.21-nmu2ubuntu2

pytz==2016.3

pyxdg==0.25

pyzmq==14.0.1

reportlab==3.0

requests==2.2.1

roman==2.0.0

scipy==0.13.3

sessioninstaller==0.0.0

simplegeneric==0.8.1

simplejson==3.3.1

six==1.5.2

software-center-aptd-plugins==0.0.0

statsmodels==0.5.0

sympy==0.7.4.1

system-service==0.1.6

tables==3.1.1

tornado==3.1.1

unity-lens-photos==1.0

urllib3==1.7.1

virtualenv==15.0.1

wheel==0.24.0

wsgiref==0.1.2

xdiagnose==3.6.3build2

xlrd==0.9.2

xlwt==0.7.5

zope.interface==4.0.5

Tiago Freitas Pereira

unread,
Apr 22, 2016, 8:11:57 AM4/22/16
to bob-...@googlegroups.com
Hi Jeroen,

This is error happens because this part of code is relying on the bob 1.2.
This particular piece of code should be:
  from bob.io.base import load

I will prepare a patch to update this inconsistency.
Thanks for the report.

Tiago


--
-- You received this message because you are subscribed to the Google Groups bob-devel group. To post to this group, send email to bob-...@googlegroups.com. To unsubscribe from this group, send email to bob-devel+...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/bob-devel or directly the project website at http://idiap.github.com/bob/
---
You received this message because you are subscribed to the Google Groups "bob-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bob-devel+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Tiago

Jeroen Fokkema

unread,
Apr 25, 2016, 9:08:05 AM4/25/16
to bob-devel
Hello Tiago,

Thanks for your reply. The solution did work, and I am now able to run the code partially. However, It seems that this addition does not solve the problem entirely.
When I run the method 'create_full_dataset(files,inputDir,retrieveNanLines=False)' from the class calclbptop.py, the dataset that is returned by this method is an 2D array with dimensions 5774x177. However, according to the comments, a list with 5 numpy arrays should be returned.
Furthermore, the line 'histmodelsfile.append(models[i], numpy.array(model_hist_real_plane))' in lbptop_mkhistmodel.py did return an error:
RuntimeError: trying to read or write `float64 ()' at `....../res/histmodelsfile.hdf5:/model_hist_real_XY' that only accepts `float64 (1)'
I was able to fix this error by changing the line to
histmodelsfile.append(models[i], model_hist_real_plane) but I am not sure of the consequences of doing this.

Further in the code I encountered some more problems, but I suspect they origin in create_full_dataset . I was able to fix most of the problems that (I think) resolve from this issue, but the results of the cmphistmodels.py do seem a very unlikely and in lda.py at machine, eig_vals = T.train(train) it cannot get any further with:
RuntimeError: train: C++ exception caught: 'The LAPACK function 'dsygvd' returned a non-zero value. This might be caused by a non-positive definite B matrix.'

I hope you can help me to get furhter.

Kind regards,

Jeroen Fokkema

Tiago Freitas Pereira

unread,
Apr 26, 2016, 9:16:09 AM4/26/16
to bob-...@googlegroups.com
Hi Jeroen,

Thanks for reporting these issues, this code really needs some maintenance and test units.

I've pushed some modifications on the branch 2.0 (https://github.com/bioidiap/antispoofing.lbptop/tree/2.0).
Could you please clone it (be sure that you are in the branch 2.0) and use this code for the time being?

After clone it, you can build everything using the commands:
  `python bootstrap-buildout.py`
  `./bin/buildout`


Regarding the issue with the LDA, the problem is that the within class scatter matrix (S_w^{1}) is not full rank, so you cannot invert it.
The best solution here is to use a pseudo inverse.
If you type `./bin/lbptop_ldatrain.py --help', you will see that I added the argument `--use-pinv`. Add this argument in your command line to use the pseudo inverse implementation to compute S_w^{1}.

Cheers



Jeroen Fokkema

unread,
Jun 14, 2016, 4:31:54 AM6/14/16
to bob-devel
Hello Tiago,

I have been running the code for a while now and with some changes I have been able to run it quite properly.
However, I do not succeed yet in running some of the code and I think the main reason for that is that I cannot get the correct version of antispoofing.utils running. When I want to install bob.db.replay (or any other database library), it will automatically install antispoofing.utils version 2.0.7 which will override the version that is installed by ./bin/buildout.

How can I solve this problem?

Jeroen

André Anjos

unread,
Jun 14, 2016, 4:47:47 AM6/14/16
to bob-...@googlegroups.com
Hello Jeroen,

Could you post your buildout.cfg to this mailing list, it would help us understand why you're having such problems.

Best, André
Dr. André Anjos
Idiap Research Institute
Centre du Parc - rue Marconi 19
CH-1920 Martigny, Suisse
Phone: +41 27 721 7763
Fax: +41 27 721 7712
http://andreanjos.org

Jeroen Fokkema

unread,
Jun 14, 2016, 5:01:01 AM6/14/16
to bob-devel
Hello Andre,

I have apologize, I was running into conclusions too fast.

I will specify the exact problems I am running into:
I am using antispoofing.lbptop (the 2.0 branch that Tiago Freitas Pereira posted above). I have everything running, using some minor changes (which I will post later, so that you can use them to fix the problems I ran into).

Almost everything works fine:
- lbptop_calculate_parameters
- lbptop_cmphistmodel
- lbptop_ldatrain
- lbptop_mkhistmodel
- lbptop_svmtrain

However, there are still 2 problems I run into:
1. when running ./bin/lbptop_make_scores.py I get the following error:
Traceback (most recent call last):
  File "./bin/lbptop_make_scores.py", line 34, in <module>
    sys.exit(antispoofing.lbptop.script.lbptop_make_scores.main())
  File "/media/jeroen/detection/antispoofing.lbptop-2.0/antispoofing/lbptop/script/lbptop_make_scores.py", line 143, in main
    scores  = svmCountermeasure.svm_predict(machine, featureVector)
  File "/media/jeroen/detection/antispoofing.lbptop-2.0/src/antispoofing.utils/antispoofing/utils/ml/svmCountermeasure.py", line 55, in svm_predict
    labels = numpy.array([svm_machine.predict_class_and_scores(x)[1][0] for x in data])
ValueError: cannot convert `numpy.ndarray' which doesn't behave (memory contiguous, aligned, C-style, minimum 1 and up to 4 dimensions) into a `bob.blitz.array'
2. when I want to run lbptop_calculate_parameters with the casia_fasd database, I encounter the following error:
Traceback (most recent call last):
  File "./bin/lbptop_calculate_parameters.py", line 34, in <module>
    sys.exit(antispoofing.lbptop.script.lbptop_calculate_parameters.main())
  File "/media/jeroen/detection/antispoofing.lbptop-2.0/antispoofing/lbptop/script/lbptop_calculate_parameters.py", line 175, in main
    locations = preprocess_detections(flocfile,input.number_of_frames,facesize_filter=facesize_filter)
  File "/media/jeroen/detection/antispoofing.lbptop-2.0/src/antispoofing.utils/antispoofing/utils/faceloc/__init__.py", line 124, in preprocess_detections
    locations = read_face(filename)
  File "/media/jeroen/detection/antispoofing.lbptop-2.0/src/antispoofing.utils/antispoofing/utils/faceloc/__init__.py", line 80, in read_face
    f = open(filename, 'rt') #opens the file for reading
IOError: [Errno 2] No such file or directory: '/media/jeroen/detection/antispoofing.lbptop-2.0/eggs/bob.db.casia_fasd-2.0.5-py2.7.egg/bob/db/casia_fasd/face-locations/train_release/1/2.face'
Which I guess has something to do with the fact that no face locations are delivered with this database. Does this mean that I have to perform this face localization myself? If that is the case: are there any restrictions for the lbptop code which I should take into account and do you have any further tips? If that is not the case, what should be changed?

Thanks for the fast reply!

Jeroen

Tiago Freitas Pereira

unread,
Jun 14, 2016, 5:28:54 AM6/14/16
to bob-...@googlegroups.com
Hi Jeroen,

You just found a bug on our PyPI release.
The face localizations are supposed to be distributed with the package bob.db.casia_fasd as you can see here (https://github.com/bioidiap/bob.db.casia_fasd).

I will fix that and push and release a new version.

Thanks

Tiago Freitas Pereira

unread,
Jun 14, 2016, 5:35:06 AM6/14/16
to bob-...@googlegroups.com
Just to keep track of the bugs I opened an issue https://github.com/bioidiap/bob.db.casia_fasd/issues/3
--
Tiago

Tiago Freitas Pereira

unread,
Jun 14, 2016, 5:49:24 AM6/14/16
to bob-...@googlegroups.com
Done,

Just released the version 2.0.6 with the annotations https://pypi.python.org/pypi/bob.db.casia_fasd/2.0.6

The easiest way to update it is by deleting the egg "bob.db.casia_fasd-2.0.5-py2.7.egg/" and do a ./bin/buildout
This should download the newest version of bob.db.casia_fasd

Cheers
--
Tiago

Jeroen Fokkema

unread,
Jun 14, 2016, 9:57:45 AM6/14/16
to bob-devel
Hello Tiago,

Thanks for the update. It does seem to work (however, since this process seems to use an unusual big amount of memory, I will need to need some time to run).

The first problem is not solved however:


1. when running ./bin/lbptop_make_scores.py I get the following error:
Traceback (most recent call last):
  File "./bin/lbptop_make_scores.py", line 34, in <module>
    sys.exit(antispoofing.lbptop.script.lbptop_make_scores.main())
  File "/media/jeroen/detection/antispoofing.lbptop-2.0/antispoofing/lbptop/script/lbptop_make_scores.py", line 143, in main
    scores  = svmCountermeasure.svm_predict(machine, featureVector)
  File "/media/jeroen/detection/antispoofing.lbptop-2.0/src/antispoofing.utils/antispoofing/utils/ml/svmCountermeasure.py", line 55, in svm_predict
    labels = numpy.array([svm_machine.predict_class_and_scores(x)[1][0] for x in data])
ValueError: cannot convert `numpy.ndarray' which doesn't behave (memory contiguous, aligned, C-style, minimum 1 and up to 4 dimensions) into a `bob.blitz.array'

It would be really nice if somebody could help me with fixing it.

Greetings,

Jeroen Fokkema

André Anjos

unread,
Jun 14, 2016, 11:35:22 AM6/14/16
to bob-...@googlegroups.com

On Tue, Jun 14, 2016 at 3:57 PM, Jeroen Fokkema <j.fo...@student.utwente.nl> wrote:
svm_machine.predict_class_and_scores(x)

I think your problem is that "predict_class_and_scores" requires data to be contiguous in memory and we're iterating over an array.

You can change the line so it reads:

svm_machine.predict_class_and_scores(x.copy())

To solve the issue for now.

André

Jeroen Fokkema

unread,
Jun 28, 2016, 5:11:59 AM6/28/16
to bob-devel
Hello guys,

Thanks for helping me so far. Unfortunately, the two problems are not solved yet. This is what I run into:
1. running ./bin/lbptop_calculate_parameters.py on the CASIA database jams with the third file: train_release/1/HR_1.avi. I tried it on a server and in a virtual machine. The server gives a memory error, the virtual pc just stalls.
2. running ./bin/lbptop_make_scores.py still gives an error. Also after implementing the suggestion given above. Running it using an SVM returns:
Traceback (most recent call last):
  File "./bin/lbptop_make_scores.py", line 34, in <module>
    sys.exit(antispoofing.lbptop.script.lbptop_make_scores.main())
  File "/media/jeroen/detection/antispoofing.lbptop-2.0/antispoofing/lbptop/script/lbptop_make_scores.py", line 143, in main
    scores  = svmCountermeasure.svm_predict(machine, featureVector)
  File "/media/jeroen/detection/antispoofing.lbptop-2.0/src/antispoofing.utils/antispoofing/utils/ml/svmCountermeasure.py", line 56, in svm_predict
    labels = numpy.array([svm_machine.predict_class_and_scores(x.copy())[1][0] for x in data])

ValueError: cannot convert `numpy.ndarray' which doesn't behave (memory contiguous, aligned, C-style, minimum 1 and up to 4 dimensions) into a `bob.blitz.array'


Running it using LDA returns:

Traceback (most recent call last):
  File "./bin/lbptop_make_scores.py", line 34, in <module>
    sys.exit(antispoofing.lbptop.script.lbptop_make_scores.main())
  File "/media/jeroen/detection/antispoofing.lbptop-2.0/antispoofing/lbptop/script/lbptop_make_scores.py", line 140, in main
    scores          = lda.get_scores(machine, featureVector)
  File "/media/jeroen/detection/antispoofing.lbptop-2.0/src/antispoofing.utils/antispoofing/utils/ml/lda.py", line 34, in get_scores
    return machine(data)
RuntimeError: 1D `input' array should have 177 elements matching `bob.learn.linear.Machine' input size, not 295 elements

--------------------------------

Some changes that I have made to the code to get it running so far:
./antispoofing/lbptop/spoof/calclbptop.py
# original: transitional:trainsitional
  elbps = {'regular':'regular', 'transitional':'transitional', 'direction_coded':'direction-coded', 'modified':'regular'}
and
# original: feat = bob.io.load(filename)
    feat = bob.io.base.load(filename)

./antispoofing/lbptop/spoof/chi2
# original:
  # for k in range(0, data_real.shape[0]):  # calc scores for the real data
  #   tmp = numpy.square(data_real[k, :] - model)
  #   s = sum(numpy.nan_to_num(tmp / (model + data_real[k, :])))
  #   scores_real[k, 0] = s
  #
  # for k in range(0, data_attack.shape[0]):  # calc scores for the attack data
  #   tmp = numpy.square(data_attack[k, :] - model)
  #   s = sum(numpy.nan_to_num(tmp / (model + data_attack[k, :])))
  #   scores_attack[k, 0] = s

  for k in range(0, data_real.shape[0]): # calc scores for the real data
    tmp = numpy.square(data_real[k] - model)
    s = sum(numpy.nan_to_num(tmp / (model + data_real[k])))
    scores_real[k,0] = s

  for k in range(0, data_attack.shape[0]): # calc scores for the attack data
    tmp = numpy.square(data_attack[k] - model)
    s = sum(numpy.nan_to_num(tmp / (model + data_attack[k])))
    scores_attack[k,0] = s

./antispoofing/lbptop/script/lbptop_make scores.py
# original: hdf5File_pca    = bob.io.base.HDF5File(pcaFile,openmode_string='r')
hdf5File_pca    = bob.io.base.HDF5File(pcaFile,'r')
and
# original: hdf5File_linear = bob.io.base.HDF5File(machineFile,openmode_string='r')
hdf5File_linear = bob.io.base.HDF5File(machineFile,'r')

./antispoofing/lbptop/script/lbptop_mkhistmodel.py
# old = histmodelsfile.append(models[i], numpy.array(model_hist_real_plane))
histmodelsfile.append(models[i], model_hist_real_plane)

Thanks for the help already. Hopefully the rest can be fixed too.


Regards,

Jeroen Fokkema

Jeroen Fokkema

unread,
Jun 28, 2016, 9:19:19 AM6/28/16
to bob-devel
a short update regarding:

1. running ./bin/lbptop_calculate_parameters.py on the CASIA database jams with the third file: train_release/1/HR_1.avi. I tried it on a server and in a virtual machine. The server gives a memory error, the virtual pc just stalls.

I have it running, but it is still really slow and resource heavy.

André Anjos

unread,
Jun 29, 2016, 2:00:28 AM6/29/16
to bob-...@googlegroups.com
The LPB TOP calculation is notoriously resource hungry. Not surprised at all to see this. A

--
André Anjos
--

Tiago Freitas Pereira

unread,
Jun 29, 2016, 2:47:26 AM6/29/16
to bob-...@googlegroups.com
Hey Jeroen,


I'm not at the office these days and I cannot help you right now with that.
I will have a look next week if you don't mind.

Cheers,
--
Tiago

Jeroen Fokkema

unread,
Jul 4, 2016, 6:16:30 AM7/4/16
to Tiago Freitas Pereira, bob-...@googlegroups.com

Hello Tiago,

 

I have an additional question. I would like to be able to run lbp-top over other footage than the default databases. I assume creating a custom implementation of antispoofing.utils.db.Database is the simplest way to do this. However, face detection has to be performed on the video’s. In the paper about LBP-TOP you mention that a face detection using MCT features (of Froba, B. and Ernst, A.) is used. Is there any implementation available of this algorithm that I could use?

 

Regards,

 

Jeroen Fokkema

You received this message because you are subscribed to a topic in the Google Groups "bob-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bob-devel/SOF4B6t0i-I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bob-devel+...@googlegroups.com.

André Anjos

unread,
Jul 4, 2016, 6:38:06 AM7/4/16
to bob-...@googlegroups.com, Tiago Freitas Pereira

On Mon, Jul 4, 2016 at 12:16 PM, Jeroen Fokkema <j.fo...@student.utwente.nl> wrote:
However, face detection has to be performed on the video’s. In the paper about LBP-TOP you mention that a face detection using MCT features (of Froba, B. and Ernst, A.) is used. Is there any implementation available of this algorithm that I could use?

We don't have a free-software implementation of that one.

You can use the package "bob.ip.facedetect" which will give you similar (if not better) results. It comes with a pre-trained face detector and it works out of the box.


A

Tiago Freitas Pereira

unread,
Jul 5, 2016, 3:20:37 PM7/5/16
to bob-...@googlegroups.com
Hi Jeroen,

I'm just got back.
I pushed an update in the branch 2.0 (https://github.com/bioidiap/antispoofing.lbptop/tree/2.0).
Just did simple things to save some memory. It is a bit better.

Could you please try?

If everything is alright, I will release a new version.

Cheers







--
Tiago
Reply all
Reply to author
Forward
0 new messages