cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, frame = cap.read()
frame = frame[120:120+250,200:200+250, :]
cv2.imshow('Verification', frame, )
# Verification trigger
if cv2.waitKey(10) & 0xFF == ord('v'):
# Save input image to application_data/input_image folder
cv2.imwrite(os.path.join('app_data', 'input_image', 'input_image.jpg'), frame)
# Run verification
results, verified = verify(model, 0.9, 0.7)
if verified == True:
print('Verified')
else:
print('Not Verified')
if cv2.waitKey(10) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
I'm trying to run this cell above and print only the "verified" or "not verified" lines, but when executing the cell the output is like this:
1/1 [==============================] - 0s 202ms/step
1/1 [==============================] - 0s 208ms/step
1/1 [==============================] - 0s 208ms/step
1/1 [==============================] - 0s 203ms/step
1/1 [==============================] - 0s 272ms/step
1/1 [==============================] - 0s 221ms/step
1/1 [==============================] - 0s 217ms/step
1/1 [==============================] - 0s 208ms/step
Not Verified
Any suggestions on how to get rid of the: 1/1 [===================] - 0s 244ms/step
and only print the desired output of "verified" or "not verified"?
Thanks!
the verify function:
def verify(model, detection_threshold, verification_threshold):
# Build results array
results = []
for image in os.listdir(os.path.join('application_data', 'verification_images')):
input_img = preprocess(os.path.join('application_data', 'input_image', 'input_image.jpg'))
validation_img = preprocess(os.path.join('application_data', 'verification_images', image))
# Make Predictions
result = model.predict(list(np.expand_dims([input_img, validation_img], axis=1)))
results.append(result)
# Detection Threshold: Metric above which a prediciton is considered positive
detection = np.sum(np.array(results) > detection_threshold)
# Verification Threshold: Proportion of positive predictions / total positive samples
verification = detection / len(os.listdir(os.path.join('application_data', 'verification_images')))
verified = verification > verification_threshold
return results, verified