Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,44 +1,35 @@
|
|
|
|
|
|
|
|
| 1 |
import cv2
|
| 2 |
-
import mediapipe as mp
|
| 3 |
import numpy as np
|
| 4 |
-
import
|
| 5 |
|
| 6 |
-
# Initialize
|
| 7 |
mp_pose = mp.solutions.pose
|
| 8 |
-
pose = mp_pose.Pose(static_image_mode=False,
|
| 9 |
mp_drawing = mp.solutions.drawing_utils
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
if
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
# Convert the image color back for OpenCV
|
| 37 |
-
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
|
| 38 |
-
|
| 39 |
-
# Display the image in the web interface
|
| 40 |
-
FRAME_WINDOW.image(image)
|
| 41 |
-
|
| 42 |
-
cap.release()
|
| 43 |
-
cv2.destroyAllWindows()
|
| 44 |
-
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import math
|
| 3 |
import cv2
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
+
import mediapipe as mp
|
| 6 |
|
| 7 |
+
# Initialize mediapipe pose class
|
| 8 |
mp_pose = mp.solutions.pose
|
| 9 |
+
pose = mp_pose.Pose(static_image_mode=False, min_detection_confidence=0.5, model_complexity=1)
|
| 10 |
mp_drawing = mp.solutions.drawing_utils
|
| 11 |
|
| 12 |
+
def detectPose(image):
|
| 13 |
+
# Your detectPose function implementation
|
| 14 |
+
pass
|
| 15 |
+
|
| 16 |
+
def classifyPose(landmarks, image):
|
| 17 |
+
# Your classifyPose function implementation
|
| 18 |
+
pass
|
| 19 |
+
|
| 20 |
+
def detect_yoga_poses(frame):
|
| 21 |
+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
| 22 |
+
frame, landmarks = detectPose(frame)
|
| 23 |
+
if landmarks:
|
| 24 |
+
frame, _ = classifyPose(landmarks, frame)
|
| 25 |
+
return frame
|
| 26 |
+
|
| 27 |
+
iface = gr.Interface(
|
| 28 |
+
fn=detect_yoga_poses,
|
| 29 |
+
inputs="webcam",
|
| 30 |
+
outputs="image",
|
| 31 |
+
title="Live Yoga Pose Detection",
|
| 32 |
+
description="This app detects yoga poses from the live camera feed using MediaPipe.",
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|