zforkash commited on
Commit
d310413
·
verified ·
1 Parent(s): aa2e594
Files changed (1) hide show
  1. app.py +56 -62
app.py CHANGED
@@ -1,65 +1,52 @@
1
- # Consolidated Streamlit App
2
- import streamlit as st
3
- import subprocess
4
-
5
- # Title and introduction
6
- st.title("Muscle Memory")
7
-
8
- import av
9
- from streamlit_webrtc import webrtc_streamer, VideoProcessorBase
10
-
11
- class VideoProcessor(VideoProcessorBase):
12
- def recv(self, frame):
13
- image = frame.to_ndarray(format="bgr24")
14
- # Perform OpenCV processing here
15
- return av.VideoFrame.from_ndarray(image, format="bgr24")
16
-
17
- st.header("Webcam Feed")
18
- webrtc_streamer(key="example", video_processor_factory=VideoProcessor)
19
-
20
- st.markdown("""
21
- Welcome to the **Workout Tracker App**!
22
- Select your desired workout below, and the app will guide you through the exercise with real-time feedback.
23
- """)
24
-
25
- # Workout options
26
- st.header("Choose Your Workout")
27
- workout_option = st.selectbox(
28
- "Available Workouts:",
29
- ["Bicep Curl", "Lateral Raise", "Shoulder Press"]
30
- )
31
 
32
- # Button to start the workout
33
- if st.button("Start Workout"):
34
- st.write(f"Starting {workout_option}...")
 
 
 
35
 
36
- # Map the workout to the corresponding script
37
- workout_scripts = {
38
- "Bicep Curl": "bicep_curl.py",
39
- "Lateral Raise": "lateral_raise.py",
40
- "Shoulder Press": "shoulder_press.py",
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
42
-
43
- selected_script = workout_scripts.get(workout_option)
44
-
45
- # Run the corresponding script
46
- try:
47
- subprocess.run(["python", selected_script], check=True)
48
- st.success(f"{workout_option} workout completed! Check the feedback on your terminal.")
49
- except subprocess.CalledProcessError as e:
50
- st.error(f"An error occurred while running {workout_option}. Please try again.")
51
- except FileNotFoundError:
52
- st.error(f"Workout script {selected_script} not found! Ensure the file exists in the same directory.")
53
 
54
- # Footer
55
- st.markdown("""
56
- ---
57
- **Note**: Close the workout window or press "q" in the camera feed to stop the workout.
58
- """)
59
 
 
 
60
 
61
- # From bicep_with_feedback.py
62
- import cv2
 
 
 
 
63
  import mediapipe as mp
64
  import numpy as np
65
  import time
@@ -270,9 +257,10 @@ def main():
270
  if __name__ == "__main__":
271
  main()
272
 
273
-
274
- # From lateral_raise.py
275
- import cv2
 
276
  import mediapipe as mp
277
  import numpy as np
278
  import time
@@ -548,9 +536,10 @@ def main():
548
  if __name__ == "__main__":
549
  main()
550
 
551
-
552
- # From shoulder_press.py
553
- import cv2
 
554
  import mediapipe as mp
555
  import numpy as np
556
  import time
@@ -731,3 +720,8 @@ if __name__ == "__main__":
731
  main()
732
 
733
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ import streamlit as st
3
+ import cv2
4
+ import mediapipe as mp
5
+ import numpy as np
6
+ import time
7
+ from sklearn.ensemble import IsolationForest
8
 
9
+ # Streamlit configuration
10
+ st.set_page_config(page_title="Workout Tracker", page_icon="💪", layout="centered")
11
+
12
+ # Custom CSS for styling
13
+ st.markdown(
14
+ '''
15
+ <style>
16
+ body {
17
+ background-color: #001f3f;
18
+ color: #7FDBFF;
19
+ font-family: Arial, sans-serif;
20
+ }
21
+ .stButton > button {
22
+ background-color: #0074D9;
23
+ color: white;
24
+ border-radius: 5px;
25
+ padding: 10px 20px;
26
+ font-size: 18px;
27
  }
28
+ .stButton > button:hover {
29
+ background-color: #7FDBFF;
30
+ color: #001f3f;
31
+ }
32
+ </style>
33
+ ''',
34
+ unsafe_allow_html=True
35
+ )
 
 
 
36
 
37
+ # Title and Introduction
38
+ st.title("Workout Tracker")
39
+ st.markdown("Welcome to the **Workout Tracker App**! Select your desired workout below and receive real-time feedback as you exercise.")
 
 
40
 
41
+ # Workout Selection
42
+ workout_option = st.radio("Select Your Workout:", ["Bicep Curl", "Lateral Raise", "Shoulder Press"])
43
 
44
+ # Start Button
45
+ if st.button("Start Workout"):
46
+ if workout_option == "Bicep Curl":
47
+ st.write("Launching Bicep Curl Tracker...")
48
+ # Bicep workout code
49
+ import cv2
50
  import mediapipe as mp
51
  import numpy as np
52
  import time
 
257
  if __name__ == "__main__":
258
  main()
259
 
260
+ elif workout_option == "Lateral Raise":
261
+ st.write("Launching Lateral Raise Tracker...")
262
+ # Lateral raise workout code
263
+ import cv2
264
  import mediapipe as mp
265
  import numpy as np
266
  import time
 
536
  if __name__ == "__main__":
537
  main()
538
 
539
+ elif workout_option == "Shoulder Press":
540
+ st.write("Launching Shoulder Press Tracker...")
541
+ # Shoulder press workout code
542
+ import cv2
543
  import mediapipe as mp
544
  import numpy as np
545
  import time
 
720
  main()
721
 
722
 
723
+ # Footer
724
+ st.markdown("---")
725
+ st.markdown("**Note**: Close the workout window or press 'q' in the camera feed to stop the workout.")
726
+
727
+