【问题标题】:how do I make face recognition with blob oracle如何使用 blob oracle 进行人脸识别
【发布时间】:2021-01-02 06:43:15
【问题描述】:

我在Oracle中有一行包含人的姓名和照片,我如何进行人脸识别,只能通过从相机拍照来识别姓名? 我可以使用哪些技术?

【问题讨论】:

  • 我们可以使用 ORDImage 来比较图像。 Find out more。然而,这距离全面的面部识别还有很长的路要走。我认为现在还没有内置任何东西,即使在最新的 20c 中也是如此。有使用Pythonlibraries的非数据库解决方案。

标签: oracle blob face-recognition


【解决方案1】:

首先,不要将原始图像存储在 blob 列中。您应该存储原始图像的矢量表示。以下 python 代码块将找到人脸图像的矢量表示。

#!pip install deepface
from deepface.basemodels import VGGFace, Facenet

model = VGGFace.loadModel() #you can use google facenet instead of vgg
target_size = model.layers[0].input_shape

#preprocess detects facial area and aligns it
img = functions.preprocess_face(img="img.jpg", target_size=target_size)

representation = model.predict(img)[0,:]

在这里,您可以将精确的图像路径(如 img.jpg 或 3D 数组)传递给 preprocess_face 的 img 参数。这样,您就可以将向量表示形式存储在 oracle 数据库的 blob 列中。

当你有一张新的人脸图像,并想在数据库中找到它的身份时,再次找到它的表示。

#preprocess detects facial area and aligns it
target_img = functions.preprocess_face(img="target.jpg", target_size=target_size)

target_representation = model.predict(target_img )[0,:]

现在,您有了目标图像的矢量表示和数据库图像的矢量表示。您需要找到目标图像表示和数据库表示的每个实例的相似度得分。

欧几里得距离是比较向量的最简单方法。

def findEuclideanDistance(source_representation, test_representation):
    euclidean_distance = source_representation - test_representation
    euclidean_distance = np.sum(np.multiply(euclidean_distance, euclidean_distance))
    euclidean_distance = np.sqrt(euclidean_distance)
    return euclidean_distance

我们会将每个数据库实例与目标进行比较。假设数据库实例的表示存储在表示对象中。

distances = []
for i in range(0, len(representations)):
   source_representation = representations[i]
   #find the distance between target_representation and source_representation
   distance = findEuclideanDistance(source_representation, target_representation )
   distances.append(distance)
   

距离列表存储数据库中每个项目到目标的距离。我们需要找到最短距离。

import numpy as np
idx = np.argmax(distances)

idx是目标图片在数据库中的id。

【讨论】:

    猜你喜欢
    • 2021-07-27
    • 2014-04-15
    • 2021-03-12
    • 2014-01-20
    • 2014-05-04
    • 2012-11-01
    • 2012-12-10
    • 2014-05-21
    • 2019-04-29
    相关资源
    最近更新 更多