Search code examples
pythonpython-3.xcondabiometricspython-bob

Python bob package API - how to format input data


I'm trying to use the bob package which is installed on my ubuntu using the Conda; however while using any of the measurement APIs like the bob.measure.eer_threshold the following error appears. I've prepared the data in 1D array but the error still exists. I've also tried to pass the pure 1D array to the function but it doesn't work. The error:

Traceback (most recent call last):   File "Test_bob.py", line 29, in <module>
threshold = bob.measure.eer_threshold(negatives, positives) 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'

This is the code:

import bob
import bob.measure
import bob.blitz
import math
import numpy
from matplotlib import pyplot

fImpostor= open("Impostor.txt", "r")
fGenuine= open("Genuine.txt", "r")

positive_scores = []
negative_scores = []

for line in fImpostor:
    ImpScore = line.split()
    negative_scores.append(ImpScore[0])
fImpostor.close()

for line in fGenuine:
    GenScore = line.split()
    positive_scores.append(GenScore[0])
fGenuine.close()

positives = numpy.array(positive_scores)
negatives = numpy.array(negative_scores)

threshold = bob.measure.eer_threshold(negatives, positives)
FAR, FRR = bob.measure.eer_rocch(negatives, positives)

And this is the Genuine.txt file:

8873
2601
2554
11872
3867
4048
6983
3833
3988
5321
2761
2139
8498
2719
3128
3790
2937
2394

and the Impostor.txt:

2941
3486
4051
3416
2176
2222
1758
1856
2283
3491
3248
3159
4027
1300
2102
1437
1420
1776
4025
3888
2522
3557

please help me how to format and prepare data for such bob API methods.


Solution

  • That function expects a 1D array of floats, but you are actually reading your data in as strings. Additionally, instead of implementing the data-loading yourself, you could for instance use numpy.loadtxt to do this for you.