RP-Azul commited on
Commit
207414d
·
verified ·
1 Parent(s): 3a4cfd6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -4,6 +4,13 @@ import mediapipe as mp
4
  import cv2
5
  from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
6
  import av
 
 
 
 
 
 
 
7
 
8
  # Initialize MediaPipe Hands
9
  mp_hands = mp.solutions.hands
@@ -50,7 +57,9 @@ st.write("This app uses MediaPipe and Streamlit to detect hand landmarks in real
50
  webrtc_streamer(
51
  key="gesture-detection",
52
  video_processor_factory=VideoProcessor,
53
- rtc_configuration={"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]},
 
 
54
  )
55
 
56
  # Footer
@@ -62,4 +71,4 @@ st.markdown(
62
  <p class="footer">Made with ❤️ using Streamlit & MediaPipe</p>
63
  """,
64
  unsafe_allow_html=True,
65
- )
 
4
  import cv2
5
  from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
6
  import av
7
+ import asyncio
8
+
9
+ # Prevent asyncio event loop conflicts
10
+ try:
11
+ asyncio.get_event_loop().run_until_complete(asyncio.sleep(0))
12
+ except RuntimeError:
13
+ asyncio.set_event_loop(asyncio.new_event_loop())
14
 
15
  # Initialize MediaPipe Hands
16
  mp_hands = mp.solutions.hands
 
57
  webrtc_streamer(
58
  key="gesture-detection",
59
  video_processor_factory=VideoProcessor,
60
+ rtc_configuration={
61
+ "iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]
62
+ },
63
  )
64
 
65
  # Footer
 
71
  <p class="footer">Made with ❤️ using Streamlit & MediaPipe</p>
72
  """,
73
  unsafe_allow_html=True,
74
+ )