Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -103,74 +103,41 @@ def classifyPose(landmarks, output_image, display=False):
|
|
103 |
landmarks[mp_pose.PoseLandmark.RIGHT_ANKLE.value])
|
104 |
|
105 |
#----------------------------------------------------------------------------------------------------------------
|
106 |
-
|
107 |
-
if abs(landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value]
|
108 |
-
abs(landmarks[mp_pose.PoseLandmark.RIGHT_WRIST.value]
|
109 |
-
abs(landmarks[mp_pose.PoseLandmark.LEFT_ANKLE.value]
|
110 |
-
abs(landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value]
|
111 |
label = "Five-Pointed Star Pose"
|
112 |
-
|
113 |
# Check if it is the warrior II pose or the T pose.
|
114 |
-
# As for both of them, both arms should be straight and shoulders should be at the specific angle.
|
115 |
-
#----------------------------------------------------------------------------------------------------------------
|
116 |
-
|
117 |
-
# Check if the both arms are straight.
|
118 |
if left_elbow_angle > 165 and left_elbow_angle < 195 and right_elbow_angle > 165 and right_elbow_angle < 195:
|
119 |
-
|
120 |
-
# Check if shoulders are at the required angle.
|
121 |
if left_shoulder_angle > 80 and left_shoulder_angle < 110 and right_shoulder_angle > 80 and right_shoulder_angle < 110:
|
122 |
-
|
123 |
-
# Check if it is the warrior II pose.
|
124 |
-
#----------------------------------------------------------------------------------------------------------------
|
125 |
-
|
126 |
-
# Check if one leg is straight.
|
127 |
if left_knee_angle > 165 and left_knee_angle < 195 or right_knee_angle > 165 and right_knee_angle < 195:
|
128 |
-
|
129 |
-
# Check if the other leg is bended at the required angle.
|
130 |
if left_knee_angle > 90 and left_knee_angle < 120 or right_knee_angle > 90 and right_knee_angle < 120:
|
131 |
-
|
132 |
-
# Specify the label of the pose that is Warrior II pose.
|
133 |
label = 'Warrior II Pose'
|
134 |
-
|
135 |
-
#----------------------------------------------------------------------------------------------------------------
|
136 |
-
|
137 |
-
# Check if it is the T pose.
|
138 |
-
#----------------------------------------------------------------------------------------------------------------
|
139 |
-
|
140 |
-
# Check if both legs are straight
|
141 |
if left_knee_angle > 160 and left_knee_angle < 195 and right_knee_angle > 160 and right_knee_angle < 195:
|
142 |
-
|
143 |
-
# Specify the label of the pose that is tree pose.
|
144 |
label = 'T Pose'
|
145 |
|
146 |
-
#----------------------------------------------------------------------------------------------------------------
|
147 |
-
|
148 |
# Check if it is the tree pose.
|
149 |
-
#----------------------------------------------------------------------------------------------------------------
|
150 |
-
|
151 |
-
# Check if one leg is straight
|
152 |
if left_knee_angle > 165 and left_knee_angle < 195 or right_knee_angle > 165 and right_knee_angle < 195:
|
153 |
-
|
154 |
-
# Check if the other leg is bended at the required angle.
|
155 |
if left_knee_angle > 315 and left_knee_angle < 335 or right_knee_angle > 25 and right_knee_angle < 45:
|
156 |
-
|
157 |
-
# Specify the label of the pose that is tree pose.
|
158 |
label = 'Tree Pose'
|
159 |
-
|
160 |
# Check for Upward Salute Pose
|
161 |
-
if abs(landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value]
|
162 |
-
abs(landmarks[mp_pose.PoseLandmark.RIGHT_WRIST.value]
|
163 |
-
landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value]
|
164 |
-
landmarks[mp_pose.PoseLandmark.RIGHT_WRIST.value]
|
165 |
-
abs(landmarks[mp_pose.PoseLandmark.LEFT_SHOULDER.value]
|
166 |
label = "Upward Salute Pose"
|
167 |
|
168 |
-
|
169 |
-
if landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value]
|
170 |
-
landmarks[mp_pose.PoseLandmark.RIGHT_WRIST.value]
|
171 |
-
abs(landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value]
|
172 |
-
abs(landmarks[mp_pose.PoseLandmark.RIGHT_WRIST.value]
|
173 |
-
label = "Hands Under Feet Pose"
|
174 |
|
175 |
|
176 |
#----------------------------------------------------------------------------------------------------------------
|
|
|
103 |
landmarks[mp_pose.PoseLandmark.RIGHT_ANKLE.value])
|
104 |
|
105 |
#----------------------------------------------------------------------------------------------------------------
|
106 |
+
# Check for Five-Pointed Star Pose
|
107 |
+
if abs(landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value].y - landmarks[mp_pose.PoseLandmark.LEFT_HIP.value].y) < 100 and \
|
108 |
+
abs(landmarks[mp_pose.PoseLandmark.RIGHT_WRIST.value].y - landmarks[mp_pose.PoseLandmark.RIGHT_HIP.value].y) < 100 and \
|
109 |
+
abs(landmarks[mp_pose.PoseLandmark.LEFT_ANKLE.value].x - landmarks[mp_pose.PoseLandmark.RIGHT_ANKLE.value].x) > 200 and \
|
110 |
+
abs(landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value].x - landmarks[mp_pose.PoseLandmark.RIGHT_WRIST.value].x) > 200:
|
111 |
label = "Five-Pointed Star Pose"
|
112 |
+
|
113 |
# Check if it is the warrior II pose or the T pose.
|
|
|
|
|
|
|
|
|
114 |
if left_elbow_angle > 165 and left_elbow_angle < 195 and right_elbow_angle > 165 and right_elbow_angle < 195:
|
|
|
|
|
115 |
if left_shoulder_angle > 80 and left_shoulder_angle < 110 and right_shoulder_angle > 80 and right_shoulder_angle < 110:
|
|
|
|
|
|
|
|
|
|
|
116 |
if left_knee_angle > 165 and left_knee_angle < 195 or right_knee_angle > 165 and right_knee_angle < 195:
|
|
|
|
|
117 |
if left_knee_angle > 90 and left_knee_angle < 120 or right_knee_angle > 90 and right_knee_angle < 120:
|
|
|
|
|
118 |
label = 'Warrior II Pose'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
if left_knee_angle > 160 and left_knee_angle < 195 and right_knee_angle > 160 and right_knee_angle < 195:
|
|
|
|
|
120 |
label = 'T Pose'
|
121 |
|
|
|
|
|
122 |
# Check if it is the tree pose.
|
|
|
|
|
|
|
123 |
if left_knee_angle > 165 and left_knee_angle < 195 or right_knee_angle > 165 and right_knee_angle < 195:
|
|
|
|
|
124 |
if left_knee_angle > 315 and left_knee_angle < 335 or right_knee_angle > 25 and right_knee_angle < 45:
|
|
|
|
|
125 |
label = 'Tree Pose'
|
126 |
+
|
127 |
# Check for Upward Salute Pose
|
128 |
+
if abs(landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value].x - landmarks[mp_pose.PoseLandmark.LEFT_HIP.value].x) < 100 and \
|
129 |
+
abs(landmarks[mp_pose.PoseLandmark.RIGHT_WRIST.value].x - landmarks[mp_pose.PoseLandmark.RIGHT_HIP.value].x) < 100 and \
|
130 |
+
landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value].y < landmarks[mp_pose.PoseLandmark.LEFT_SHOULDER.value].y and \
|
131 |
+
landmarks[mp_pose.PoseLandmark.RIGHT_WRIST.value].y < landmarks[mp_pose.PoseLandmark.RIGHT_SHOULDER.value].y and \
|
132 |
+
abs(landmarks[mp_pose.PoseLandmark.LEFT_SHOULDER.value].y - landmarks[mp_pose.PoseLandmark.RIGHT_SHOULDER.value].y) < 50:
|
133 |
label = "Upward Salute Pose"
|
134 |
|
135 |
+
# Check for Hands Under Feet Pose
|
136 |
+
if landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value].y > landmarks[mp_pose.PoseLandmark.LEFT_KNEE.value].y and \
|
137 |
+
landmarks[mp_pose.PoseLandmark.RIGHT_WRIST.value].y > landmarks[mp_pose.PoseLandmark.RIGHT_KNEE.value].y and \
|
138 |
+
abs(landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value].x - landmarks[mp_pose.PoseLandmark.LEFT_ANKLE.value].x) < 50 and \
|
139 |
+
abs(landmarks[mp_pose.PoseLandmark.RIGHT_WRIST.value].x - landmarks[mp_pose.PoseLandmark.RIGHT_ANKLE.value].x) < 50:
|
140 |
+
label = "Hands Under Feet Pose"
|
141 |
|
142 |
|
143 |
#----------------------------------------------------------------------------------------------------------------
|