Spaces:
Runtime error
Runtime error
File size: 862 Bytes
8478e62 2778924 8478e62 2778924 8478e62 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import mediapipe as mp
from utils import read_n_resize
def mp_pose_estimation_fn(image, min_detect_conf=0.5):
mp_drawing = mp.solutions.drawing_utils
mp_drawing_styles = mp.solutions.drawing_styles
mp_pose = mp.solutions.pose
with mp_pose.Pose(
static_image_mode=True,
model_complexity=2,
enable_segmentation=True,
min_detection_confidence=min_detect_conf
) as pose:
image = read_n_resize(image, read=False)
results = pose.process(image)
annotated_image = image.copy()
# Draw pose landmarks on the image.
mp_drawing.draw_landmarks(
annotated_image,
results.pose_landmarks,
mp_pose.POSE_CONNECTIONS,
landmark_drawing_spec=mp_drawing_styles.get_default_pose_landmarks_style()
)
return annotated_image
|