【问题标题】:how to get labels in multilabel facial recognition如何在多标签面部识别中获取标签
【发布时间】:2019-09-23 23:07:04
【问题描述】:

我使用ImagedataGenerator 和flow from directory 为任务训练CNN 模型并保存到.h5 文件中。预测时显示的是 logits 或一组数字,而不是标签。

我需要在预测时显示标签。

我尝试的一种可能方法是将每个 logit 的值重新分配给所需的标签或字符串,但我认为这可能是一项乏味的任务

我得到了什么:

[[1 0 0]]

我需要什么: “史蒂夫·罗杰斯”

【问题讨论】:

  • PutText(currentImageFrame, name + " ", new System.Drawing.Point(facesDetected[i].X, facesDetected[i].Y), Emgu.CV.CvEnum.FontFace.HersheyComplex, 1.0 , 新 Bgr(255, 255, 0).MCvScalar);我们就这样使用。您应该搜索类似的内容。

标签: keras deep-learning label face-recognition multilabel-classification


【解决方案1】:

您需要从 Keras 模型收到的预测的字符串标签。这很容易使用np.argmax(x, axis=0 )

如果pred 是 Keras 模型的输出(预测),那么,

import numpy as np

max_indices = np.argmax( pred , axis=1 )

定义一个带有str 标签的Python list。喜欢,

labels = [ 'NAME1' , 'NAME2' , 'NAME3' ]

然后,我们遍历 max_indices 数组并从 labels 获取对象,

for i in max_indices:
    print( 'Label is {}'.format( labels[i] ) )

【讨论】:

    猜你喜欢
    • 2014-09-08
    • 1970-01-01
    • 2013-11-29
    • 1970-01-01
    • 2021-12-21
    • 2012-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多