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

时间:2018-03-03 07:25:21

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

我正在尝试使用Conda上安装在我的ubuntu上的bob包;但是,在使用"builders": [{ "type": "amazon-ebs", "access_key": "XXXXXXXXXXXXXXXXXXXXXXX", "secret_key": "XXXXXXXXXXXXXXXXXXXXXXX", "region": "us-east-1", "source_ami": "XXXXXXXXXXXXXXXXXXXXXXX", "instance_type": "m4.2xlarge", "ssh_username": "ubuntu", "ami_users": [ "XXXXXXXXXXXX", "YYYYYYYYYYYY" ], "ami_name": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "launch_block_device_mappings": [{ "device_name": "/dev/sda1", "volume_type": "gp2", "delete_on_termination": true, "volume_size": 30 }] }] 之类的任何测量API时,会出现以下错误。我已经用1D数组准备了数据,但错误仍然存​​在。我也尝试将纯1D数组传递给函数,但它不起作用。错误:

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

请帮助我如何格式化和准备这些bob API方法的数据。

1 个答案:

答案 0 :(得分:2)

该函数numpy.loadtxt是一系列浮点数,但实际上是以字符串形式读取数据。此外,您可以使用{{3}}为自己执行此操作,而不是自己实施数据加载。