wider face人脸数据集label格式
现在下载的一般是v2版本,按行:
————文件名 + 图片大小
————框左上角点坐标 + 框大小 + 左眼 + 右眼 + 鼻子 +左嘴角 + 右嘴角
中间用0隔开,如下所示:
# 0--Parade/0_Parade_marchingband_1_849.jpg 1024 1385
449.00000 330.00000 571.00000 479.00000 488.90601 373.64301 0.00000 542.08899 376.44199 0.00000 515.03101 412.82999 0.00000 485.17401 425.89301 0.00000 538.35699 431.49100 0.00000
# 0--Parade/0_Parade_Parade_0_904.jpg 1024 1432
361.00000 98.00000 624.00000 437.00000 424.14301 251.65601 0.00000 547.13397 232.57100 0.00000 494.12100 325.87500 0.00000 453.82999 368.28601 0.00000 561.97803 342.83899 0.00000
# 0--Parade/0_Parade_marchingband_1_799.jpg 1024 768
使用retinaface等模型训练的时候一般用widerface人脸数据集,但有其他需求所以直接用widerface还不太够,需要自己做一个数据集,标注工具使用labelme,然后标注完毕后把jason文件放在一起运行以下脚本:
python脚本
import os
import json
data_dir = './data/labels'
all_json = os.listdir(data_dir)
c = 0
with open("./data/demo1/label.txt", "w") as f:
for j_name in all_json:
f.write('# ' + j_name.split('.')[0] + '.png' + '\n')
j_name = '\\' + j_name
j = open(data_dir + j_name, encoding='utf-8')
info = json.load(j)
x1 = info['shapes'][0]['points'][0][0]
y1 = info['shapes'][0]['points'][0][1]
x2 = info['shapes'][0]['points'][1][0]
y2 = info['shapes'][0]['points'][1][1]
w = str(round(x2 - x1, 5))
h = str(round(y2 - y1, 5))
x1 = str(round(x1, 5))
y1 = str(round(y1, 5))
d1x = str(round(info['shapes'][1]['points'][0][0], 5))
d1y = str(round(info['shapes'][1]['points'][0][1], 5))
d2x = str(round(info['shapes'][2]['points'][0][0], 5))
d2y = str(round(info['shapes'][2]['points'][0][1], 5))
d3x = str(round(info['shapes'][3]['points'][0][0], 5))
d3y = str(round(info['shapes'][3]['points'][0][1], 5))
d4x = str(round(info['shapes'][4]['points'][0][0], 5))
d4y = str(round(info['shapes'][4]['points'][0][1], 5))
d5x = str(round(info['shapes'][5]['points'][0][0], 5))
d5y = str(round(info['shapes'][5]['points'][0][1], 5))
label = x1 + ' ' + y1 + ' ' + w + ' ' + h + ' ' + d1x + ' ' + d1y + ' ' + '0.0' + ' ' + d2x + ' ' + d2y + ' ' + '0.0' + ' ' + d3x + ' ' + d3y + ' ' + '0.0' + ' ' + d4x + ' ' + d4y + ' ' + '0.0' + ' ' + d5x + ' ' + d5y + ' ' + '0.0' + ' ' + '1'
c += 1
print(c)
f.write(label + '\n')