Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,34 @@
|
|
1 |
-
|
|
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
6 |
|
7 |
-
#
|
8 |
-
def
|
9 |
-
|
|
|
10 |
|
11 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
interface = gr.Interface(
|
13 |
-
fn=
|
14 |
-
inputs="
|
15 |
-
outputs="
|
16 |
-
title="
|
17 |
-
description="
|
18 |
)
|
19 |
|
20 |
-
# Launch the
|
21 |
if __name__ == "__main__":
|
22 |
interface.launch(server_name="0.0.0.0")
|
|
|
1 |
+
import cv2
|
2 |
+
import numpy as np
|
3 |
+
import mediapipe as mp
|
4 |
import gradio as gr
|
5 |
|
6 |
+
# Initialize MediaPipe Pose model
|
7 |
+
mp_pose = mp.solutions.pose
|
8 |
+
pose = mp_pose.Pose()
|
9 |
|
10 |
+
# Function to detect pose
|
11 |
+
def detect_pose(image):
|
12 |
+
# Convert image from RGB to BGR for OpenCV processing
|
13 |
+
image_rgb = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
|
14 |
|
15 |
+
# Run MediaPipe Pose model
|
16 |
+
results = pose.process(image_rgb)
|
17 |
+
|
18 |
+
if results.pose_landmarks:
|
19 |
+
return "Person Detected: Standing or Sitting Pose Identified"
|
20 |
+
else:
|
21 |
+
return "No person detected, please try again"
|
22 |
+
|
23 |
+
# Gradio Interface
|
24 |
interface = gr.Interface(
|
25 |
+
fn=detect_pose,
|
26 |
+
inputs=gr.Image(type="pil"), # Accepts an image as input
|
27 |
+
outputs="text", # Outputs the detected pose
|
28 |
+
title="Pose Detection for Exoskeleton",
|
29 |
+
description="Upload an image of a person sitting or standing. The model will determine their pose."
|
30 |
)
|
31 |
|
32 |
+
# Launch the Gradio App
|
33 |
if __name__ == "__main__":
|
34 |
interface.launch(server_name="0.0.0.0")
|