Spaces:
Configuration error
Configuration error
File size: 841 Bytes
2787dfd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import cv2
import mediapipe as mp
import numpy as np
mp_face_detection = mp.solutions.face_detection
def extract_features(image_path):
"""Extract face shape, skin tone, and size from an image."""
image = cv2.imread(image_path)
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# Detect face (simplified example)
with mp_face_detection.FaceDetection(min_detection_confidence=0.5) as face_detector:
results = face_detector.process(image_rgb)
if not results.detections:
return None, None, None
# Mock logic (replace with actual calculations)
face_shape = "Oval" # Use landmarks to classify shape
skin_tone = "Medium" # Estimate from cheek region
face_size = "Medium" # Measure bounding box
return face_shape, skin_tone, face_size |