Spaces:
Sleeping
Sleeping
David Driscoll
commited on
Commit
·
e109e3e
1
Parent(s):
d539f74
mirror
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def process_frame(image):
|
|
27 |
"""
|
28 |
Processes a frame by:
|
29 |
1. Converting RGB to BGR for OpenCV.
|
30 |
-
2. Flipping the frame for a mirror view.
|
31 |
3. Creating a black background.
|
32 |
4. Drawing body landmarks and computing shoulder center.
|
33 |
5. Drawing facial mesh and extracting chin point.
|
@@ -35,7 +35,7 @@ def process_frame(image):
|
|
35 |
7. Converting the result back to RGB.
|
36 |
"""
|
37 |
frame = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
|
38 |
-
frame = cv2.flip(frame, 1)
|
39 |
output = np.zeros_like(frame)
|
40 |
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
41 |
|
@@ -94,11 +94,11 @@ def process_frame(image):
|
|
94 |
# --- Gradio Interface for Live Webcam Inference ---
|
95 |
iface = gr.Interface(
|
96 |
fn=process_frame,
|
97 |
-
inputs=gr.Image(sources=["webcam"], streaming=True, label="Webcam Input"),
|
98 |
outputs=gr.Image(type="numpy", label="Processed Output"),
|
99 |
live=True,
|
100 |
-
title="Live Body Posture & Neck Analysis (
|
101 |
-
description="Real-time webcam analysis using MediaPipe Pose and Face Mesh with live inference."
|
102 |
)
|
103 |
|
104 |
iface.launch()
|
|
|
27 |
"""
|
28 |
Processes a frame by:
|
29 |
1. Converting RGB to BGR for OpenCV.
|
30 |
+
2. Flipping the frame horizontally for a mirror view.
|
31 |
3. Creating a black background.
|
32 |
4. Drawing body landmarks and computing shoulder center.
|
33 |
5. Drawing facial mesh and extracting chin point.
|
|
|
35 |
7. Converting the result back to RGB.
|
36 |
"""
|
37 |
frame = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
|
38 |
+
frame = cv2.flip(frame, 1) # Flip horizontally for mirror effect
|
39 |
output = np.zeros_like(frame)
|
40 |
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
41 |
|
|
|
94 |
# --- Gradio Interface for Live Webcam Inference ---
|
95 |
iface = gr.Interface(
|
96 |
fn=process_frame,
|
97 |
+
inputs=gr.Image(sources=["webcam"], streaming=True, label="Webcam Input"),
|
98 |
outputs=gr.Image(type="numpy", label="Processed Output"),
|
99 |
live=True,
|
100 |
+
title="Live Body Posture & Neck Analysis (Mirror View)",
|
101 |
+
description="Real-time webcam analysis using MediaPipe Pose and Face Mesh with live inference and mirrored camera view."
|
102 |
)
|
103 |
|
104 |
iface.launch()
|