【发布时间】:2023-03-23 05:15:02
【问题描述】:
TL;DR 即使我使用了 while 循环,该函数也没有从所有行返回值
FDDB fold txt 文件的数据格式如下。首先是图片文件路径,然后下一行是面数,下面几行是每个面椭圆的参数。
2002/08/11/big/img_591
1
123.583300 85.549500 1.265839 269.693400 161.781200 1
2002/08/26/big/img_265
3
67.363819 44.511485 -1.476417 105.249970 87.209036 1
41.936870 27.064477 1.471906 184.070915 129.345601 1
70.993052 43.355200 1.370217 340.894300 117.498951 1
2002/07/19/big/img_423
1
87.080955 59.379319 1.550861 255.383099 133.767857 1
2002/08/24/big/img_490
1
54.692105 35.056825 -1.384924 145.665694 78.101005 1
我写了下面的代码,提取数据的方式可以返回center_x或angle等具体参数
def fddb_dataset(annotations):
for d in os.listdir(annotations):
if fnmatch(d, 'FDDB-fold-*-ellipseList.txt'):
with open(os.path.join(annotations, d), 'rt') as f:
lines = [line.rstrip('\n') for line in f]
lineId = 0
while lineId < len(lines):
# Image
imgPath = lines[lineId]
lineId += 1
# Faces
numFaces = int(lines[lineId])
lineId += 1
for i in range(numFaces):
params = [float(v) for v in lines[lineId].split()]
lineId += 1
rad_x, rad_y, angle, center_x, center_y, detection_score = params
return imgPath, rad_x, rad_y, angle, center_x, center_y, detection_score
问题是即使我尝试使用 .append() 也只会返回一行
最终,我想将数据集转换为字典到 JSON。
更多信息:我知道有许多关于 FDDB 评估的问题和教程。但是,我不打算根据注释评估我的算法。我打算使用这些注释作为ground truth来训练Mask RCNN。
【问题讨论】:
标签: python json dictionary dataset txt