脸部周围没有准确的边界框

时间:2018-12-25 10:35:55

标签: python

我正在CNN中使用滑动窗口方法来检测人脸并在其周围创建边框,以便获取坐标并将其馈送到facenet进行识别。但是即使获得了99%的准确度,我的边界框也不是准确的。

如果我的CNN和从中获得的99%的准确度,我已经使用2个数据集PASCAL作为负值,而LFW作为阳性数据集,现在通过测试图像时,我没有得到正确的边界框。

示例:

enter image description here enter image description here

`def sliding_window(image, stepSize, windowSize):
# slide a window across the image
for y in range(0, image.shape[0], stepSize):
    for x in range(0, image.shape[1], stepSize):
        # yield the current window
        yield (x, y, image[y:y + windowSize[1], x:x + windowSize[0]])


import argparse
import time
import cv2

from matplotlib import pyplot as plt
from keras.models import Sequential
from keras.layers import Dense
from keras.models import model_from_json,load_model
import numpy
import os

# load json and create model
json_file = open('model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
model = model_from_json(loaded_model_json)

# load weights into new model
model.load_weights("model.h5")
print("Loaded model from disk")
# construct the argument parser and parse the arguments

# load the image and define the window width and height
image = cv2.imread("test1.jpg")
(winW, winH) = (70, 70)

for (x, y, window) in sliding_window(image, stepSize=32, windowSize=(winW, winH)):
        # if the window does not meet our desired window size, ignore it
  if window.shape[0] != winH or window.shape[1] != winW:
    continue
  window = window.reshape((1,winW,winH,3))
  if model.predict(window)>0.000002:
      cv2.rectangle(image, (y, x), (x + winW, y + winH), (0, 255, 0),2)



plt.imshow(image)
plt.show()`

0 个答案:

没有答案