如何将人脸识别模型转换为H5文件

时间:2020-04-15 06:14:39

标签: face-detection tf-lite

我正在尝试开发一种面部识别应用程序,该应用程序将在许多面部中提取最大的面部并将其保存。 您能帮忙将文件转换为h5文件/ tflite

这是我的代码:

import cv2
import sys

#Face detection image
imagePath = sys.argv[1]
image = cv2.imread(imagePath)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

#Face dectection 
faceCascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
faces = faceCascade.detectMultiScale(
    gray,
    scaleFactor=1.3,
    minNeighbors=3,
    minSize=(30, 30)
)
print(len(faces))
print("[INFO] Found {0} Faces!".format(len(faces)))
a=0
for (x, y, w, h) in faces:

    cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)     
    a1 = h*w

    if(a1>a):
        a = a1
        h1 = h
        w1 = w
        roi_color = image[y:y + h1, x:x + w1]

print("[INFO] Object found. Saving locally.") 
image1 = roi_color
cv2.imwrite('faces.jpg', image1)

0 个答案:

没有答案