import cv2 import mediapipe as mp mp_face_detection = mp.solutions.face_detection mp_drawing = mp.solutions.drawing_utils def detect_faces(image_path): image = cv2.imread(image_path) with mp_face_detection.FaceDetection(model_selection=1, min_detection_confidence=0.5) as face_detection: results = face_detection.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB)) if results.detections: for detection in results.detections: mp_drawing.draw_detection(image, detection) return image