Python bob package API - 如何格式化输入数据
Python bob package API - how to format input data
我正在尝试使用安装在我 ubuntu 上的 bob 包,使用 Conda;但是,在使用 API 之类的任何测量 bob.measure.eer_threshold
时,会出现以下错误。我已经准备好一维数组中的数据,但错误仍然存在。我也尝试将纯一维数组传递给函数,但它不起作用。错误:
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'
这是代码:
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)
这是 Genuine.txt
文件:
8873
2601
2554
11872
3867
4048
6983
3833
3988
5321
2761
2139
8498
2719
3128
3790
2937
2394
和 Impostor.txt
:
2941
3486
4051
3416
2176
2222
1758
1856
2283
3491
3248
3159
4027
1300
2102
1437
1420
1776
4025
3888
2522
3557
请帮助我如何为此类 bob API 方法格式化和准备数据。
那个函数 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 可以为你做这件事。
我正在尝试使用安装在我 ubuntu 上的 bob 包,使用 Conda;但是,在使用 API 之类的任何测量 bob.measure.eer_threshold
时,会出现以下错误。我已经准备好一维数组中的数据,但错误仍然存在。我也尝试将纯一维数组传递给函数,但它不起作用。错误:
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'
这是代码:
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)
这是 Genuine.txt
文件:
8873
2601
2554
11872
3867
4048
6983
3833
3988
5321
2761
2139
8498
2719
3128
3790
2937
2394
和 Impostor.txt
:
2941
3486
4051
3416
2176
2222
1758
1856
2283
3491
3248
3159
4027
1300
2102
1437
1420
1776
4025
3888
2522
3557
请帮助我如何为此类 bob API 方法格式化和准备数据。
那个函数 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 可以为你做这件事。