前言
人脸关键点检测是计算机视觉中的重要任务,它在人脸识别、表情识别、人脸美化等应用中发挥着关键作用。然而,为了训练高效准确的人脸关键点检测模型,我们需要大量的标注数据集。在本篇博客中,我们将介绍如何快速制作高质量的人脸关键点数据集,以支持后续模型的训练与优化。
关键点标注信息展示
在这里向大家介绍一款简单常见的关键点标注程序:labelme,大家可以通过这款软件进行关键点标注。在这里我以帅气的郭富城为例子进行标注五官关键点以及相应的json文件:
shell
复制代码
{ "version": "5.2.1", "flags": {}, "shapes": [ { "label": "0", "points": [ [ 74.02476780185759, 130.80495356037153 ] ], "group_id": null, "description": "", "shape_type": "point", "flags": {} }, { "label": "1", "points": [ [ 126.656346749226, 136.687306501548 ] ], "group_id": null, "description": "", "shape_type": "point", "flags": {} }, { "label": "2", "points": [ [ 101.26934984520125, 169.1950464396285 ] ], "group_id": null, "description": "", "shape_type": "point", "flags": {} }, { "label": "3", "points": [ [ 101.57894736842104, 194.89164086687308 ] ], "group_id": null, "description": "", "shape_type": "point", "flags": {} }, { "label": "4", "points": [ [ 45.8513931888545, 134.82972136222912 ] ], "group_id": null, "description": "", "shape_type": "point", "flags": {} }, { "label": "5", "points": [ [ 162.26006191950466, 143.49845201238392 ] ], "group_id": null, "description": "", "shape_type": "point", "flags": {} } ], "imagePath": "300.jpg", "imageData": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAEsAPADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK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247Zru/DESHqO1RN2R0QiZWvWv2eyaQqcKOa2PBZ3CMg8YBo8XxqNKmAHG01D4JYiCHB/gWoesTVL3jvdYhWfSJ488NGQfyrw2OMZO7k17Xr8jx+H7h0Yq3lnp9K8cCjJqobE1FqSQIAeuK0o3CDg1mglelKZGweasnYuz3oVeayV1B2naIjOWIqKaRjOik8bqoRO32snPO41rTRz1JXdj/9k=", "imageHeight": 300, "imageWidth": 240
标注信息获取
分析【关键点标注信息展示】的信息,我们可以得到其组成为version 、 flags 、 shapes 、 imagePath 、 imageData 、 imageHeight 、 imageWidth 。 其中的【version 、 flags】 为固定信息,【shapes】中的信息为标注的关键点信息 , 【imagePath 、 imageData 、 imageHeight 、imageWidth】分别为图像名称 、 图像Base64编码字符串 、 图像的高 、 图像的宽。而在【shapes】中的信息仅label和points是变动的,分布代表类别和坐标点。
关键点检测
既然需要制作人脸关键点数据集,所以人脸关键点的检测是必不可少的,我们仍然是通过开源项目进行人脸关键点检测。在这里我们选择的是人脸关键点较少的开源项目检测:【mediapipe】在这里大家可以翻阅我往期关于【mediapipe】介绍。例如:
- 【特效】对实时动态人脸进行马赛克及贴图马赛克处理及一些拓展
- 【姿态估计】从理论到实践逐步分析讲解传统姿态估计算法
- 【实操:人脸矫正】两次定位操作解决人脸矫正问题
- 一起来学MediaPipe(二)人脸面网格
- 一起来学MediaPipe(二)人脸面网格
在这一步骤中我们核心目的是为了使用mediapipe包对人脸关键点检测后输出:
shell
复制代码
import cv2 import mediapipe as mp mp_face_detection = mp.solutions.face_detection mp_drawing = mp.solutions.drawing_utils def get_face_info(image): image.flags.writeable = False image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) results = face_detection.process(image) facial_axis = None if results.detections: for detection in results.detections: facial_axis = detection.location_data.relative_keypoints return facial_axis def AxisTransformation(w, h, img_fa): # 左眼 left_eye = [img_fa[0].x * h, img_fa[0].y * w] # 右眼 right_eye = [img_fa[1].x * h, img_fa[1].y * w] # 鼻子 nose = [img_fa[2].x * h, img_fa[2].y * w] # 嘴巴 mouth = [img_fa[3].x * h, img_fa[3].y * w] # 左耳 left_ear = [img_fa[4].x * h, img_fa[4].y * w] # 右耳 right_ear = [img_fa[5].x * h, img_fa[5].y * w] points = [[left_eye], [right_eye], [nose], [mouth], [left_ear], [right_ear]] labels = ["left_eye", "right_eye", "nose", "mouth", "left_ear", "right_ear"] return points, labels
image信息获取
通过关键点标注分析我们可以获得在image信息中需要填入的信息,其中图像的尺寸和名称较为轻易获取,我们在批量读取图像的时候通过for循环可以解决,在这里我们着重解决BASE64编码字符串的获取问题:
shell
复制代码
def get_imageData(img): # 将图像数据转换为Base64编码字符串 image_data_binary = cv2.imencode(".jpg", img)[1].tobytes() image_data_base64 = base64.b64encode(image_data_binary).decode() return image_data_base64
shapes信息获取
由于一张图内的关键点往往不是一个,是需要多个关键点组合而成的,我们从上述的分析中也可以得到shapes信息中改变的也仅仅为lebel和points信息,而group_id、description、shape_type和flags参数爆出不变。同时每个关键点的信息也都是有如下关键信息所示,我们可以这样定义一个函数进行获取shapes信息:
shell
复制代码
def get_shapes_data(points, label): info = { "label": label, "points": points, "group_id": None, "description": "", "shape_type": "point", "flags": {} } return info
生成标注文件
在批量生成标注数据时,我们假定是通过文件夹中的图像进行处理,基础逻辑流程为:
可以通过下面这段代码实现上述逻辑,我们使用四大天王的照片进行测试实验:
shell
复制代码
if __name__ == "__main__": img_path = "./img/" with mp_face_detection.FaceDetection(model_selection=0, min_detection_confidence=0.5) as face_detection: for name in os.listdir(img_path): src_img = cv2.imread(img_path + name) # 读取原始图像 facial_axis = get_face_info(src_img) # 五官坐标集 if facial_axis is not None: # 判定关键点坐标是否存在 Height, Width, _ = src_img.shape imageData = get_imageData(src_img) # 获取图像的imageData信息 # 标签的基础信息 json_base = { "version": "5.2.1", "flags": {}, "shapes": None, "imagePath": name, "imageData": imageData, "imageHeight": Height, "imageWidth": Width } points, labels = AxisTransformation(Height, Width, facial_axis) # 获取关键点坐标, 类别名称 # 获取关键点信息 shape_infos = [] for epoch in range(len(points)): shape_info = get_shapes_data(points[epoch], labels[epoch]) shape_infos.append(shape_info) # 对基础款进行修改 json_base["shapes"] = shape_infos json.dump(json_base, open('./img/%s.json' % name[:-4], 'w'), indent=2)
生成后观察文件夹下图像及标注文件:
使用labelme检验标注结果:
结语
周五了,匆忙中实现了一个人脸关键点数据集的快速制作脚本,仅以此篇以飨读者!这样大家可以快速制作自己的关键点数据集了,大家也可以使用Dlib包制作自己的人脸关键点或者其他开源项目制作自己的关键点数据集。