hi , I am new to python I trying to give the prediction output with box that detect human face but after I run the video not have the box so how can I applied it in the codes?
def prediction (filepath):
input_shape = (128, 128, 3)
pr_data = []
detector = dlib.get_frontal_face_detector()
cap = cv2.VideoCapture(filepath)
frameRate = cap.get(5)
while cap.isOpened():
frameId = cap.get(1)
ret, frame = cap.read()
if ret != True:
break
if frameId % ((int(frameRate)+1)*1) == 0:
face_rects, scores, idx = detector.run(frame, 0)
for i, d in enumerate(face_rects):
x1 = d.left()
y1 = d.top()
x2 = d.right()
y2 = d.bottom()
crop_img = frame[y1:y2, x1:x2]
data = img_to_array(cv2.resize(crop_img, (128, 128))).flatten() / 255.0
data = data.reshape(-1, 128, 128, 3)
print((model.predict(data) > 0.5).astype("int32"))
outt=''
if ((model.predict(data) > 0.5).astype("int32")[0][0] == 0 ):
return 'Real'
else:
return 'Fake'