// Prediction.
pred = model.predict(array_img)[0]
top_indices = pred.argsort()[-1:][::-1]
results = [(classes[i], pred[i]) for i in top_indices]
// Final judgement.
judge = "Reject"
After Change
cv2.imwrite(file_name, resized_face_image)
// Transform image to 4 dimension tensor.
img = image.img_to_array(image.load_img(file_name, target_size=(img_width, img_height)))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = x / 255.0
// Prediction.
preds = model.predict(x)[0]
predict_idx = np.argmax(preds)
// Final judgement.
judge = "Reject"
prob = preds[predict_idx] * 100
if prob > THRESHOLD:
judge = "Unlock"
msg = "{} ({:.1f}%). res="{}"".format(classes[predict_idx], prob, judge)
print(msg)
// Draw frame to face.