Spaces:
Runtime error
Runtime error
import mediapipe as mp | |
from utils import read_n_resize | |
def mp_face_detect_fn(image, min_detect_conf=0.5): | |
mp_face_detection = mp.solutions.face_detection | |
mp_drawing = mp.solutions.drawing_utils | |
with mp_face_detection.FaceDetection( | |
min_detection_confidence=min_detect_conf, model_selection=0 | |
) as face_detection: | |
resized_image_array = read_n_resize(image, read=False) | |
# Convert the BGR image to RGB and process it with MediaPipe Face Detection. | |
results = face_detection.process(resized_image_array) | |
annotated_image = resized_image_array.copy() | |
for detection in results.detections: | |
mp_drawing.draw_detection(annotated_image, detection) | |
resized_annotated_image = read_n_resize(annotated_image, read=False) | |
return resized_annotated_image | |