Python bob 包 API - 如何格式化输入数据

标签 python python-3.x conda biometrics python-bob

我正在尝试使用使用 Conda 安装在我的 ubuntu 上的 bob 软件包;但是,在使用任何测量 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一维 float 数组,但实际上您是以字符串形式读取数据的。此外,您可以使用 numpy.loadtxt 来代替自己实现数据加载。为您做这件事。

关于Python bob 包 API - 如何格式化输入数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49081792/

相关文章:

python - 在 Anaconda 中安装 Python 模块开发版本的最佳实践是什么?

python - Conda 命令(>> conda info --envs)现在在更改 .condarc 后显示所有环境两次

用于希腊语单词的 Python 正则表达式

python2.7名称 '__path__'未定义

python - 循环遍历 numpy 矩阵

linux - 使用 python 脚本运行 linux 命令

rust - 无法从 conda 环境中的 jupyter 服务器连接到 rust 内核

Python Jinja2 宏空白问题

python - python librosa.core.stft() 和 matlab spectrogram(x) 的输出之间的区别

python - 为什么这是一个糟糕的冒泡排序算法?