在实时人脸检测的基础上, 做表情的实时识别真的可以。 但要有好的效果 一要有好的模型,二要有很棒的图像预处理。
三检测的人要有丰富的表情, 目光呆滞🤪的程序狗恐怕也让会算法素手无策。。 当然可以找个表情丰富的妹子鉴定以下效果。
这里只讲 模型的应用, 开始。
项目github 地址:
https://github.com/walletiger/jetson_facial_emotion_examples
一 把人脸检测封装成库
#darknet_fd.py
#!/usr/bin/python3
# -*- coding:utf-8 -*-
import sys
import cv2
import numpy as np
import time
from ctypes import *
from darknet import detect_image
from darknet import load_net_custom
from darknet import load_meta
from darknet import IMAGE
from darknet import network_width, network_height
from camera import JetCamera
import traceback
class DarkNetFD(object):
def __init__(self, config_path='yoloface-500k-v2.cfg', weight_path='yoloface-500k-v2.weights', meta_path='face.data'):
self.net = load_net_custom(config_path.encode('utf-8'), weight_path.encode('utf-8'), 0, 1)
self.meta = load_meta(meta_path.encode('utf-8'))
self.thresh = .5
self.hier_thresh = .5
self.nms = .45
def detect(self, img):
image_list = [img]
pred_height, pred_width, c = image_list[0].shape
net_width, net_height = (network_width(self.net), network_height(self.net))
img_list = []
for custom_image_bgr in image_list:
custom_image = cv2.cvtColor(custom_image_bgr, cv2.COLOR_BGR2RGB)
custom_image = cv2.resize(
custom_image, (net_width, net_height), interpolation=cv2.INTER_NEAREST)
custom_image = custom_image.transpose(2, 0, 1)
img_list.append(custom_image)
arr = np.concatenate(img_list, axis=0)
arr = np.ascontiguousarray(arr.flat, dtype=np.float32) / 255.0
data = arr.ctypes.data_as(POINTER(c_float))
im = IMAGE(net_width, net_height, c, data)
ret_lst = detect_image(self.net, self.meta, im, self.thresh, self.hier_thresh, self.nms)
ret_out_lst = []
if ret_lst:
for ret in ret_lst:
x

本文介绍了一种基于实时人脸检测的表情识别方法,通过多种模型(包括Keras、Facial Emotion Recognition及ONNX模型)实现表情识别,并展示了不同模型在Jetson Nano平台上的应用实例。
最低0.47元/天 解锁文章
3194

被折叠的 条评论
为什么被折叠?



