import streamlit as st import json from streamlit_lottie import st_lottie # Load Lottie animation from a JSON file def load_lottiefile(filepath: str): with open(filepath, "r") as f: return json.load(f) st.set_page_config(layout="wide") st.markdown("

Workout Easz

", unsafe_allow_html=True) lottie_animation = load_lottiefile("ltt.json") st_lottie(lottie_animation, height=300, key="header_animation") # Disclaimer st.markdown("""
Disclaimer: The performance of pose detection depends on the model's accuracy. As of now, our application uses a model with approximately 50% pose detection accuracy. Results may vary based on the quality of the video input and the model's limitations.
""", unsafe_allow_html=True) # Introduction and Key Points with st.expander("Introduction to MediaPipe"): st.header("Introduction to MediaPipe") st.write(""" MediaPipe is an open-source framework developed by Google for building multimodal machine learning pipelines. Its Pose solution is designed for high-fidelity body pose tracking, detecting 33 key body landmarks in real-time[1][2]. """) with st.expander("Extraction of 33 Key Points"): st.header("Extraction of 33 Key Points") st.write(""" MediaPipe Pose detects 33 key body landmarks, each with x, y, z coordinates, and a visibility score. These landmarks represent various parts of the body, such as the nose, eyes, ears, shoulders, elbows, wrists, hips, knees, ankles, and feet[1][2]. """) st.image("pose_landmarks_index.png", caption="MediaPipe Pose Landmarks", width=400) # Squat Analysis squat_expander = st.expander("Squat Form Analysis") with squat_expander: st.header("Squat Form Analysis") # Key Landmarks for Squat Analysis st.subheader("1. Key Landmarks for Squat Analysis") st.write(""" For squat analysis, we focus on the following key landmarks: - Shoulder (left and right) - Hip (left and right) - Knee (left and right) - Ankle (left and right) These landmarks are essential for calculating the joint angles critical for analyzing squat form[3]. """) # Calculation of Joint Angles for Squat st.subheader("2. Calculation of Joint Angles for Squat") # Knee Angle st.write("**a. Knee Angle**") st.write(""" The knee angle is formed by the hip, knee, and ankle. It is calculated using the arctangent function: """) st.latex(r"\theta_{\text{knee}} = \left| \frac{180}{\pi} \times \left( \arctan2(y_{\text{ankle}} - y_{\text{knee}}, x_{\text{ankle}} - x_{\text{knee}}) - \arctan2(y_{\text{hip}} - y_{\text{knee}}, x_{\text{hip}} - x_{\text{knee}}) \right) \right|") # Hip Angle st.write("**b. Hip Angle**") st.write(""" The hip angle is formed by the shoulder, hip, and knee. It is calculated similarly: """) st.latex(r"\theta_{\text{hip}} = \left| \frac{180}{\pi} \times \left( \arctan2(y_{\text{knee}} - y_{\text{hip}}, x_{\text{knee}} - x_{\text{hip}}) - \arctan2(y_{\text{shoulder}} - y_{\text{hip}}, x_{\text{shoulder}} - x_{\text{hip}}) \right) \right|") # Back Angle st.write("**c. Back Angle**") st.write(""" The back angle is formed by the shoulder, hip, and ankle: """) st.latex(r"\theta_{\text{back}} = \left| \frac{180}{\pi} \times \left( \arctan2(y_{\text{ankle}} - y_{\text{hip}}, x_{\text{ankle}} - x_{\text{hip}}) - \arctan2(y_{\text{shoulder}} - y_{\text{hip}}, x_{\text{shoulder}} - x_{\text{hip}}) \right) \right|") # Form Issue Detection for Squat st.subheader("3. Form Issue Detection for Squat") st.write("**Ideal Angle Ranges:**") st.write(""" - Knee Angle: 90 to 110 degrees - Hip Angle: 80 to 100 degrees - Back Angle: 70 to 90 degrees """) st.write("**Detection of Deviations:**") st.write(""" - Knees Bending Too Much: Knee angle < 90 degrees - Hips Bending Too Much: Hip angle < 80 degrees - Back Leaning Too Much: Back angle < 70 degrees """) # Providing Suggestions for Squat st.subheader("4. Providing Suggestions for Squat") st.write(""" Based on the detected form issues, specific suggestions are provided: 1. Knees Bending Too Much: - Suggestion: "Watch your knee bend. Ensure your knees do not bend excessively and maintain proper alignment with your toes." 2. Hips Bending Too Much: - Suggestion: "Keep your hips higher. Avoid excessive hip bending by maintaining a more upright posture." 3. Back Leaning Too Much: - Suggestion: "Maintain a straighter back. Focus on keeping your back straight and avoid leaning forward excessively." """) # Push-up Analysis pushup_expander = st.expander("Push-up Form Analysis") with pushup_expander: st.header("Push-up Form Analysis") # Key Landmarks for Push-up Analysis st.subheader("1. Key Landmarks for Push-up Analysis") st.write(""" For push-up analysis, we focus on the following key landmarks: - Shoulder (left and right) - Elbow (left and right) - Wrist (left and right) - Hip (left and right) - Ankle (left and right) These landmarks are crucial for calculating the joint angles and body alignment in push-ups[3]. """) # Calculation of Joint Angles for Push-up st.subheader("2. Calculation of Joint Angles for Push-up") # Elbow Angle st.write("**a. Elbow Angle**") st.write(""" The elbow angle is formed by the shoulder, elbow, and wrist. It is calculated using: """) st.latex(r"\theta_{\text{elbow}} = \left| \frac{180}{\pi} \times \left( \arctan2(y_{\text{wrist}} - y_{\text{elbow}}, x_{\text{wrist}} - x_{\text{elbow}}) - \arctan2(y_{\text{shoulder}} - y_{\text{elbow}}, x_{\text{shoulder}} - x_{\text{elbow}}) \right) \right|") # Body Alignment Angle st.write("**b. Body Alignment Angle**") st.write(""" The body alignment angle is formed by the shoulder, hip, and ankle. It is calculated as: """) st.latex(r"\theta_{\text{alignment}} = \left| \frac{180}{\pi} \times \left( \arctan2(y_{\text{ankle}} - y_{\text{hip}}, x_{\text{ankle}} - x_{\text{hip}}) - \arctan2(y_{\text{shoulder}} - y_{\text{hip}}, x_{\text{shoulder}} - x_{\text{hip}}) \right) \right|") # Form Issue Detection for Push-up st.subheader("3. Form Issue Detection for Push-up") st.write("**Ideal Angle Ranges:**") st.write(""" - Elbow Angle: 90 to 110 degrees (at the bottom of the push-up) - Body Alignment Angle: 170 to 180 degrees (straight body) """) st.write("**Detection of Deviations:**") st.write(""" - Incomplete Push-up: Elbow angle > 110 degrees at the bottom - Elbow Flaring: Elbow angle < 90 degrees - Sagging Hips: Body alignment angle < 170 degrees """) # Providing Suggestions for Push-up st.subheader("4. Providing Suggestions for Push-up") st.write(""" Based on the detected form issues, specific suggestions are provided: 1. Incomplete Push-up: - Suggestion: "Lower your body further. Aim to bring your chest closer to the ground for a full range of motion." 2. Elbow Flaring: - Suggestion: "Keep your elbows closer to your body. Tuck them in to engage your chest and triceps more effectively." 3. Sagging Hips: - Suggestion: "Maintain a straight body line. Engage your core to keep your hips aligned with your shoulders and ankles." """) # Conclusion with st.expander("Conclusion",expanded=False): st.write(""" By leveraging MediaPipe's pose estimation capabilities, this application can effectively analyze both squat and push-up forms. It calculates key joint angles and body alignments, compares them to ideal ranges, and provides specific suggestions for improvement. This approach enables users to receive real-time feedback on their exercise technique, helping them to perform exercises correctly and reduce the risk of injury[1][2][3]. """) # Version Updates with st.expander("Version Updates", expanded=False): st.header("Version Updates") st.subheader("Current Version") st.write(""" **Current Update:** As of today, our application now includes both squat and push-up form analysis. """) st.subheader("Previous Versions") st.write(""" **Initial Release:** Squat workout analysis, released on July 19th. """) st.write(""" Stay tuned for more updates as we continue to enhance our application's features and performance. """) # References with st.expander("References"): st.header("References") st.write(""" [1] [MediaPipe Pose Documentation](https://github.com/google-ai-edge/mediapipe/blob/master/docs/solutions/pose.md) [2] [Google AI Edge - MediaPipe Pose Landmarker](https://ai.google.dev/edge/mediapipe/solutions/vision/pose_landmarker) [3] [Real-time Human Pose Estimation using MediaPipe](https://sigmoidal.ai/en/real-time-human-pose-estimation-using-mediapipe/) [4] [Kaggle Dataset for Push-Up Analysis](https://www.kaggle.com/datasets/mohamadashrafsalama/pushup) """)