-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest2.py
24 lines (23 loc) · 814 Bytes
/
test2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from models.m7.model import M7FaceAntiSpoofing
import os
# from m6 import predict_one_img
import warnings
from detector.cv_face_detector.model import CVFaceDetector
face_detector = CVFaceDetector()
spoof_detectors = [M7FaceAntiSpoofing()]
import urllib.request
import cv2
def predict_one_img(img_path, spoof_detector):
bgr = cv2.imread(img_path)
face_bboxes = face_detector.get_face_bboxes(bgr)
for bbox in face_bboxes:
crop = bgr[bbox[1]:bbox[3], bbox[0]:bbox[2], :]
real_score = spoof_detector.get_real_score(bgr, bbox)
print("Real score for image name " + img_path + " is: ",
real_score)
if real_score < 0.5:
return False
else:
return True
x = predict_one_img("benchmarks/fake/fake1.jpg", spoof_detectors[0])
print(x)